mesauth-angular 0.1.10 → 0.1.11

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.
Files changed (37) hide show
  1. package/dist/README.md +265 -0
  2. package/dist/esm2020/index.mjs +9 -0
  3. package/dist/esm2020/ma-user.component.mjs +26 -0
  4. package/dist/esm2020/mes-auth.interceptor.mjs +29 -0
  5. package/dist/esm2020/mes-auth.module.mjs +23 -0
  6. package/dist/esm2020/mes-auth.service.mjs +103 -0
  7. package/dist/esm2020/mesauth-angular.mjs +5 -0
  8. package/dist/esm2020/notification-badge.component.mjs +57 -0
  9. package/dist/esm2020/notification-panel.component.mjs +196 -0
  10. package/dist/esm2020/toast-container.component.mjs +60 -0
  11. package/dist/esm2020/toast.service.mjs +41 -0
  12. package/dist/esm2020/user-profile.component.mjs +197 -0
  13. package/dist/fesm2015/mesauth-angular.mjs +701 -0
  14. package/dist/fesm2015/mesauth-angular.mjs.map +1 -0
  15. package/dist/fesm2020/mesauth-angular.mjs +700 -0
  16. package/dist/fesm2020/mesauth-angular.mjs.map +1 -0
  17. package/dist/ma-user.component.d.ts +3 -0
  18. package/dist/mes-auth.interceptor.d.ts +3 -0
  19. package/dist/mes-auth.module.d.ts +4 -0
  20. package/dist/mes-auth.service.d.ts +5 -1
  21. package/dist/notification-badge.component.d.ts +3 -0
  22. package/dist/notification-panel.component.d.ts +3 -0
  23. package/dist/package.json +52 -0
  24. package/dist/toast-container.component.d.ts +3 -0
  25. package/dist/toast.service.d.ts +3 -0
  26. package/dist/user-profile.component.d.ts +3 -0
  27. package/package.json +15 -9
  28. package/dist/index.js +0 -8
  29. package/dist/ma-user.component.js +0 -33
  30. package/dist/mes-auth.interceptor.js +0 -36
  31. package/dist/mes-auth.module.js +0 -33
  32. package/dist/mes-auth.service.js +0 -107
  33. package/dist/notification-badge.component.js +0 -100
  34. package/dist/notification-panel.component.js +0 -327
  35. package/dist/toast-container.component.js +0 -185
  36. package/dist/toast.service.js +0 -43
  37. package/dist/user-profile.component.js +0 -363
