From 396cf5c586d39dd813a9baaae3e4f42e25101271 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Tue, 10 Feb 2026 16:24:37 +0000 Subject: [PATCH] Add page for showing notifications --- html/template/sync/notification-list.html | 71 +++++++++++++++++++++++ notification/notification.go | 2 +- scss/custom.scss | 1 + scss/sync/notification.scss | 10 ++++ sync/notification.go | 42 ++++++++++++++ sync/routes.go | 5 +- 6 files changed, 128 insertions(+), 3 deletions(-) create mode 100644 html/template/sync/notification-list.html create mode 100644 scss/sync/notification.scss create mode 100644 sync/notification.go diff --git a/html/template/sync/notification-list.html b/html/template/sync/notification-list.html new file mode 100644 index 00000000..c4f9a490 --- /dev/null +++ b/html/template/sync/notification-list.html @@ -0,0 +1,71 @@ +{{ template "sync/layout/authenticated.html" . }} +{{ define "title" }}Layout Test{{ end }} +{{ define "extraheader" }} +{{ end }} +{{ define "content" }} +
+ +
+{{ end }} diff --git a/notification/notification.go b/notification/notification.go index 3e306c8b..4421ff81 100644 --- a/notification/notification.go +++ b/notification/notification.go @@ -85,7 +85,7 @@ func ForUser(ctx context.Context, u *models.User) ([]Notification, error) { func notificationTypeName(t enums.Notificationtype) string { switch t { case enums.NotificationtypeOauthTokenInvalidated: - return "alert" + return "oauth-token-invalid" default: return "unknown-type" } diff --git a/scss/custom.scss b/scss/custom.scss index 4231f3e1..004166ad 100644 --- a/scss/custom.scss +++ b/scss/custom.scss @@ -51,5 +51,6 @@ $theme-colors: map-merge( @import "./rmo/root.scss"; @import "./rmo/status.scss"; @import "./sync/dashboard.scss"; +@import "./sync/notification.scss"; @import "./sync/pool-csv-upload.scss"; @import "./sync/pool-by-id.scss"; diff --git a/scss/sync/notification.scss b/scss/sync/notification.scss new file mode 100644 index 00000000..c0a32667 --- /dev/null +++ b/scss/sync/notification.scss @@ -0,0 +1,10 @@ +.notification-item { + transition: all 0.2s ease; +} +.notification-item:hover { + background-color: rgba(0,0,0,0.05); +} +.notification-time { + font-size: 0.8rem; + color: #6c757d; +} diff --git a/sync/notification.go b/sync/notification.go new file mode 100644 index 00000000..dda61a46 --- /dev/null +++ b/sync/notification.go @@ -0,0 +1,42 @@ +package sync + +import ( + //"context" + //"fmt" + "net/http" + //"strings" + //"time" + + "github.com/Gleipnir-Technology/nidus-sync/db/models" + "github.com/Gleipnir-Technology/nidus-sync/html" + "github.com/Gleipnir-Technology/nidus-sync/notification" + //"github.com/Gleipnir-Technology/bob" + //"github.com/Gleipnir-Technology/bob/dialect/psql" + //"github.com/Gleipnir-Technology/bob/dialect/psql/sm" + //"github.com/Gleipnir-Technology/nidus-sync/db" + //"github.com/Gleipnir-Technology/nidus-sync/db/sql" + //"github.com/google/uuid" + //"github.com/uber/h3-go/v4" +) + +type contentNotificationList struct { + Notifications []notification.Notification + User User +} + +func getNotificationList(w http.ResponseWriter, r *http.Request, u *models.User) { + userContent, err := contentForUser(r.Context(), u) + if err != nil { + respondError(w, "Failed to get user", err, http.StatusInternalServerError) + return + } + ctx := r.Context() + notifications, err := notification.ForUser(ctx, u) + if err != nil { + respondError(w, "Failed to get notifications", err, http.StatusInternalServerError) + } + html.RenderOrError(w, "sync/notification-list.html", &contentNotificationList{ + Notifications: notifications, + User: userContent, + }) +} diff --git a/sync/routes.go b/sync/routes.go index e91a3b60..4db913e5 100644 --- a/sync/routes.go +++ b/sync/routes.go @@ -17,6 +17,7 @@ func Router() chi.Router { r.Get("/arcgis/oauth/callback", getArcgisOauthCallback) r.Get("/district", getDistrict) + // Mock endpoints r.Get("/mock", renderMock("mock-root.html")) r.Get("/mock/admin", renderMock("admin.html")) r.Get("/mock/admin/service-request", renderMock("admin-service-request.html")) @@ -46,10 +47,9 @@ func Router() chi.Router { r.Get("/mock/setting/user", renderMock("setting-user.html")) r.Get("/mock/setting/user/add", renderMock("setting-user-add.html")) + // Utility endpoints r.Get("/oauth/refresh", getOAuthRefresh) - r.Get("/privacy", getPrivacy) - r.Get("/qr-code/report/{code}", getQRCodeReport) r.Get("/signin", getSignin) r.Post("/signin", postSignin) @@ -61,6 +61,7 @@ func Router() chi.Router { r.Route("/api", api.AddRoutes) r.Method("GET", "/cell/{cell}", auth.NewEnsureAuth(getCellDetails)) r.Method("GET", "/layout-test", auth.NewEnsureAuth(getLayoutTest)) + r.Method("GET", "/notification", auth.NewEnsureAuth(getNotificationList)) r.Method("GET", "/pool", auth.NewEnsureAuth(getPoolList)) r.Method("GET", "/pool/upload", auth.NewEnsureAuth(getPoolUpload)) r.Method("GET", "/pool/upload/{id}", auth.NewEnsureAuth(getPoolUploadByID))