From fa59f87d3c1824885ded91a2f705bbf30ae24f9f Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 16 Mar 2024 12:28:50 +0800 Subject: [PATCH] :sparkles: Notification list --- pkg/server/accounts_api.go | 8 +- pkg/server/notifications_api.go | 5 +- pkg/views/src/components/NotificationList.vue | 87 +++++++++++++++++++ pkg/views/src/components/UserMenu.vue | 43 +++++++++ pkg/views/src/layouts/master.vue | 38 ++------ pkg/views/src/views/security.vue | 2 +- 6 files changed, 146 insertions(+), 37 deletions(-) create mode 100644 pkg/views/src/components/NotificationList.vue create mode 100644 pkg/views/src/components/UserMenu.vue diff --git a/pkg/server/accounts_api.go b/pkg/server/accounts_api.go index 30947ca..738f296 100644 --- a/pkg/server/accounts_api.go +++ b/pkg/server/accounts_api.go @@ -1,15 +1,16 @@ package server import ( + "fmt" + "strconv" + "time" + "code.smartsheep.studio/hydrogen/identity/pkg/database" "code.smartsheep.studio/hydrogen/identity/pkg/models" "code.smartsheep.studio/hydrogen/identity/pkg/services" - "fmt" "github.com/gofiber/fiber/v2" jsoniter "github.com/json-iterator/go" "github.com/spf13/viper" - "strconv" - "time" ) func getUserinfo(c *fiber.Ctx) error { @@ -20,7 +21,6 @@ func getUserinfo(c *fiber.Ctx) error { Where(&models.Account{BaseModel: models.BaseModel{ID: user.ID}}). Preload("Profile"). Preload("Contacts"). - Preload("Notifications", "read_at IS NULL"). First(&data).Error; err != nil { return fiber.NewError(fiber.StatusInternalServerError, err.Error()) } diff --git a/pkg/server/notifications_api.go b/pkg/server/notifications_api.go index c8f9cdf..1e84b38 100644 --- a/pkg/server/notifications_api.go +++ b/pkg/server/notifications_api.go @@ -1,12 +1,13 @@ package server import ( + "time" + "code.smartsheep.studio/hydrogen/identity/pkg/database" "code.smartsheep.studio/hydrogen/identity/pkg/models" "code.smartsheep.studio/hydrogen/identity/pkg/services" "github.com/gofiber/fiber/v2" "github.com/samber/lo" - "time" ) func getNotifications(c *fiber.Ctx) error { @@ -14,7 +15,7 @@ func getNotifications(c *fiber.Ctx) error { take := c.QueryInt("take", 0) offset := c.QueryInt("offset", 0) - only_unread := c.QueryBool("only_unread", true) + only_unread := !c.QueryBool("past", false) tx := database.C.Where(&models.Notification{RecipientID: user.ID}).Model(&models.Notification{}) if only_unread { diff --git a/pkg/views/src/components/NotificationList.vue b/pkg/views/src/components/NotificationList.vue new file mode 100644 index 0000000..c5cf0c5 --- /dev/null +++ b/pkg/views/src/components/NotificationList.vue @@ -0,0 +1,87 @@ + + + diff --git a/pkg/views/src/components/UserMenu.vue b/pkg/views/src/components/UserMenu.vue new file mode 100644 index 0000000..10a1c28 --- /dev/null +++ b/pkg/views/src/components/UserMenu.vue @@ -0,0 +1,43 @@ + + + diff --git a/pkg/views/src/layouts/master.vue b/pkg/views/src/layouts/master.vue index 5dd8f16..2231ccd 100644 --- a/pkg/views/src/layouts/master.vue +++ b/pkg/views/src/layouts/master.vue @@ -7,21 +7,13 @@ - - +
+ +
- - - - - - - -
+
+ +
@@ -31,26 +23,12 @@ diff --git a/pkg/views/src/views/security.vue b/pkg/views/src/views/security.vue index c081a9c..979527f 100644 --- a/pkg/views/src/views/security.vue +++ b/pkg/views/src/views/security.vue @@ -105,7 +105,7 @@