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.
- package/dist/README.md +265 -0
- package/dist/esm2020/index.mjs +9 -0
- package/dist/esm2020/ma-user.component.mjs +26 -0
- package/dist/esm2020/mes-auth.interceptor.mjs +29 -0
- package/dist/esm2020/mes-auth.module.mjs +23 -0
- package/dist/esm2020/mes-auth.service.mjs +103 -0
- package/dist/esm2020/mesauth-angular.mjs +5 -0
- package/dist/esm2020/notification-badge.component.mjs +57 -0
- package/dist/esm2020/notification-panel.component.mjs +196 -0
- package/dist/esm2020/toast-container.component.mjs +60 -0
- package/dist/esm2020/toast.service.mjs +41 -0
- package/dist/esm2020/user-profile.component.mjs +197 -0
- package/dist/fesm2015/mesauth-angular.mjs +701 -0
- package/dist/fesm2015/mesauth-angular.mjs.map +1 -0
- package/dist/fesm2020/mesauth-angular.mjs +700 -0
- package/dist/fesm2020/mesauth-angular.mjs.map +1 -0
- package/dist/ma-user.component.d.ts +3 -0
- package/dist/mes-auth.interceptor.d.ts +3 -0
- package/dist/mes-auth.module.d.ts +4 -0
- package/dist/mes-auth.service.d.ts +5 -1
- package/dist/notification-badge.component.d.ts +3 -0
- package/dist/notification-panel.component.d.ts +3 -0
- package/dist/package.json +52 -0
- package/dist/toast-container.component.d.ts +3 -0
- package/dist/toast.service.d.ts +3 -0
- package/dist/user-profile.component.d.ts +3 -0
- package/package.json +15 -9
- package/dist/index.js +0 -8
- package/dist/ma-user.component.js +0 -33
- package/dist/mes-auth.interceptor.js +0 -36
- package/dist/mes-auth.module.js +0 -33
- package/dist/mes-auth.service.js +0 -107
- package/dist/notification-badge.component.js +0 -100
- package/dist/notification-panel.component.js +0 -327
- package/dist/toast-container.component.js +0 -185
- package/dist/toast.service.js +0 -43
- package/dist/user-profile.component.js +0 -363
|
@@ -1,363 +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 { Router } from '@angular/router';
|
|
13
|
-
import { MesAuthService } from './mes-auth.service';
|
|
14
|
-
import { Subject } from 'rxjs';
|
|
15
|
-
import { takeUntil } from 'rxjs/operators';
|
|
16
|
-
let UserProfileComponent = class UserProfileComponent {
|
|
17
|
-
constructor(authService, router) {
|
|
18
|
-
this.authService = authService;
|
|
19
|
-
this.router = router;
|
|
20
|
-
this.notificationClick = new EventEmitter();
|
|
21
|
-
this.currentUser = null;
|
|
22
|
-
this.unreadCount = 0;
|
|
23
|
-
this.dropdownOpen = false;
|
|
24
|
-
this.destroy$ = new Subject();
|
|
25
|
-
}
|
|
26
|
-
ngOnInit() {
|
|
27
|
-
console.log('UserProfileComponent: Service injected?', !!this.authService);
|
|
28
|
-
this.authService.currentUser$
|
|
29
|
-
.pipe(takeUntil(this.destroy$))
|
|
30
|
-
.subscribe(user => {
|
|
31
|
-
console.log('UserProfileComponent: currentUser', user);
|
|
32
|
-
this.currentUser = user;
|
|
33
|
-
});
|
|
34
|
-
this.loadUnreadCount();
|
|
35
|
-
// Listen for new notifications
|
|
36
|
-
this.authService.notifications$
|
|
37
|
-
.pipe(takeUntil(this.destroy$))
|
|
38
|
-
.subscribe(() => {
|
|
39
|
-
this.loadUnreadCount();
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
ngOnDestroy() {
|
|
43
|
-
this.destroy$.next();
|
|
44
|
-
this.destroy$.complete();
|
|
45
|
-
}
|
|
46
|
-
loadUnreadCount() {
|
|
47
|
-
this.authService.getUnreadCount().subscribe({
|
|
48
|
-
next: (response) => {
|
|
49
|
-
this.unreadCount = response.unreadCount || 0;
|
|
50
|
-
},
|
|
51
|
-
error: (err) => console.error('Error loading unread count:', err)
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
getAvatarUrl(user) {
|
|
55
|
-
const config = this.authService.getConfig();
|
|
56
|
-
const baseUrl = config?.avatarUrl || 'https://ui-avatars.com/api/';
|
|
57
|
-
// Use userName first, fallback to userId, final fallback to 'User'
|
|
58
|
-
const displayName = user.userName || user.userId || 'User';
|
|
59
|
-
return `${baseUrl}?name=${encodeURIComponent(displayName)}&background=1976d2&color=fff`;
|
|
60
|
-
}
|
|
61
|
-
getLastNameInitial(user) {
|
|
62
|
-
const fullName = user.fullName || user.userName || 'U';
|
|
63
|
-
const parts = fullName.split(' ');
|
|
64
|
-
const lastPart = parts[parts.length - 1];
|
|
65
|
-
return lastPart.charAt(0).toUpperCase();
|
|
66
|
-
}
|
|
67
|
-
toggleDropdown() {
|
|
68
|
-
this.dropdownOpen = !this.dropdownOpen;
|
|
69
|
-
}
|
|
70
|
-
onLogin() {
|
|
71
|
-
const config = this.authService.getConfig();
|
|
72
|
-
const baseUrl = config?.userBaseUrl || '';
|
|
73
|
-
const returnUrl = encodeURIComponent(this.router.url);
|
|
74
|
-
window.location.href = `${baseUrl}/login?returnUrl=${returnUrl}`;
|
|
75
|
-
}
|
|
76
|
-
onViewProfile() {
|
|
77
|
-
const config = this.authService.getConfig();
|
|
78
|
-
const baseUrl = config?.userBaseUrl || '';
|
|
79
|
-
window.location.href = `${baseUrl}/profile`;
|
|
80
|
-
this.dropdownOpen = false;
|
|
81
|
-
}
|
|
82
|
-
onLogout() {
|
|
83
|
-
this.authService.logout().subscribe({
|
|
84
|
-
next: () => {
|
|
85
|
-
// Clear current user after successful logout
|
|
86
|
-
this.currentUser = null;
|
|
87
|
-
this.dropdownOpen = false;
|
|
88
|
-
// Navigate to login with return URL
|
|
89
|
-
const config = this.authService.getConfig();
|
|
90
|
-
const baseUrl = config?.userBaseUrl || '';
|
|
91
|
-
const returnUrl = encodeURIComponent(window.location.href);
|
|
92
|
-
window.location.href = `${baseUrl}/login?returnUrl=${returnUrl}`;
|
|
93
|
-
},
|
|
94
|
-
error: (err) => {
|
|
95
|
-
console.error('Logout error:', err);
|
|
96
|
-
// Still navigate to login even if logout fails
|
|
97
|
-
const config = this.authService.getConfig();
|
|
98
|
-
const baseUrl = config?.userBaseUrl || '';
|
|
99
|
-
window.location.href = `${baseUrl}/login`;
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
onNotificationClick() {
|
|
104
|
-
this.notificationClick.emit();
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
__decorate([
|
|
108
|
-
Output(),
|
|
109
|
-
__metadata("design:type", Object)
|
|
110
|
-
], UserProfileComponent.prototype, "notificationClick", void 0);
|
|
111
|
-
UserProfileComponent = __decorate([
|
|
112
|
-
Component({
|
|
113
|
-
selector: 'ma-user-profile',
|
|
114
|
-
standalone: true,
|
|
115
|
-
imports: [NgIf],
|
|
116
|
-
template: `
|
|
117
|
-
<div class="user-profile-container">
|
|
118
|
-
<!-- Not logged in -->
|
|
119
|
-
<ng-container *ngIf="!currentUser">
|
|
120
|
-
<button class="login-btn" (click)="onLogin()">
|
|
121
|
-
Login
|
|
122
|
-
</button>
|
|
123
|
-
</ng-container>
|
|
124
|
-
|
|
125
|
-
<!-- Logged in -->
|
|
126
|
-
<ng-container *ngIf="currentUser">
|
|
127
|
-
<div class="user-header">
|
|
128
|
-
<button class="notification-btn" (click)="onNotificationClick()" title="Notifications">
|
|
129
|
-
<span class="icon">🔔</span>
|
|
130
|
-
<span class="badge" *ngIf="unreadCount > 0">{{ unreadCount }}</span>
|
|
131
|
-
</button>
|
|
132
|
-
|
|
133
|
-
<div class="user-menu-wrapper">
|
|
134
|
-
<button class="user-menu-btn" (click)="toggleDropdown()">
|
|
135
|
-
<img
|
|
136
|
-
*ngIf="currentUser.fullName || currentUser.userName"
|
|
137
|
-
[src]="getAvatarUrl(currentUser)"
|
|
138
|
-
[alt]="currentUser.fullName || currentUser.userName"
|
|
139
|
-
class="avatar"
|
|
140
|
-
/>
|
|
141
|
-
<span *ngIf="!(currentUser.fullName || currentUser.userName)" class="avatar-initial">
|
|
142
|
-
{{ getLastNameInitial(currentUser) }}
|
|
143
|
-
</span>
|
|
144
|
-
</button>
|
|
145
|
-
|
|
146
|
-
<div class="dropdown-menu" *ngIf="dropdownOpen">
|
|
147
|
-
<div class="dropdown-header">
|
|
148
|
-
{{ currentUser.fullName || currentUser.userName }}
|
|
149
|
-
</div>
|
|
150
|
-
<button class="dropdown-item profile-link" (click)="onViewProfile()">
|
|
151
|
-
View Profile
|
|
152
|
-
</button>
|
|
153
|
-
<button class="dropdown-item logout-item" (click)="onLogout()">
|
|
154
|
-
Logout
|
|
155
|
-
</button>
|
|
156
|
-
</div>
|
|
157
|
-
</div>
|
|
158
|
-
</div>
|
|
159
|
-
</ng-container>
|
|
160
|
-
</div>
|
|
161
|
-
`,
|
|
162
|
-
styles: [`
|
|
163
|
-
.user-profile-container {
|
|
164
|
-
display: flex;
|
|
165
|
-
align-items: center;
|
|
166
|
-
gap: 16px;
|
|
167
|
-
padding: 0 16px;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
.login-btn {
|
|
171
|
-
padding: 8px 16px;
|
|
172
|
-
background-color: #1976d2;
|
|
173
|
-
color: white;
|
|
174
|
-
border: none;
|
|
175
|
-
border-radius: 4px;
|
|
176
|
-
cursor: pointer;
|
|
177
|
-
font-weight: 500;
|
|
178
|
-
transition: background-color 0.3s;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
.login-btn:hover {
|
|
182
|
-
background-color: #1565c0;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
.user-header {
|
|
186
|
-
display: flex;
|
|
187
|
-
align-items: center;
|
|
188
|
-
gap: 16px;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
.notification-btn {
|
|
192
|
-
position: relative;
|
|
193
|
-
background: none;
|
|
194
|
-
border: none;
|
|
195
|
-
font-size: 24px;
|
|
196
|
-
cursor: pointer;
|
|
197
|
-
padding: 8px;
|
|
198
|
-
transition: opacity 0.2s;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
.notification-btn:hover {
|
|
202
|
-
opacity: 0.7;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
.icon {
|
|
206
|
-
display: inline-block;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
.badge {
|
|
210
|
-
position: absolute;
|
|
211
|
-
top: 0;
|
|
212
|
-
right: 0;
|
|
213
|
-
background-color: #f44336;
|
|
214
|
-
color: white;
|
|
215
|
-
border-radius: 50%;
|
|
216
|
-
width: 20px;
|
|
217
|
-
height: 20px;
|
|
218
|
-
display: flex;
|
|
219
|
-
align-items: center;
|
|
220
|
-
justify-content: center;
|
|
221
|
-
font-size: 12px;
|
|
222
|
-
font-weight: bold;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
.user-menu-wrapper {
|
|
226
|
-
position: relative;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
.user-menu-btn {
|
|
230
|
-
background: none;
|
|
231
|
-
border: none;
|
|
232
|
-
cursor: pointer;
|
|
233
|
-
padding: 4px;
|
|
234
|
-
border-radius: 50%;
|
|
235
|
-
transition: background-color 0.2s;
|
|
236
|
-
display: flex;
|
|
237
|
-
align-items: center;
|
|
238
|
-
justify-content: center;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
.user-menu-btn:hover {
|
|
242
|
-
background-color: rgba(25, 118, 210, 0.1);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
.avatar {
|
|
246
|
-
width: 40px;
|
|
247
|
-
height: 40px;
|
|
248
|
-
border-radius: 50%;
|
|
249
|
-
object-fit: cover;
|
|
250
|
-
background-color: #e0e0e0;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
.avatar-initial {
|
|
254
|
-
width: 40px;
|
|
255
|
-
height: 40px;
|
|
256
|
-
border-radius: 50%;
|
|
257
|
-
background-color: #1976d2;
|
|
258
|
-
color: white;
|
|
259
|
-
display: flex;
|
|
260
|
-
align-items: center;
|
|
261
|
-
justify-content: center;
|
|
262
|
-
font-weight: bold;
|
|
263
|
-
font-size: 16px;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
.dropdown-menu {
|
|
267
|
-
position: absolute;
|
|
268
|
-
top: calc(100% + 8px);
|
|
269
|
-
right: 0;
|
|
270
|
-
background: white;
|
|
271
|
-
border: 1px solid #e0e0e0;
|
|
272
|
-
border-radius: 4px;
|
|
273
|
-
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
|
274
|
-
min-width: 200px;
|
|
275
|
-
z-index: 1000;
|
|
276
|
-
overflow: hidden;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
.dropdown-header {
|
|
280
|
-
padding: 12px 16px;
|
|
281
|
-
border-bottom: 1px solid #f0f0f0;
|
|
282
|
-
font-weight: 600;
|
|
283
|
-
color: #333;
|
|
284
|
-
font-size: 14px;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
.dropdown-item {
|
|
288
|
-
display: block;
|
|
289
|
-
width: 100%;
|
|
290
|
-
padding: 12px 16px;
|
|
291
|
-
border: none;
|
|
292
|
-
background: none;
|
|
293
|
-
text-align: left;
|
|
294
|
-
cursor: pointer;
|
|
295
|
-
font-size: 14px;
|
|
296
|
-
color: #333;
|
|
297
|
-
text-decoration: none;
|
|
298
|
-
transition: background-color 0.2s;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
.dropdown-item:hover {
|
|
302
|
-
background-color: #f5f5f5;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
.profile-link {
|
|
306
|
-
color: #1976d2;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
.logout-item {
|
|
310
|
-
border-top: 1px solid #f0f0f0;
|
|
311
|
-
color: #f44336;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
.logout-item:hover {
|
|
315
|
-
background-color: #ffebee;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
.user-info {
|
|
319
|
-
display: flex;
|
|
320
|
-
flex-direction: column;
|
|
321
|
-
gap: 2px;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
.user-name {
|
|
325
|
-
font-weight: 500;
|
|
326
|
-
font-size: 14px;
|
|
327
|
-
color: #333;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
.user-position {
|
|
331
|
-
font-size: 12px;
|
|
332
|
-
color: #666;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
.logout-btn {
|
|
336
|
-
background: none;
|
|
337
|
-
border: none;
|
|
338
|
-
font-size: 20px;
|
|
339
|
-
cursor: pointer;
|
|
340
|
-
color: #666;
|
|
341
|
-
padding: 4px 8px;
|
|
342
|
-
transition: color 0.2s;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
.logout-btn:hover {
|
|
346
|
-
color: #1976d2;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
@media (max-width: 768px) {
|
|
350
|
-
.user-info {
|
|
351
|
-
display: none;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
.avatar {
|
|
355
|
-
width: 32px;
|
|
356
|
-
height: 32px;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
`]
|
|
360
|
-
}),
|
|
361
|
-
__metadata("design:paramtypes", [MesAuthService, Router])
|
|
362
|
-
], UserProfileComponent);
|
|
363
|
-
export { UserProfileComponent };
|