diff --git a/backend/db/main.go b/backend/db/main.go index ff130cd..f22f25f 100644 --- a/backend/db/main.go +++ b/backend/db/main.go @@ -27,10 +27,10 @@ func InitDB(driver string, connStr string) error { ); CREATE TABLE IF NOT EXISTS cards ( id INTEGER PRIMARY KEY AUTOINCREMENT, - list_id INTEGER, + project_id INTEGER, title TEXT, content TEXT, - FOREIGN KEY(list_id) REFERENCES lists(id) + FOREIGN KEY(project_id) REFERENCES projects(id) ); `) if err != nil { diff --git a/backend/handlers/cards.go b/backend/handlers/cards.go index 925d59a..dce7bfd 100644 --- a/backend/handlers/cards.go +++ b/backend/handlers/cards.go @@ -1,6 +1,7 @@ package handlers import ( + "fmt" "strconv" "git.bhasher.com/bhasher/focus/backend/db" @@ -16,24 +17,24 @@ func CreateCards(c *fiber.Ctx) error { id, err := db.CreateCard(card) if err != nil { - return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "Cannot create card"}) + return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "Cannot create card", "trace": fmt.Sprint(err)}) } return c.Status(fiber.StatusCreated).JSON(fiber.Map{"id": id}) } func GetAllCardsOf(c *fiber.Ctx) error { - listID, err := strconv.Atoi(c.Params("project_id")) + projectID, err := strconv.Atoi(c.Params("project_id")) if err != nil { - return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "Invalid project_id"}) + return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{"status": "error", "error": "Invalid project_id"}) } - lists, err := db.GetAllListsOf(listID) + projects, err := db.GetAllCardsOf(projectID) if err != nil { return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "Cannot retrieve cards"}) } - return c.JSON(lists) + return c.JSON(fiber.Map{"status": "ok", "data": projects}) } func GetCard(c *fiber.Ctx) error { diff --git a/backend/handlers/projects.go b/backend/handlers/projects.go index 9970163..7455310 100644 --- a/backend/handlers/projects.go +++ b/backend/handlers/projects.go @@ -1,8 +1,6 @@ package handlers import ( - "fmt" - "git.bhasher.com/bhasher/focus/backend/db" "git.bhasher.com/bhasher/focus/backend/types" "github.com/gofiber/fiber/v2" @@ -14,8 +12,6 @@ func GetAllProjects(c *fiber.Ctx) error { return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "Cannot retrieve projects"}) } - fmt.Println(projects) - return c.JSON(projects) } diff --git a/backend/main.go b/backend/main.go index ff1410e..bd523e6 100644 --- a/backend/main.go +++ b/backend/main.go @@ -30,17 +30,23 @@ func main() { AllowHeaders: "Origin, Content-Type, Accept", })) + app.Post("/api/project", handlers.CreateProject) app.Get("/api/projects", handlers.GetAllProjects) app.Get("/api/project/:id", handlers.GetProject) - app.Post("/api/project", handlers.CreateProject) app.Put("/api/project/:id", handlers.UpdateProject) app.Delete("/api/project/:id", handlers.DeleteProject) app.Post("/api/list", handlers.CreateList) - app.Get("/api/lists/:board_id", handlers.GetAllListsOf) + app.Get("/api/lists/:project_id", handlers.GetAllListsOf) app.Get("/api/list/:id", handlers.GetList) app.Delete("/api/list/:id", handlers.DeleteList) app.Put("/api/list/:id", handlers.UpdateList) + app.Post("/api/card", handlers.CreateCards) + app.Get("/api/cards/:project_id", handlers.GetAllCardsOf) + app.Get("/api/card/:id", handlers.GetCard) + app.Delete("/api/card/:id", handlers.DeleteCard) + app.Put("/api/card/:id", handlers.UpdateCard) + log.Fatal(app.Listen(fmt.Sprintf(":%v", port))) } diff --git a/frontend/src/components/card.svelte b/frontend/src/components/card.svelte new file mode 100644 index 0000000..1067964 --- /dev/null +++ b/frontend/src/components/card.svelte @@ -0,0 +1,25 @@ + + + + + + +
+
{card.title}
+
+ HIGH + PERSONAL +
+
diff --git a/frontend/src/components/project.svelte b/frontend/src/components/project.svelte index 2645f6f..bca328c 100644 --- a/frontend/src/components/project.svelte +++ b/frontend/src/components/project.svelte @@ -1,9 +1,56 @@ -{#if Number.isNaN(projectId)} -

Invalid number

-{:else} -

Hello on dashboard {projectId}!

+ + + + +{#if project} +
+

{project.title}

+ + +
{/if} \ No newline at end of file diff --git a/frontend/src/routes/[project]/+page.svelte b/frontend/src/routes/[project]/+page.svelte index 03ea08d..36ac04d 100644 --- a/frontend/src/routes/[project]/+page.svelte +++ b/frontend/src/routes/[project]/+page.svelte @@ -1,10 +1,18 @@ - - \ No newline at end of file +
+ + +
+ + diff --git a/frontend/static/css/card.css b/frontend/static/css/card.css new file mode 100644 index 0000000..9099020 --- /dev/null +++ b/frontend/static/css/card.css @@ -0,0 +1,31 @@ +.card { + padding: 10px; + border-radius: 6px; + border: 1px solid #555; + margin: 10px; + width: 200px; + font-family: "Open Sans", sans-serif; + font-size: 14px; +} + +.card:hover{ + background-color: #303030; + cursor: pointer; +} + +.card .title { + font-weight: normal; +} + +.card .tags { + padding-top: 10px; + font-weight: lighter; +} + +.card .tag { + padding: 2px 8px; + margin: 4px 4px 0 0; + text-transform: uppercase; + border-radius: 3px; + font-size: 90%; +} \ No newline at end of file diff --git a/frontend/static/css/index.css b/frontend/static/css/index.css index f5c79a9..4914f78 100644 --- a/frontend/static/css/index.css +++ b/frontend/static/css/index.css @@ -1,8 +1,10 @@ -body { - margin: 0; - font-family: "Open sans", sans-serif; - color: white; - background-color: #2b2e30; +* { margin: 0; padding: 0; -} \ No newline at end of file +} + +body { + font-family: "Open sans", sans-serif; + color: white; + background-color: #252525; +} diff --git a/frontend/static/css/project.css b/frontend/static/css/project.css new file mode 100644 index 0000000..ada689f --- /dev/null +++ b/frontend/static/css/project.css @@ -0,0 +1,3 @@ +#project { + padding: 10px 20px; +} \ No newline at end of file diff --git a/frontend/static/css/sidebar.css b/frontend/static/css/sidebar.css index dcb173f..f81d80b 100644 --- a/frontend/static/css/sidebar.css +++ b/frontend/static/css/sidebar.css @@ -5,6 +5,7 @@ height: 100vh; display: flex; flex-direction: column; + float: left; } #sidebar .logo {