diff --git a/backend/db/tags.go b/backend/db/tags.go index aff703b..a732467 100644 --- a/backend/db/tags.go +++ b/backend/db/tags.go @@ -74,7 +74,7 @@ func UpdateTag(t types.Tag) (int64, error) { func ExistTag(id int) (bool, error) { var count int - err := db.QueryRow("SELECT COUNT(*) FROM tas WHERE id = ?", id).Scan(&count) + err := db.QueryRow("SELECT COUNT(*) FROM tags WHERE id = ?", id).Scan(&count) if err != nil { return false, err } diff --git a/backend/go.mod b/backend/go.mod index ccd5f4b..7d30c9c 100644 --- a/backend/go.mod +++ b/backend/go.mod @@ -11,6 +11,8 @@ require ( github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.15 // indirect + github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect github.com/rivo/uniseg v0.2.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasthttp v1.50.0 // indirect @@ -18,4 +20,7 @@ require ( golang.org/x/sys v0.14.0 // indirect ) -require github.com/mattn/go-sqlite3 v1.14.19 +require ( + github.com/json-iterator/go v1.1.12 + github.com/mattn/go-sqlite3 v1.14.19 +) diff --git a/backend/go.sum b/backend/go.sum index 1b8f97a..1c7ad0b 100644 --- a/backend/go.sum +++ b/backend/go.sum @@ -1,9 +1,14 @@ github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/gofiber/fiber/v2 v2.51.0 h1:JNACcZy5e2tGApWB2QrRpenTWn0fq0hkFm6k0C86gKQ= github.com/gofiber/fiber/v2 v2.51.0/go.mod h1:xaQRZQJGqnKOQnbQw+ltvku3/h8QxvNi8o6JiJ7Ll0U= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= @@ -15,8 +20,15 @@ github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZ github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-sqlite3 v1.14.19 h1:fhGleo2h1p8tVChob4I9HpmVFIAkKGpiukdrgQbWfGI= github.com/mattn/go-sqlite3 v1.14.19/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasthttp v1.50.0 h1:H7fweIlBm0rXLs2q0XbalvJ6r0CUPFWK3/bB4N13e9M= diff --git a/backend/handlers/tags.go b/backend/handlers/tags.go index 524bed7..17cb520 100644 --- a/backend/handlers/tags.go +++ b/backend/handlers/tags.go @@ -52,7 +52,7 @@ func GetProjectTags(c *fiber.Ctx) error { }) } - return c.JSON(tags) + return c.Status(fiber.StatusOK).JSON(tags) } func GetTag(c *fiber.Ctx) error { diff --git a/backend/main.go b/backend/main.go index e199de5..4ecc44a 100644 --- a/backend/main.go +++ b/backend/main.go @@ -30,29 +30,29 @@ func main() { AllowHeaders: "Origin, Content-Type, Accept", })) - app.Post("/api/projects", handlers.CreateProject) - app.Get("/api/projects", handlers.GetAllProjects) - app.Get("/api/projects/:id", handlers.GetProject) - app.Put("/api/projects/:id", handlers.UpdateProject) - app.Delete("/api/projects/:id", handlers.DeleteProject) - app.Get("/api/projects/:project_id/cards", handlers.GetProjectCards) - app.Get("/api/projects/:project_id/tags", handlers.GetProjectTags) + app.Post("/api/v1/projects", handlers.CreateProject) + app.Get("/api/v1/projects", handlers.GetAllProjects) + app.Get("/api/v1/projects/:id", handlers.GetProject) + app.Put("/api/v1/projects/:id", handlers.UpdateProject) + app.Delete("/api/v1/projects/:id", handlers.DeleteProject) + app.Get("/api/v1/projects/:project_id/cards", handlers.GetProjectCards) + app.Get("/api/v1/projects/:project_id/tags", handlers.GetProjectTags) - app.Post("/api/cards", handlers.CreateCard) - app.Get("/api/cards/:id", handlers.GetCard) - app.Put("/api/cards/:id", handlers.UpdateCard) - app.Delete("/api/cards/:id", handlers.DeleteCard) + app.Post("/api/v1/cards", handlers.CreateCard) + app.Get("/api/v1/cards/:id", handlers.GetCard) + app.Put("/api/v1/cards/:id", handlers.UpdateCard) + app.Delete("/api/v1/cards/:id", handlers.DeleteCard) - app.Post("/api/tags", handlers.CreateTag) - app.Get("/api/tags/:id", handlers.GetTag) - app.Delete("/api/tags/:id", handlers.DeleteTag) - app.Put("/api/tags/:id", handlers.UpdateTag) + app.Post("/api/v1/tags", handlers.CreateTag) + app.Get("/api/v1/tags/:id", handlers.GetTag) + app.Delete("/api/v1/tags/:id", handlers.DeleteTag) + app.Put("/api/v1/tags/:id", handlers.UpdateTag) - app.Post("/api/cards/:card_id/tags/:tag_id", handlers.CreateCardTag) - app.Get("/api/cards/:card_id/tags", handlers.GetCardTags) - app.Put("/api/cards/:card_id/tags/:tag_id", handlers.UpdateCardTag) - app.Delete("/api/cards/:card_id/tags/:tag_id", handlers.DeleteCardTag) - app.Delete("/api/cards/:card_id/tags", handlers.DeleteCardTags) + app.Post("/api/v1/cards/:card_id/tags/:tag_id", handlers.CreateCardTag) + app.Get("/api/v1/cards/:card_id/tags", handlers.GetCardTags) + app.Put("/api/v1/cards/:card_id/tags/:tag_id", handlers.UpdateCardTag) + app.Delete("/api/v1/cards/:card_id/tags/:tag_id", handlers.DeleteCardTag) + app.Delete("/api/v1/cards/:card_id/tags", handlers.DeleteCardTags) log.Fatal(app.Listen(fmt.Sprintf(":%v", port))) } diff --git a/frontend/src/components/card.svelte b/frontend/src/components/card.svelte index 14b7702..82ac5da 100644 --- a/frontend/src/components/card.svelte +++ b/frontend/src/components/card.svelte @@ -2,17 +2,9 @@ import axios from 'axios'; import type { Card } from '../stores/interfaces'; import ModalCard from './modal_card.svelte'; - import { backend } from '../stores/config'; - export let card: Card = { - id: 0, - project_id: 0, - title: 'No title', - content: 'Nocontent', - tags: [] - }; - - export let showModal = false; + export let card: Card; + export let showModal: boolean; export let onDelete: () => void; function editCard() { diff --git a/frontend/src/components/modal_card.svelte b/frontend/src/components/modal_card.svelte index a82ced4..08d923b 100644 --- a/frontend/src/components/modal_card.svelte +++ b/frontend/src/components/modal_card.svelte @@ -12,8 +12,12 @@ let tempCard: Card = { ...card }; function save(closeModal: boolean = true) { - if (card != tempCard) { - axios.put(`${backend}/api/card/${card.id}`, { + if ( + card.project_id != tempCard.project_id || + card.title !== tempCard.title || + card.content !== tempCard.content + ) { + axios.put(`${backend}/api/v1/cards/${card.id}`, { project_id: tempCard.project_id, title: tempCard.title, content: tempCard.content @@ -70,7 +74,7 @@
- +