From a748e2c2dbf15a18b1878cb6205e3a4b321db5bb Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Thu, 23 May 2024 21:25:22 +0530 Subject: [PATCH] feat: notification on mentions --- frontend/src/components/AppSidebar.vue | 51 +++++-- frontend/src/components/DiscussionReplies.vue | 11 +- frontend/src/components/SidebarLink.vue | 5 +- frontend/src/pages/Courses.vue | 12 +- frontend/src/pages/Notifications.vue | 134 +++++++++++++++--- lms/hooks.py | 1 + .../doctype/course_lesson/course_lesson.py | 1 - lms/lms/utils.py | 37 ++++- 8 files changed, 212 insertions(+), 40 deletions(-) diff --git a/frontend/src/components/AppSidebar.vue b/frontend/src/components/AppSidebar.vue index 7f9a05d0..cb22560f 100644 --- a/frontend/src/components/AppSidebar.vue +++ b/frontend/src/components/AppSidebar.vue @@ -10,7 +10,7 @@
{ + socket.on('publish_lms_notifications', (data) => { + unreadNotifications.reload() }) -} +}) + +const unreadNotifications = createResource({ + cache: 'Unread Notifications Count', + url: 'frappe.client.get_count', + makeParams(values) { + return { + doctype: 'Notification Log', + filters: { + for_user: user, + read: 0, + }, + } + }, + onSuccess(data) { + unreadCount.value = data + }, + auto: true, +}) + +const sidebarLinks = computed(() => { + const links = getSidebarLinks() + if (user) { + links.push({ + label: 'Notifications', + icon: Bell, + to: 'Notifications', + activeFor: ['Notifications'], + count: unreadCount.value, + }) + } + return links +}) const getSidebarFromStorage = () => { return useStorage('sidebar_is_collapsed', false) diff --git a/frontend/src/components/DiscussionReplies.vue b/frontend/src/components/DiscussionReplies.vue index b35b9620..4b77a937 100644 --- a/frontend/src/components/DiscussionReplies.vue +++ b/frontend/src/components/DiscussionReplies.vue @@ -151,7 +151,16 @@ const newReplyResource = createResource({ }) const mentionUsers = computed(() => { - return allUsers.data /* [{ + console.log(allUsers.data['jannat@frappe.io']) + let users = Object.values(allUsers.data).map((user) => { + return { + value: user.name, + label: user.full_name, + } + }) + return users + + /* [{ label: "jannat", value: "jannat" }, { diff --git a/frontend/src/components/SidebarLink.vue b/frontend/src/components/SidebarLink.vue index 74a70014..37432a78 100644 --- a/frontend/src/components/SidebarLink.vue +++ b/frontend/src/components/SidebarLink.vue @@ -6,7 +6,7 @@ @click="handleClick" >
@@ -29,6 +29,9 @@ > {{ link.label }} + + {{ link.count }} +
diff --git a/frontend/src/pages/Courses.vue b/frontend/src/pages/Courses.vue index cb3f323c..4f48e033 100644 --- a/frontend/src/pages/Courses.vue +++ b/frontend/src/pages/Courses.vue @@ -57,6 +57,14 @@ v-if="tab.courses && tab.courses.value.length" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-5 my-5 mx-5" > + +
+ + +
-
+
- - {{ __('View') }} - +
+ + {{ __('View') }} + + + + +
+
+
+ {{ __('Nothing to see here.') }}