mesauth-angular 0.1.6 → 0.1.8
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 +64 -13
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/mes-auth.module.d.ts +2 -0
- package/dist/mes-auth.module.js +32 -0
- package/dist/notification-panel.component.js +2 -2
- package/dist/user-profile.component.js +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,28 +11,37 @@ Angular helper library to connect to a backend API and SignalR hub to surface th
|
|
|
11
11
|
npm install ../path/to/mesauth-angular
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
2. Provide the service
|
|
15
|
-
- **For
|
|
14
|
+
2. Provide the service and import components:
|
|
15
|
+
- **For standalone components/apps**: Import `MesAuthModule` in your standalone component or `app.config.ts`.
|
|
16
16
|
```ts
|
|
17
|
-
import {
|
|
17
|
+
import { MesAuthModule } from 'mesauth-angular';
|
|
18
18
|
|
|
19
|
-
@
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
@Component({
|
|
20
|
+
standalone: true,
|
|
21
|
+
imports: [MesAuthModule, /* other imports */],
|
|
22
|
+
// ...
|
|
22
23
|
})
|
|
23
|
-
export class
|
|
24
|
+
export class MyComponent {}
|
|
24
25
|
```
|
|
25
|
-
|
|
26
|
+
Or in `app.config.ts`:
|
|
26
27
|
```ts
|
|
27
|
-
import {
|
|
28
|
+
import { MesAuthModule } from 'mesauth-angular';
|
|
28
29
|
|
|
29
30
|
export const appConfig: ApplicationConfig = {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
MesAuthService
|
|
33
|
-
]
|
|
31
|
+
imports: [MesAuthModule],
|
|
32
|
+
// ... other config
|
|
34
33
|
};
|
|
35
34
|
```
|
|
35
|
+
- **For module-based apps**: Import `MesAuthModule` in your `AppModule` or feature module.
|
|
36
|
+
```ts
|
|
37
|
+
import { MesAuthModule } from 'mesauth-angular';
|
|
38
|
+
|
|
39
|
+
@NgModule({
|
|
40
|
+
imports: [MesAuthModule],
|
|
41
|
+
// ... other config
|
|
42
|
+
})
|
|
43
|
+
export class AppModule { }
|
|
44
|
+
```
|
|
36
45
|
|
|
37
46
|
3. (Optional) Provide the HTTP interceptor to handle 403 errors:
|
|
38
47
|
- The interceptor redirects to `${userBaseUrl}/403?returnUrl=encodedCurrentUrl` using `window.location.href` for external URLs (since `userBaseUrl` may be outside the client app).
|
|
@@ -146,6 +155,8 @@ Angular helper library to connect to a backend API and SignalR hub to surface th
|
|
|
146
155
|
|
|
147
156
|
## Components
|
|
148
157
|
|
|
158
|
+
**Note:** All components are standalone and can only be imported in standalone components or apps. If your app uses NgModules, use dynamic imports or convert to standalone.
|
|
159
|
+
|
|
149
160
|
### ma-user-profile
|
|
150
161
|
|
|
151
162
|
A reusable Angular component for displaying the current user's profile information, with options for navigation and logout.
|
|
@@ -179,6 +190,26 @@ A reusable Angular component for displaying the current user's profile informati
|
|
|
179
190
|
}
|
|
180
191
|
```
|
|
181
192
|
|
|
193
|
+
### ma-notification-panel
|
|
194
|
+
|
|
195
|
+
A standalone component for displaying a slide-out notification panel with real-time updates.
|
|
196
|
+
|
|
197
|
+
- **Description**: Shows a list of notifications, allows marking as read/delete, and integrates with toast notifications for new alerts.
|
|
198
|
+
- **Inputs**: None.
|
|
199
|
+
- **Outputs**: None (uses internal methods for actions).
|
|
200
|
+
- **Usage Example**:
|
|
201
|
+
|
|
202
|
+
```html
|
|
203
|
+
<ma-notification-panel #notificationPanel></ma-notification-panel>
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
In your component:
|
|
207
|
+
|
|
208
|
+
```ts
|
|
209
|
+
// To open the panel
|
|
210
|
+
notificationPanel.open();
|
|
211
|
+
```
|
|
212
|
+
|
|
182
213
|
## Notes
|
|
183
214
|
- The service expects an endpoint `GET /api/user/current` that returns the current user.
|
|
184
215
|
- SignalR events used: `UserUpdated` and `NewNotification` (adjust to your backend).
|
|
@@ -212,3 +243,23 @@ If you encounter an error like "The injectable 'MesAuthService' needs to be comp
|
|
|
212
243
|
- If using standalone components, confirm the service is available in the injection context.
|
|
213
244
|
|
|
214
245
|
If issues persist, check your Angular version compatibility and ensure the package's `package.json` includes the correct entry points for AOT.
|
|
246
|
+
|
|
247
|
+
### Components Appear Empty
|
|
248
|
+
If components like `ma-user` or `ma-user-profile` render as empty:
|
|
249
|
+
- Ensure `MesAuthService` is provided in your app (see Quick Start step 2).
|
|
250
|
+
- Check browser console for logs from components (e.g., "UserProfileComponent: currentUser").
|
|
251
|
+
- If `currentUser` is null, the component shows a login button—verify the service is initialized and the API returns user data.
|
|
252
|
+
- For standalone apps, confirm `APP_INITIALIZER` or manual init is used.
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
# Dynamic import in a module-based component
|
|
257
|
+
import { Component } from '@angular/core';
|
|
258
|
+
|
|
259
|
+
@Component({...})
|
|
260
|
+
export class DefaultHeaderComponent {
|
|
261
|
+
async ngOnInit() {
|
|
262
|
+
const { MaUserComponent } = await import('mesauth-angular');
|
|
263
|
+
// Use it dynamically
|
|
264
|
+
}
|
|
265
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export * from './mes-auth.service';
|
|
2
2
|
export * from './mes-auth.interceptor';
|
|
3
|
+
export * from './mes-auth.module';
|
|
3
4
|
export * from './user-profile.component';
|
|
4
5
|
export * from './ma-user.component';
|
|
5
6
|
export * from './notification-badge.component';
|
|
6
|
-
export * from './toast.service';
|
|
7
7
|
export * from './notification-panel.component';
|
|
8
|
+
export * from './toast.service';
|
|
8
9
|
export * from './toast-container.component';
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export * from './mes-auth.service';
|
|
2
2
|
export * from './mes-auth.interceptor';
|
|
3
|
+
export * from './mes-auth.module';
|
|
3
4
|
export * from './user-profile.component';
|
|
4
5
|
export * from './ma-user.component';
|
|
5
6
|
export * from './notification-badge.component';
|
|
6
|
-
export * from './toast.service';
|
|
7
7
|
export * from './notification-panel.component';
|
|
8
|
+
export * from './toast.service';
|
|
8
9
|
export * from './toast-container.component';
|
|
@@ -0,0 +1,32 @@
|
|
|
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 { NgModule } from '@angular/core';
|
|
8
|
+
import { HTTP_INTERCEPTORS } from '@angular/common/http';
|
|
9
|
+
import { MesAuthService } from './mes-auth.service';
|
|
10
|
+
import { MesAuthInterceptor } from './mes-auth.interceptor';
|
|
11
|
+
import { UserProfileComponent } from './user-profile.component';
|
|
12
|
+
import { MaUserComponent } from './ma-user.component';
|
|
13
|
+
import { NotificationBadgeComponent } from './notification-badge.component';
|
|
14
|
+
import { NotificationPanelComponent } from './notification-panel.component';
|
|
15
|
+
// Import ToastContainerComponent if available
|
|
16
|
+
let MesAuthModule = class MesAuthModule {
|
|
17
|
+
};
|
|
18
|
+
MesAuthModule = __decorate([
|
|
19
|
+
NgModule({
|
|
20
|
+
providers: [
|
|
21
|
+
MesAuthService,
|
|
22
|
+
{ provide: HTTP_INTERCEPTORS, useClass: MesAuthInterceptor, multi: true }
|
|
23
|
+
],
|
|
24
|
+
exports: [
|
|
25
|
+
UserProfileComponent,
|
|
26
|
+
MaUserComponent,
|
|
27
|
+
NotificationBadgeComponent,
|
|
28
|
+
NotificationPanelComponent
|
|
29
|
+
]
|
|
30
|
+
})
|
|
31
|
+
], MesAuthModule);
|
|
32
|
+
export { MesAuthModule };
|
|
@@ -8,7 +8,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
10
|
import { Component } from '@angular/core';
|
|
11
|
-
import {
|
|
11
|
+
import { NgIf, NgFor } from '@angular/common';
|
|
12
12
|
import { MesAuthService } from './mes-auth.service';
|
|
13
13
|
import { ToastService } from './toast.service';
|
|
14
14
|
import { Subject } from 'rxjs';
|
|
@@ -101,7 +101,7 @@ NotificationPanelComponent = __decorate([
|
|
|
101
101
|
Component({
|
|
102
102
|
selector: 'ma-notification-panel',
|
|
103
103
|
standalone: true,
|
|
104
|
-
imports: [
|
|
104
|
+
imports: [NgIf, NgFor],
|
|
105
105
|
template: `
|
|
106
106
|
<div class="notification-panel" [class.open]="isOpen">
|
|
107
107
|
<!-- Header -->
|
|
@@ -24,9 +24,11 @@ let UserProfileComponent = class UserProfileComponent {
|
|
|
24
24
|
this.destroy$ = new Subject();
|
|
25
25
|
}
|
|
26
26
|
ngOnInit() {
|
|
27
|
+
console.log('UserProfileComponent: Service injected?', !!this.authService);
|
|
27
28
|
this.authService.currentUser$
|
|
28
29
|
.pipe(takeUntil(this.destroy$))
|
|
29
30
|
.subscribe(user => {
|
|
31
|
+
console.log('UserProfileComponent: currentUser', user);
|
|
30
32
|
this.currentUser = user;
|
|
31
33
|
});
|
|
32
34
|
this.loadUnreadCount();
|