@cccteam/ccc-lib 0.0.15 → 0.0.16
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 +38 -13
- package/fesm2022/cccteam-ccc-lib-src-auth-authentication-guard.mjs +36 -0
- package/fesm2022/cccteam-ccc-lib-src-auth-authentication-guard.mjs.map +1 -0
- package/fesm2022/cccteam-ccc-lib-src-auth-authorization-guard.mjs +25 -0
- package/fesm2022/cccteam-ccc-lib-src-auth-authorization-guard.mjs.map +1 -0
- package/fesm2022/cccteam-ccc-lib-src-auth-forms.mjs +83 -0
- package/fesm2022/cccteam-ccc-lib-src-auth-forms.mjs.map +1 -0
- package/fesm2022/cccteam-ccc-lib-src-auth-has-permission.mjs +44 -0
- package/fesm2022/cccteam-ccc-lib-src-auth-has-permission.mjs.map +1 -0
- package/fesm2022/cccteam-ccc-lib-src-auth-service.mjs +82 -0
- package/fesm2022/cccteam-ccc-lib-src-auth-service.mjs.map +1 -0
- package/fesm2022/cccteam-ccc-lib-src-ccc-camel-case-to-title.mjs +33 -0
- package/fesm2022/cccteam-ccc-lib-src-ccc-camel-case-to-title.mjs.map +1 -0
- package/fesm2022/cccteam-ccc-lib-src-ccc-grid.mjs +256 -0
- package/fesm2022/cccteam-ccc-lib-src-ccc-grid.mjs.map +1 -0
- package/fesm2022/cccteam-ccc-lib-src-ccc-resource.mjs +3129 -0
- package/fesm2022/cccteam-ccc-lib-src-ccc-resource.mjs.map +1 -0
- package/fesm2022/cccteam-ccc-lib-src-forms.mjs +79 -0
- package/fesm2022/cccteam-ccc-lib-src-forms.mjs.map +1 -0
- package/fesm2022/cccteam-ccc-lib-src-internal-types.mjs +6 -0
- package/fesm2022/cccteam-ccc-lib-src-internal-types.mjs.map +1 -0
- package/fesm2022/cccteam-ccc-lib-src-types.mjs +431 -0
- package/fesm2022/cccteam-ccc-lib-src-types.mjs.map +1 -0
- package/fesm2022/cccteam-ccc-lib-src-ui-alert.mjs +48 -0
- package/fesm2022/cccteam-ccc-lib-src-ui-alert.mjs.map +1 -0
- 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-idle-service.mjs +157 -0
- package/fesm2022/cccteam-ccc-lib-src-ui-idle-service.mjs.map +1 -0
- package/fesm2022/cccteam-ccc-lib-src-ui-interceptor.mjs +50 -0
- package/fesm2022/cccteam-ccc-lib-src-ui-interceptor.mjs.map +1 -0
- package/fesm2022/cccteam-ccc-lib-src-ui-notification-service.mjs +63 -0
- package/fesm2022/cccteam-ccc-lib-src-ui-notification-service.mjs.map +1 -0
- package/fesm2022/cccteam-ccc-lib-src-ui-sidenav.mjs +60 -0
- package/fesm2022/cccteam-ccc-lib-src-ui-sidenav.mjs.map +1 -0
- package/fesm2022/cccteam-ccc-lib-src-util-request-options.mjs +19 -0
- package/fesm2022/cccteam-ccc-lib-src-util-request-options.mjs.map +1 -0
- package/fesm2022/cccteam-ccc-lib.mjs +4444 -0
- package/fesm2022/cccteam-ccc-lib.mjs.map +1 -0
- package/package.json +88 -5
- package/types/cccteam-ccc-lib-src-auth-authentication-guard.d.ts +6 -0
- package/types/cccteam-ccc-lib-src-auth-authorization-guard.d.ts +6 -0
- package/types/cccteam-ccc-lib-src-auth-forms.d.ts +28 -0
- package/types/cccteam-ccc-lib-src-auth-has-permission.d.ts +15 -0
- package/types/cccteam-ccc-lib-src-auth-service.d.ts +38 -0
- package/types/cccteam-ccc-lib-src-ccc-camel-case-to-title.d.ts +10 -0
- package/types/cccteam-ccc-lib-src-ccc-grid.d.ts +35 -0
- package/types/cccteam-ccc-lib-src-ccc-resource.d.ts +674 -0
- package/types/cccteam-ccc-lib-src-forms.d.ts +27 -0
- package/types/cccteam-ccc-lib-src-types.d.ts +934 -0
- package/types/cccteam-ccc-lib-src-ui-alert.d.ts +16 -0
- package/types/cccteam-ccc-lib-src-ui-core-service.d.ts +20 -0
- package/types/cccteam-ccc-lib-src-ui-idle-service.d.ts +49 -0
- package/types/cccteam-ccc-lib-src-ui-interceptor.d.ts +16 -0
- package/types/cccteam-ccc-lib-src-ui-notification-service.d.ts +33 -0
- package/types/cccteam-ccc-lib-src-ui-sidenav.d.ts +33 -0
- package/types/cccteam-ccc-lib-src-util-request-options.d.ts +12 -0
- package/types/cccteam-ccc-lib.d.ts +1877 -0
- package/eslint.config.js +0 -32
- package/ng-package.json +0 -11
- package/src/auth-authentication-guard/authentication.guard.ts +0 -40
- package/src/auth-authentication-guard/index.ts +0 -1
- package/src/auth-authentication-guard/ng-package.json +0 -6
- package/src/auth-authorization-guard/authorization.guard.ts +0 -17
- package/src/auth-authorization-guard/index.ts +0 -1
- package/src/auth-authorization-guard/ng-package.json +0 -6
- package/src/auth-forms/ccc-field/ccc-field.component.html +0 -1
- package/src/auth-forms/ccc-field/ccc-field.component.scss +0 -0
- package/src/auth-forms/ccc-field/ccc-field.component.spec.ts +0 -22
- package/src/auth-forms/ccc-field/ccc-field.component.ts +0 -74
- package/src/auth-forms/form-helpers.ts +0 -39
- package/src/auth-forms/index.ts +0 -3
- package/src/auth-forms/ng-package.json +0 -6
- package/src/auth-has-permission/has-permission.directive.ts +0 -34
- package/src/auth-has-permission/index.ts +0 -1
- package/src/auth-has-permission/ng-package.json +0 -6
- package/src/auth-service/auth.service.ts +0 -92
- package/src/auth-service/index.ts +0 -1
- package/src/auth-service/ng-package.json +0 -6
- package/src/ccc-camel-case-to-title/camel-case-to-title.pipe.ts +0 -23
- package/src/ccc-camel-case-to-title/index.ts +0 -1
- package/src/ccc-camel-case-to-title/ng-package.json +0 -6
- package/src/ccc-grid/ccc-grid.component.ts +0 -155
- package/src/ccc-grid/index.ts +0 -3
- package/src/ccc-grid/ng-package.json +0 -6
- package/src/ccc-grid/table-button/table-button.component.html +0 -16
- package/src/ccc-grid/table-button/table-button.component.scss +0 -5
- package/src/ccc-grid/table-button/table-button.component.spec.ts +0 -22
- package/src/ccc-grid/table-button/table-button.component.ts +0 -49
- package/src/ccc-resource/can-deactivate.guard.ts +0 -41
- package/src/ccc-resource/compound-resource/compound-resource.component.html +0 -57
- package/src/ccc-resource/compound-resource/compound-resource.component.scss +0 -86
- package/src/ccc-resource/compound-resource/compound-resource.component.spec.ts +0 -22
- package/src/ccc-resource/compound-resource/compound-resource.component.ts +0 -158
- package/src/ccc-resource/concat-fns.ts +0 -162
- package/src/ccc-resource/empty-readonly-field/empty-readonly-field.component.html +0 -12
- package/src/ccc-resource/empty-readonly-field/empty-readonly-field.component.scss +0 -0
- package/src/ccc-resource/empty-readonly-field/empty-readonly-field.component.spec.ts +0 -23
- package/src/ccc-resource/empty-readonly-field/empty-readonly-field.component.ts +0 -17
- package/src/ccc-resource/form-state.service.ts +0 -24
- package/src/ccc-resource/format-fns.ts +0 -49
- package/src/ccc-resource/gui-constants.ts +0 -88
- package/src/ccc-resource/index.ts +0 -23
- package/src/ccc-resource/leave-page-confirmation-modal/leave-page-confirmation-modal.component.html +0 -8
- package/src/ccc-resource/leave-page-confirmation-modal/leave-page-confirmation-modal.component.scss +0 -0
- package/src/ccc-resource/leave-page-confirmation-modal/leave-page-confirmation-modal.component.spec.ts +0 -22
- package/src/ccc-resource/leave-page-confirmation-modal/leave-page-confirmation-modal.component.ts +0 -12
- package/src/ccc-resource/ng-package.json +0 -6
- package/src/ccc-resource/operation-types.ts +0 -19
- package/src/ccc-resource/padding-element/padding-element.component.html +0 -1
- package/src/ccc-resource/padding-element/padding-element.component.scss +0 -3
- package/src/ccc-resource/padding-element/padding-element.component.spec.ts +0 -22
- package/src/ccc-resource/padding-element/padding-element.component.ts +0 -20
- package/src/ccc-resource/resource-array-view/resource-array-view.component.html +0 -81
- package/src/ccc-resource/resource-array-view/resource-array-view.component.scss +0 -21
- package/src/ccc-resource/resource-array-view/resource-array-view.component.spec.ts +0 -22
- package/src/ccc-resource/resource-array-view/resource-array-view.component.ts +0 -143
- package/src/ccc-resource/resource-base/resource-base.component.spec.ts +0 -22
- package/src/ccc-resource/resource-base/resource-base.component.ts +0 -11
- package/src/ccc-resource/resource-cache.service.ts +0 -232
- package/src/ccc-resource/resource-create/resource-create.component.html +0 -31
- package/src/ccc-resource/resource-create/resource-create.component.scss +0 -130
- package/src/ccc-resource/resource-create/resource-create.component.spec.ts +0 -22
- package/src/ccc-resource/resource-create/resource-create.component.ts +0 -303
- package/src/ccc-resource/resource-field/base-field.directive.ts +0 -102
- package/src/ccc-resource/resource-field/fields/boolean-field/boolean-field.component.html +0 -16
- package/src/ccc-resource/resource-field/fields/boolean-field/boolean-field.component.scss +0 -0
- package/src/ccc-resource/resource-field/fields/boolean-field/boolean-field.component.spec.ts +0 -22
- package/src/ccc-resource/resource-field/fields/boolean-field/boolean-field.component.ts +0 -15
- package/src/ccc-resource/resource-field/fields/computed-field/computed-field.component.html +0 -13
- package/src/ccc-resource/resource-field/fields/computed-field/computed-field.component.scss +0 -0
- package/src/ccc-resource/resource-field/fields/computed-field/computed-field.component.spec.ts +0 -23
- package/src/ccc-resource/resource-field/fields/computed-field/computed-field.component.ts +0 -50
- package/src/ccc-resource/resource-field/fields/date-field/date-field.component.html +0 -22
- package/src/ccc-resource/resource-field/fields/date-field/date-field.component.scss +0 -0
- package/src/ccc-resource/resource-field/fields/date-field/date-field.component.spec.ts +0 -22
- package/src/ccc-resource/resource-field/fields/date-field/date-field.component.ts +0 -14
- package/src/ccc-resource/resource-field/fields/enumerated-field/enumerated-field.component.html +0 -71
- package/src/ccc-resource/resource-field/fields/enumerated-field/enumerated-field.component.scss +0 -9
- package/src/ccc-resource/resource-field/fields/enumerated-field/enumerated-field.component.spec.ts +0 -22
- package/src/ccc-resource/resource-field/fields/enumerated-field/enumerated-field.component.ts +0 -207
- package/src/ccc-resource/resource-field/fields/nullboolean-field/nullboolean-field.component.html +0 -38
- package/src/ccc-resource/resource-field/fields/nullboolean-field/nullboolean-field.component.scss +0 -3
- package/src/ccc-resource/resource-field/fields/nullboolean-field/nullboolean-field.component.spec.ts +0 -22
- package/src/ccc-resource/resource-field/fields/nullboolean-field/nullboolean-field.component.ts +0 -87
- package/src/ccc-resource/resource-field/fields/number-field/number-field.component.html +0 -23
- package/src/ccc-resource/resource-field/fields/number-field/number-field.component.scss +0 -6
- package/src/ccc-resource/resource-field/fields/number-field/number-field.component.spec.ts +0 -22
- package/src/ccc-resource/resource-field/fields/number-field/number-field.component.ts +0 -14
- package/src/ccc-resource/resource-field/fields/text-field/text-field.component.html +0 -29
- package/src/ccc-resource/resource-field/fields/text-field/text-field.component.scss +0 -6
- package/src/ccc-resource/resource-field/fields/text-field/text-field.component.spec.ts +0 -22
- package/src/ccc-resource/resource-field/fields/text-field/text-field.component.ts +0 -23
- package/src/ccc-resource/resource-field/resource-field.component.html +0 -112
- package/src/ccc-resource/resource-field/resource-field.component.scss +0 -7
- package/src/ccc-resource/resource-field/resource-field.component.spec.ts +0 -22
- package/src/ccc-resource/resource-field/resource-field.component.ts +0 -214
- package/src/ccc-resource/resource-layout/resource-layout.component.html +0 -73
- package/src/ccc-resource/resource-layout/resource-layout.component.scss +0 -26
- package/src/ccc-resource/resource-layout/resource-layout.component.spec.ts +0 -22
- package/src/ccc-resource/resource-layout/resource-layout.component.ts +0 -176
- package/src/ccc-resource/resource-list/ resource-list.component.spec.ts +0 -22
- package/src/ccc-resource/resource-list/resource-list.component.html +0 -27
- package/src/ccc-resource/resource-list/resource-list.component.scss +0 -67
- package/src/ccc-resource/resource-list/resource-list.component.ts +0 -376
- package/src/ccc-resource/resource-list-create/resource-list-create.component.html +0 -71
- package/src/ccc-resource/resource-list-create/resource-list-create.component.scss +0 -9
- package/src/ccc-resource/resource-list-create/resource-list-create.component.spec.ts +0 -22
- package/src/ccc-resource/resource-list-create/resource-list-create.component.ts +0 -103
- package/src/ccc-resource/resource-resolver/resource-resolver.component.html +0 -1
- package/src/ccc-resource/resource-resolver/resource-resolver.component.scss +0 -0
- package/src/ccc-resource/resource-resolver/resource-resolver.component.spec.ts +0 -22
- package/src/ccc-resource/resource-resolver/resource-resolver.component.ts +0 -69
- package/src/ccc-resource/resource-store.service.ts +0 -93
- package/src/ccc-resource/resource-view/resource-view.component.html +0 -133
- package/src/ccc-resource/resource-view/resource-view.component.scss +0 -150
- package/src/ccc-resource/resource-view/resource-view.component.spec.ts +0 -22
- package/src/ccc-resource/resource-view/resource-view.component.ts +0 -354
- package/src/ccc-resource/resources-helpers.ts +0 -262
- package/src/ccc-resource/utils/validator-utils.ts +0 -6
- package/src/index.ts +0 -44
- package/src/internal-types/ng-package.json +0 -6
- package/src/types/auth.actions.ts +0 -46
- package/src/types/configs.ts +0 -952
- package/src/types/constants.ts +0 -1
- package/src/types/core.actions.ts +0 -33
- package/src/types/index.ts +0 -9
- package/src/types/ng-package.json +0 -6
- package/src/types/notification-message.ts +0 -20
- package/src/types/permissions.ts +0 -17
- package/src/types/session-info.ts +0 -10
- package/src/types/tokens.ts +0 -20
- package/src/ui-alert/alert.component.html +0 -13
- package/src/ui-alert/alert.component.scss +0 -48
- package/src/ui-alert/alert.component.spec.ts +0 -22
- package/src/ui-alert/alert.component.ts +0 -35
- package/src/ui-alert/index.ts +0 -1
- package/src/ui-alert/ng-package.json +0 -6
- package/src/ui-core-service/index.ts +0 -1
- package/src/ui-core-service/ng-package.json +0 -6
- package/src/ui-core-service/ui-core.service.ts +0 -34
- package/src/ui-interceptor/api.interceptor.spec.ts +0 -16
- package/src/ui-interceptor/api.interceptor.ts +0 -45
- package/src/ui-interceptor/index.ts +0 -1
- package/src/ui-interceptor/ng-package.json +0 -6
- package/src/ui-notification-service/index.ts +0 -1
- package/src/ui-notification-service/ng-package.json +0 -6
- package/src/ui-notification-service/notification.service.ts +0 -59
- package/src/ui-sidenav/index.ts +0 -1
- package/src/ui-sidenav/ng-package.json +0 -6
- package/src/ui-sidenav/sidenav.component.html +0 -60
- package/src/ui-sidenav/sidenav.component.scss +0 -99
- package/src/ui-sidenav/sidenav.component.spec.ts +0 -22
- package/src/ui-sidenav/sidenav.component.ts +0 -64
- package/src/util-request-options/index.ts +0 -1
- package/src/util-request-options/ng-package.json +0 -6
- package/src/util-request-options/request-options.ts +0 -17
- package/tsconfig.lib.json +0 -13
- package/tsconfig.lib.prod.json +0 -11
- package/tsconfig.spec.json +0 -15
- /package/{src/internal-types/index.ts → types/cccteam-ccc-lib-src-internal-types.d.ts} +0 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as i3 from '@angular/common';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import * as i0 from '@angular/core';
|
|
4
|
+
import { EventEmitter, inject, Output, Input, Component } from '@angular/core';
|
|
5
|
+
import * as i2 from '@angular/material/button';
|
|
6
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
7
|
+
import * as i1 from '@angular/material/icon';
|
|
8
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
9
|
+
import * as i4 from '@angular/router';
|
|
10
|
+
import { RouterModule } from '@angular/router';
|
|
11
|
+
import { NotificationService } from '@cccteam/ccc-lib/src/ui-notification-service';
|
|
12
|
+
|
|
13
|
+
class AlertComponent {
|
|
14
|
+
error;
|
|
15
|
+
dismiss = new EventEmitter();
|
|
16
|
+
errors = inject(NotificationService);
|
|
17
|
+
ngOnInit() {
|
|
18
|
+
if (this.error.duration === undefined) {
|
|
19
|
+
this.error.duration = 30000;
|
|
20
|
+
}
|
|
21
|
+
setTimeout(() => {
|
|
22
|
+
this.dismissAlert();
|
|
23
|
+
}, this.error.duration);
|
|
24
|
+
}
|
|
25
|
+
dismissAlert() {
|
|
26
|
+
if (this.error.id !== undefined) {
|
|
27
|
+
this.errors.dismissGlobalNotification(this.error);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: AlertComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
31
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.2", 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
|
+
}
|
|
33
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: AlertComponent, decorators: [{
|
|
34
|
+
type: Component,
|
|
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
|
+
}], propDecorators: { error: [{
|
|
37
|
+
type: Input,
|
|
38
|
+
args: [{ required: true }]
|
|
39
|
+
}], dismiss: [{
|
|
40
|
+
type: Output
|
|
41
|
+
}] } });
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Generated bundle index. Do not edit.
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
export { AlertComponent };
|
|
48
|
+
//# sourceMappingURL=cccteam-ccc-lib-src-ui-alert.mjs.map
|
|
@@ -0,0 +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 './index';\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;QAC7B;QAEA,UAAU,CAAC,MAAK;YACd,IAAI,CAAC,YAAY,EAAE;AACrB,QAAA,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;IACzB;IAEA,YAAY,GAAA;QACV,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,SAAS,EAAE;YAC/B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AA;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;;sBAGpE,KAAK;uBAAC,EAAE,QAAQ,EAAE,IAAI,EAAE;;sBACxB;;;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([], { ...(ngDevMode ? { debugName: "loadingSignal" } : {}) });
|
|
8
|
+
sidenavOpened = signal(true, { ...(ngDevMode ? { debugName: "sidenavOpened" } : {}) });
|
|
9
|
+
currentSidenavIdentifier = signal('', { ...(ngDevMode ? { debugName: "currentSidenavIdentifier" } : {}) });
|
|
10
|
+
loading = this.loadingSignal.asReadonly();
|
|
11
|
+
isLoading = computed(() => this.loading().length > 0, { ...(ngDevMode ? { debugName: "isLoading" } : {}) });
|
|
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: "21.0.2", ngImport: i0, type: UiCoreService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
27
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: UiCoreService, providedIn: 'root' });
|
|
28
|
+
}
|
|
29
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.2", 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 *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A,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,aAAa,cAFZ,MAAM,EAAA,CAAA;;2FAEP,aAAa,EAAA,UAAA,EAAA,CAAA;kBAHzB,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;ACND;;AAEG;;;;"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, signal, computed, Injectable } from '@angular/core';
|
|
3
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
4
|
+
import { Router } from '@angular/router';
|
|
5
|
+
import { AuthService } from '@cccteam/ccc-lib/src/auth-service';
|
|
6
|
+
import { IDLE_SESSION_DURATION, IDLE_WARNING_DURATION, IDLE_KEEPALIVE_DURATION, AlertLevel } from '@cccteam/ccc-lib/src/types';
|
|
7
|
+
import { UiCoreService } from '@cccteam/ccc-lib/src/ui-core-service';
|
|
8
|
+
import { NotificationService } from '@cccteam/ccc-lib/src/ui-notification-service';
|
|
9
|
+
import { interval } from 'rxjs';
|
|
10
|
+
|
|
11
|
+
class IdleService {
|
|
12
|
+
auth = inject(AuthService);
|
|
13
|
+
core = inject(UiCoreService);
|
|
14
|
+
router = inject(Router);
|
|
15
|
+
notifications = inject(NotificationService);
|
|
16
|
+
sessionDuration = inject(IDLE_SESSION_DURATION);
|
|
17
|
+
warningDuration = inject(IDLE_WARNING_DURATION);
|
|
18
|
+
keepAliveDuration = inject(IDLE_KEEPALIVE_DURATION);
|
|
19
|
+
idleCheckFrequency = 1000;
|
|
20
|
+
warningThreshold = this.sessionDuration - this.warningDuration;
|
|
21
|
+
isActive = signal(false, { ...(ngDevMode ? { debugName: "isActive" } : {}) });
|
|
22
|
+
lastActivityTimestamp = signal(0, { ...(ngDevMode ? { debugName: "lastActivityTimestamp" } : {}) });
|
|
23
|
+
tick = signal(Date.now(), { ...(ngDevMode ? { debugName: "tick" } : {}) }); // A signal to represent the current time
|
|
24
|
+
secondsIdle = computed(() => {
|
|
25
|
+
if (!this.isActive() || this.lastActivityTimestamp() === 0) {
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
28
|
+
// Depends on tick() to force re-evaluation as time passes
|
|
29
|
+
return Math.floor((this.tick() - this.lastActivityTimestamp()) / 1000);
|
|
30
|
+
}, { ...(ngDevMode ? { debugName: "secondsIdle" } : {}) });
|
|
31
|
+
isWarning = computed(() => this.secondsIdle() >= this.warningThreshold, { ...(ngDevMode ? { debugName: "isWarning" } : {}) });
|
|
32
|
+
countdown = computed(() => {
|
|
33
|
+
if (!this.isWarning()) {
|
|
34
|
+
return 0;
|
|
35
|
+
}
|
|
36
|
+
const remaining = this.sessionDuration - this.secondsIdle();
|
|
37
|
+
return Math.max(0, remaining);
|
|
38
|
+
}, { ...(ngDevMode ? { debugName: "countdown" } : {}) });
|
|
39
|
+
alertId;
|
|
40
|
+
mainTickerSubscription;
|
|
41
|
+
activityEvents = ['mousedown', 'mousemove', 'keypress', 'scroll', 'touchstart', 'click'];
|
|
42
|
+
constructor() {
|
|
43
|
+
interval(this.keepAliveDuration * 1000)
|
|
44
|
+
.pipe(takeUntilDestroyed())
|
|
45
|
+
.subscribe(() => this.checkSession());
|
|
46
|
+
}
|
|
47
|
+
ngOnDestroy() {
|
|
48
|
+
this.stop();
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Starts the idle monitoring service.
|
|
52
|
+
*/
|
|
53
|
+
start() {
|
|
54
|
+
if (this.isActive()) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
this.isActive.set(true);
|
|
58
|
+
this.lastActivityTimestamp.set(Date.now());
|
|
59
|
+
this.addActivityListeners();
|
|
60
|
+
this.startMainTicker();
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Stops the idle monitoring service and cleans up timers and alerts.
|
|
64
|
+
*/
|
|
65
|
+
stop() {
|
|
66
|
+
this.isActive.set(false);
|
|
67
|
+
this.mainTickerSubscription?.unsubscribe();
|
|
68
|
+
this.removeActivityListeners();
|
|
69
|
+
this.dismissWarningAlert();
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Logs out the user due to inactivity and stops the service.
|
|
73
|
+
*/
|
|
74
|
+
logoutAndStop() {
|
|
75
|
+
this.stop();
|
|
76
|
+
this.router.navigate([this.auth.loginRoute()]);
|
|
77
|
+
this.core.publishError({
|
|
78
|
+
message: 'You have been logged out due to inactivity.',
|
|
79
|
+
level: AlertLevel.INFO,
|
|
80
|
+
link: '',
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
startMainTicker() {
|
|
84
|
+
this.mainTickerSubscription = interval(this.idleCheckFrequency).subscribe(() => {
|
|
85
|
+
this.tick.set(Date.now());
|
|
86
|
+
if (this.secondsIdle() >= this.sessionDuration) {
|
|
87
|
+
this.logoutAndStop();
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (this.isWarning()) {
|
|
91
|
+
this.showOrUpdateWarningAlert(this.countdown());
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
this.dismissWarningAlert();
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
checkSession() {
|
|
99
|
+
if (this.auth.authenticated()) {
|
|
100
|
+
this.auth.checkUserSession().subscribe({
|
|
101
|
+
next: () => {
|
|
102
|
+
if (!this.auth.authenticated()) {
|
|
103
|
+
this.logoutAndStop();
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
setLastActivity() {
|
|
110
|
+
this.lastActivityTimestamp.set(Date.now());
|
|
111
|
+
}
|
|
112
|
+
boundActivity = this.setLastActivity.bind(this);
|
|
113
|
+
addActivityListeners() {
|
|
114
|
+
this.activityEvents.forEach((event) => {
|
|
115
|
+
document.addEventListener(event, this.boundActivity, true);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
removeActivityListeners() {
|
|
119
|
+
this.activityEvents.forEach((event) => {
|
|
120
|
+
document.removeEventListener(event, this.boundActivity, true);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
showOrUpdateWarningAlert(countdown) {
|
|
124
|
+
const message = `You will be logged out in ${countdown} seconds due to inactivity.`;
|
|
125
|
+
if (this.alertId !== undefined) {
|
|
126
|
+
this.notifications.updateNotification({ id: this.alertId, level: AlertLevel.INFO, link: '', message });
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
this.alertId = this.notifications.addGlobalNotification({
|
|
130
|
+
message,
|
|
131
|
+
level: AlertLevel.INFO,
|
|
132
|
+
link: '',
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
dismissWarningAlert() {
|
|
137
|
+
if (this.alertId !== undefined) {
|
|
138
|
+
this.notifications.dismissGlobalNotificationById(this.alertId);
|
|
139
|
+
this.alertId = undefined;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: IdleService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
143
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: IdleService, providedIn: 'root' });
|
|
144
|
+
}
|
|
145
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: IdleService, decorators: [{
|
|
146
|
+
type: Injectable,
|
|
147
|
+
args: [{
|
|
148
|
+
providedIn: 'root',
|
|
149
|
+
}]
|
|
150
|
+
}], ctorParameters: () => [] });
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Generated bundle index. Do not edit.
|
|
154
|
+
*/
|
|
155
|
+
|
|
156
|
+
export { IdleService };
|
|
157
|
+
//# sourceMappingURL=cccteam-ccc-lib-src-ui-idle-service.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cccteam-ccc-lib-src-ui-idle-service.mjs","sources":["../../../projects/ccc-lib/src/ui-idle-service/idle.service.ts","../../../projects/ccc-lib/src/ui-idle-service/cccteam-ccc-lib-src-ui-idle-service.ts"],"sourcesContent":["import { computed, inject, Injectable, OnDestroy, signal, WritableSignal } from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { Router } from '@angular/router';\nimport { AuthService } from '@cccteam/ccc-lib/src/auth-service';\nimport {\n AlertLevel,\n IDLE_KEEPALIVE_DURATION,\n IDLE_SESSION_DURATION,\n IDLE_WARNING_DURATION,\n} from '@cccteam/ccc-lib/src/types';\nimport { UiCoreService } from '@cccteam/ccc-lib/src/ui-core-service';\nimport { NotificationService } from '@cccteam/ccc-lib/src/ui-notification-service';\nimport { interval, Subscription } from 'rxjs';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class IdleService implements OnDestroy {\n private auth = inject(AuthService);\n private core = inject(UiCoreService);\n private router = inject(Router);\n private notifications = inject(NotificationService);\n\n private readonly sessionDuration = inject(IDLE_SESSION_DURATION);\n private readonly warningDuration = inject(IDLE_WARNING_DURATION);\n private readonly keepAliveDuration = inject(IDLE_KEEPALIVE_DURATION);\n private readonly idleCheckFrequency = 1000;\n private readonly warningThreshold = this.sessionDuration - this.warningDuration;\n\n public readonly isActive = signal(false);\n private lastActivityTimestamp: WritableSignal<number> = signal(0);\n private tick = signal(Date.now()); // A signal to represent the current time\n\n public readonly secondsIdle = computed(() => {\n if (!this.isActive() || this.lastActivityTimestamp() === 0) {\n return 0;\n }\n // Depends on tick() to force re-evaluation as time passes\n return Math.floor((this.tick() - this.lastActivityTimestamp()) / 1000);\n });\n\n public readonly isWarning = computed(() => this.secondsIdle() >= this.warningThreshold);\n public readonly countdown = computed(() => {\n if (!this.isWarning()) {\n return 0;\n }\n const remaining = this.sessionDuration - this.secondsIdle();\n return Math.max(0, remaining);\n });\n\n private alertId: number | undefined;\n private mainTickerSubscription: Subscription | undefined;\n\n private readonly activityEvents = ['mousedown', 'mousemove', 'keypress', 'scroll', 'touchstart', 'click'];\n\n constructor() {\n interval(this.keepAliveDuration * 1000)\n .pipe(takeUntilDestroyed())\n .subscribe(() => this.checkSession());\n }\n\n ngOnDestroy(): void {\n this.stop();\n }\n\n /**\n * Starts the idle monitoring service.\n */\n start(): void {\n if (this.isActive()) {\n return;\n }\n this.isActive.set(true);\n this.lastActivityTimestamp.set(Date.now());\n this.addActivityListeners();\n this.startMainTicker();\n }\n\n /**\n * Stops the idle monitoring service and cleans up timers and alerts.\n */\n stop(): void {\n this.isActive.set(false);\n this.mainTickerSubscription?.unsubscribe();\n this.removeActivityListeners();\n this.dismissWarningAlert();\n }\n\n /**\n * Logs out the user due to inactivity and stops the service.\n */\n logoutAndStop(): void {\n this.stop();\n\n this.router.navigate([this.auth.loginRoute()]);\n this.core.publishError({\n message: 'You have been logged out due to inactivity.',\n level: AlertLevel.INFO,\n link: '',\n });\n }\n\n private startMainTicker(): void {\n this.mainTickerSubscription = interval(this.idleCheckFrequency).subscribe(() => {\n this.tick.set(Date.now());\n\n if (this.secondsIdle() >= this.sessionDuration) {\n this.logoutAndStop();\n return;\n }\n\n if (this.isWarning()) {\n this.showOrUpdateWarningAlert(this.countdown());\n } else {\n this.dismissWarningAlert();\n }\n });\n }\n\n private checkSession(): void {\n if (this.auth.authenticated()) {\n this.auth.checkUserSession().subscribe({\n next: () => {\n if (!this.auth.authenticated()) {\n this.logoutAndStop();\n }\n },\n });\n }\n }\n\n setLastActivity(): void {\n this.lastActivityTimestamp.set(Date.now());\n }\n boundActivity = this.setLastActivity.bind(this);\n\n private addActivityListeners(): void {\n this.activityEvents.forEach((event) => {\n document.addEventListener(event, this.boundActivity, true);\n });\n }\n\n private removeActivityListeners(): void {\n this.activityEvents.forEach((event) => {\n document.removeEventListener(event, this.boundActivity, true);\n });\n }\n\n private showOrUpdateWarningAlert(countdown: number): void {\n const message = `You will be logged out in ${countdown} seconds due to inactivity.`;\n if (this.alertId !== undefined) {\n this.notifications.updateNotification({ id: this.alertId, level: AlertLevel.INFO, link: '', message });\n } else {\n this.alertId = this.notifications.addGlobalNotification({\n message,\n level: AlertLevel.INFO,\n link: '',\n });\n }\n }\n\n private dismissWarningAlert(): void {\n if (this.alertId !== undefined) {\n this.notifications.dismissGlobalNotificationById(this.alertId);\n this.alertId = undefined;\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;MAiBa,WAAW,CAAA;AACd,IAAA,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC;AAC1B,IAAA,IAAI,GAAG,MAAM,CAAC,aAAa,CAAC;AAC5B,IAAA,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;AACvB,IAAA,aAAa,GAAG,MAAM,CAAC,mBAAmB,CAAC;AAElC,IAAA,eAAe,GAAG,MAAM,CAAC,qBAAqB,CAAC;AAC/C,IAAA,eAAe,GAAG,MAAM,CAAC,qBAAqB,CAAC;AAC/C,IAAA,iBAAiB,GAAG,MAAM,CAAC,uBAAuB,CAAC;IACnD,kBAAkB,GAAG,IAAI;IACzB,gBAAgB,GAAG,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe;AAE/D,IAAA,QAAQ,GAAG,MAAM,CAAC,KAAK,sDAAC;AAChC,IAAA,qBAAqB,GAA2B,MAAM,CAAC,CAAC,mEAAC;IACzD,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,EAAA,EAAA,IAAA,SAAA,GAAA,EAAA,SAAA,EAAA,MAAA,EAAA,GAAA,EAAA,CAAA,EAAA,CAAC,CAAC;AAElB,IAAA,WAAW,GAAG,QAAQ,CAAC,MAAK;AAC1C,QAAA,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,IAAI,CAAC,qBAAqB,EAAE,KAAK,CAAC,EAAE;AAC1D,YAAA,OAA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AAO,KAAK,SAAS,EAAE;YAC9B,IAAI,CAAC,aAAa,CAAC,6BAA6B,CAAC,IAAI,CAAC,OAAO,CAAC;AAC9D,YAAA,IAAI,CAAC,OAAO,GAAG,SAAS;QAC1B;IACF;uGArJW,WAAW,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAX,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAW,cAFV,MAAM,EAAA,CAAA;;2FAEP,WAAW,EAAA,UAAA,EAAA,CAAA;kBAHvB,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;AChBD;;AAEG;;;;"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, NgZone, Injectable } from '@angular/core';
|
|
3
|
+
import { Router } from '@angular/router';
|
|
4
|
+
import { AuthService } from '@cccteam/ccc-lib/src/auth-service';
|
|
5
|
+
import { BASE_URL, AlertLevel } from '@cccteam/ccc-lib/src/types';
|
|
6
|
+
import { UiCoreService } from '@cccteam/ccc-lib/src/ui-core-service';
|
|
7
|
+
import { CUSTOM_HTTP_REQUEST_OPTIONS } from '@cccteam/ccc-lib/src/util-request-options';
|
|
8
|
+
import { catchError, throwError, finalize } from 'rxjs';
|
|
9
|
+
|
|
10
|
+
class ApiInterceptor {
|
|
11
|
+
ui = inject(UiCoreService);
|
|
12
|
+
auth = inject(AuthService);
|
|
13
|
+
router = inject(Router);
|
|
14
|
+
ngZone = inject(NgZone);
|
|
15
|
+
baseUrl = inject(BASE_URL);
|
|
16
|
+
intercept(request, next) {
|
|
17
|
+
this.ui.beginActivity(request.method + ' ' + request.url);
|
|
18
|
+
return next.handle(request).pipe(catchError((error) => {
|
|
19
|
+
if (error.status === 401) {
|
|
20
|
+
this.ngZone.run(() => {
|
|
21
|
+
this.auth.redirectUrl.set(this.baseUrl + this.router.url);
|
|
22
|
+
this.router.navigate([this.auth.loginRoute()]);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
if (!request.context.get(CUSTOM_HTTP_REQUEST_OPTIONS).suppressGlobalError) {
|
|
26
|
+
const message = error.error?.message ?? error.message ?? error.error;
|
|
27
|
+
this.ui.publishError({
|
|
28
|
+
message: message,
|
|
29
|
+
level: AlertLevel.ERROR,
|
|
30
|
+
link: '',
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return throwError(() => error);
|
|
34
|
+
}), finalize(() => {
|
|
35
|
+
this.ui.endActivity(request.method + ' ' + request.url);
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: ApiInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
39
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: ApiInterceptor });
|
|
40
|
+
}
|
|
41
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: ApiInterceptor, decorators: [{
|
|
42
|
+
type: Injectable
|
|
43
|
+
}] });
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Generated bundle index. Do not edit.
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
export { ApiInterceptor };
|
|
50
|
+
//# sourceMappingURL=cccteam-ccc-lib-src-ui-interceptor.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cccteam-ccc-lib-src-ui-interceptor.mjs","sources":["../../../projects/ccc-lib/src/ui-interceptor/api.interceptor.ts","../../../projects/ccc-lib/src/ui-interceptor/cccteam-ccc-lib-src-ui-interceptor.ts"],"sourcesContent":["import { HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';\nimport { inject, Injectable, NgZone } from '@angular/core';\nimport { Router } from '@angular/router';\nimport { AuthService } from '@cccteam/ccc-lib/src/auth-service';\nimport { AlertLevel, BASE_URL } from '@cccteam/ccc-lib/src/types';\nimport { UiCoreService } from '@cccteam/ccc-lib/src/ui-core-service';\nimport { CUSTOM_HTTP_REQUEST_OPTIONS } from '@cccteam/ccc-lib/src/util-request-options';\nimport { catchError, finalize, Observable, throwError } from 'rxjs';\n\n@Injectable()\nexport class ApiInterceptor implements HttpInterceptor {\n private ui = inject(UiCoreService);\n private auth = inject(AuthService);\n private router = inject(Router);\n private ngZone = inject(NgZone);\n private baseUrl = inject(BASE_URL);\n\n intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {\n this.ui.beginActivity(request.method + ' ' + request.url);\n\n return next.handle(request).pipe(\n catchError((error: HttpErrorResponse): Observable<HttpEvent<unknown>> => {\n if (error.status === 401) {\n this.ngZone.run(() => {\n this.auth.redirectUrl.set(this.baseUrl + this.router.url);\n this.router.navigate([this.auth.loginRoute()]);\n });\n }\n if (!request.context.get(CUSTOM_HTTP_REQUEST_OPTIONS).suppressGlobalError) {\n const message = error.error?.message ?? error.message ?? error.error;\n this.ui.publishError({\n message: message,\n level: AlertLevel.ERROR,\n link: '',\n });\n }\n\n return throwError(() => error);\n }),\n finalize(() => {\n this.ui.endActivity(request.method + ' ' + request.url);\n }),\n );\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;MAUa,cAAc,CAAA;AACjB,IAAA,EAAE,GAAG,MAAM,CAAC,aAAa,CAAC;AAC1B,IAAA,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC;AAC1B,IAAA,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;AACvB,IAAA,MAAM,GAAG,MAAM,CA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AAG,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;QACzD,CAAC,CAAC,CACH;IACH;uGAjCW,cAAc,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;2GAAd,cAAc,EAAA,CAAA;;2FAAd,cAAc,EAAA,UAAA,EAAA,CAAA;kBAD1B;;;ACTD;;AAEG;;;;"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { signal, Injectable } from '@angular/core';
|
|
3
|
+
|
|
4
|
+
class NotificationService {
|
|
5
|
+
notificationId = signal(0, { ...(ngDevMode ? { debugName: "notificationId" } : {}) });
|
|
6
|
+
_notifications = signal([], { ...(ngDevMode ? { debugName: "_notifications" } : {}) });
|
|
7
|
+
notifications = this._notifications.asReadonly();
|
|
8
|
+
/**
|
|
9
|
+
* Adds a new global notification.
|
|
10
|
+
* @param notification The notification message to add.
|
|
11
|
+
* @returns The unique ID assigned to the notification.
|
|
12
|
+
*/
|
|
13
|
+
addGlobalNotification(notification) {
|
|
14
|
+
this.notificationId.update((id) => id + 1);
|
|
15
|
+
const newNotification = {
|
|
16
|
+
...notification,
|
|
17
|
+
id: this.notificationId(),
|
|
18
|
+
};
|
|
19
|
+
const existingNotification = this._notifications().find((n) => n.message === newNotification.message);
|
|
20
|
+
if (existingNotification) {
|
|
21
|
+
this.updateNotification({ ...existingNotification, ...newNotification });
|
|
22
|
+
return existingNotification.id;
|
|
23
|
+
}
|
|
24
|
+
this._notifications.update((current) => [...current, newNotification]);
|
|
25
|
+
return newNotification.id;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Dismisses a global notification by its ID.
|
|
29
|
+
* @param notificationId The ID of the notification to dismiss.
|
|
30
|
+
*/
|
|
31
|
+
dismissGlobalNotificationById(notificationId) {
|
|
32
|
+
this._notifications.update((current) => current.filter((notification) => notification.id !== notificationId));
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Dismisses a specific global notification.
|
|
36
|
+
* @param notification The notification to dismiss.
|
|
37
|
+
*/
|
|
38
|
+
dismissGlobalNotification(notification) {
|
|
39
|
+
this.dismissGlobalNotificationById(notification.id);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Updates an existing notification.
|
|
43
|
+
* @param updatedNotification The notification with updated information.
|
|
44
|
+
*/
|
|
45
|
+
updateNotification(updatedNotification) {
|
|
46
|
+
this._notifications.update((current) => current.map((notification) => notification.id === updatedNotification.id ? { ...notification, ...updatedNotification } : notification));
|
|
47
|
+
}
|
|
48
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: NotificationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
49
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: NotificationService, providedIn: 'root' });
|
|
50
|
+
}
|
|
51
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: NotificationService, decorators: [{
|
|
52
|
+
type: Injectable,
|
|
53
|
+
args: [{
|
|
54
|
+
providedIn: 'root',
|
|
55
|
+
}]
|
|
56
|
+
}] });
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Generated bundle index. Do not edit.
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
export { NotificationService };
|
|
63
|
+
//# sourceMappingURL=cccteam-ccc-lib-src-ui-notification-service.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cccteam-ccc-lib-src-ui-notification-service.mjs","sources":["../../../projects/ccc-lib/src/ui-notification-service/notification.service.ts","../../../projects/ccc-lib/src/ui-notification-service/cccteam-ccc-lib-src-ui-notification-service.ts"],"sourcesContent":["import { Injectable, signal } from '@angular/core';\nimport { CreateNotificationMessage, NotificationMessage } from '@cccteam/ccc-lib/src/types';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class NotificationService {\n private notificationId = signal(0);\n private _notifications = signal<NotificationMessage[]>([]);\n notifications = this._notifications.asReadonly();\n\n /**\n * Adds a new global notification.\n * @param notification The notification message to add.\n * @returns The unique ID assigned to the notification.\n */\n addGlobalNotification(notification: CreateNotificationMessage): number {\n this.notificationId.update((id) => id + 1);\n const newNotification: NotificationMessage = {\n ...notification,\n id: this.notificationId(),\n };\n const existingNotification = this._notifications().find((n) => n.message === newNotification.message);\n if (existingNotification) {\n this.updateNotification({ ...existingNotification, ...newNotification });\n return existingNotification.id;\n }\n this._notifications.update((current) => [...current, newNotification]);\n return newNotification.id;\n }\n\n /**\n * Dismisses a global notification by its ID.\n * @param notificationId The ID of the notification to dismiss.\n */\n dismissGlobalNotificationById(notificationId: number): void {\n this._notifications.update((current) => current.filter((notification) => notification.id !== notificationId));\n }\n\n /**\n * Dismisses a specific global notification.\n * @param notification The notification to dismiss.\n */\n dismissGlobalNotification(notification: NotificationMessage): void {\n this.dismissGlobalNotificationById(notification.id);\n }\n\n /**\n * Updates an existing notification.\n * @param updatedNotification The notification with updated information.\n */\n updateNotification(updatedNotification: NotificationMessage): void {\n this._notifications.update((current) =>\n current.map((notification) =>\n notification.id === updatedNotification.id ? { ...notification, ...updatedNotification } : notification,\n ),\n );\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;MAMa,mBAAmB,CAAA;AACtB,IAAA,cAAc,GAAG,MAAM,CAAC,CAAC,4DAAC;AAC1B,IAAA,cAAc,GAAG,MAAM,CAAwB,EAAE,4DAAC;AAC1D,IAAA,aAAa,GAAG,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE;AAEhD;;;;AAIG;AACH,IAAA,qBAAqB,CAAC,YAAuC,EAAA;AAC3D,QAAA,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;AAC1C,Q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AA,CAAA;AAAnB,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,mBAAmB,cAFlB,MAAM,EAAA,CAAA;;2FAEP,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAH/B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;ACLD;;AAEG;;;;"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as i3 from '@angular/common';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import * as i0 from '@angular/core';
|
|
4
|
+
import { inject, computed, Input, Component } from '@angular/core';
|
|
5
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
6
|
+
import { MatExpansionModule } from '@angular/material/expansion';
|
|
7
|
+
import * as i1 from '@angular/material/icon';
|
|
8
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
9
|
+
import { MatSidenavModule } from '@angular/material/sidenav';
|
|
10
|
+
import * as i2 from '@angular/router';
|
|
11
|
+
import { RouterModule } from '@angular/router';
|
|
12
|
+
import { HasPermissionDirective } from '@cccteam/ccc-lib/src/auth-has-permission';
|
|
13
|
+
import { UiCoreService } from '@cccteam/ccc-lib/src/ui-core-service';
|
|
14
|
+
|
|
15
|
+
class SidenavComponent {
|
|
16
|
+
ui = inject(UiCoreService);
|
|
17
|
+
navGroups;
|
|
18
|
+
currentNav = computed(() => {
|
|
19
|
+
return this.updateNavItems(this.ui.currentSidenavIdentifier());
|
|
20
|
+
}, { ...(ngDevMode ? { debugName: "currentNav" } : {}) });
|
|
21
|
+
/**
|
|
22
|
+
* Updates the currentNav based on the identifier
|
|
23
|
+
* @param identifier
|
|
24
|
+
* @returns NavItem[]
|
|
25
|
+
* @memberof SidenavComponent
|
|
26
|
+
*/
|
|
27
|
+
updateNavItems(identifier) {
|
|
28
|
+
if (!this.navGroups) {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
if (!this.navGroups[identifier]) {
|
|
32
|
+
// pick the first one if the identifier is not found so we don't break the UI
|
|
33
|
+
identifier = Object.keys(this.navGroups)[0];
|
|
34
|
+
}
|
|
35
|
+
return this.navGroups[identifier];
|
|
36
|
+
}
|
|
37
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: SidenavComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
38
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.2", type: SidenavComponent, isStandalone: true, selector: "ccc-sidenav", inputs: { navGroups: "navGroups" }, ngImport: i0, template: "<div class=\"nav-container\">\n <nav>\n @for (navItem of currentNav(); track navItem) {\n <ng-container *ngTemplateOutlet=\"typeRendererTemplate; context: { navItem: navItem }\"></ng-container>\n }\n </nav>\n</div>\n<ng-template #typeRendererTemplate let-navItem=\"navItem\">\n @switch (navItem.type) {\n @case ('header') {\n <ng-container [ngTemplateOutlet]=\"headerTemplate\" [ngTemplateOutletContext]=\"{ navItem: navItem }\"></ng-container>\n }\n @case ('link') {\n <ng-container [ngTemplateOutlet]=\"linkTemplate\" [ngTemplateOutletContext]=\"{ navItem: navItem }\"></ng-container>\n }\n @case ('expandable') {\n <ng-container\n [ngTemplateOutlet]=\"expandableTemplate\"\n [ngTemplateOutletContext]=\"{ navItem: navItem }\"></ng-container>\n }\n }\n</ng-template>\n<ng-template #headerTemplate let-navItem=\"navItem\">\n <div class=\"link-header\">{{ navItem.label }}</div>\n</ng-template>\n<ng-template #linkTemplate let-navItem=\"navItem\">\n <a [routerLink]=\"navItem.routerLink\" *cccHasPermission=\"navItem.permission\">\n <div class=\"nav-item\" routerLinkActive=\"active-link\">\n <div class=\"link-button\">\n <div class=\"icon\">\n <mat-icon class=\"material-icons-outlined\" [inline]=\"true\">\n {{ navItem.icon }}\n </mat-icon>\n </div>\n <div class=\"text\">\n {{ navItem.label | titlecase }}\n </div>\n </div>\n </div>\n </a>\n</ng-template>\n<ng-template #expandableTemplate let-navItem=\"navItem\">\n <div class=\"nav-item\" aria-hidden=\"true\" (click)=\"navItem.isExpanded = !navItem.isExpanded\">\n <div class=\"link-button\">\n <div class=\"icon\">\n <mat-icon class=\"material-icons-outlined\" [inline]=\"true\">\n {{ navItem.isExpanded ? 'expand_less' : 'expand_more' }}\n </mat-icon>\n </div>\n <div class=\"text\">{{ navItem.label }}</div>\n </div>\n </div>\n @if (navItem.isExpanded) {\n <div class=\"expandable-links\">\n @for (navItemChild of navItem.children; track navItemChild) {\n <ng-container *ngTemplateOutlet=\"typeRendererTemplate; context: { navItem: navItemChild }\"> </ng-container>\n }\n </div>\n }\n</ng-template>\n", styles: [".nav-container{padding:0;height:100%}nav{max-width:100%;margin:0 10px}.nav-item{width:100%;height:48px;font-size:18px;display:flex;flex-direction:column;justify-content:center;color:#003b49;padding:0 15px;position:relative}.nav-item:hover{background-color:#0000000a;transition:background-color .1s ease}.nav-item:active{background-color:#0000001a;transition:background-color .1s ease}.link-header{color:#003b49;text-transform:uppercase;font-weight:700;font-size:12px;margin:20px 0 0 5px}.link-button{display:flex;flex-direction:row;width:100%}.link-button .icon{min-width:20px;margin-right:10px;display:flex;flex-direction:column;justify-content:center}.link-button .text{margin-right:10px;text-align:left;display:flex;flex-direction:row;justify-content:left;text-decoration:capitalize}.expandable-links{display:flex;flex-direction:column;width:100%;padding-left:30px}a:active,a:link,a:visited{color:#003b49!important}a{text-decoration:none}.active-link:before{content:\"\";position:absolute;left:3px;width:5px;height:38px;background-color:#003b49}.active-link{background-color:#0000000a;position:relative}\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: RouterModule }, { kind: "directive", type: i2.RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "directive", type: i2.RouterLinkActive, selector: "[routerLinkActive]", inputs: ["routerLinkActiveOptions", "ariaCurrentWhenActive", "routerLinkActive"], outputs: ["isActiveChange"], exportAs: ["routerLinkActive"] }, { kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i3.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: MatExpansionModule }, { kind: "ngmodule", type: MatButtonModule }, { kind: "ngmodule", type: MatSidenavModule }, { kind: "directive", type: HasPermissionDirective, selector: "[cccHasPermission]", inputs: ["cccHasPermission"] }, { kind: "pipe", type: i3.TitleCasePipe, name: "titlecase" }] });
|
|
39
|
+
}
|
|
40
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.2", ngImport: i0, type: SidenavComponent, decorators: [{
|
|
41
|
+
type: Component,
|
|
42
|
+
args: [{ selector: 'ccc-sidenav', imports: [
|
|
43
|
+
MatIconModule,
|
|
44
|
+
RouterModule,
|
|
45
|
+
CommonModule,
|
|
46
|
+
MatExpansionModule,
|
|
47
|
+
MatButtonModule,
|
|
48
|
+
MatSidenavModule,
|
|
49
|
+
HasPermissionDirective,
|
|
50
|
+
], template: "<div class=\"nav-container\">\n <nav>\n @for (navItem of currentNav(); track navItem) {\n <ng-container *ngTemplateOutlet=\"typeRendererTemplate; context: { navItem: navItem }\"></ng-container>\n }\n </nav>\n</div>\n<ng-template #typeRendererTemplate let-navItem=\"navItem\">\n @switch (navItem.type) {\n @case ('header') {\n <ng-container [ngTemplateOutlet]=\"headerTemplate\" [ngTemplateOutletContext]=\"{ navItem: navItem }\"></ng-container>\n }\n @case ('link') {\n <ng-container [ngTemplateOutlet]=\"linkTemplate\" [ngTemplateOutletContext]=\"{ navItem: navItem }\"></ng-container>\n }\n @case ('expandable') {\n <ng-container\n [ngTemplateOutlet]=\"expandableTemplate\"\n [ngTemplateOutletContext]=\"{ navItem: navItem }\"></ng-container>\n }\n }\n</ng-template>\n<ng-template #headerTemplate let-navItem=\"navItem\">\n <div class=\"link-header\">{{ navItem.label }}</div>\n</ng-template>\n<ng-template #linkTemplate let-navItem=\"navItem\">\n <a [routerLink]=\"navItem.routerLink\" *cccHasPermission=\"navItem.permission\">\n <div class=\"nav-item\" routerLinkActive=\"active-link\">\n <div class=\"link-button\">\n <div class=\"icon\">\n <mat-icon class=\"material-icons-outlined\" [inline]=\"true\">\n {{ navItem.icon }}\n </mat-icon>\n </div>\n <div class=\"text\">\n {{ navItem.label | titlecase }}\n </div>\n </div>\n </div>\n </a>\n</ng-template>\n<ng-template #expandableTemplate let-navItem=\"navItem\">\n <div class=\"nav-item\" aria-hidden=\"true\" (click)=\"navItem.isExpanded = !navItem.isExpanded\">\n <div class=\"link-button\">\n <div class=\"icon\">\n <mat-icon class=\"material-icons-outlined\" [inline]=\"true\">\n {{ navItem.isExpanded ? 'expand_less' : 'expand_more' }}\n </mat-icon>\n </div>\n <div class=\"text\">{{ navItem.label }}</div>\n </div>\n </div>\n @if (navItem.isExpanded) {\n <div class=\"expandable-links\">\n @for (navItemChild of navItem.children; track navItemChild) {\n <ng-container *ngTemplateOutlet=\"typeRendererTemplate; context: { navItem: navItemChild }\"> </ng-container>\n }\n </div>\n }\n</ng-template>\n", styles: [".nav-container{padding:0;height:100%}nav{max-width:100%;margin:0 10px}.nav-item{width:100%;height:48px;font-size:18px;display:flex;flex-direction:column;justify-content:center;color:#003b49;padding:0 15px;position:relative}.nav-item:hover{background-color:#0000000a;transition:background-color .1s ease}.nav-item:active{background-color:#0000001a;transition:background-color .1s ease}.link-header{color:#003b49;text-transform:uppercase;font-weight:700;font-size:12px;margin:20px 0 0 5px}.link-button{display:flex;flex-direction:row;width:100%}.link-button .icon{min-width:20px;margin-right:10px;display:flex;flex-direction:column;justify-content:center}.link-button .text{margin-right:10px;text-align:left;display:flex;flex-direction:row;justify-content:left;text-decoration:capitalize}.expandable-links{display:flex;flex-direction:column;width:100%;padding-left:30px}a:active,a:link,a:visited{color:#003b49!important}a{text-decoration:none}.active-link:before{content:\"\";position:absolute;left:3px;width:5px;height:38px;background-color:#003b49}.active-link{background-color:#0000000a;position:relative}\n"] }]
|
|
51
|
+
}], propDecorators: { navGroups: [{
|
|
52
|
+
type: Input
|
|
53
|
+
}] } });
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Generated bundle index. Do not edit.
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
export { SidenavComponent };
|
|
60
|
+
//# sourceMappingURL=cccteam-ccc-lib-src-ui-sidenav.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cccteam-ccc-lib-src-ui-sidenav.mjs","sources":["../../../projects/ccc-lib/src/ui-sidenav/sidenav.component.ts","../../../projects/ccc-lib/src/ui-sidenav/sidenav.component.html","../../../projects/ccc-lib/src/ui-sidenav/cccteam-ccc-lib-src-ui-sidenav.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { Component, computed, inject, Input, Signal } from '@angular/core';\nimport { MatButtonModule } from '@angular/material/button';\nimport { MatExpansionModule } from '@angular/material/expansion';\nimport { MatIconModule } from '@angular/material/icon';\nimport { MatSidenavModule } from '@angular/material/sidenav';\nimport { RouterModule } from '@angular/router';\n\nimport { HasPermissionDirective } from '@cccteam/ccc-lib/src/auth-has-permission';\nimport { PermissionScope } from '@cccteam/ccc-lib/src/types';\nimport { UiCoreService } from '@cccteam/ccc-lib/src/ui-core-service';\n\nexport interface NavItem {\n type: 'link' | 'header' | 'expandable';\n routerLink?: string[];\n label: string;\n icon?: string;\n permission?: PermissionScope;\n children?: NavItem[];\n isExpanded?: boolean;\n attentionCount?: Signal<number>;\n}\n\nexport type NavGroups = Record<string, NavItem[]>;\n\n@Component({\n selector: 'ccc-sidenav',\n templateUrl: './sidenav.component.html',\n styleUrls: ['./sidenav.component.scss'],\n imports: [\n MatIconModule,\n RouterModule,\n CommonModule,\n MatExpansionModule,\n MatButtonModule,\n MatSidenavModule,\n HasPermissionDirective,\n ],\n})\nexport class SidenavComponent {\n ui = inject(UiCoreService);\n\n @Input() navGroups?: NavGroups;\n currentNav = computed(() => {\n return this.updateNavItems(this.ui.currentSidenavIdentifier());\n });\n\n /**\n * Updates the currentNav based on the identifier\n * @param identifier\n * @returns NavItem[]\n * @memberof SidenavComponent\n */\n updateNavItems(identifier: string): NavItem[] {\n if (!this.navGroups) {\n return [];\n }\n if (!this.navGroups[identifier]) {\n // pick the first one if the identifier is not found so we don't break the UI\n identifier = Object.keys(this.navGroups)[0];\n }\n return this.navGroups[identifier];\n }\n}\n","<div class=\"nav-container\">\n <nav>\n @for (navItem of currentNav(); track navItem) {\n <ng-container *ngTemplateOutlet=\"typeRendererTemplate; context: { navItem: navItem }\"></ng-container>\n }\n </nav>\n</div>\n<ng-template #typeRendererTemplate let-navItem=\"navItem\">\n @switch (navItem.type) {\n @case ('header') {\n <ng-container [ngTemplateOutlet]=\"headerTemplate\" [ngTemplateOutletContext]=\"{ navItem: navItem }\"></ng-container>\n }\n @case ('link') {\n <ng-container [ngTemplateOutlet]=\"linkTemplate\" [ngTemplateOutletContext]=\"{ navItem: navItem }\"></ng-container>\n }\n @case ('expandable') {\n <ng-container\n [ngTemplateOutlet]=\"expandableTemplate\"\n [ngTemplateOutletContext]=\"{ navItem: navItem }\"></ng-container>\n }\n }\n</ng-template>\n<ng-template #headerTemplate let-navItem=\"navItem\">\n <div class=\"link-header\">{{ navItem.label }}</div>\n</ng-template>\n<ng-template #linkTemplate let-navItem=\"navItem\">\n <a [routerLink]=\"navItem.routerLink\" *cccHasPermission=\"navItem.permission\">\n <div class=\"nav-item\" routerLinkActive=\"active-link\">\n <div class=\"link-button\">\n <div class=\"icon\">\n <mat-icon class=\"material-icons-outlined\" [inline]=\"true\">\n {{ navItem.icon }}\n </mat-icon>\n </div>\n <div class=\"text\">\n {{ navItem.label | titlecase }}\n </div>\n </div>\n </div>\n </a>\n</ng-template>\n<ng-template #expandableTemplate let-navItem=\"navItem\">\n <div class=\"nav-item\" aria-hidden=\"true\" (click)=\"navItem.isExpanded = !navItem.isExpanded\">\n <div class=\"link-button\">\n <div class=\"icon\">\n <mat-icon class=\"material-icons-outlined\" [inline]=\"true\">\n {{ navItem.isExpanded ? 'expand_less' : 'expand_more' }}\n </mat-icon>\n </div>\n <div class=\"text\">{{ navItem.label }}</div>\n </div>\n </div>\n @if (navItem.isExpanded) {\n <div class=\"expandable-links\">\n @for (navItemChild of navItem.children; track navItemChild) {\n <ng-container *ngTemplateOutlet=\"typeRendererTemplate; context: { navItem: navItemChild }\"> </ng-container>\n }\n </div>\n }\n</ng-template>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;;MAuCa,gBAAgB,CAAA;AAC3B,IAAA,EAAE,GAAG,MAAM,CAAC,aAAa,CAAC;AAEjB,IAAA,SAAS;AAClB,IAAA,UAAU,GAAG,QAAQ,CAAC,MAAK;QACzB,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,wBAAwB,EAAE,CAAC;AAChE,IAAA,CAAC,wDAAC;AAEF;;;;;AAKG;AACH,IAAA,cAAc,CAAC,UAAkB,EAAA;AAC/B,QAAA,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;AACnB,YAAA,OAAO,EAAE;QACX;QACA,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE;;AAE/B,YAAA,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC7C;AACA,QAAA,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;IACnC;uGAvBW,gBAAgB,EAAA,IAAA,EAAA,EAAA,EAA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BAAkB,EAAA,EAAA,EAAA,IAAA,EAAA,UAAA,EAAA,IAAA,EAClB,eAAe,EAAA,EAAA,EAAA,IAAA,EAAA,UAAA,EAAA,IAAA,EACf,gBAAgB,+BAChB,sBAAsB,EAAA,QAAA,EAAA,oBAAA,EAAA,MAAA,EAAA,CAAA,kBAAA,CAAA,EAAA,EAAA,EAAA,IAAA,EAAA,MAAA,EAAA,IAAA,EAAA,EAAA,CAAA,aAAA,EAAA,IAAA,EAAA,WAAA,EAAA,CAAA,EAAA,CAAA;;2FAGb,gBAAgB,EAAA,UAAA,EAAA,CAAA;kBAd5B,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,aAAa,EAAA,OAAA,EAGd;wBACP,aAAa;wBACb,YAAY;wBACZ,YAAY;wBACZ,kBAAkB;wBAClB,eAAe;wBACf,gBAAgB;wBAChB,sBAAsB;AACvB,qBAAA,EAAA,QAAA,EAAA,wuEAAA,EAAA,MAAA,EAAA,CAAA,slCAAA,CAAA,EAAA;;sBAKA;;;AE1CH;;AAEG;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { HttpContextToken, HttpContext } from '@angular/common/http';
|
|
2
|
+
|
|
3
|
+
const CUSTOM_HTTP_REQUEST_OPTIONS = new HttpContextToken(() => ({
|
|
4
|
+
suppressGlobalError: false,
|
|
5
|
+
}));
|
|
6
|
+
function errorOptions(suppressGlobalError) {
|
|
7
|
+
return {
|
|
8
|
+
context: new HttpContext().set(CUSTOM_HTTP_REQUEST_OPTIONS, {
|
|
9
|
+
suppressGlobalError: suppressGlobalError ?? false,
|
|
10
|
+
}),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Generated bundle index. Do not edit.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export { CUSTOM_HTTP_REQUEST_OPTIONS, errorOptions };
|
|
19
|
+
//# sourceMappingURL=cccteam-ccc-lib-src-util-request-options.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cccteam-ccc-lib-src-util-request-options.mjs","sources":["../../../projects/ccc-lib/src/util-request-options/request-options.ts","../../../projects/ccc-lib/src/util-request-options/cccteam-ccc-lib-src-util-request-options.ts"],"sourcesContent":["import { HttpContext, HttpContextToken } from '@angular/common/http';\n\nexport interface CustomHttpRequestOptions {\n suppressGlobalError: boolean;\n}\n\nexport const CUSTOM_HTTP_REQUEST_OPTIONS = new HttpContextToken<CustomHttpRequestOptions>(() => ({\n suppressGlobalError: false,\n}));\n\nexport function errorOptions(suppressGlobalError: boolean | undefined): { context: HttpContext } {\n return {\n context: new HttpContext().set(CUSTOM_HTTP_REQUEST_OPTIONS, {\n suppressGlobalError: suppressGlobalError ?? false,\n }),\n };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAMO,MAAM,2BAA2B,GAAG,IAAI,gBAAgB,CAA2B,OAAO;AAC/F,IAAA,mBAAmB,EAAE,KAAK;AAC3B,CAAA,CAAC;AAEI,SAAU,YAAY,CAAC,mBAAwC,EAAA;IACnE,OAAO;QACL,OAAO,EAAE,IAAI,WAAW,EAAE,CAAC,GAAG,CAAC,2BAA2B,EAAE;YAC1D,mBAAmB,EAAE,mBAAmB,IAAI,KAAK;SAClD,CAAC;KACH;AACH;;AChBA;;AAEG;;;;"}
|