@cccteam/ccc-lib 0.0.12 → 0.0.14
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/fesm2022/cccteam-ccc-lib-src-auth-authentication-guard.mjs +7 -15
- package/fesm2022/cccteam-ccc-lib-src-auth-authentication-guard.mjs.map +1 -1
- package/fesm2022/cccteam-ccc-lib-src-auth-authorization-guard.mjs +10 -9
- package/fesm2022/cccteam-ccc-lib-src-auth-authorization-guard.mjs.map +1 -1
- package/fesm2022/cccteam-ccc-lib-src-auth-forms.mjs +9 -10
- package/fesm2022/cccteam-ccc-lib-src-auth-forms.mjs.map +1 -1
- package/fesm2022/cccteam-ccc-lib-src-auth-has-permission.mjs +11 -18
- package/fesm2022/cccteam-ccc-lib-src-auth-has-permission.mjs.map +1 -1
- package/fesm2022/cccteam-ccc-lib-src-auth-service.mjs +45 -13
- package/fesm2022/cccteam-ccc-lib-src-auth-service.mjs.map +1 -1
- package/fesm2022/cccteam-ccc-lib-src-types.mjs.map +1 -1
- package/fesm2022/cccteam-ccc-lib-src-ui-alert.mjs +4 -4
- package/fesm2022/cccteam-ccc-lib-src-ui-alert.mjs.map +1 -1
- package/fesm2022/cccteam-ccc-lib-src-ui-core-service.mjs +41 -0
- package/fesm2022/cccteam-ccc-lib-src-ui-core-service.mjs.map +1 -0
- package/fesm2022/cccteam-ccc-lib-src-ui-interceptor.mjs +13 -11
- package/fesm2022/cccteam-ccc-lib-src-ui-interceptor.mjs.map +1 -1
- package/fesm2022/cccteam-ccc-lib-src-ui-notification-service.mjs +11 -5
- package/fesm2022/cccteam-ccc-lib-src-ui-notification-service.mjs.map +1 -1
- package/fesm2022/cccteam-ccc-lib-src-ui-sidenav.mjs +10 -20
- package/fesm2022/cccteam-ccc-lib-src-ui-sidenav.mjs.map +1 -1
- package/fesm2022/cccteam-ccc-lib.mjs +3 -4
- package/fesm2022/cccteam-ccc-lib.mjs.map +1 -1
- package/index.d.ts +12 -5
- package/package.json +11 -15
- package/src/auth-authentication-guard/index.d.ts +6 -5
- package/src/auth-authorization-guard/index.d.ts +6 -5
- package/src/auth-forms/index.d.ts +43 -3
- package/src/auth-has-permission/index.d.ts +15 -5
- package/src/auth-service/index.d.ts +36 -5
- package/src/types/index.d.ts +131 -3
- package/src/ui-alert/index.d.ts +16 -5
- package/src/ui-core-service/index.d.ts +20 -0
- package/src/ui-interceptor/index.d.ts +16 -5
- package/src/ui-notification-service/index.d.ts +33 -5
- package/src/ui-sidenav/index.d.ts +33 -5
- package/src/util-request-options/index.d.ts +12 -5
- package/fesm2022/cccteam-ccc-lib-src-auth-state.mjs +0 -109
- package/fesm2022/cccteam-ccc-lib-src-auth-state.mjs.map +0 -1
- package/fesm2022/cccteam-ccc-lib-src-ui-core-state.mjs +0 -100
- package/fesm2022/cccteam-ccc-lib-src-ui-core-state.mjs.map +0 -1
- package/public-api.d.ts +0 -13
- package/src/auth-authentication-guard/authentication.guard.d.ts +0 -3
- package/src/auth-authentication-guard/public-api.d.ts +0 -1
- package/src/auth-authorization-guard/authorization.guard.d.ts +0 -3
- package/src/auth-authorization-guard/public-api.d.ts +0 -1
- package/src/auth-forms/ccc-field/ccc-field.component.d.ts +0 -25
- package/src/auth-forms/form-helpers.d.ts +0 -16
- package/src/auth-forms/public-api.d.ts +0 -2
- package/src/auth-has-permission/has-permission.directive.d.ts +0 -12
- package/src/auth-has-permission/public-api.d.ts +0 -1
- package/src/auth-service/auth.service.d.ts +0 -24
- package/src/auth-service/public-api.d.ts +0 -1
- package/src/auth-state/auth.state.d.ts +0 -27
- package/src/auth-state/index.d.ts +0 -5
- package/src/auth-state/public-api.d.ts +0 -1
- package/src/types/auth.actions.d.ts +0 -41
- package/src/types/core.actions.d.ts +0 -31
- package/src/types/notification-message.d.ts +0 -18
- package/src/types/permissions.d.ts +0 -15
- package/src/types/public-api.d.ts +0 -6
- package/src/types/session-info.d.ts +0 -9
- package/src/types/tokens.d.ts +0 -13
- package/src/ui-alert/alert.component.d.ts +0 -13
- package/src/ui-alert/public-api.d.ts +0 -1
- package/src/ui-core-state/core.state.d.ts +0 -28
- package/src/ui-core-state/index.d.ts +0 -5
- package/src/ui-core-state/public-api.d.ts +0 -1
- package/src/ui-interceptor/api.interceptor.d.ts +0 -12
- package/src/ui-interceptor/public-api.d.ts +0 -1
- package/src/ui-notification-service/notification.service.d.ts +0 -30
- package/src/ui-notification-service/public-api.d.ts +0 -1
- package/src/ui-sidenav/public-api.d.ts +0 -1
- package/src/ui-sidenav/sidenav.component.d.ts +0 -31
- package/src/util-request-options/public-api.d.ts +0 -1
- package/src/util-request-options/request-options.d.ts +0 -8
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { inject } from '@angular/core';
|
|
2
2
|
import { AuthService } from '@cccteam/ccc-lib/src/auth-service';
|
|
3
|
-
import {
|
|
4
|
-
import { BASE_URL, AuthenticationGuardAction } from '@cccteam/ccc-lib/src/types';
|
|
5
|
-
import { Store } from '@ngxs/store';
|
|
3
|
+
import { BASE_URL } from '@cccteam/ccc-lib/src/types';
|
|
6
4
|
import { of } from 'rxjs';
|
|
7
|
-
import {
|
|
5
|
+
import { map, catchError } from 'rxjs/operators';
|
|
8
6
|
|
|
9
7
|
const AuthenticationGuard = (route, routerState) => {
|
|
10
|
-
const store = inject(Store);
|
|
11
8
|
const authService = inject(AuthService);
|
|
12
9
|
const baseUrl = inject(BASE_URL);
|
|
13
10
|
const authenticate = () => {
|
|
@@ -16,16 +13,11 @@ const AuthenticationGuard = (route, routerState) => {
|
|
|
16
13
|
const encodedUrl = encodeURIComponent(absoluteUrl);
|
|
17
14
|
window.location.href = `${authService.loginRoute()}?returnUrl=${encodedUrl}`;
|
|
18
15
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return store.dispatch(AuthenticationGuardAction.CheckUserSession).pipe(switchMap(() => {
|
|
25
|
-
return store.select(AuthState.isAuthenticated);
|
|
26
|
-
}));
|
|
27
|
-
}), map((authenticated) => {
|
|
28
|
-
if (authenticated) {
|
|
16
|
+
if (authService.authenticated()) {
|
|
17
|
+
return of(true);
|
|
18
|
+
}
|
|
19
|
+
return authService.checkUserSession().pipe(map((sessionInfo) => {
|
|
20
|
+
if (sessionInfo?.authenticated) {
|
|
29
21
|
return true;
|
|
30
22
|
}
|
|
31
23
|
authenticate();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cccteam-ccc-lib-src-auth-authentication-guard.mjs","sources":["../../../projects/ccc-lib/src/auth-authentication-guard/authentication.guard.ts","../../../projects/ccc-lib/src/auth-authentication-guard/cccteam-ccc-lib-src-auth-authentication-guard.ts"],"sourcesContent":["import { inject } from '@angular/core';\nimport { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';\nimport { AuthService } from '@cccteam/ccc-lib/src/auth-service';\nimport {
|
|
1
|
+
{"version":3,"file":"cccteam-ccc-lib-src-auth-authentication-guard.mjs","sources":["../../../projects/ccc-lib/src/auth-authentication-guard/authentication.guard.ts","../../../projects/ccc-lib/src/auth-authentication-guard/cccteam-ccc-lib-src-auth-authentication-guard.ts"],"sourcesContent":["import { inject } from '@angular/core';\nimport { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';\nimport { AuthService } from '@cccteam/ccc-lib/src/auth-service';\nimport { BASE_URL } from '@cccteam/ccc-lib/src/types';\nimport { Observable, of } from 'rxjs';\nimport { catchError, map } from 'rxjs/operators';\n\nexport const AuthenticationGuard = (\n route: ActivatedRouteSnapshot,\n routerState: RouterStateSnapshot,\n): Observable<boolean> => {\n const authService = inject(AuthService);\n const baseUrl = inject(BASE_URL);\n\n const authenticate = (): void => {\n const url = routerState.url;\n const absoluteUrl = baseUrl + (!url.toString().startsWith('/') ? '/' + url : url);\n const encodedUrl = encodeURIComponent(absoluteUrl);\n window.location.href = `${authService.loginRoute()}?returnUrl=${encodedUrl}`;\n };\n\n if (authService.authenticated()) {\n return of(true);\n }\n\n return authService.checkUserSession().pipe(\n map((sessionInfo) => {\n if (sessionInfo?.authenticated) {\n return true;\n }\n\n authenticate();\n return false;\n }),\n catchError(() => {\n authenticate();\n return of(false);\n }),\n );\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;MAOa,mBAAmB,GAAG,CACjC,KAA6B,EAC7B,WAAgC,KACT;AACvB,IAAA,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;AACvC,IAAA,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC;IAEhC,MAAM,YAAY,GAAG,MAAW;AAC9B,QAAA,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG;QAC3B,MAAM,WAAW,GAAG,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AACjF,QAAA,MAAM,UAAU,GAAG,kBAAkB,CAAC,WAAW,CAAC;AAClD,QAAA,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAA,EAAG,WAAW,CAAC,UAAU,EAAE,CAAc,WAAA,EAAA,UAAU,EAAE;AAC9E,KAAC;AAED,IAAA,IAAI,WAAW,CAAC,aAAa,EAAE,EAAE;AAC/B,QAAA,OAAO,EAAE,CAAC,IAAI,CAAC;;AAGjB,IAAA,OAAO,WAAW,CAAC,gBAAgB,EAAE,CAAC,IAAI,CACxC,GAAG,CAAC,CAAC,WAAW,KAAI;AAClB,QAAA,IAAI,WAAW,EAAE,aAAa,EAAE;AAC9B,YAAA,OAAO,IAAI;;AAGb,QAAA,YAAY,EAAE;AACd,QAAA,OAAO,KAAK;AACd,KAAC,CAAC,EACF,UAAU,CAAC,MAAK;AACd,QAAA,YAAY,EAAE;AACd,QAAA,OAAO,EAAE,CAAC,KAAK,CAAC;KACjB,CAAC,CACH;AACH;;ACvCA;;AAEG;;;;"}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { inject } from '@angular/core';
|
|
1
|
+
import { inject, computed } from '@angular/core';
|
|
2
2
|
import { Router } from '@angular/router';
|
|
3
|
-
import {
|
|
4
|
-
import { Store } from '@ngxs/store';
|
|
5
|
-
import { map } from 'rxjs';
|
|
3
|
+
import { AuthService } from '@cccteam/ccc-lib/src/auth-service';
|
|
6
4
|
|
|
7
5
|
const AuthorizationGuard = (route) => {
|
|
8
|
-
const store = inject(Store);
|
|
9
6
|
const router = inject(Router);
|
|
10
|
-
|
|
7
|
+
const auth = inject(AuthService);
|
|
8
|
+
return computed(() => {
|
|
9
|
+
const hasPermission = auth.hasPermission(route.data['scope']);
|
|
11
10
|
if (hasPermission) {
|
|
12
11
|
return true;
|
|
13
12
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
else {
|
|
14
|
+
router.navigate(['/']);
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cccteam-ccc-lib-src-auth-authorization-guard.mjs","sources":["../../../projects/ccc-lib/src/auth-authorization-guard/authorization.guard.ts","../../../projects/ccc-lib/src/auth-authorization-guard/cccteam-ccc-lib-src-auth-authorization-guard.ts"],"sourcesContent":["import { inject } from '@angular/core';\nimport { ActivatedRouteSnapshot, Router } from '@angular/router';\nimport {
|
|
1
|
+
{"version":3,"file":"cccteam-ccc-lib-src-auth-authorization-guard.mjs","sources":["../../../projects/ccc-lib/src/auth-authorization-guard/authorization.guard.ts","../../../projects/ccc-lib/src/auth-authorization-guard/cccteam-ccc-lib-src-auth-authorization-guard.ts"],"sourcesContent":["import { computed, inject, Signal } from '@angular/core';\nimport { ActivatedRouteSnapshot, Router } from '@angular/router';\nimport { AuthService } from '@cccteam/ccc-lib/src/auth-service';\n\nexport const AuthorizationGuard = (route: ActivatedRouteSnapshot): Signal<boolean> => {\n const router = inject(Router);\n const auth = inject(AuthService);\n return computed(() => {\n const hasPermission = auth.hasPermission(route.data['scope']);\n if (hasPermission) {\n return true;\n } else {\n router.navigate(['/']);\n return false;\n }\n });\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;AAIa,MAAA,kBAAkB,GAAG,CAAC,KAA6B,KAAqB;AACnF,IAAA,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;AAC7B,IAAA,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC;IAChC,OAAO,QAAQ,CAAC,MAAK;AACnB,QAAA,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7D,IAAI,aAAa,EAAE;AACjB,YAAA,OAAO,IAAI;;aACN;AACL,YAAA,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC;AACtB,YAAA,OAAO,KAAK;;AAEhB,KAAC,CAAC;AACJ;;AChBA;;AAEG;;;;"}
|
|
@@ -4,9 +4,8 @@ import * as i1 from '@angular/material/form-field';
|
|
|
4
4
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
5
5
|
import * as i2 from '@angular/material/input';
|
|
6
6
|
import { MatInputModule } from '@angular/material/input';
|
|
7
|
-
import {
|
|
7
|
+
import { AuthService } from '@cccteam/ccc-lib/src/auth-service';
|
|
8
8
|
import { ReadPermission, UpdatePermission } from '@cccteam/ccc-lib/src/types';
|
|
9
|
-
import { Store } from '@ngxs/store';
|
|
10
9
|
import { isEqual } from 'lodash-es';
|
|
11
10
|
|
|
12
11
|
var InputMode;
|
|
@@ -15,7 +14,7 @@ var InputMode;
|
|
|
15
14
|
InputMode["Edit"] = "edit";
|
|
16
15
|
})(InputMode || (InputMode = {}));
|
|
17
16
|
class CccInputFieldComponent {
|
|
18
|
-
|
|
17
|
+
auth = inject(AuthService);
|
|
19
18
|
className = input();
|
|
20
19
|
mode = input.required();
|
|
21
20
|
resource = input.required();
|
|
@@ -28,12 +27,12 @@ class CccInputFieldComponent {
|
|
|
28
27
|
canRead = signal(false);
|
|
29
28
|
canReadSelector = false;
|
|
30
29
|
ngOnInit() {
|
|
31
|
-
this.canEditSelector = this.
|
|
30
|
+
this.canEditSelector = this.auth.hasPermission({
|
|
32
31
|
resource: this.resource(),
|
|
33
32
|
permission: ReadPermission,
|
|
34
33
|
domain: this.domain(),
|
|
35
34
|
});
|
|
36
|
-
this.canReadSelector = this.
|
|
35
|
+
this.canReadSelector = this.auth.hasPermission({
|
|
37
36
|
resource: this.resource(),
|
|
38
37
|
permission: UpdatePermission,
|
|
39
38
|
domain: this.domain(),
|
|
@@ -43,7 +42,7 @@ class CccInputFieldComponent {
|
|
|
43
42
|
if (!res) {
|
|
44
43
|
return false;
|
|
45
44
|
}
|
|
46
|
-
if (
|
|
45
|
+
if (AuthService.requiresPermission(this.resource(), ReadPermission)) {
|
|
47
46
|
return this.canReadSelector;
|
|
48
47
|
}
|
|
49
48
|
return false;
|
|
@@ -53,21 +52,21 @@ class CccInputFieldComponent {
|
|
|
53
52
|
if (!res) {
|
|
54
53
|
return false;
|
|
55
54
|
}
|
|
56
|
-
if (
|
|
55
|
+
if (AuthService.requiresPermission(this.resource(), UpdatePermission)) {
|
|
57
56
|
return this.canEditSelector;
|
|
58
57
|
}
|
|
59
58
|
return false;
|
|
60
59
|
});
|
|
61
60
|
}
|
|
62
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
63
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "
|
|
61
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: CccInputFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
62
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.0.0", type: CccInputFieldComponent, isStandalone: true, selector: "ccc-input-field", inputs: { className: { classPropertyName: "className", publicName: "className", isSignal: true, isRequired: false, transformFunction: null }, mode: { classPropertyName: "mode", publicName: "mode", isSignal: true, isRequired: true, transformFunction: null }, resource: { classPropertyName: "resource", publicName: "resource", isSignal: true, isRequired: true, transformFunction: null }, domain: { classPropertyName: "domain", publicName: "domain", isSignal: true, isRequired: true, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: `
|
|
64
63
|
<mat-form-field [class]="className()">
|
|
65
64
|
<mat-label>{{ name() }}</mat-label>
|
|
66
65
|
<input matInput [disabled]="mode() === inputMode.Edit && canEdit()" [value]="value()" />
|
|
67
66
|
</mat-form-field>
|
|
68
67
|
`, isInline: true, styles: [""], dependencies: [{ kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i1.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i1.MatLabel, selector: "mat-label" }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i2.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }] });
|
|
69
68
|
}
|
|
70
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
69
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: CccInputFieldComponent, decorators: [{
|
|
71
70
|
type: Component,
|
|
72
71
|
args: [{ selector: 'ccc-input-field', imports: [MatFormFieldModule, MatInputModule], template: `
|
|
73
72
|
<mat-form-field [class]="className()">
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cccteam-ccc-lib-src-auth-forms.mjs","sources":["../../../projects/ccc-lib/src/auth-forms/ccc-field/ccc-field.component.ts","../../../projects/ccc-lib/src/auth-forms/form-helpers.ts","../../../projects/ccc-lib/src/auth-forms/cccteam-ccc-lib-src-auth-forms.ts"],"sourcesContent":["import { Component, computed, inject, input, OnInit, signal, Signal } from '@angular/core';\nimport { MatFormFieldModule } from '@angular/material/form-field';\nimport { MatInputModule } from '@angular/material/input';\nimport {
|
|
1
|
+
{"version":3,"file":"cccteam-ccc-lib-src-auth-forms.mjs","sources":["../../../projects/ccc-lib/src/auth-forms/ccc-field/ccc-field.component.ts","../../../projects/ccc-lib/src/auth-forms/form-helpers.ts","../../../projects/ccc-lib/src/auth-forms/cccteam-ccc-lib-src-auth-forms.ts"],"sourcesContent":["import { Component, computed, inject, input, OnInit, signal, Signal } from '@angular/core';\nimport { MatFormFieldModule } from '@angular/material/form-field';\nimport { MatInputModule } from '@angular/material/input';\nimport { AuthService } from '@cccteam/ccc-lib/src/auth-service';\nimport { Domain, ReadPermission, Resource, UpdatePermission } from '@cccteam/ccc-lib/src/types';\n\nexport enum InputMode {\n Read = 'read',\n Edit = 'edit',\n}\n\n@Component({\n selector: 'ccc-input-field',\n imports: [MatFormFieldModule, MatInputModule],\n template: `\n <mat-form-field [class]=\"className()\">\n <mat-label>{{ name() }}</mat-label>\n <input matInput [disabled]=\"mode() === inputMode.Edit && canEdit()\" [value]=\"value()\" />\n </mat-form-field>\n `,\n styleUrl: './ccc-field.component.scss',\n})\nexport class CccInputFieldComponent implements OnInit {\n auth = inject(AuthService);\n className = input();\n mode = input.required<InputMode>();\n resource = input.required<Resource>();\n domain = input.required<Domain>();\n value = input.required();\n name = input.required<string>();\n\n inputMode = InputMode;\n\n canEdit: Signal<boolean> = signal(false);\n canEditSelector = false;\n\n canRead: Signal<boolean> = signal(false);\n canReadSelector = false;\n\n ngOnInit(): void {\n this.canEditSelector = this.auth.hasPermission({\n resource: this.resource(),\n permission: ReadPermission,\n domain: this.domain(),\n });\n this.canReadSelector = this.auth.hasPermission({\n resource: this.resource(),\n permission: UpdatePermission,\n domain: this.domain(),\n });\n\n this.canRead = computed(() => {\n const res = this.resource();\n if (!res) {\n return false;\n }\n if (AuthService.requiresPermission(this.resource(), ReadPermission)) {\n return this.canReadSelector;\n }\n return false;\n });\n\n this.canEdit = computed(() => {\n const res = this.resource();\n if (!res) {\n return false;\n }\n if (AuthService.requiresPermission(this.resource(), UpdatePermission)) {\n return this.canEditSelector;\n }\n return false;\n });\n }\n}\n","import { FormArray, FormGroup } from '@angular/forms';\nimport { isEqual } from 'lodash-es';\n\n/**\n * Accepts a FormGroup and compares it to an object to return the dirty form values\n * as a sparse object\n * @param form - FormGroup\n * @param compareData - object to compare form values against\n * @returns Partial<T>\n * @example sparseFormData<UserCreate>(this.userForm, initUser)\n */\nexport function sparseFormData<T>(form: FormGroup, compareData: T): T {\n const sparseFormData: T = {} as T;\n\n for (const [key, control] of Object.entries(form.controls)) {\n const controlValue = control.value;\n const compareValue = compareData[key as keyof T];\n\n if (!isEqual(controlValue, compareValue)) {\n sparseFormData[key as keyof T] = controlValue as T[keyof T];\n }\n }\n\n return sparseFormData;\n}\n\n/**\n * Accepts a FormArray and removes empty strings\n * @param formArray - FormArray\n * @returns FormArray\n */\nexport function cleanStringFormArray(formArray: FormArray): FormArray {\n for (let i = formArray.controls.length - 1; i >= 0; i--) {\n if (formArray.at(i).value === '') {\n formArray.removeAt(i);\n }\n }\n return formArray;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;IAMY;AAAZ,CAAA,UAAY,SAAS,EAAA;AACnB,IAAA,SAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,SAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACf,CAAC,EAHW,SAAS,KAAT,SAAS,GAGpB,EAAA,CAAA,CAAA;MAaY,sBAAsB,CAAA;AACjC,IAAA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,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;AAC1D,QAAA,MAAM,YAAY,GAAG,OAAO,CAAC,KAAK;AAClC,QAAA,MAAM,YAAY,GAAG,WAAW,CAAC,GAAc,CAAC;QAEhD,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,YAAY,CAAC,EAAE;AACxC,YAAA,cAAc,CAAC,GAAc,CAAC,GAAG,YAA0B;;;AAI/D,IAAA,OAAO,cAAc;AACvB;AAEA;;;;AAIG;AACG,SAAU,oBAAoB,CAAC,SAAoB,EAAA;AACvD,IAAA,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;QACvD,IAAI,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE,EAAE;AAChC,YAAA,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;;;AAGzB,IAAA,OAAO,SAAS;AAClB;;ACtCA;;AAEG;;;;"}
|
|
@@ -1,26 +1,19 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, TemplateRef, ViewContainerRef,
|
|
3
|
-
import {
|
|
4
|
-
import { AuthState } from '@cccteam/ccc-lib/src/auth-state';
|
|
5
|
-
import { Store } from '@ngxs/store';
|
|
6
|
-
import { Subject, combineLatest, map, catchError, of } from 'rxjs';
|
|
2
|
+
import { inject, TemplateRef, ViewContainerRef, signal, effect, Input, Directive } from '@angular/core';
|
|
3
|
+
import { AuthService } from '@cccteam/ccc-lib/src/auth-service';
|
|
7
4
|
|
|
8
5
|
class HasPermissionDirective {
|
|
6
|
+
auth = inject(AuthService);
|
|
9
7
|
templateRef = inject((TemplateRef));
|
|
10
8
|
viewContainer = inject(ViewContainerRef);
|
|
11
|
-
|
|
12
|
-
scope = new Subject();
|
|
9
|
+
scope = signal(undefined);
|
|
13
10
|
set cccHasPermission(scope) {
|
|
14
|
-
this.scope.
|
|
11
|
+
this.scope.set(scope);
|
|
15
12
|
}
|
|
16
13
|
constructor() {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
})
|
|
21
|
-
.pipe(takeUntilDestroyed(), map(({ permissionFn, scope }) => (scope !== undefined ? permissionFn(scope) : true)), catchError(() => of(false)))
|
|
22
|
-
.subscribe((result) => {
|
|
23
|
-
if (result) {
|
|
14
|
+
effect(() => {
|
|
15
|
+
const scope = this.scope();
|
|
16
|
+
if (this.auth.hasPermission(scope) && this.auth.authenticated()) {
|
|
24
17
|
if (!this.viewContainer.get(0)) {
|
|
25
18
|
this.viewContainer.createEmbeddedView(this.templateRef);
|
|
26
19
|
}
|
|
@@ -30,10 +23,10 @@ class HasPermissionDirective {
|
|
|
30
23
|
}
|
|
31
24
|
});
|
|
32
25
|
}
|
|
33
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
34
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
26
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: HasPermissionDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
27
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.0.0", type: HasPermissionDirective, isStandalone: true, selector: "[cccHasPermission]", inputs: { cccHasPermission: "cccHasPermission" }, ngImport: i0 });
|
|
35
28
|
}
|
|
36
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
29
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: HasPermissionDirective, decorators: [{
|
|
37
30
|
type: Directive,
|
|
38
31
|
args: [{
|
|
39
32
|
selector: '[cccHasPermission]',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cccteam-ccc-lib-src-auth-has-permission.mjs","sources":["../../../projects/ccc-lib/src/auth-has-permission/has-permission.directive.ts","../../../projects/ccc-lib/src/auth-has-permission/cccteam-ccc-lib-src-auth-has-permission.ts"],"sourcesContent":["import { Directive, Input, TemplateRef, ViewContainerRef, inject
|
|
1
|
+
{"version":3,"file":"cccteam-ccc-lib-src-auth-has-permission.mjs","sources":["../../../projects/ccc-lib/src/auth-has-permission/has-permission.directive.ts","../../../projects/ccc-lib/src/auth-has-permission/cccteam-ccc-lib-src-auth-has-permission.ts"],"sourcesContent":["import { Directive, Input, TemplateRef, ViewContainerRef, effect, inject, signal } from '@angular/core';\nimport { AuthService } from '@cccteam/ccc-lib/src/auth-service';\nimport { PermissionScope } from '@cccteam/ccc-lib/src/types';\n\n@Directive({\n selector: '[cccHasPermission]',\n standalone: true,\n})\nexport class HasPermissionDirective {\n private auth = inject(AuthService);\n private templateRef = inject(TemplateRef<unknown>);\n private viewContainer = inject(ViewContainerRef);\n\n private scope = signal<PermissionScope | undefined>(undefined);\n\n @Input()\n set cccHasPermission(scope: PermissionScope) {\n this.scope.set(scope);\n }\n\n constructor() {\n effect(() => {\n const scope = this.scope();\n\n if (this.auth.hasPermission(scope) && this.auth.authenticated()) {\n if (!this.viewContainer.get(0)) {\n this.viewContainer.createEmbeddedView(this.templateRef);\n }\n } else {\n this.viewContainer.clear();\n }\n });\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;MAQa,sBAAsB,CAAA;AACzB,IAAA,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC;AAC1B,IAAA,WAAW,GAAG,MAAM,EAAC,WAAoB,EAAC;AAC1C,IAAA,aAAa,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAExC,IAAA,KAAK,GAAG,MAAM,CAA8B,SAAS,CAAC;IAE9D,IACI,gBAAgB,CAAC,KAAsB,EAAA;AACzC,QAAA,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC;;AAGvB,IAAA,WAAA,GAAA;QACE,MAAM,CAAC,MAAK;AACV,YAAA,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,EAAE;AAE1B,YAAA,IAAI,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE;gBAC/D,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;oBAC9B,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,WAAW,CAAC;;;iBAEpD;AACL,gBAAA,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE;;AAE9B,SAAC,CAAC;;uGAvBO,sBAAsB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;2FAAtB,sBAAsB,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,oBAAA,EAAA,MAAA,EAAA,EAAA,gBAAA,EAAA,kBAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;2FAAtB,sBAAsB,EAAA,UAAA,EAAA,CAAA;kBAJlC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,oBAAoB;AAC9B,oBAAA,UAAU,EAAE,IAAI;AACjB,iBAAA;wDASK,gBAAgB,EAAA,CAAA;sBADnB;;;ACfH;;AAEG;;;;"}
|
|
@@ -1,20 +1,43 @@
|
|
|
1
|
+
import { HttpClient } from '@angular/common/http';
|
|
1
2
|
import * as i0 from '@angular/core';
|
|
2
|
-
import {
|
|
3
|
-
import { API_URL } from '@cccteam/ccc-lib/src/types';
|
|
3
|
+
import { inject, signal, Inject, Injectable } from '@angular/core';
|
|
4
|
+
import { PERMISSION_REQUIRED, API_URL } from '@cccteam/ccc-lib/src/types';
|
|
4
5
|
import { errorOptions } from '@cccteam/ccc-lib/src/util-request-options';
|
|
5
|
-
import { map } from 'rxjs';
|
|
6
|
-
import * as i1 from '@angular/common/http';
|
|
6
|
+
import { map, tap } from 'rxjs';
|
|
7
7
|
|
|
8
8
|
const routes = {
|
|
9
9
|
login: (rootUrl) => `${rootUrl}/user/login`,
|
|
10
10
|
session: (rootUrl) => `${rootUrl}/user/session`,
|
|
11
11
|
};
|
|
12
12
|
class AuthService {
|
|
13
|
-
http;
|
|
14
13
|
apiUrl;
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
http = inject(HttpClient);
|
|
15
|
+
authenticatedSignal = signal(false);
|
|
16
|
+
sessionInfoSignal = signal({});
|
|
17
|
+
redirectUrl = signal('');
|
|
18
|
+
authenticated = this.authenticatedSignal.asReadonly();
|
|
19
|
+
sessionInfo = this.sessionInfoSignal.asReadonly();
|
|
20
|
+
constructor(apiUrl) {
|
|
17
21
|
this.apiUrl = apiUrl;
|
|
22
|
+
this.initializePermissionFn();
|
|
23
|
+
}
|
|
24
|
+
static permissionFn;
|
|
25
|
+
hasPermission(scope) {
|
|
26
|
+
if (!scope)
|
|
27
|
+
return true;
|
|
28
|
+
const resourcePermissions = this.sessionInfo().permissions?.[scope.domain]?.[scope.resource];
|
|
29
|
+
return Array.isArray(resourcePermissions) && resourcePermissions.includes(scope.permission);
|
|
30
|
+
}
|
|
31
|
+
static requiresPermission(resource, permission) {
|
|
32
|
+
if (!AuthService.permissionFn) {
|
|
33
|
+
throw new Error(`AuthState has not been initialized. Ensure AuthState is provided in your module or instantiated at least once.`);
|
|
34
|
+
}
|
|
35
|
+
return AuthService.permissionFn(resource, permission);
|
|
36
|
+
}
|
|
37
|
+
initializePermissionFn() {
|
|
38
|
+
if (!AuthService.permissionFn) {
|
|
39
|
+
AuthService.permissionFn = inject(PERMISSION_REQUIRED);
|
|
40
|
+
}
|
|
18
41
|
}
|
|
19
42
|
/**
|
|
20
43
|
* Logs a user out.
|
|
@@ -22,7 +45,13 @@ class AuthService {
|
|
|
22
45
|
* @returns Observable with a boolean indicating whether they were logged out.
|
|
23
46
|
*/
|
|
24
47
|
logout() {
|
|
25
|
-
return this.http
|
|
48
|
+
return this.http
|
|
49
|
+
.delete(routes.session(this.apiUrl), errorOptions(false))
|
|
50
|
+
.pipe(map(() => true))
|
|
51
|
+
.pipe(tap(() => {
|
|
52
|
+
this.authenticatedSignal.set(false);
|
|
53
|
+
this.sessionInfoSignal.set({});
|
|
54
|
+
}));
|
|
26
55
|
}
|
|
27
56
|
/**
|
|
28
57
|
* Checks a user's session with the server.
|
|
@@ -30,20 +59,23 @@ class AuthService {
|
|
|
30
59
|
* @returns Observable with the user session info
|
|
31
60
|
*/
|
|
32
61
|
checkUserSession() {
|
|
33
|
-
return this.http.get(routes.session(this.apiUrl), errorOptions(false))
|
|
62
|
+
return this.http.get(routes.session(this.apiUrl), errorOptions(false)).pipe(tap((sessionInfo) => {
|
|
63
|
+
this.authenticatedSignal.set(!!sessionInfo?.authenticated);
|
|
64
|
+
this.sessionInfoSignal.set(sessionInfo);
|
|
65
|
+
}));
|
|
34
66
|
}
|
|
35
67
|
loginRoute() {
|
|
36
68
|
return routes.login(this.apiUrl);
|
|
37
69
|
}
|
|
38
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
39
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
70
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: AuthService, deps: [{ token: API_URL }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
71
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: AuthService, providedIn: 'root' });
|
|
40
72
|
}
|
|
41
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
73
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: AuthService, decorators: [{
|
|
42
74
|
type: Injectable,
|
|
43
75
|
args: [{
|
|
44
76
|
providedIn: 'root',
|
|
45
77
|
}]
|
|
46
|
-
}], ctorParameters: () => [{ type:
|
|
78
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
47
79
|
type: Inject,
|
|
48
80
|
args: [API_URL]
|
|
49
81
|
}] }] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cccteam-ccc-lib-src-auth-service.mjs","sources":["../../../projects/ccc-lib/src/auth-service/auth.service.ts","../../../projects/ccc-lib/src/auth-service/cccteam-ccc-lib-src-auth-service.ts"],"sourcesContent":["import { HttpClient } from '@angular/common/http';\nimport { Inject, Injectable } from '@angular/core';\nimport {
|
|
1
|
+
{"version":3,"file":"cccteam-ccc-lib-src-auth-service.mjs","sources":["../../../projects/ccc-lib/src/auth-service/auth.service.ts","../../../projects/ccc-lib/src/auth-service/cccteam-ccc-lib-src-auth-service.ts"],"sourcesContent":["import { HttpClient } from '@angular/common/http';\nimport { inject, Inject, Injectable, signal } from '@angular/core';\nimport {\n API_URL,\n Permission,\n PERMISSION_REQUIRED,\n PermissionScope,\n Resource,\n SessionInfo,\n} from '@cccteam/ccc-lib/src/types';\nimport { errorOptions } from '@cccteam/ccc-lib/src/util-request-options';\nimport { map, Observable, tap } from 'rxjs';\n\nconst routes = {\n login: (rootUrl: string): string => `${rootUrl}/user/login`,\n session: (rootUrl: string): string => `${rootUrl}/user/session`,\n};\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AuthService {\n http = inject(HttpClient);\n private authenticatedSignal = signal(false);\n private sessionInfoSignal = signal({} as SessionInfo);\n\n redirectUrl = signal('');\n authenticated = this.authenticatedSignal.asReadonly();\n sessionInfo = this.sessionInfoSignal.asReadonly();\n\n constructor(@Inject(API_URL) private apiUrl: string) {\n this.initializePermissionFn();\n }\n\n private static permissionFn: (resource: Resource, permission: Permission) => boolean;\n\n hasPermission(scope?: PermissionScope): boolean {\n if (!scope) return true;\n const resourcePermissions = this.sessionInfo().permissions?.[scope.domain]?.[scope.resource];\n return Array.isArray(resourcePermissions) && resourcePermissions.includes(scope.permission);\n }\n\n static requiresPermission(resource: Resource, permission: Permission): boolean {\n if (!AuthService.permissionFn) {\n throw new Error(\n `AuthState has not been initialized. Ensure AuthState is provided in your module or instantiated at least once.`,\n );\n }\n return AuthService.permissionFn(resource, permission);\n }\n\n private initializePermissionFn(): void {\n if (!AuthService.permissionFn) {\n AuthService.permissionFn = inject(PERMISSION_REQUIRED);\n }\n }\n\n /**\n * Logs a user out.\n *\n * @returns Observable with a boolean indicating whether they were logged out.\n */\n logout(): Observable<boolean> {\n return this.http\n .delete(routes.session(this.apiUrl), errorOptions(false))\n .pipe(map(() => true))\n .pipe(\n tap(() => {\n this.authenticatedSignal.set(false);\n this.sessionInfoSignal.set({} as SessionInfo);\n }),\n );\n }\n\n /**\n * Checks a user's session with the server.\n *\n * @returns Observable with the user session info\n */\n checkUserSession(): Observable<SessionInfo> {\n return this.http.get<SessionInfo>(routes.session(this.apiUrl), errorOptions(false)).pipe(\n tap((sessionInfo) => {\n this.authenticatedSignal.set(!!sessionInfo?.authenticated);\n this.sessionInfoSignal.set(sessionInfo);\n }),\n );\n }\n\n loginRoute(): string {\n return routes.login(this.apiUrl);\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;AAaA,MAAM,MAAM,GAAG;IACb,KAAK,EAAE,CAAC,OAAe,KAAa,CAAA,EAAG,OAAO,CAAa,WAAA,CAAA;IAC3D,OAAO,EAAE,CAAC,OAAe,KAAa,CAAA,EAAG,OAAO,CAAe,aAAA,CAAA;CAChE;MAKY,WAAW,CAAA;AASe,IAAA,MAAA;AARrC,IAAA,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC;AACjB,IAAA,mBAAmB,GAAG,MAAM,CAAC,KAAK,CAAC;AACnC,IAAA,iBAAiB,GAAG,MAAM,CAAC,EAAiB,CAAC;AAErD,IAAA,WAAW,GAAG,MAAM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file":"cccteam-ccc-lib-src-types.mjs","sources":["../../../projects/ccc-lib/src/types/auth.actions.ts","../../../projects/ccc-lib/src/types/core.actions.ts","../../../projects/ccc-lib/src/types/notification-message.ts","../../../projects/ccc-lib/src/types/permissions.ts","../../../projects/ccc-lib/src/types/tokens.ts","../../../projects/ccc-lib/src/types/cccteam-ccc-lib-src-types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-namespace */\n// no-namespace rule is disabled because action hygiene prevents import pollution\n\nimport { CreateNotificationMessage } from './notification-message';\nexport namespace AuthenticationGuardAction {\n export class SetRedirectUrl {\n static readonly type = '[AuthenticationGuard] Set Redirect Url And Navigate To Login Page';\n constructor(public redirectUrl: string) {}\n }\n\n export class CheckUserSession {\n static readonly type = '[AuthenticationGuard] Check User Session';\n }\n}\n\nexport namespace LoginAction {\n export class Logout {\n static readonly type = '[Login] Auto Logout';\n }\n\n export class SetRedirectUrl {\n static readonly type = '[Login] Set Redirect Url';\n constructor(public redirectUrl: string) {}\n }\n\n export class PublishError {\n static readonly type = '[Login] Publish Error';\n constructor(public message: CreateNotificationMessage) {}\n }\n}\n\nexport namespace AppAction {\n export class CheckUserSession {\n static readonly type = '[App] Check User Session';\n }\n\n export class SetRedirectUrl {\n static readonly type = '[App] Set Redirect Url';\n constructor(public redirectUrl: string) {}\n }\n\n export class SetNavIdentifier {\n static readonly type = '[App] Set Nav Identifier';\n constructor(public identifier: string) {}\n }\n}\n","/* eslint-disable @typescript-eslint/no-namespace */\n// no-namespace rule is disabled because action hygiene prevents import pollution\n\nimport { CreateNotificationMessage } from './notification-message';\n\nexport namespace ApiInterceptorAction {\n export class BeginActivity {\n static readonly type = '[ApiInterceptor] Add Loading Activity';\n constructor(public process: string) {}\n }\n export class EndActivity {\n static readonly type = '[ApiInterceptor] Remove Loading Activity';\n constructor(public process: string) {}\n }\n export class PublishError {\n static readonly type = '[ApiInterceptor] Publish Error';\n constructor(public message: CreateNotificationMessage) {}\n }\n export class SetRedirectUrl {\n static readonly type = '[ApiInterceptor] Set Redirect Url';\n constructor(public redirectUrl: string) {}\n }\n}\n\nexport namespace HeaderAction {\n export class ToggleSidenav {\n static readonly type = '[Header] Toggle Sidenav';\n }\n\n export class Logout {\n static readonly type = '[Header] User Logout';\n }\n}\n","export enum AlertLevel {\n ERROR = 'warn',\n INFO = 'accent',\n SUCCESS = 'success',\n}\n\nexport interface CreateNotificationMessage {\n duration?: number;\n message: string;\n link: string;\n level: AlertLevel;\n}\n\nexport interface NotificationMessage {\n id: number;\n duration?: number;\n message: string;\n link: string;\n level: AlertLevel;\n}\n","type Brand<K, T> = K & { __brand: T };\n\nexport type Permission = Brand<string, 'Permission'>;\nexport type Resource = Brand<string, 'Resource'>;\nexport type Domain = Brand<string, 'Domain'>;\nexport type DomainPermissions = Record<Domain, Record<Resource, Record<Permission, Permissions>>>;\n\nexport interface PermissionScope {\n resource: Resource;\n permission: Permission;\n domain: Domain;\n}\n\nexport const ReadPermission = 'Read' as Permission;\nexport const UpdatePermission = 'Update' as Permission;\n","import { InjectionToken } from '@angular/core';\nimport { Domain, Permission, Resource } from './permissions';\n\nexport const BASE_URL = new InjectionToken<string>('BASE_URL');\nexport const API_URL = new InjectionToken<string>('API_URL');\nexport const PERMISSION_REQUIRED = new InjectionToken<(resource: Resource, permission: Permission) => boolean>(\n 'PERMISSION_REQUIRED',\n);\n\nexport const AVAILABLE_PERMISSIONS = new InjectionToken<{\n Create: Permission;\n Delete: Permission;\n List: Permission;\n Read: Permission;\n Update: Permission;\n}>('AVAILABLE_PERMISSIONS');\nexport const AVAILABLE_DOMAINS = new InjectionToken<Record<string, Domain>[]>('AVAILABLE_DOMAINS');\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAAA;AACA;AAGM,IAAW;AAAjB,CAAA,UAAiB,yBAAyB,EAAA;AACxC,IAAA,MAAa,cAAc,CAAA;AAEN,QAAA,WAAA;AADnB,QAAA,OAAgB,IAAI,GAAG,mEAAmE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KAApB,oBAAoB,GAiBpC,EAAA,CAAA,CAAA;AAEK,IAAW;AAAjB,CAAA,UAAiB,YAAY,EAAA;AAC3B,IAAA,MAAa,aAAa,CAAA;AACxB,QAAA,OAAgB,IAAI,GAAG,yBAAyB;;AADrC,IAAA,YAAA,CAAA,aAAa,gBAEzB;AAED,IAAA,MAAa,MAAM,CAAA;AACjB,QAAA,OAAgB,IAAI,GAAG,sBAAsB;;AADlC,IAAA,YAAA,CAAA,MAAM,SAElB;AACH,CAAC,EARgB,YAAY,KAAZ,YAAY,GAQ5B,EAAA,CAAA,CAAA;;IChCW;AAAZ,CAAA,UAAY,UAAU,EAAA;AACpB,IAAA,UAAA,CAAA,OAAA,CAAA,GAAA,MAAc;AACd,IAAA,UAAA,CAAA,MAAA,CAAA,GAAA,QAAe;AACf,IAAA,UAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACrB,CAAC,EAJW,UAAU,KAAV,UAAU,GAIrB,EAAA,CAAA,CAAA;;
|
|
1
|
+
{"version":3,"file":"cccteam-ccc-lib-src-types.mjs","sources":["../../../projects/ccc-lib/src/types/auth.actions.ts","../../../projects/ccc-lib/src/types/core.actions.ts","../../../projects/ccc-lib/src/types/notification-message.ts","../../../projects/ccc-lib/src/types/permissions.ts","../../../projects/ccc-lib/src/types/tokens.ts","../../../projects/ccc-lib/src/types/cccteam-ccc-lib-src-types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-namespace */\n// no-namespace rule is disabled because action hygiene prevents import pollution\n\nimport { CreateNotificationMessage } from './notification-message';\nexport namespace AuthenticationGuardAction {\n export class SetRedirectUrl {\n static readonly type = '[AuthenticationGuard] Set Redirect Url And Navigate To Login Page';\n constructor(public redirectUrl: string) {}\n }\n\n export class CheckUserSession {\n static readonly type = '[AuthenticationGuard] Check User Session';\n }\n}\n\nexport namespace LoginAction {\n export class Logout {\n static readonly type = '[Login] Auto Logout';\n }\n\n export class SetRedirectUrl {\n static readonly type = '[Login] Set Redirect Url';\n constructor(public redirectUrl: string) {}\n }\n\n export class PublishError {\n static readonly type = '[Login] Publish Error';\n constructor(public message: CreateNotificationMessage) {}\n }\n}\n\nexport namespace AppAction {\n export class CheckUserSession {\n static readonly type = '[App] Check User Session';\n }\n\n export class SetRedirectUrl {\n static readonly type = '[App] Set Redirect Url';\n constructor(public redirectUrl: string) {}\n }\n\n export class SetNavIdentifier {\n static readonly type = '[App] Set Nav Identifier';\n constructor(public identifier: string) {}\n }\n}\n","/* eslint-disable @typescript-eslint/no-namespace */\n// no-namespace rule is disabled because action hygiene prevents import pollution\n\nimport { CreateNotificationMessage } from './notification-message';\n\nexport namespace ApiInterceptorAction {\n export class BeginActivity {\n static readonly type = '[ApiInterceptor] Add Loading Activity';\n constructor(public process: string) {}\n }\n export class EndActivity {\n static readonly type = '[ApiInterceptor] Remove Loading Activity';\n constructor(public process: string) {}\n }\n export class PublishError {\n static readonly type = '[ApiInterceptor] Publish Error';\n constructor(public message: CreateNotificationMessage) {}\n }\n export class SetRedirectUrl {\n static readonly type = '[ApiInterceptor] Set Redirect Url';\n constructor(public redirectUrl: string) {}\n }\n}\n\nexport namespace HeaderAction {\n export class ToggleSidenav {\n static readonly type = '[Header] Toggle Sidenav';\n }\n\n export class Logout {\n static readonly type = '[Header] User Logout';\n }\n}\n","export enum AlertLevel {\n ERROR = 'warn',\n INFO = 'accent',\n SUCCESS = 'success',\n}\n\nexport interface CreateNotificationMessage {\n duration?: number;\n message: string;\n link: string;\n level: AlertLevel;\n}\n\nexport interface NotificationMessage {\n id: number;\n duration?: number;\n message: string;\n link: string;\n level: AlertLevel;\n}\n","type Brand<K, T> = K & { __brand: T };\n\nexport type Permission = Brand<string, 'Permission'>;\nexport type Resource = Brand<string, 'Resource'>;\nexport type Domain = Brand<string, 'Domain'>;\nexport type FieldName = Brand<string, 'FieldName'>;\nexport type Method = Brand<string, 'Method'>;\nexport type DomainPermissions = Record<Domain, Record<Resource, Record<Permission, Permissions>>>;\n\nexport interface PermissionScope {\n resource: Resource;\n permission: Permission;\n domain: Domain;\n}\n\nexport const ReadPermission = 'Read' as Permission;\nexport const UpdatePermission = 'Update' as Permission;\n","import { InjectionToken } from '@angular/core';\nimport { Domain, Permission, Resource } from './permissions';\n\nexport const BASE_URL = new InjectionToken<string>('BASE_URL');\nexport const API_URL = new InjectionToken<string>('API_URL');\nexport const PERMISSION_REQUIRED = new InjectionToken<(resource: Resource, permission: Permission) => boolean>(\n 'PERMISSION_REQUIRED',\n);\n\nexport const AVAILABLE_PERMISSIONS = new InjectionToken<{\n Create: Permission;\n Delete: Permission;\n List: Permission;\n Read: Permission;\n Update: Permission;\n}>('AVAILABLE_PERMISSIONS');\nexport const AVAILABLE_DOMAINS = new InjectionToken<Record<string, Domain>[]>('AVAILABLE_DOMAINS');\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAAA;AACA;AAGM,IAAW;AAAjB,CAAA,UAAiB,yBAAyB,EAAA;AACxC,IAAA,MAAa,cAAc,CAAA;AAEN,QAAA,WAAA;AADnB,QAAA,OAAgB,IAAI,GAAG,mEAAmE;AAC1F,QAAA,WAAA,CAAmB,WAAmB,EAAA;YAAnB,IAAW,CAAA,WAAA,GAAX,WAAW;;;AAFnB,IAAA,yBAAA,CAAA,cAAc,iBAG1B;AAED,IAAA,MAAa,gBAAgB,CAAA;AAC3B,QAAA,OAAgB,IAAI,GAAG,0CAA0C;;AADtD,IAAA,yBAAA,CAAA,gBAAgB,mBAE5B;AACH,CAAC,EATgB,yBAAyB,KAAzB,yBAAyB,GASzC,EAAA,CAAA,CAAA;AAEK,IAAW;AAAjB,CAAA,UAAiB,WAAW,EAAA;AAC1B,IAAA,MAAa,MAAM,CAAA;AACjB,QAAA,OAAgB,IAAI,GAAG,qBAAqB;;AADjC,IAAA,WAAA,CAAA,MAAM,SAElB;AAED,IAAA,MAAa,cAAc,CAAA;AAEN,QAAA,WAAA;AADnB,QAAA,OAAgB,IAAI,GAAG,0BAA0B;AACjD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AACrB,CAAC,EAJW,UAAU,KAAV,UAAU,GAIrB,EAAA,CAAA,CAAA;;ACWM,MAAM,cAAc,GAAG;AACvB,MAAM,gBAAgB,GAAG;;MCbnB,QAAQ,GAAG,IAAI,cAAc,CAAS,UAAU;MAChD,OAAO,GAAG,IAAI,cAAc,CAAS,SAAS;MAC9C,mBAAmB,GAAG,IAAI,cAAc,CACnD,qBAAqB;MAGV,qBAAqB,GAAG,IAAI,cAAc,CAMpD,uBAAuB;MACb,iBAAiB,GAAG,IAAI,cAAc,CAA2B,mBAAmB;;AChBjG;;AAEG;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i3 from '@angular/common';
|
|
2
2
|
import { CommonModule } from '@angular/common';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
|
-
import { EventEmitter, inject,
|
|
4
|
+
import { EventEmitter, inject, Output, Input, Component } from '@angular/core';
|
|
5
5
|
import * as i2 from '@angular/material/button';
|
|
6
6
|
import { MatButtonModule } from '@angular/material/button';
|
|
7
7
|
import * as i1 from '@angular/material/icon';
|
|
@@ -27,10 +27,10 @@ class AlertComponent {
|
|
|
27
27
|
this.errors.dismissGlobalNotification(this.error);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
31
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
30
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: AlertComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
31
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.0.0", type: AlertComponent, isStandalone: true, selector: "ccc-alert", inputs: { error: "error" }, outputs: { dismiss: "dismiss" }, ngImport: i0, template: "<div class=\"alert\" [ngClass]=\"error.level\">\n <div class=\"message\">\n <span>{{ error.message }}</span>\n </div>\n <div class=\"alert-end\">\n @if (error.link) {\n <span [routerLink]=\"error.link\" class=\"link\">View</span>\n }\n <button (click)=\"dismissAlert()\" mat-icon-button aria-label=\"Close Alert\">\n <mat-icon>close</mat-icon>\n </button>\n </div>\n</div>\n", styles: [".alert{margin:auto;border:1px solid;max-width:450px;border-radius:5px;background-color:#d3d3d3;display:flex;flex-direction:row;align-items:center;justify-content:space-between}.message{padding-left:15px;max-width:400px;display:flex;justify-content:space-between}.alert-end{display:flex;flex-direction:row;align-items:center;gap:5px}.link{cursor:pointer}.link:hover{text-decoration:underline}.warn{border-color:red;background-color:#fff5f4}.accent{border-color:#dfb51d;background-color:#fff8e0}.success{border-color:#4caf50;background-color:#f0fff0}\n"], dependencies: [{ kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i2.MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "ngmodule", type: RouterModule }, { kind: "directive", type: i4.RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }] });
|
|
32
32
|
}
|
|
33
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
33
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: AlertComponent, decorators: [{
|
|
34
34
|
type: Component,
|
|
35
35
|
args: [{ selector: 'ccc-alert', imports: [MatIconModule, MatButtonModule, CommonModule, RouterModule], template: "<div class=\"alert\" [ngClass]=\"error.level\">\n <div class=\"message\">\n <span>{{ error.message }}</span>\n </div>\n <div class=\"alert-end\">\n @if (error.link) {\n <span [routerLink]=\"error.link\" class=\"link\">View</span>\n }\n <button (click)=\"dismissAlert()\" mat-icon-button aria-label=\"Close Alert\">\n <mat-icon>close</mat-icon>\n </button>\n </div>\n</div>\n", styles: [".alert{margin:auto;border:1px solid;max-width:450px;border-radius:5px;background-color:#d3d3d3;display:flex;flex-direction:row;align-items:center;justify-content:space-between}.message{padding-left:15px;max-width:400px;display:flex;justify-content:space-between}.alert-end{display:flex;flex-direction:row;align-items:center;gap:5px}.link{cursor:pointer}.link:hover{text-decoration:underline}.warn{border-color:red;background-color:#fff5f4}.accent{border-color:#dfb51d;background-color:#fff8e0}.success{border-color:#4caf50;background-color:#f0fff0}\n"] }]
|
|
36
36
|
}], propDecorators: { error: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cccteam-ccc-lib-src-ui-alert.mjs","sources":["../../../projects/ccc-lib/src/ui-alert/alert.component.ts","../../../projects/ccc-lib/src/ui-alert/alert.component.html","../../../projects/ccc-lib/src/ui-alert/cccteam-ccc-lib-src-ui-alert.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { Component, EventEmitter, Input, OnInit, Output, inject } from '@angular/core';\nimport { MatButtonModule } from '@angular/material/button';\nimport { MatIconModule } from '@angular/material/icon';\nimport { RouterModule } from '@angular/router';\nimport { NotificationMessage } from '@cccteam/ccc-lib/src/types';\nimport { NotificationService } from '@cccteam/ccc-lib/src/ui-notification-service';\n\n@Component({\n selector: 'ccc-alert',\n templateUrl: './alert.component.html',\n styleUrls: ['./alert.component.scss'],\n imports: [MatIconModule, MatButtonModule, CommonModule, RouterModule],\n})\nexport class AlertComponent implements OnInit {\n @Input({ required: true }) error!: NotificationMessage;\n @Output() dismiss = new EventEmitter();\n\n errors = inject(NotificationService);\n ngOnInit(): void {\n if (this.error.duration === undefined) {\n this.error.duration = 30000;\n }\n\n setTimeout(() => {\n this.dismissAlert();\n }, this.error.duration);\n }\n\n dismissAlert(): void {\n if (this.error.id !== undefined) {\n this.errors.dismissGlobalNotification(this.error);\n }\n }\n}\n","<div class=\"alert\" [ngClass]=\"error.level\">\n <div class=\"message\">\n <span>{{ error.message }}</span>\n </div>\n <div class=\"alert-end\">\n @if (error.link) {\n <span [routerLink]=\"error.link\" class=\"link\">View</span>\n }\n <button (click)=\"dismissAlert()\" mat-icon-button aria-label=\"Close Alert\">\n <mat-icon>close</mat-icon>\n </button>\n </div>\n</div>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;;MAca,cAAc,CAAA;AACE,IAAA,KAAK;AACtB,IAAA,OAAO,GAAG,IAAI,YAAY,EAAE;AAEtC,IAAA,MAAM,GAAG,MAAM,CAAC,mBAAmB,CAAC;IACpC,QAAQ,GAAA;QACN,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,KAAK,SAAS,EAAE;AACrC,YAAA,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,KAAK;;QAG7B,UAAU,CAAC,MAAK;YACd,IAAI,CAAC,YAAY,EAAE;AACrB,SAAC,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;;IAGzB,YAAY,GAAA;QACV,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,SAAS,EAAE;YAC/B,IAAI,CAAC,MAAM,CAAC,yBAAyB,CAAC,IAAI,CAAC,KAAK,CAAC;;;uGAjB1C,cAAc,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;2FAAd,cAAc,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,WAAA,EAAA,MAAA,EAAA,EAAA,KAAA,EAAA,OAAA,EAAA,EAAA,OAAA,EAAA,EAAA,OAAA,EAAA,SAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,QAAA,ECd3B,mZAaA,EDDY,MAAA,EAAA,CAAA,wiBAAA,CAAA,EAAA,YAAA,EAAA,CAAA,EAAA,IAAA,EAAA,UAAA,EAAA,IAAA,EAAA,aAAa,mLAAE,eAAe,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAAA,EAAA,CAAA,aAAA,EAAA,QAAA,EAAA,
|
|
1
|
+
{"version":3,"file":"cccteam-ccc-lib-src-ui-alert.mjs","sources":["../../../projects/ccc-lib/src/ui-alert/alert.component.ts","../../../projects/ccc-lib/src/ui-alert/alert.component.html","../../../projects/ccc-lib/src/ui-alert/cccteam-ccc-lib-src-ui-alert.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { Component, EventEmitter, Input, OnInit, Output, inject } from '@angular/core';\nimport { MatButtonModule } from '@angular/material/button';\nimport { MatIconModule } from '@angular/material/icon';\nimport { RouterModule } from '@angular/router';\nimport { NotificationMessage } from '@cccteam/ccc-lib/src/types';\nimport { NotificationService } from '@cccteam/ccc-lib/src/ui-notification-service';\n\n@Component({\n selector: 'ccc-alert',\n templateUrl: './alert.component.html',\n styleUrls: ['./alert.component.scss'],\n imports: [MatIconModule, MatButtonModule, CommonModule, RouterModule],\n})\nexport class AlertComponent implements OnInit {\n @Input({ required: true }) error!: NotificationMessage;\n @Output() dismiss = new EventEmitter();\n\n errors = inject(NotificationService);\n ngOnInit(): void {\n if (this.error.duration === undefined) {\n this.error.duration = 30000;\n }\n\n setTimeout(() => {\n this.dismissAlert();\n }, this.error.duration);\n }\n\n dismissAlert(): void {\n if (this.error.id !== undefined) {\n this.errors.dismissGlobalNotification(this.error);\n }\n }\n}\n","<div class=\"alert\" [ngClass]=\"error.level\">\n <div class=\"message\">\n <span>{{ error.message }}</span>\n </div>\n <div class=\"alert-end\">\n @if (error.link) {\n <span [routerLink]=\"error.link\" class=\"link\">View</span>\n }\n <button (click)=\"dismissAlert()\" mat-icon-button aria-label=\"Close Alert\">\n <mat-icon>close</mat-icon>\n </button>\n </div>\n</div>\n","/**\n * Generated bundle index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,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAAA,EAAA,CAAA,OAAA,EAAA,QAAA,EAAA,WAAA,EAAA,MAAA,EAAA,CAAA,OAAA,EAAA,SAAA,CAAA,EAAA,EAAA,EAAA,IAAA,EAAA,UAAA,EAAA,IAAA,EAAE,YAAY,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAAA,EAAA,CAAA,UAAA,EAAA,QAAA,EAAA,cAAA,EAAA,MAAA,EAAA,CAAA,QAAA,EAAA,aAAA,EAAA,UAAA,EAAA,qBAAA,EAAA,OAAA,EAAA,MAAA,EAAA,YAAA,EAAA,kBAAA,EAAA,oBAAA,EAAA,YAAA,EAAA,YAAA,CAAA,EAAA,CAAA,EAAA,CAAA;;2FAEzD,cAAc,EAAA,UAAA,EAAA,CAAA;kBAN1B,SAAS;+BACE,WAAW,EAAA,OAAA,EAGZ,CAAC,aAAa,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,CAAC,EAAA,QAAA,EAAA,mZAAA,EAAA,MAAA,EAAA,CAAA,wiBAAA,CAAA,EAAA;8BAG1C,KAAK,EAAA,CAAA;sBAA/B,KAAK;uBAAC,EAAE,QAAQ,EAAE,IAAI,EAAE;gBACf,OAAO,EAAA,CAAA;sBAAhB;;;AEhBH;;AAEG;;;;"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, signal, computed, Injectable } from '@angular/core';
|
|
3
|
+
import { NotificationService } from '@cccteam/ccc-lib/src/ui-notification-service';
|
|
4
|
+
|
|
5
|
+
class UiCoreService {
|
|
6
|
+
notifications = inject(NotificationService);
|
|
7
|
+
loadingSignal = signal([]);
|
|
8
|
+
sidenavOpened = signal(true);
|
|
9
|
+
currentSidenavIdentifier = signal('');
|
|
10
|
+
loading = this.loadingSignal.asReadonly();
|
|
11
|
+
isLoading = computed(() => this.loading().length > 0);
|
|
12
|
+
publishError(message) {
|
|
13
|
+
this.notifications.addGlobalNotification(message);
|
|
14
|
+
}
|
|
15
|
+
beginActivity(process) {
|
|
16
|
+
if (!this.loading().includes(process)) {
|
|
17
|
+
this.loadingSignal.update((current) => [...current, process]);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
endActivity(process) {
|
|
21
|
+
this.loadingSignal.update((current) => current.filter((p) => p !== process));
|
|
22
|
+
}
|
|
23
|
+
toggleSidenav() {
|
|
24
|
+
this.sidenavOpened.update((opened) => !opened);
|
|
25
|
+
}
|
|
26
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: UiCoreService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
27
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: UiCoreService, providedIn: 'root' });
|
|
28
|
+
}
|
|
29
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: UiCoreService, decorators: [{
|
|
30
|
+
type: Injectable,
|
|
31
|
+
args: [{
|
|
32
|
+
providedIn: 'root',
|
|
33
|
+
}]
|
|
34
|
+
}] });
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Generated bundle index. Do not edit.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
export { UiCoreService };
|
|
41
|
+
//# sourceMappingURL=cccteam-ccc-lib-src-ui-core-service.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cccteam-ccc-lib-src-ui-core-service.mjs","sources":["../../../projects/ccc-lib/src/ui-core-service/ui-core.service.ts","../../../projects/ccc-lib/src/ui-core-service/cccteam-ccc-lib-src-ui-core-service.ts"],"sourcesContent":["import { computed, inject, Injectable, signal } from '@angular/core';\nimport { CreateNotificationMessage } from '@cccteam/ccc-lib/src/types';\nimport { NotificationService } from '@cccteam/ccc-lib/src/ui-notification-service';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class UiCoreService {\n notifications = inject(NotificationService);\n loadingSignal = signal([] as string[]);\n sidenavOpened = signal(true);\n currentSidenavIdentifier = signal('');\n\n private loading = this.loadingSignal.asReadonly();\n isLoading = computed(() => this.loading().length > 0);\n\n publishError(message: CreateNotificationMessage): void {\n this.notifications.addGlobalNotification(message);\n }\n\n beginActivity(process: string): void {\n if (!this.loading().includes(process)) {\n this.loadingSignal.update((current) => [...current, process]);\n }\n }\n\n endActivity(process: string): void {\n this.loadingSignal.update((current) => current.filter((p) => p !== process));\n }\n\n toggleSidenav(): void {\n this.sidenavOpened.update((opened) => !opened);\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;MAOa,aAAa,CAAA;AACxB,IAAA,aAAa,GAAG,MAAM,CAAC,mBAAmB,CAAC;AAC3C,IAAA,aAAa,GAAG,MAAM,CAAC,EAAc,CAAC;AACtC,IAAA,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC;AAC5B,IAAA,wBAAwB,GAAG,MAAM,CAAC,EAAE,CAAC;AAE7B,IAAA,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE;AACjD,IAAA,SAAS,GAAG,QAAQ,CAAC,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;AAErD,IAAA,YAAY,CAAC,OAAkC,EAAA;AAC7C,QAAA,IAAI,CAAC,aAAa,CAAC,qBAAqB,CAAC,OAAO,CAAC;;AAGnD,IAAA,aAAa,CAAC,OAAe,EAAA;QAC3B,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;AACrC,YAAA,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,OAAO,KAAK,CAAC,GAAG,OAAO,EAAE,OAAO,CAAC,CAAC;;;AAIjE,IAAA,WAAW,CAAC,OAAe,EAAA;QACzB,IAAI,CAAC,aAAa,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