@memberjunction/ng-notifications 2.32.2 → 2.34.0
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/README.md +147 -0
- package/package.json +5 -5
package/README.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# @memberjunction/ng-notifications
|
|
2
|
+
|
|
3
|
+
Angular service for handling user notifications in MemberJunction applications, providing both UI notifications and database-backed persistent notifications.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Singleton notification service for consistent application-wide notifications
|
|
8
|
+
- Support for temporary UI notifications
|
|
9
|
+
- Database-backed persistent user notifications
|
|
10
|
+
- Real-time push notification updates
|
|
11
|
+
- Notification styling options (success, error, warning, info)
|
|
12
|
+
- Automatic notification refresh on login
|
|
13
|
+
- Unread notification tracking
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @memberjunction/ng-notifications
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
The service is automatically provided at the root level, so you can inject it directly into your components:
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { MJNotificationService } from '@memberjunction/ng-notifications';
|
|
27
|
+
|
|
28
|
+
@Component({
|
|
29
|
+
// ...
|
|
30
|
+
})
|
|
31
|
+
export class YourComponent {
|
|
32
|
+
constructor(private notificationService: MJNotificationService) {
|
|
33
|
+
// Use the service directly
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Or access the singleton instance
|
|
37
|
+
showNotification() {
|
|
38
|
+
MJNotificationService.Instance.CreateSimpleNotification('Operation completed', 'success', 3000);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Features
|
|
44
|
+
|
|
45
|
+
### Simple UI Notifications
|
|
46
|
+
|
|
47
|
+
Display temporary notifications to the user:
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
// Basic success notification
|
|
51
|
+
notificationService.CreateSimpleNotification('Operation completed successfully');
|
|
52
|
+
|
|
53
|
+
// Error notification that disappears after 5 seconds
|
|
54
|
+
notificationService.CreateSimpleNotification(
|
|
55
|
+
'An error occurred while processing your request',
|
|
56
|
+
'error',
|
|
57
|
+
5000
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
// Warning notification with manual close button
|
|
61
|
+
notificationService.CreateSimpleNotification(
|
|
62
|
+
'Please verify your input data',
|
|
63
|
+
'warning'
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
// Informational notification
|
|
67
|
+
notificationService.CreateSimpleNotification(
|
|
68
|
+
'New updates are available',
|
|
69
|
+
'info',
|
|
70
|
+
3000
|
|
71
|
+
);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Persistent Database Notifications
|
|
75
|
+
|
|
76
|
+
Create notifications that are stored in the database and can be viewed later:
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
// Create a simple notification
|
|
80
|
+
await notificationService.CreateNotification(
|
|
81
|
+
'New Comment',
|
|
82
|
+
'User John added a comment to your post',
|
|
83
|
+
null,
|
|
84
|
+
null,
|
|
85
|
+
null
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
// Create a notification linked to a resource
|
|
89
|
+
await notificationService.CreateNotification(
|
|
90
|
+
'Report Ready',
|
|
91
|
+
'Your requested report is now available',
|
|
92
|
+
reportResourceTypeId,
|
|
93
|
+
reportId,
|
|
94
|
+
{ reportConfig: 'some-config-data' }
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
// Create a notification but don't display it to the user immediately
|
|
98
|
+
await notificationService.CreateNotification(
|
|
99
|
+
'Background Update',
|
|
100
|
+
'System updated your preferences',
|
|
101
|
+
null,
|
|
102
|
+
null,
|
|
103
|
+
null,
|
|
104
|
+
false
|
|
105
|
+
);
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Accessing User Notifications
|
|
109
|
+
|
|
110
|
+
Retrieve user notifications:
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
// Get all notifications for the current user
|
|
114
|
+
const notifications = MJNotificationService.UserNotifications;
|
|
115
|
+
|
|
116
|
+
// Get only unread notifications
|
|
117
|
+
const unreadNotifications = MJNotificationService.UnreadUserNotifications;
|
|
118
|
+
|
|
119
|
+
// Get count of unread notifications
|
|
120
|
+
const unreadCount = MJNotificationService.UnreadUserNotificationCount;
|
|
121
|
+
|
|
122
|
+
// Manually refresh notifications from the database
|
|
123
|
+
await MJNotificationService.RefreshUserNotifications();
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Push Notifications
|
|
127
|
+
|
|
128
|
+
The service automatically subscribes to push notifications after login, handling:
|
|
129
|
+
|
|
130
|
+
- User notification updates
|
|
131
|
+
- System status messages
|
|
132
|
+
- Custom event propagation
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
// Access push status updates directly
|
|
136
|
+
notificationService.PushStatusUpdates().subscribe(status => {
|
|
137
|
+
// Handle status updates
|
|
138
|
+
});
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Event Integration
|
|
142
|
+
|
|
143
|
+
The service integrates with MemberJunction global events, reacting to:
|
|
144
|
+
|
|
145
|
+
- `MJEventType.LoggedIn`: Refreshes notifications and sets up push updates
|
|
146
|
+
- `MJEventType.DisplaySimpleNotificationRequest`: Displays notifications from other parts of the application
|
|
147
|
+
- `MJEventType.ComponentEvent` with `UserNotificationsUpdated` code: Refreshes notification list
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ng-notifications",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.34.0",
|
|
4
4
|
"description": "MemberJunction: Simple Angular library for displaying user notifications",
|
|
5
5
|
"main": "./dist/public-api.js",
|
|
6
6
|
"typings": "./dist/public-api.d.ts",
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"@progress/kendo-angular-notification": "16.2.0"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@memberjunction/core": "2.
|
|
28
|
-
"@memberjunction/core-entities": "2.
|
|
29
|
-
"@memberjunction/global": "2.
|
|
30
|
-
"@memberjunction/graphql-dataprovider": "2.
|
|
27
|
+
"@memberjunction/core": "2.34.0",
|
|
28
|
+
"@memberjunction/core-entities": "2.34.0",
|
|
29
|
+
"@memberjunction/global": "2.34.0",
|
|
30
|
+
"@memberjunction/graphql-dataprovider": "2.34.0",
|
|
31
31
|
"tslib": "^2.3.0",
|
|
32
32
|
"rxjs": "^7.8.1"
|
|
33
33
|
},
|