@ozdao/martyrs 0.2.430 → 0.2.431
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chats.server.js +0 -19
- package/dist/chats.server.mjs +0 -19
- package/dist/martyrs/src/components/Button/{Button.vue.cjs → Button.vue2.cjs} +2 -2
- package/dist/martyrs/src/components/Button/Button.vue2.cjs.map +1 -0
- package/dist/martyrs/src/components/Button/{Button.vue.js → Button.vue2.js} +2 -2
- package/dist/martyrs/src/components/Button/{Button.vue.cjs.map → Button.vue2.js.map} +1 -1
- package/dist/martyrs/src/components/Chips/{Chips.vue.cjs → Chips.vue2.cjs} +2 -2
- package/dist/martyrs/src/components/Chips/Chips.vue2.cjs.map +1 -0
- package/dist/martyrs/src/components/Chips/{Chips.vue.js → Chips.vue2.js} +2 -2
- package/dist/martyrs/src/components/Chips/Chips.vue2.js.map +1 -0
- package/dist/martyrs/src/components/Menu/{Menu.vue2.cjs → Menu.vue.cjs} +2 -2
- package/dist/martyrs/src/components/Menu/Menu.vue.cjs.map +1 -0
- package/dist/martyrs/src/components/Menu/{Menu.vue2.js → Menu.vue.js} +2 -2
- package/dist/martyrs/src/components/Menu/Menu.vue.js.map +1 -0
- package/dist/martyrs/src/components/Popup/{Popup.vue2.cjs → Popup.vue.cjs} +2 -2
- package/dist/martyrs/src/components/Popup/{Popup.vue2.js.map → Popup.vue.cjs.map} +1 -1
- package/dist/martyrs/src/components/Popup/{Popup.vue2.js → Popup.vue.js} +2 -2
- package/dist/martyrs/src/components/Popup/Popup.vue.js.map +1 -0
- package/dist/martyrs/src/components/Tab/{Tab.vue.cjs → Tab.vue2.cjs} +2 -2
- package/dist/martyrs/src/components/Tab/Tab.vue2.cjs.map +1 -0
- package/dist/martyrs/src/components/Tab/{Tab.vue.js → Tab.vue2.js} +2 -2
- package/dist/martyrs/src/components/Tab/{Tab.vue.cjs.map → Tab.vue2.js.map} +1 -1
- package/dist/martyrs/src/modules/auth/views/components/layouts/Auth.vue.cjs +2 -2
- package/dist/martyrs/src/modules/auth/views/components/layouts/Auth.vue.js +2 -2
- package/dist/martyrs/src/modules/auth/views/components/pages/EnterPassword.vue.cjs +2 -2
- package/dist/martyrs/src/modules/auth/views/components/pages/EnterPassword.vue.js +2 -2
- package/dist/martyrs/src/modules/auth/views/components/pages/Invite.vue.cjs +2 -2
- package/dist/martyrs/src/modules/auth/views/components/pages/Invite.vue.js +2 -2
- package/dist/martyrs/src/modules/auth/views/components/pages/Profile.vue.cjs +2 -2
- package/dist/martyrs/src/modules/auth/views/components/pages/Profile.vue.js +2 -2
- package/dist/martyrs/src/modules/auth/views/components/pages/ProfileBlogposts.vue.cjs +1 -1
- package/dist/martyrs/src/modules/auth/views/components/pages/ProfileBlogposts.vue.js +1 -1
- package/dist/martyrs/src/modules/auth/views/components/pages/ProfileEdit.vue.cjs +2 -2
- package/dist/martyrs/src/modules/auth/views/components/pages/ProfileEdit.vue.js +2 -2
- package/dist/martyrs/src/modules/auth/views/components/pages/ResetPassword.vue.cjs +2 -2
- package/dist/martyrs/src/modules/auth/views/components/pages/ResetPassword.vue.js +2 -2
- package/dist/martyrs/src/modules/auth/views/components/pages/SignIn.vue.cjs +2 -2
- package/dist/martyrs/src/modules/auth/views/components/pages/SignIn.vue.js +2 -2
- package/dist/martyrs/src/modules/auth/views/components/pages/SignUp.vue.cjs +2 -2
- package/dist/martyrs/src/modules/auth/views/components/pages/SignUp.vue.js +2 -2
- package/dist/martyrs/src/modules/auth/views/components/sections/ProfileEditCredentials.vue.cjs +1 -1
- package/dist/martyrs/src/modules/auth/views/components/sections/ProfileEditCredentials.vue.js +1 -1
- package/dist/martyrs/src/modules/community/components/blocks/CardBlogpost.vue.cjs +1 -1
- package/dist/martyrs/src/modules/community/components/blocks/CardBlogpost.vue.js +1 -1
- package/dist/martyrs/src/modules/community/components/pages/BlogPost.vue.cjs +3 -3
- package/dist/martyrs/src/modules/community/components/pages/BlogPost.vue.js +3 -3
- package/dist/martyrs/src/modules/community/components/pages/CreateBlogPost.vue.cjs +2 -2
- package/dist/martyrs/src/modules/community/components/pages/CreateBlogPost.vue.js +2 -2
- package/dist/martyrs/src/modules/events/components/blocks/CardEvent.vue.cjs +1 -1
- package/dist/martyrs/src/modules/events/components/blocks/CardEvent.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/elements/ButtonCheck.vue.cjs +1 -1
- package/dist/martyrs/src/modules/events/components/elements/ButtonCheck.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/elements/ButtonJoin.vue.cjs +1 -1
- package/dist/martyrs/src/modules/events/components/elements/ButtonJoin.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/pages/EditEvent.vue.cjs +2 -2
- package/dist/martyrs/src/modules/events/components/pages/EditEvent.vue.js +2 -2
- package/dist/martyrs/src/modules/events/components/pages/EditEventTickets.vue.cjs +2 -2
- package/dist/martyrs/src/modules/events/components/pages/EditEventTickets.vue.js +2 -2
- package/dist/martyrs/src/modules/events/components/pages/Event.vue.cjs +1 -1
- package/dist/martyrs/src/modules/events/components/pages/Event.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/pages/Events.vue.cjs +1 -1
- package/dist/martyrs/src/modules/events/components/pages/Events.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/pages/EventsBackoffice.vue.cjs +1 -1
- package/dist/martyrs/src/modules/events/components/pages/EventsBackoffice.vue.js +1 -1
- package/dist/martyrs/src/modules/gallery/components/pages/Gallery.vue.cjs +1 -1
- package/dist/martyrs/src/modules/gallery/components/pages/Gallery.vue.js +1 -1
- package/dist/martyrs/src/modules/gallery/components/sections/BackofficeGallery.vue.cjs +3 -3
- package/dist/martyrs/src/modules/gallery/components/sections/BackofficeGallery.vue.js +3 -3
- package/dist/martyrs/src/modules/globals/views/components/blocks/CardHeader.vue.cjs +1 -1
- package/dist/martyrs/src/modules/globals/views/components/blocks/CardHeader.vue.js +1 -1
- package/dist/martyrs/src/modules/globals/views/components/blocks/PopupDateSelector.vue.cjs +2 -2
- package/dist/martyrs/src/modules/globals/views/components/blocks/PopupDateSelector.vue.js +2 -2
- package/dist/martyrs/src/modules/globals/views/components/layouts/Client.vue.cjs +5 -4
- package/dist/martyrs/src/modules/globals/views/components/layouts/Client.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/globals/views/components/layouts/Client.vue.js +5 -4
- package/dist/martyrs/src/modules/globals/views/components/layouts/Client.vue.js.map +1 -1
- package/dist/martyrs/src/modules/globals/views/components/partials/Header.vue.cjs +1 -1
- package/dist/martyrs/src/modules/globals/views/components/partials/Header.vue.js +1 -1
- package/dist/martyrs/src/modules/globals/views/components/partials/NavigationBar.vue.cjs +1 -1
- package/dist/martyrs/src/modules/globals/views/components/partials/NavigationBar.vue.js +1 -1
- package/dist/martyrs/src/modules/globals/views/components/sections/SectionPageTitle.vue.cjs +1 -1
- package/dist/martyrs/src/modules/globals/views/components/sections/SectionPageTitle.vue.js +1 -1
- package/dist/martyrs/src/modules/landing/components/sections/SectionFeaturesImages.vue.cjs +101 -0
- package/dist/martyrs/src/modules/landing/components/sections/SectionFeaturesImages.vue.cjs.map +1 -0
- package/dist/martyrs/src/modules/landing/components/sections/SectionFeaturesImages.vue.js +101 -0
- package/dist/martyrs/src/modules/landing/components/sections/SectionFeaturesImages.vue.js.map +1 -0
- package/dist/martyrs/src/modules/landing/components/sections/SectionHeroToken.vue.cjs +85 -0
- package/dist/martyrs/src/modules/landing/components/sections/SectionHeroToken.vue.cjs.map +1 -0
- package/dist/martyrs/src/modules/landing/components/sections/SectionHeroToken.vue.js +85 -0
- package/dist/martyrs/src/modules/landing/components/sections/SectionHeroToken.vue.js.map +1 -0
- package/dist/martyrs/src/modules/landing/components/sections/SectionRoadmap.vue.cjs +97 -0
- package/dist/martyrs/src/modules/landing/components/sections/SectionRoadmap.vue.cjs.map +1 -0
- package/dist/martyrs/src/modules/landing/components/sections/SectionRoadmap.vue.js +97 -0
- package/dist/martyrs/src/modules/landing/components/sections/SectionRoadmap.vue.js.map +1 -0
- package/dist/martyrs/src/modules/landing/landing.client.cjs +6 -0
- package/dist/martyrs/src/modules/landing/landing.client.cjs.map +1 -1
- package/dist/martyrs/src/modules/landing/landing.client.js +6 -0
- package/dist/martyrs/src/modules/landing/landing.client.js.map +1 -1
- package/dist/martyrs/src/modules/notifications/components/elements/NotificationBadge.vue.cjs +4 -12
- package/dist/martyrs/src/modules/notifications/components/elements/NotificationBadge.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/notifications/components/elements/NotificationBadge.vue.js +4 -12
- package/dist/martyrs/src/modules/notifications/components/elements/NotificationBadge.vue.js.map +1 -1
- package/dist/martyrs/src/modules/notifications/notifications.client.cjs +135 -248
- package/dist/martyrs/src/modules/notifications/notifications.client.cjs.map +1 -1
- package/dist/martyrs/src/modules/notifications/notifications.client.js +135 -248
- package/dist/martyrs/src/modules/notifications/notifications.client.js.map +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderBackoffice.vue.cjs +2 -2
- package/dist/martyrs/src/modules/orders/components/pages/OrderBackoffice.vue.js +2 -2
- package/dist/martyrs/src/modules/orders/components/pages/OrderCreate.vue.cjs +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderCreate.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderCreate.vue.js +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderCreate.vue.js.map +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderCreateBackoffice.vue.cjs +3 -3
- package/dist/martyrs/src/modules/orders/components/pages/OrderCreateBackoffice.vue.js +3 -3
- package/dist/martyrs/src/modules/orders/components/pages/Orders.vue.cjs +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/Orders.vue.js +1 -1
- package/dist/martyrs/src/modules/orders/components/sections/FormAddCustomer.vue.cjs +1 -1
- package/dist/martyrs/src/modules/orders/components/sections/FormAddCustomer.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/blocks/CardOrganization.vue.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/components/blocks/CardOrganization.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/elements/ButtonToggleMembership.vue.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/components/elements/ButtonToggleMembership.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/pages/DepartmentEdit.vue.cjs +3 -3
- package/dist/martyrs/src/modules/organizations/components/pages/DepartmentEdit.vue.js +3 -3
- package/dist/martyrs/src/modules/organizations/components/pages/Members.vue.cjs +3 -3
- package/dist/martyrs/src/modules/organizations/components/pages/Members.vue.js +3 -3
- package/dist/martyrs/src/modules/organizations/components/pages/Organization.vue.cjs +5 -5
- package/dist/martyrs/src/modules/organizations/components/pages/Organization.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/organizations/components/pages/Organization.vue.js +5 -5
- package/dist/martyrs/src/modules/organizations/components/pages/Organization.vue.js.map +1 -1
- package/dist/martyrs/src/modules/organizations/components/pages/OrganizationBackoffice.vue.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/components/pages/OrganizationBackoffice.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/pages/OrganizationEdit.vue.cjs +3 -3
- package/dist/martyrs/src/modules/organizations/components/pages/OrganizationEdit.vue.js +3 -3
- package/dist/martyrs/src/modules/organizations/components/pages/Organizations.vue.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/components/pages/Organizations.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/sections/DetailsTabSection.vue.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/components/sections/DetailsTabSection.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/sections/Documents.vue.cjs +2 -2
- package/dist/martyrs/src/modules/organizations/components/sections/Documents.vue.js +2 -2
- package/dist/martyrs/src/modules/organizations/components/sections/MembersAdd.vue.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/components/sections/MembersAdd.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/sections/Organizations.vue.cjs +2 -2
- package/dist/martyrs/src/modules/organizations/components/sections/Organizations.vue.js +2 -2
- package/dist/martyrs/src/modules/pages/views/components/blocks/CardPage.vue.cjs +1 -1
- package/dist/martyrs/src/modules/pages/views/components/blocks/CardPage.vue.js +1 -1
- package/dist/martyrs/src/modules/pages/views/components/pages/PageEdit.vue.cjs +1 -1
- package/dist/martyrs/src/modules/pages/views/components/pages/PageEdit.vue.js +1 -1
- package/dist/martyrs/src/modules/pages/views/components/partials/SidebarPages.vue.cjs +2 -2
- package/dist/martyrs/src/modules/pages/views/components/partials/SidebarPages.vue.js +2 -2
- package/dist/martyrs/src/modules/products/components/blocks/ImagesThumbnails.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/blocks/ImagesThumbnails.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Categories.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Categories.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/pages/CategoryEdit.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/pages/CategoryEdit.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/pages/EditLeftover.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/pages/EditLeftover.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Leftovers.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Leftovers.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Product.vue.cjs +12 -10
- package/dist/martyrs/src/modules/products/components/pages/Product.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Product.vue.js +12 -10
- package/dist/martyrs/src/modules/products/components/pages/Product.vue.js.map +1 -1
- package/dist/martyrs/src/modules/products/components/pages/ProductEdit.vue.cjs +3 -3
- package/dist/martyrs/src/modules/products/components/pages/ProductEdit.vue.js +3 -3
- package/dist/martyrs/src/modules/products/components/pages/Products.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Products.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/sections/EditProductInfo.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/sections/EditProductInfo.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/sections/SectionProduct.vue.cjs +2 -2
- package/dist/martyrs/src/modules/products/components/sections/SectionProduct.vue.js +2 -2
- package/dist/martyrs/src/modules/rents/views/components/pages/GanttChart.vue.cjs +1 -1
- package/dist/martyrs/src/modules/rents/views/components/pages/GanttChart.vue.js +1 -1
- package/dist/martyrs/src/modules/rents/views/components/pages/Rents.vue.cjs +1 -1
- package/dist/martyrs/src/modules/rents/views/components/pages/Rents.vue.js +1 -1
- package/dist/martyrs/src/modules/rents/views/components/pages/RentsEdit.vue.cjs +1 -1
- package/dist/martyrs/src/modules/rents/views/components/pages/RentsEdit.vue.js +1 -1
- package/dist/martyrs/src/modules/reports/components/sections/FormReport.vue.cjs +2 -2
- package/dist/martyrs/src/modules/reports/components/sections/FormReport.vue.js +2 -2
- package/dist/martyrs/src/modules/spots/components/blocks/CardSpot.vue.cjs +1 -1
- package/dist/martyrs/src/modules/spots/components/blocks/CardSpot.vue.js +1 -1
- package/dist/martyrs/src/modules/spots/components/pages/Map.vue.cjs +1 -1
- package/dist/martyrs/src/modules/spots/components/pages/Map.vue.js +1 -1
- package/dist/martyrs/src/modules/spots/components/pages/SpotEdit.vue.cjs +3 -3
- package/dist/martyrs/src/modules/spots/components/pages/SpotEdit.vue.js +3 -3
- package/dist/notifications.server.js +85 -1
- package/dist/notifications.server.mjs +85 -1
- package/dist/orders.server.js +0 -27
- package/dist/orders.server.mjs +0 -27
- package/dist/style.css +101 -18
- package/package.json +1 -1
- package/src/builder/modes/ssr.dev.js +0 -20
- package/src/modules/chats/routes/chats.routes.js +19 -19
- package/src/modules/globals/controllers/utils/queryProcessor.js +1 -1
- package/src/modules/globals/views/components/layouts/Client.vue +6 -6
- package/src/modules/landing/components/sections/SectionHeroToken.vue +1 -1
- package/src/modules/landing/landing.client.js +7 -0
- package/src/modules/notifications/components/elements/NotificationBadge.vue +4 -13
- package/src/modules/notifications/notifications.client.js +166 -350
- package/src/modules/notifications/services/notification.service.js +4 -3
- package/src/modules/notifications/services/websocket.service.js +54 -56
- package/src/modules/orders/components/pages/OrderCreate.vue +1 -1
- package/src/modules/orders/controllers/orders.controller.js +1 -2
- package/src/modules/organizations/components/pages/Organization.vue +3 -3
- package/src/modules/products/components/pages/Product.vue +10 -9
- package/dist/martyrs/src/components/Button/Button.vue.js.map +0 -1
- package/dist/martyrs/src/components/Chips/Chips.vue.cjs.map +0 -1
- package/dist/martyrs/src/components/Chips/Chips.vue.js.map +0 -1
- package/dist/martyrs/src/components/Menu/Menu.vue2.cjs.map +0 -1
- package/dist/martyrs/src/components/Menu/Menu.vue2.js.map +0 -1
- package/dist/martyrs/src/components/Popup/Popup.vue2.cjs.map +0 -1
- package/dist/martyrs/src/components/Tab/Tab.vue.js.map +0 -1
|
@@ -1,322 +1,168 @@
|
|
|
1
1
|
import { watch, toRefs } from "vue";
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
// Store
|
|
5
|
-
import * as storeNotifications from './store/notifications.store.js';
|
|
6
|
-
// Auth store import
|
|
2
|
+
import routerNotifications from './router/notifications.router.js';
|
|
3
|
+
import * as storeNotifications from './store/notifications.store.js';
|
|
7
4
|
import * as auth from '@martyrs/src/modules/auth/views/store/auth';
|
|
8
|
-
// Global WebSocket import
|
|
9
5
|
import globalWebSocket from '@martyrs/src/modules/globals/views/classes/globals.websocket.js';
|
|
10
|
-
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
import Notifications from './components/pages/Notifications.vue';
|
|
17
|
-
// Components
|
|
18
|
-
import NotificationBadge from './components/elements/NotificationBadge.vue';
|
|
19
|
-
import NotificationItem from './components/blocks/NotificationItem.vue';
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* WebSocket notification handler that uses the global WebSocket connection
|
|
23
|
-
*/
|
|
24
|
-
class WebSocketNotificationHandler {
|
|
25
|
-
constructor(store, options = {}) {
|
|
26
|
-
this.store = store;
|
|
27
|
-
this.options = options;
|
|
28
|
-
this.moduleName = 'notifications';
|
|
29
|
-
this.listeners = [];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Connect to notifications channel
|
|
34
|
-
*/
|
|
35
|
-
connect(userId) {
|
|
36
|
-
// Skip if running in SSR
|
|
37
|
-
if (typeof window === 'undefined' || !userId) {
|
|
38
|
-
return Promise.resolve(false);
|
|
39
|
-
}
|
|
6
|
+
import NotificationsLayout from './components/layouts/NotificationsLayout.vue';
|
|
7
|
+
import NotificationsList from './components/sections/NotificationsList.vue';
|
|
8
|
+
import NotificationPreferences from './components/sections/NotificationPreferences.vue';
|
|
9
|
+
import Notifications from './components/pages/Notifications.vue';
|
|
10
|
+
import NotificationBadge from './components/elements/NotificationBadge.vue';
|
|
11
|
+
import NotificationItem from './components/blocks/NotificationItem.vue';
|
|
40
12
|
|
|
41
|
-
|
|
13
|
+
// WebSocket notification handlers
|
|
14
|
+
const wsNotificationHandlers = {
|
|
15
|
+
connect: (store, userId, options = {}) => {
|
|
16
|
+
if (typeof window === 'undefined' || !userId) return Promise.resolve(false);
|
|
17
|
+
|
|
42
18
|
return globalWebSocket.connect(userId).then(() => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return true;
|
|
46
|
-
});
|
|
47
|
-
}
|
|
19
|
+
const moduleName = 'notifications';
|
|
20
|
+
const listeners = [];
|
|
48
21
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
disconnect() {
|
|
53
|
-
globalWebSocket.removeModuleListeners(this.moduleName);
|
|
54
|
-
}
|
|
22
|
+
const addListener = (event, handler) => {
|
|
23
|
+
listeners.push(globalWebSocket.addEventListener(event, handler, { module: moduleName }));
|
|
24
|
+
};
|
|
55
25
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}, { module: this.moduleName })
|
|
72
|
-
);
|
|
73
|
-
}
|
|
26
|
+
addListener('notification', (data) => {
|
|
27
|
+
if (!data || !data.data) return;
|
|
28
|
+
const notification = data.data;
|
|
29
|
+
|
|
30
|
+
store.notifications.actions.addLocalNotification({
|
|
31
|
+
_id: notification._id,
|
|
32
|
+
title: notification.title,
|
|
33
|
+
body: notification.body,
|
|
34
|
+
type: notification.type || 'info',
|
|
35
|
+
metadata: notification.metadata || {},
|
|
36
|
+
status: 'unread',
|
|
37
|
+
createdAt: notification.createdAt || new Date().toISOString(),
|
|
38
|
+
updatedAt: notification.updatedAt || new Date().toISOString()
|
|
39
|
+
});
|
|
40
|
+
});
|
|
74
41
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const notification = data.data;
|
|
82
|
-
|
|
83
|
-
// Add notification to store
|
|
84
|
-
this.store.notifications.actions.addLocalNotification({
|
|
85
|
-
_id: notification._id,
|
|
86
|
-
title: notification.title,
|
|
87
|
-
body: notification.body,
|
|
88
|
-
type: notification.type || 'info',
|
|
89
|
-
metadata: notification.metadata || {},
|
|
90
|
-
status: 'unread',
|
|
91
|
-
createdAt: notification.createdAt || new Date().toISOString(),
|
|
92
|
-
updatedAt: notification.updatedAt || new Date().toISOString()
|
|
42
|
+
addListener('notification_read', (data) => {
|
|
43
|
+
store.notifications.actions.syncNotificationStatus(data.notificationId, 'read');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
return { listeners, moduleName };
|
|
93
47
|
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Capacitor Push Notification handler
|
|
99
|
-
*/
|
|
100
|
-
class CapacitorPushHandler {
|
|
101
|
-
constructor(store) {
|
|
102
|
-
this.store = store;
|
|
103
|
-
this.pushNotifications = null;
|
|
104
|
-
this.device = null;
|
|
105
|
-
this.isInitialized = false;
|
|
106
|
-
}
|
|
48
|
+
},
|
|
107
49
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
async initialize() {
|
|
112
|
-
// Skip if running in SSR
|
|
113
|
-
if (typeof window === 'undefined') {
|
|
114
|
-
return false;
|
|
50
|
+
disconnect: (moduleName, listeners) => {
|
|
51
|
+
if (listeners) {
|
|
52
|
+
globalWebSocket.removeModuleListeners(moduleName);
|
|
115
53
|
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// Capacitor Push Notification handlers
|
|
58
|
+
const pushNotificationHandlers = {
|
|
59
|
+
initialize: async () => {
|
|
60
|
+
if (typeof window === 'undefined') return false;
|
|
116
61
|
|
|
117
62
|
try {
|
|
118
|
-
// Dynamic imports to prevent errors in web environment
|
|
119
63
|
const { Capacitor } = await import('@capacitor/core');
|
|
120
64
|
const { PushNotifications } = await import('@capacitor/push-notifications');
|
|
121
65
|
const { Device } = await import('@capacitor/device');
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
// Only proceed if running on a native platform
|
|
128
|
-
if (!this.capacitor.isNativePlatform()) {
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
this.isInitialized = true;
|
|
133
|
-
return true;
|
|
66
|
+
|
|
67
|
+
if (!Capacitor.isNativePlatform()) return false;
|
|
68
|
+
|
|
69
|
+
return { pushNotifications: PushNotifications, device: Device };
|
|
134
70
|
} catch (error) {
|
|
135
71
|
console.error('Error importing Capacitor plugins:', error);
|
|
136
72
|
return false;
|
|
137
73
|
}
|
|
138
|
-
}
|
|
74
|
+
},
|
|
139
75
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
*/
|
|
143
|
-
async requestPermissions() {
|
|
144
|
-
// Skip if running in SSR
|
|
145
|
-
if (typeof window === 'undefined') {
|
|
146
|
-
return false;
|
|
147
|
-
}
|
|
76
|
+
requestPermissions: async (store) => {
|
|
77
|
+
if (typeof window === 'undefined') return false;
|
|
148
78
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
if (!initialized) return false;
|
|
152
|
-
}
|
|
79
|
+
const plugins = await pushNotificationHandlers.initialize();
|
|
80
|
+
if (!plugins) return false;
|
|
153
81
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
return false;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// Set up event listeners
|
|
163
|
-
this._setupListeners();
|
|
164
|
-
|
|
165
|
-
// Register with Apple/Google
|
|
166
|
-
await this.pushNotifications.register();
|
|
167
|
-
return true;
|
|
168
|
-
} catch (error) {
|
|
169
|
-
console.error('Error requesting push notification permissions:', error);
|
|
82
|
+
const { pushNotifications, device } = plugins;
|
|
83
|
+
|
|
84
|
+
const permissionResult = await pushNotifications.requestPermissions();
|
|
85
|
+
if (permissionResult.receive !== 'granted') {
|
|
86
|
+
console.log('Push notification permission denied');
|
|
170
87
|
return false;
|
|
171
88
|
}
|
|
172
|
-
}
|
|
173
89
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
this.pushNotifications.addListener('registration',
|
|
180
|
-
this._handleRegistration.bind(this)
|
|
181
|
-
);
|
|
182
|
-
|
|
183
|
-
// Notification received event
|
|
184
|
-
this.pushNotifications.addListener('pushNotificationReceived',
|
|
185
|
-
this._handleNotificationReceived.bind(this)
|
|
186
|
-
);
|
|
187
|
-
|
|
188
|
-
// Notification action performed event
|
|
189
|
-
this.pushNotifications.addListener('pushNotificationActionPerformed',
|
|
190
|
-
this._handleNotificationAction.bind(this)
|
|
191
|
-
);
|
|
192
|
-
}
|
|
90
|
+
const setupListeners = () => {
|
|
91
|
+
pushNotifications.addListener('registration', async (token) => {
|
|
92
|
+
try {
|
|
93
|
+
const deviceInfo = await device.getInfo();
|
|
94
|
+
const deviceId = await device.getId();
|
|
193
95
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
// Get device info
|
|
200
|
-
const deviceInfo = await this.device.getInfo();
|
|
201
|
-
const deviceId = await this.device.getId();
|
|
202
|
-
|
|
203
|
-
// Prepare device data
|
|
204
|
-
const deviceData = {
|
|
205
|
-
deviceId: deviceId.uuid,
|
|
206
|
-
deviceType: deviceInfo.platform.toLowerCase(),
|
|
207
|
-
deviceToken: token.value
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
// Register device with backend
|
|
211
|
-
await this.store.notifications.actions.registerDevice(deviceData);
|
|
212
|
-
} catch (error) {
|
|
213
|
-
console.error('Error handling push registration:', error);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
96
|
+
const deviceData = {
|
|
97
|
+
deviceId: deviceId.uuid,
|
|
98
|
+
deviceType: deviceInfo.platform.toLowerCase(),
|
|
99
|
+
deviceToken: token.value
|
|
100
|
+
};
|
|
216
101
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
this.store.notifications.actions.addLocalNotification({
|
|
223
|
-
title: notification.title,
|
|
224
|
-
body: notification.body,
|
|
225
|
-
data: notification.data || {}
|
|
226
|
-
});
|
|
227
|
-
}
|
|
102
|
+
await store.notifications.actions.registerDevice(deviceData);
|
|
103
|
+
} catch (error) {
|
|
104
|
+
console.error('Error handling push registration:', error);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
228
107
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
108
|
+
pushNotifications.addListener('pushNotificationReceived', (notification) => {
|
|
109
|
+
store.notifications.actions.addLocalNotification({
|
|
110
|
+
title: notification.title,
|
|
111
|
+
body: notification.body,
|
|
112
|
+
data: notification.data || {}
|
|
113
|
+
});
|
|
114
|
+
});
|
|
239
115
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
* Notification Manager for coordinating WebSocket and Push notifications
|
|
256
|
-
*/
|
|
257
|
-
class NotificationManager {
|
|
258
|
-
constructor(store, options = {}) {
|
|
259
|
-
this.store = store;
|
|
260
|
-
this.options = options;
|
|
261
|
-
this.wsHandler = new WebSocketNotificationHandler(store, options);
|
|
262
|
-
this.pushHandler = new CapacitorPushHandler(store);
|
|
263
|
-
this.initialized = false;
|
|
264
|
-
this.isServer = typeof window === 'undefined';
|
|
116
|
+
pushNotifications.addListener('pushNotificationActionPerformed', (actionData) => {
|
|
117
|
+
if (actionData.notification && actionData.notification.data) {
|
|
118
|
+
store.notifications.actions.handleNotificationAction(actionData.notification.data);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
setupListeners();
|
|
124
|
+
await pushNotifications.register();
|
|
125
|
+
return true;
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
removeListeners: (pushNotifications) => {
|
|
129
|
+
if (typeof window === 'undefined' || !pushNotifications) return;
|
|
130
|
+
pushNotifications.removeAllListeners();
|
|
265
131
|
}
|
|
132
|
+
};
|
|
266
133
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
// Get current user ID from auth store instead of localStorage
|
|
274
|
-
const userId = this.store.auth.state.user?._id;
|
|
134
|
+
// Notification utilities
|
|
135
|
+
const notificationUtils = {
|
|
136
|
+
initialize: async (store, options = {}) => {
|
|
137
|
+
if (typeof window === 'undefined') return;
|
|
138
|
+
|
|
139
|
+
const userId = store.auth.state.user?._id;
|
|
275
140
|
if (!userId) {
|
|
276
141
|
console.warn('Cannot initialize notifications: No user ID found in auth store');
|
|
277
142
|
return;
|
|
278
143
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
// Initialize push notifications for mobile if enabled
|
|
284
|
-
if (this.options.enablePush !== false) {
|
|
285
|
-
await this.pushHandler.requestPermissions();
|
|
144
|
+
|
|
145
|
+
let wsListeners = null;
|
|
146
|
+
if (options.enablePush !== false) {
|
|
147
|
+
await pushNotificationHandlers.requestPermissions(store);
|
|
286
148
|
}
|
|
287
|
-
|
|
288
|
-
this.initialized = true;
|
|
289
|
-
|
|
290
|
-
// Fetch existing notifications
|
|
291
|
-
await this.store.notifications.actions.getNotifications(userId);
|
|
292
|
-
}
|
|
293
149
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
* Server-side utility for pre-fetching notification data
|
|
308
|
-
*/
|
|
309
|
-
const SSRUtils = {
|
|
310
|
-
/**
|
|
311
|
-
* Pre-fetch notifications for SSR
|
|
312
|
-
* @param {Object} store - Store instance
|
|
313
|
-
* @param {Object} context - SSR context
|
|
314
|
-
*/
|
|
315
|
-
async prefetchNotifications(store, context) {
|
|
150
|
+
wsListeners = await wsNotificationHandlers.connect(store, userId, options);
|
|
151
|
+
|
|
152
|
+
await store.notifications.actions.getNotifications(userId);
|
|
153
|
+
|
|
154
|
+
return {
|
|
155
|
+
disconnect: () => {
|
|
156
|
+
wsNotificationHandlers.disconnect(wsListeners?.moduleName, wsListeners?.listeners);
|
|
157
|
+
pushNotificationHandlers.removeListeners(globalThis.pushNotifications);
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
},
|
|
161
|
+
|
|
162
|
+
prefetchForSSR: async (store, context) => {
|
|
316
163
|
try {
|
|
317
164
|
const userId = store.auth.state.user?._id;
|
|
318
165
|
if (userId) {
|
|
319
|
-
// Fetch notifications without WebSocket or push setup
|
|
320
166
|
await store.notifications.actions.getNotifications(userId);
|
|
321
167
|
}
|
|
322
168
|
} catch (error) {
|
|
@@ -325,116 +171,86 @@ const SSRUtils = {
|
|
|
325
171
|
}
|
|
326
172
|
};
|
|
327
173
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
* @param {Object} app - Vue app instance
|
|
331
|
-
* @param {Object} store - Vuex/Pinia store
|
|
332
|
-
* @param {Object} router - Vue Router instance
|
|
333
|
-
* @param {Object} options - Configuration options
|
|
334
|
-
*/
|
|
335
|
-
function initializeNotifications(app, store, router, options = {}) {
|
|
336
|
-
// Add routes and store
|
|
174
|
+
// Main initialization function
|
|
175
|
+
const initializeNotifications = (app, store, router, options = {}) => {
|
|
337
176
|
const route = options.route || 'User Profile Root';
|
|
338
177
|
router.addRoute(route, routerNotifications);
|
|
339
178
|
store.addStore('notifications', storeNotifications);
|
|
340
|
-
|
|
341
|
-
// Initialize global WebSocket if needed
|
|
179
|
+
|
|
342
180
|
if (options.wsUrl) {
|
|
343
181
|
globalWebSocket.initialize({ wsUrl: options.wsUrl });
|
|
344
182
|
}
|
|
345
|
-
|
|
346
|
-
// Create notification manager
|
|
347
|
-
const notificationManager = new NotificationManager(store, {
|
|
348
|
-
enablePush: options.enablePush !== false,
|
|
349
|
-
maxReconnectAttempts: options.maxReconnectAttempts || 5,
|
|
350
|
-
reconnectDelay: options.reconnectDelay || 3000,
|
|
351
|
-
pingInterval: options.pingInterval || 30000
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
// Attach notification manager to store for access in components
|
|
355
|
-
store.notificationManager = notificationManager;
|
|
356
|
-
|
|
357
|
-
// Don't auto-initialize on server
|
|
183
|
+
|
|
358
184
|
const isServer = typeof window === 'undefined';
|
|
359
185
|
const autoInit = !isServer && options.autoInit !== false;
|
|
360
|
-
|
|
186
|
+
|
|
187
|
+
let notificationManager = null;
|
|
188
|
+
|
|
361
189
|
if (autoInit) {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
190
|
+
const initNotifications = async () => {
|
|
191
|
+
if (store.auth.state.isAuthenticated && store.auth.state.user?._id) {
|
|
192
|
+
notificationManager = await notificationUtils.initialize(store, {
|
|
193
|
+
enablePush: options.enablePush !== false,
|
|
194
|
+
maxReconnectAttempts: options.maxReconnectAttempts || 5,
|
|
195
|
+
reconnectDelay: options.reconnectDelay || 3000,
|
|
196
|
+
pingInterval: options.pingInterval || 30000
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
|
|
371
201
|
watch(() => store.auth.state.isAuthenticated, (isAuthenticated) => {
|
|
372
202
|
if (isAuthenticated) {
|
|
373
|
-
|
|
374
|
-
} else {
|
|
203
|
+
initNotifications();
|
|
204
|
+
} else if (notificationManager) {
|
|
375
205
|
notificationManager.disconnect();
|
|
376
206
|
store.notifications.mutations.resetNotifications();
|
|
207
|
+
notificationManager = null;
|
|
377
208
|
}
|
|
378
209
|
});
|
|
210
|
+
|
|
211
|
+
if (store.auth.state.isAuthenticated) {
|
|
212
|
+
initNotifications();
|
|
213
|
+
}
|
|
379
214
|
}
|
|
380
|
-
|
|
381
|
-
// Provide composable for components to access notification functionality
|
|
382
|
-
app.provide('useNotifications', () => {
|
|
383
|
-
return {
|
|
384
|
-
...toRefs(store.notifications.state),
|
|
385
|
-
...store.notifications.actions,
|
|
386
|
-
...store.notifications.mutations,
|
|
387
|
-
init: notificationManager.initialize.bind(notificationManager),
|
|
388
|
-
disconnect: notificationManager.disconnect.bind(notificationManager),
|
|
389
|
-
isServer
|
|
390
|
-
};
|
|
391
|
-
});
|
|
392
|
-
|
|
393
|
-
return notificationManager;
|
|
394
|
-
}
|
|
395
215
|
|
|
396
|
-
|
|
216
|
+
app.provide('useNotifications', () => ({
|
|
217
|
+
...toRefs(store.notifications.state),
|
|
218
|
+
...store.notifications.actions,
|
|
219
|
+
...store.notifications.mutations,
|
|
220
|
+
init: () => notificationUtils.initialize(store, options),
|
|
221
|
+
disconnect: () => notificationManager?.disconnect(),
|
|
222
|
+
isServer
|
|
223
|
+
}));
|
|
224
|
+
|
|
225
|
+
return {
|
|
226
|
+
SSR: { prefetchNotifications: notificationUtils.prefetchForSSR }
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
|
|
397
230
|
const ModuleNotifications = {
|
|
398
231
|
initialize: initializeNotifications,
|
|
399
|
-
SSR: SSRUtils, // Export SSR utilities
|
|
400
232
|
views: {
|
|
401
|
-
store: {
|
|
402
|
-
|
|
403
|
-
},
|
|
404
|
-
router: {
|
|
405
|
-
routerNotifications
|
|
406
|
-
},
|
|
233
|
+
store: { storeNotifications },
|
|
234
|
+
router: { routerNotifications },
|
|
407
235
|
components: {
|
|
408
|
-
// Elements
|
|
409
236
|
NotificationBadge,
|
|
410
|
-
// Blocks
|
|
411
237
|
NotificationItem,
|
|
412
|
-
// Sections
|
|
413
238
|
NotificationsList,
|
|
414
239
|
NotificationPreferences,
|
|
415
|
-
// Pages
|
|
416
240
|
Notifications,
|
|
417
|
-
// Layouts
|
|
418
241
|
NotificationsLayout
|
|
419
242
|
}
|
|
420
243
|
}
|
|
421
244
|
};
|
|
422
245
|
|
|
423
|
-
// Component exports
|
|
424
246
|
export {
|
|
425
|
-
// Elements
|
|
426
247
|
NotificationBadge,
|
|
427
|
-
// Blocks
|
|
428
248
|
NotificationItem,
|
|
429
|
-
// Sections
|
|
430
249
|
NotificationsList,
|
|
431
250
|
NotificationPreferences,
|
|
432
|
-
// Pages
|
|
433
251
|
Notifications,
|
|
434
|
-
// Layouts
|
|
435
252
|
NotificationsLayout,
|
|
436
|
-
|
|
437
|
-
SSRUtils
|
|
253
|
+
notificationUtils as SSRUtils
|
|
438
254
|
};
|
|
439
255
|
|
|
440
256
|
export default ModuleNotifications;
|
|
@@ -108,14 +108,15 @@ const NotificationService = (db, wss) => {
|
|
|
108
108
|
};
|
|
109
109
|
|
|
110
110
|
// Send web notification (for real-time notifications via WebSocket/SSE)
|
|
111
|
+
const webSocketService = require('./websocket.service')(wss);
|
|
112
|
+
|
|
111
113
|
const sendWebNotification = async (notification, user) => {
|
|
112
|
-
|
|
113
|
-
return wss.sendToUser(user._id, {
|
|
114
|
+
return webSocketService.sendToUser(user._id, {
|
|
114
115
|
type: 'notification',
|
|
115
116
|
data: notification
|
|
116
117
|
});
|
|
117
118
|
};
|
|
118
|
-
|
|
119
|
+
|
|
119
120
|
// Send push notification to mobile device
|
|
120
121
|
const sendPushNotification = async (notification, user, device) => {
|
|
121
122
|
// Implementation would depend on your push notification provider (Firebase, APN, etc.)
|