@@ -1,100 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- import { Component, Output, EventEmitter } from '@angular/core';
11
- import { NgIf } from '@angular/common';
12
- import { MesAuthService } from './mes-auth.service';
13
- import { Subject } from 'rxjs';
14
- import { takeUntil } from 'rxjs/operators';
15
- let NotificationBadgeComponent = class NotificationBadgeComponent {
16
- constructor(authService) {
17
- this.authService = authService;
18
- this.notificationClick = new EventEmitter();
19
- this.unreadCount = 0;
20
- this.destroy$ = new Subject();
21
- }
22
- ngOnInit() {
23
- this.loadUnreadCount();
24
- // Listen for new notifications
25
- this.authService.notifications$
26
- .pipe(takeUntil(this.destroy$))
27
- .subscribe(() => {
28
- this.loadUnreadCount();
29
- });
30
- }
31
- ngOnDestroy() {
32
- this.destroy$.next();
33
- this.destroy$.complete();
34
- }
35
- loadUnreadCount() {
36
- this.authService.getUnreadCount().subscribe({
37
- next: (response) => {
38
- this.unreadCount = response.unreadCount || 0;
39
- },
40
- error: (err) => console.error('Error loading unread count:', err)
41
- });
42
- }
43
- onNotificationClick() {
44
- this.notificationClick.emit();
45
- }
46
- };
47
- __decorate([
48
- Output(),
49
- __metadata("design:type", Object)
50
- ], NotificationBadgeComponent.prototype, "notificationClick", void 0);
51
- NotificationBadgeComponent = __decorate([
52
- Component({
53
- selector: 'ma-notification-badge',
54
- standalone: true,
55
- imports: [NgIf],
56
- template: `
57
- <button class="notification-btn" (click)="onNotificationClick()" title="Notifications">
58
- <span class="icon">🔔</span>
59
- <span class="badge" *ngIf="unreadCount > 0">{{ unreadCount }}</span>
60
- </button>
61
- `,
62
- styles: [`
63
- .notification-btn {
64
- position: relative;
65
- background: none;
66
- border: none;
67
- font-size: 24px;
68
- cursor: pointer;
69
- padding: 8px;
70
- transition: opacity 0.2s;
71
- }
72
-
73
- .notification-btn:hover {
74
- opacity: 0.7;
75
- }
76
-
77
- .icon {
78
- display: inline-block;
79
- }
80
-
81
- .badge {
82
- position: absolute;
83
- top: 0;
84
- right: 0;
85
- background-color: #f44336;
86
- color: white;
87
- border-radius: 50%;
88
- width: 20px;
89
- height: 20px;
90
- display: flex;
91
- align-items: center;
92
- justify-content: center;
93
- font-size: 12px;
94
- font-weight: bold;
95
- }
96
- `]
97
- }),
98
- __metadata("design:paramtypes", [MesAuthService])
99
- ], NotificationBadgeComponent);
100
- export { NotificationBadgeComponent };
@@ -1,327 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- import { Component } from '@angular/core';
11
- import { NgIf, NgFor } from '@angular/common';
12
- import { MesAuthService } from './mes-auth.service';
13
- import { ToastService } from './toast.service';
14
- import { Subject } from 'rxjs';
15
- import { takeUntil } from 'rxjs/operators';
16
- let NotificationPanelComponent = class NotificationPanelComponent {
17
- constructor(authService, toastService) {
18
- this.authService = authService;
19
- this.toastService = toastService;
20
- this.isOpen = false;
21
- this.notifications = [];
22
- this.destroy$ = new Subject();
23
- }
24
- ngOnInit() {
25
- this.loadNotifications();
26
- // Listen for new real-time notifications
27
- this.authService.notifications$
28
- .pipe(takeUntil(this.destroy$))
29
- .subscribe((notification) => {
30
- // Show toast for new notification
31
- this.toastService.show(notification.message, notification.title, 'info', 5000);
32
- // Reload notifications list
33
- this.loadNotifications();
34
- });
35
- }
36
- ngOnDestroy() {
37
- this.destroy$.next();
38
- this.destroy$.complete();
39
- }
40
- loadNotifications() {
41
- this.authService.getNotifications(1, 50, false).subscribe({
42
- next: (response) => {
43
- this.notifications = response.items || [];
44
- },
45
- error: (err) => console.error('Error loading notifications:', err)
46
- });
47
- }
48
- open() {
49
- this.isOpen = true;
50
- }
51
- close() {
52
- this.isOpen = false;
53
- }
54
- markAsRead(notificationId) {
55
- this.authService.markAsRead(notificationId).subscribe({
56
- next: () => {
57
- const notification = this.notifications.find(n => n.id === notificationId);
58
- if (notification) {
59
- notification.isRead = true;
60
- }
61
- },
62
- error: (err) => console.error('Error marking as read:', err)
63
- });
64
- }
65
- markAllAsRead() {
66
- this.authService.markAllAsRead().subscribe({
67
- next: () => {
68
- this.notifications.forEach(n => n.isRead = true);
69
- },
70
- error: (err) => console.error('Error marking all as read:', err)
71
- });
72
- }
73
- delete(notificationId, event) {
74
- event.stopPropagation();
75
- this.authService.deleteNotification(notificationId).subscribe({
76
- next: () => {
77
- this.notifications = this.notifications.filter(n => n.id !== notificationId);
78
- },
79
- error: (err) => console.error('Error deleting notification:', err)
80
- });
81
- }
82
- formatDate(dateString) {
83
- const date = new Date(dateString);
84
- const now = new Date();
85
- const diffMs = now.getTime() - date.getTime();
86
- const diffMins = Math.floor(diffMs / 60000);
87
- const diffHours = Math.floor(diffMs / 3600000);
88
- const diffDays = Math.floor(diffMs / 86400000);
89
- if (diffMins < 1)
90
- return 'Now';
91
- if (diffMins < 60)
92
- return `${diffMins}m ago`;
93
- if (diffHours < 24)
94
- return `${diffHours}h ago`;
95
- if (diffDays < 7)
96
- return `${diffDays}d ago`;
97
- return date.toLocaleDateString();
98
- }
99
- };
100
- NotificationPanelComponent = __decorate([
101
- Component({
102
- selector: 'ma-notification-panel',
103
- standalone: true,
104
- imports: [NgIf, NgFor],
105
- template: `
106
- <div class="notification-panel" [class.open]="isOpen">
107
- <!-- Header -->
108
- <div class="panel-header">
109
- <h3>Notifications</h3>
110
- <button class="close-btn" (click)="close()" title="Close">✕</button>
111
- </div>
112
-
113
- <!-- Notifications List -->
114
- <div class="notifications-list">
115
- <ng-container *ngIf="notifications.length > 0">
116
- <div
117
- *ngFor="let notification of notifications"
118
- class="notification-item"
119
- [class.unread]="!notification.isRead"
120
- (click)="markAsRead(notification.id)"
121
- >
122
- <div class="notification-content">
123
- <div class="notification-title">{{ notification.title }}</div>
124
- <div class="notification-message">{{ notification.message }}</div>
125
- <div class="notification-meta">
126
- <span class="app-name">{{ notification.sourceAppName }}</span>
127
- <span class="time">{{ formatDate(notification.createdAt) }}</span>
128
- </div>
129
- </div>
130
- <button
131
- class="delete-btn"
132
- (click)="delete(notification.id, $event)"
133
- title="Delete"
134
- >
135
-
136
- </button>
137
- </div>
138
- </ng-container>
139
-
140
- <ng-container *ngIf="notifications.length === 0">
141
- <div class="empty-state">
142
- No notifications
143
- </div>
144
- </ng-container>
145
- </div>
146
-
147
- <!-- Footer Actions -->
148
- <div class="panel-footer" *ngIf="notifications.length > 0">
149
- <button class="action-btn" (click)="markAllAsRead()">
150
- Mark all as read
151
- </button>
152
- </div>
153
- </div>
154
- `,
155
- styles: [`
156
- .notification-panel {
157
- position: fixed;
158
- top: 0;
159
- right: -350px;
160
- width: 350px;
161
- height: 100vh;
162
- background: white;
163
- box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
164
- display: flex;
165
- flex-direction: column;
166
- z-index: 1000;
167
- transition: right 0.3s ease;
168
- }
169
-
170
- .notification-panel.open {
171
- right: 0;
172
- }
173
-
174
- .panel-header {
175
- display: flex;
176
- justify-content: space-between;
177
- align-items: center;
178
- padding: 16px;
179
- border-bottom: 1px solid #e0e0e0;
180
- background-color: #f5f5f5;
181
- }
182
-
183
- .panel-header h3 {
184
- margin: 0;
185
- font-size: 18px;
186
- color: #333;
187
- }
188
-
189
- .close-btn {
190
- background: none;
191
- border: none;
192
- font-size: 20px;
193
- cursor: pointer;
194
- color: #666;
195
- padding: 0;
196
- width: 32px;
197
- height: 32px;
198
- display: flex;
199
- align-items: center;
200
- justify-content: center;
201
- transition: color 0.2s;
202
- }
203
-
204
- .close-btn:hover {
205
- color: #333;
206
- }
207
-
208
- .notifications-list {
209
- flex: 1;
210
- overflow-y: auto;
211
- }
212
-
213
- .notification-item {
214
- display: flex;
215
- gap: 12px;
216
- padding: 12px 16px;
217
- border-bottom: 1px solid #f0f0f0;
218
- cursor: pointer;
219
- background-color: #fafafa;
220
- transition: background-color 0.2s;
221
- }
222
-
223
- .notification-item:hover {
224
- background-color: #f5f5f5;
225
- }
226
-
227
- .notification-item.unread {
228
- background-color: #e3f2fd;
229
- }
230
-
231
- .notification-content {
232
- flex: 1;
233
- min-width: 0;
234
- }
235
-
236
- .notification-title {
237
- font-weight: 600;
238
- color: #333;
239
- font-size: 14px;
240
- margin-bottom: 4px;
241
- }
242
-
243
- .notification-message {
244
- color: #666;
245
- font-size: 13px;
246
- line-height: 1.4;
247
- margin-bottom: 6px;
248
- display: -webkit-box;
249
- -webkit-line-clamp: 2;
250
- -webkit-box-orient: vertical;
251
- overflow: hidden;
252
- }
253
-
254
- .notification-meta {
255
- display: flex;
256
- justify-content: space-between;
257
- font-size: 12px;
258
- color: #999;
259
- }
260
-
261
- .app-name {
262
- font-weight: 500;
263
- color: #1976d2;
264
- }
265
-
266
- .delete-btn {
267
- background: none;
268
- border: none;
269
- color: #999;
270
- cursor: pointer;
271
- font-size: 14px;
272
- padding: 0;
273
- width: 24px;
274
- height: 24px;
275
- display: flex;
276
- align-items: center;
277
- justify-content: center;
278
- flex-shrink: 0;
279
- transition: color 0.2s;
280
- }
281
-
282
- .delete-btn:hover {
283
- color: #f44336;
284
- }
285
-
286
- .empty-state {
287
- display: flex;
288
- align-items: center;
289
- justify-content: center;
290
- height: 100%;
291
- color: #999;
292
- font-size: 14px;
293
- }
294
-
295
- .panel-footer {
296
- padding: 12px 16px;
297
- border-top: 1px solid #e0e0e0;
298
- background-color: #f5f5f5;
299
- }
300
-
301
- .action-btn {
302
- width: 100%;
303
- padding: 8px;
304
- background-color: #1976d2;
305
- color: white;
306
- border: none;
307
- border-radius: 4px;
308
- cursor: pointer;
309
- font-weight: 500;
310
- transition: background-color 0.2s;
311
- }
312
-
313
- .action-btn:hover {
314
- background-color: #1565c0;
315
- }
316
-
317
- @media (max-width: 600px) {
318
- .notification-panel {
319
- width: 100%;
320
- right: -100%;
321
- }
322
- }
323
- `]
324
- }),
325
- __metadata("design:paramtypes", [MesAuthService, ToastService])
326
- ], NotificationPanelComponent);
327
- export { NotificationPanelComponent };
@@ -1,185 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- import { Component } from '@angular/core';
11
- import { CommonModule } from '@angular/common';
12
- import { ToastService } from './toast.service';
13
- let ToastContainerComponent = class ToastContainerComponent {
14
- constructor(toastService) {
15
- this.toastService = toastService;
16
- this.toasts = [];
17
- }
18
- ngOnInit() {
19
- this.toastService.toasts.subscribe(toasts => {
20
- this.toasts = toasts;
21
- });
22
- }
23
- close(id) {
24
- this.toastService.remove(id);
25
- }
26
- };
27
- ToastContainerComponent = __decorate([
28
- Component({
29
- selector: 'ma-toast-container',
30
- standalone: true,
31
- imports: [CommonModule],
32
- template: `
33
- <div class="toast-container">
34
- <div
35
- *ngFor="let toast of toasts"
36
- class="toast"
37
- [class]="'toast-' + toast.type"
38
- [@slideIn]
39
- >
40
- <div class="toast-content">
41
- <div *ngIf="toast.title" class="toast-title">{{ toast.title }}</div>
42
- <div class="toast-message">{{ toast.message }}</div>
43
- </div>
44
- <button class="toast-close" (click)="close(toast.id)" aria-label="Close">
45
-
46
- </button>
47
- </div>
48
- </div>
49
- `,
50
- styles: [`
51
- .toast-container {
52
- position: fixed;
53
- top: 20px;
54
- right: 20px;
55
- z-index: 9999;
56
- pointer-events: none;
57
- }
58
-
59
- .toast {
60
- display: flex;
61
- align-items: flex-start;
62
- gap: 12px;
63
- padding: 12px 16px;
64
- margin-bottom: 12px;
65
- border-radius: 4px;
66
- background-color: white;
67
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
68
- pointer-events: auto;
69
- min-width: 300px;
70
- max-width: 500px;
71
- animation: slideIn 0.3s ease-out;
72
- }
73
-
74
- .toast-content {
75
- flex: 1;
76
- }
77
-
78
- .toast-title {
79
- font-weight: 600;
80
- font-size: 14px;
81
- margin-bottom: 4px;
82
- }
83
-
84
- .toast-message {
85
- font-size: 13px;
86
- line-height: 1.4;
87
- }
88
-
89
- .toast-close {
90
- background: none;
91
- border: none;
92
- cursor: pointer;
93
- font-size: 18px;
94
- color: #999;
95
- padding: 0;
96
- width: 24px;
97
- height: 24px;
98
- display: flex;
99
- align-items: center;
100
- justify-content: center;
101
- flex-shrink: 0;
102
- transition: color 0.2s;
103
- }
104
-
105
- .toast-close:hover {
106
- color: #333;
107
- }
108
-
109
- /* Toast types */
110
- .toast-info {
111
- border-left: 4px solid #2196f3;
112
- }
113
-
114
- .toast-info .toast-title {
115
- color: #2196f3;
116
- }
117
-
118
- .toast-info .toast-message {
119
- color: #333;
120
- }
121
-
122
- .toast-success {
123
- border-left: 4px solid #4caf50;
124
- }
125
-
126
- .toast-success .toast-title {
127
- color: #4caf50;
128
- }
129
-
130
- .toast-success .toast-message {
131
- color: #333;
132
- }
133
-
134
- .toast-warning {
135
- border-left: 4px solid #ff9800;
136
- }
137
-
138
- .toast-warning .toast-title {
139
- color: #ff9800;
140
- }
141
-
142
- .toast-warning .toast-message {
143
- color: #333;
144
- }
145
-
146
- .toast-error {
147
- border-left: 4px solid #f44336;
148
- }
149
-
150
- .toast-error .toast-title {
151
- color: #f44336;
152
- }
153
-
154
- .toast-error .toast-message {
155
- color: #333;
156
- }
157
-
158
- @keyframes slideIn {
159
- from {
160
- transform: translateX(400px);
161
- opacity: 0;
162
- }
163
- to {
164
- transform: translateX(0);
165
- opacity: 1;
166
- }
167
- }
168
-
169
- @media (max-width: 600px) {
170
- .toast-container {
171
- top: 10px;
172
- right: 10px;
173
- left: 10px;
174
- }
175
-
176
- .toast {
177
- min-width: auto;
178
- max-width: 100%;
179
- }
180
- }
181
- `]
182
- }),
183
- __metadata("design:paramtypes", [ToastService])
184
- ], ToastContainerComponent);
185
- export { ToastContainerComponent };
@@ -1,43 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { Injectable } from '@angular/core';
8
- import { BehaviorSubject } from 'rxjs';
9
- let ToastService = class ToastService {
10
- constructor() {
11
- this.toasts$ = new BehaviorSubject([]);
12
- this.toasts = this.toasts$.asObservable();
13
- }
14
- show(message, title, type = 'info', duration = 5000) {
15
- const id = Math.random().toString(36).substr(2, 9);
16
- const toast = {
17
- id,
18
- message,
19
- title,
20
- type,
21
- duration
22
- };
23
- const currentToasts = this.toasts$.value;
24
- this.toasts$.next([...currentToasts, toast]);
25
- if (duration > 0) {
26
- setTimeout(() => {
27
- this.remove(id);
28
- }, duration);
29
- }
30
- return id;
31
- }
32
- remove(id) {
33
- const currentToasts = this.toasts$.value;
34
- this.toasts$.next(currentToasts.filter(t => t.id !== id));
35
- }
36
- clear() {
37
- this.toasts$.next([]);
38
- }
39
- };
40
- ToastService = __decorate([
41
- Injectable({ providedIn: 'root' })
42
- ], ToastService);
43
- export { ToastService };