@cccteam/ccc-lib 0.0.13 → 0.0.15
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/eslint.config.js +32 -0
- package/ng-package.json +11 -0
- package/package.json +7 -68
- package/src/auth-authentication-guard/authentication.guard.ts +40 -0
- package/src/auth-authentication-guard/ng-package.json +6 -0
- package/src/auth-authorization-guard/authorization.guard.ts +17 -0
- package/src/auth-authorization-guard/ng-package.json +6 -0
- package/src/auth-forms/ccc-field/ccc-field.component.html +1 -0
- package/src/auth-forms/ccc-field/ccc-field.component.scss +0 -0
- package/src/auth-forms/ccc-field/ccc-field.component.spec.ts +22 -0
- package/src/auth-forms/ccc-field/ccc-field.component.ts +74 -0
- package/src/auth-forms/form-helpers.ts +39 -0
- package/src/auth-forms/{public-api.d.ts → index.ts} +1 -0
- package/src/auth-forms/ng-package.json +6 -0
- package/src/auth-has-permission/has-permission.directive.ts +34 -0
- package/src/auth-has-permission/ng-package.json +6 -0
- package/src/auth-service/auth.service.ts +92 -0
- package/src/auth-service/ng-package.json +6 -0
- package/src/ccc-camel-case-to-title/camel-case-to-title.pipe.ts +23 -0
- package/src/ccc-camel-case-to-title/index.ts +1 -0
- package/src/ccc-camel-case-to-title/ng-package.json +6 -0
- package/src/ccc-grid/ccc-grid.component.ts +155 -0
- package/src/ccc-grid/index.ts +3 -0
- package/src/ccc-grid/ng-package.json +6 -0
- package/src/ccc-grid/table-button/table-button.component.html +16 -0
- package/src/ccc-grid/table-button/table-button.component.scss +5 -0
- package/src/ccc-grid/table-button/table-button.component.spec.ts +22 -0
- package/src/ccc-grid/table-button/table-button.component.ts +49 -0
- package/src/ccc-resource/can-deactivate.guard.ts +41 -0
- package/src/ccc-resource/compound-resource/compound-resource.component.html +57 -0
- package/src/ccc-resource/compound-resource/compound-resource.component.scss +86 -0
- package/src/ccc-resource/compound-resource/compound-resource.component.spec.ts +22 -0
- package/src/ccc-resource/compound-resource/compound-resource.component.ts +158 -0
- package/src/ccc-resource/concat-fns.ts +162 -0
- package/src/ccc-resource/empty-readonly-field/empty-readonly-field.component.html +12 -0
- 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 +23 -0
- package/src/ccc-resource/empty-readonly-field/empty-readonly-field.component.ts +17 -0
- package/src/ccc-resource/form-state.service.ts +24 -0
- package/src/ccc-resource/format-fns.ts +49 -0
- package/src/ccc-resource/gui-constants.ts +88 -0
- package/src/ccc-resource/index.ts +23 -0
- package/src/ccc-resource/leave-page-confirmation-modal/leave-page-confirmation-modal.component.html +8 -0
- 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 +22 -0
- package/src/ccc-resource/leave-page-confirmation-modal/leave-page-confirmation-modal.component.ts +12 -0
- package/src/ccc-resource/ng-package.json +6 -0
- package/src/ccc-resource/operation-types.ts +19 -0
- package/src/ccc-resource/padding-element/padding-element.component.html +1 -0
- package/src/ccc-resource/padding-element/padding-element.component.scss +3 -0
- package/src/ccc-resource/padding-element/padding-element.component.spec.ts +22 -0
- package/src/ccc-resource/padding-element/padding-element.component.ts +20 -0
- package/src/ccc-resource/resource-array-view/resource-array-view.component.html +81 -0
- package/src/ccc-resource/resource-array-view/resource-array-view.component.scss +21 -0
- package/src/ccc-resource/resource-array-view/resource-array-view.component.spec.ts +22 -0
- package/src/ccc-resource/resource-array-view/resource-array-view.component.ts +143 -0
- package/src/ccc-resource/resource-base/resource-base.component.spec.ts +22 -0
- package/src/ccc-resource/resource-base/resource-base.component.ts +11 -0
- package/src/ccc-resource/resource-cache.service.ts +232 -0
- package/src/ccc-resource/resource-create/resource-create.component.html +31 -0
- package/src/ccc-resource/resource-create/resource-create.component.scss +130 -0
- package/src/ccc-resource/resource-create/resource-create.component.spec.ts +22 -0
- package/src/ccc-resource/resource-create/resource-create.component.ts +303 -0
- package/src/ccc-resource/resource-field/base-field.directive.ts +102 -0
- package/src/ccc-resource/resource-field/fields/boolean-field/boolean-field.component.html +16 -0
- 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 +22 -0
- package/src/ccc-resource/resource-field/fields/boolean-field/boolean-field.component.ts +15 -0
- package/src/ccc-resource/resource-field/fields/computed-field/computed-field.component.html +13 -0
- 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 +23 -0
- package/src/ccc-resource/resource-field/fields/computed-field/computed-field.component.ts +50 -0
- package/src/ccc-resource/resource-field/fields/date-field/date-field.component.html +22 -0
- 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 +22 -0
- package/src/ccc-resource/resource-field/fields/date-field/date-field.component.ts +14 -0
- package/src/ccc-resource/resource-field/fields/enumerated-field/enumerated-field.component.html +71 -0
- package/src/ccc-resource/resource-field/fields/enumerated-field/enumerated-field.component.scss +9 -0
- package/src/ccc-resource/resource-field/fields/enumerated-field/enumerated-field.component.spec.ts +22 -0
- package/src/ccc-resource/resource-field/fields/enumerated-field/enumerated-field.component.ts +207 -0
- package/src/ccc-resource/resource-field/fields/nullboolean-field/nullboolean-field.component.html +38 -0
- package/src/ccc-resource/resource-field/fields/nullboolean-field/nullboolean-field.component.scss +3 -0
- package/src/ccc-resource/resource-field/fields/nullboolean-field/nullboolean-field.component.spec.ts +22 -0
- package/src/ccc-resource/resource-field/fields/nullboolean-field/nullboolean-field.component.ts +87 -0
- package/src/ccc-resource/resource-field/fields/number-field/number-field.component.html +23 -0
- package/src/ccc-resource/resource-field/fields/number-field/number-field.component.scss +6 -0
- package/src/ccc-resource/resource-field/fields/number-field/number-field.component.spec.ts +22 -0
- package/src/ccc-resource/resource-field/fields/number-field/number-field.component.ts +14 -0
- package/src/ccc-resource/resource-field/fields/text-field/text-field.component.html +29 -0
- package/src/ccc-resource/resource-field/fields/text-field/text-field.component.scss +6 -0
- package/src/ccc-resource/resource-field/fields/text-field/text-field.component.spec.ts +22 -0
- package/src/ccc-resource/resource-field/fields/text-field/text-field.component.ts +23 -0
- package/src/ccc-resource/resource-field/resource-field.component.html +112 -0
- package/src/ccc-resource/resource-field/resource-field.component.scss +7 -0
- package/src/ccc-resource/resource-field/resource-field.component.spec.ts +22 -0
- package/src/ccc-resource/resource-field/resource-field.component.ts +214 -0
- package/src/ccc-resource/resource-layout/resource-layout.component.html +73 -0
- package/src/ccc-resource/resource-layout/resource-layout.component.scss +26 -0
- package/src/ccc-resource/resource-layout/resource-layout.component.spec.ts +22 -0
- package/src/ccc-resource/resource-layout/resource-layout.component.ts +176 -0
- package/src/ccc-resource/resource-list/ resource-list.component.spec.ts +22 -0
- package/src/ccc-resource/resource-list/resource-list.component.html +27 -0
- package/src/ccc-resource/resource-list/resource-list.component.scss +67 -0
- package/src/ccc-resource/resource-list/resource-list.component.ts +376 -0
- package/src/ccc-resource/resource-list-create/resource-list-create.component.html +71 -0
- package/src/ccc-resource/resource-list-create/resource-list-create.component.scss +9 -0
- package/src/ccc-resource/resource-list-create/resource-list-create.component.spec.ts +22 -0
- package/src/ccc-resource/resource-list-create/resource-list-create.component.ts +103 -0
- package/src/ccc-resource/resource-resolver/resource-resolver.component.html +1 -0
- package/src/ccc-resource/resource-resolver/resource-resolver.component.scss +0 -0
- package/src/ccc-resource/resource-resolver/resource-resolver.component.spec.ts +22 -0
- package/src/ccc-resource/resource-resolver/resource-resolver.component.ts +69 -0
- package/src/ccc-resource/resource-store.service.ts +93 -0
- package/src/ccc-resource/resource-view/resource-view.component.html +133 -0
- package/src/ccc-resource/resource-view/resource-view.component.scss +150 -0
- package/src/ccc-resource/resource-view/resource-view.component.spec.ts +22 -0
- package/src/ccc-resource/resource-view/resource-view.component.ts +354 -0
- package/src/ccc-resource/resources-helpers.ts +262 -0
- package/src/ccc-resource/utils/validator-utils.ts +6 -0
- package/{fesm2022/cccteam-ccc-lib.mjs → src/index.ts} +32 -11
- package/src/internal-types/index.ts +1 -0
- package/src/internal-types/ng-package.json +6 -0
- package/src/types/auth.actions.ts +46 -0
- package/src/types/configs.ts +952 -0
- package/src/types/constants.ts +1 -0
- package/src/types/core.actions.ts +33 -0
- package/src/types/{public-api.d.ts → index.ts} +3 -0
- package/src/types/ng-package.json +6 -0
- package/src/types/notification-message.ts +20 -0
- package/src/types/{permissions.d.ts → permissions.ts} +9 -9
- package/src/types/{session-info.d.ts → session-info.ts} +4 -3
- package/src/types/tokens.ts +20 -0
- package/src/ui-alert/alert.component.html +13 -0
- package/src/ui-alert/alert.component.scss +48 -0
- package/src/ui-alert/alert.component.spec.ts +22 -0
- package/src/ui-alert/alert.component.ts +35 -0
- package/src/ui-alert/ng-package.json +6 -0
- package/src/ui-core-service/index.ts +1 -0
- package/src/ui-core-service/ng-package.json +6 -0
- package/src/ui-core-service/ui-core.service.ts +34 -0
- package/src/ui-interceptor/api.interceptor.spec.ts +16 -0
- package/src/ui-interceptor/api.interceptor.ts +45 -0
- package/src/ui-interceptor/ng-package.json +6 -0
- package/src/ui-notification-service/ng-package.json +6 -0
- package/src/ui-notification-service/notification.service.ts +59 -0
- package/src/ui-sidenav/ng-package.json +6 -0
- package/src/ui-sidenav/sidenav.component.html +60 -0
- package/src/ui-sidenav/sidenav.component.scss +99 -0
- package/src/ui-sidenav/sidenav.component.spec.ts +22 -0
- package/src/ui-sidenav/sidenav.component.ts +64 -0
- package/src/util-request-options/ng-package.json +6 -0
- package/src/util-request-options/request-options.ts +17 -0
- package/tsconfig.lib.json +13 -0
- package/tsconfig.lib.prod.json +11 -0
- package/tsconfig.spec.json +15 -0
- package/cccteam-ccc-lib-0.0.13.tgz +0 -0
- package/fesm2022/cccteam-ccc-lib-src-auth-authentication-guard.mjs +0 -44
- package/fesm2022/cccteam-ccc-lib-src-auth-authentication-guard.mjs.map +0 -1
- package/fesm2022/cccteam-ccc-lib-src-auth-authorization-guard.mjs +0 -24
- package/fesm2022/cccteam-ccc-lib-src-auth-authorization-guard.mjs.map +0 -1
- package/fesm2022/cccteam-ccc-lib-src-auth-forms.mjs +0 -118
- package/fesm2022/cccteam-ccc-lib-src-auth-forms.mjs.map +0 -1
- package/fesm2022/cccteam-ccc-lib-src-auth-has-permission.mjs +0 -51
- package/fesm2022/cccteam-ccc-lib-src-auth-has-permission.mjs.map +0 -1
- package/fesm2022/cccteam-ccc-lib-src-auth-service.mjs +0 -56
- package/fesm2022/cccteam-ccc-lib-src-auth-service.mjs.map +0 -1
- 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-types.mjs +0 -137
- package/fesm2022/cccteam-ccc-lib-src-types.mjs.map +0 -1
- package/fesm2022/cccteam-ccc-lib-src-ui-alert.mjs +0 -48
- package/fesm2022/cccteam-ccc-lib-src-ui-alert.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/fesm2022/cccteam-ccc-lib-src-ui-interceptor.mjs +0 -48
- package/fesm2022/cccteam-ccc-lib-src-ui-interceptor.mjs.map +0 -1
- package/fesm2022/cccteam-ccc-lib-src-ui-notification-service.mjs +0 -57
- package/fesm2022/cccteam-ccc-lib-src-ui-notification-service.mjs.map +0 -1
- package/fesm2022/cccteam-ccc-lib-src-ui-sidenav.mjs +0 -70
- package/fesm2022/cccteam-ccc-lib-src-ui-sidenav.mjs.map +0 -1
- package/fesm2022/cccteam-ccc-lib-src-util-request-options.mjs +0 -19
- package/fesm2022/cccteam-ccc-lib-src-util-request-options.mjs.map +0 -1
- package/fesm2022/cccteam-ccc-lib.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/public-api.d.ts +0 -13
- package/src/auth-authentication-guard/authentication.guard.d.ts +0 -3
- package/src/auth-authentication-guard/index.d.ts +0 -5
- package/src/auth-authorization-guard/authorization.guard.d.ts +0 -3
- package/src/auth-authorization-guard/index.d.ts +0 -5
- 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/index.d.ts +0 -5
- package/src/auth-has-permission/has-permission.directive.d.ts +0 -12
- package/src/auth-has-permission/index.d.ts +0 -5
- package/src/auth-service/auth.service.d.ts +0 -24
- package/src/auth-service/index.d.ts +0 -5
- 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/index.d.ts +0 -5
- package/src/types/notification-message.d.ts +0 -18
- package/src/types/tokens.d.ts +0 -13
- package/src/ui-alert/alert.component.d.ts +0 -13
- package/src/ui-alert/index.d.ts +0 -5
- 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/index.d.ts +0 -5
- package/src/ui-notification-service/index.d.ts +0 -5
- package/src/ui-notification-service/notification.service.d.ts +0 -30
- package/src/ui-sidenav/index.d.ts +0 -5
- package/src/ui-sidenav/sidenav.component.d.ts +0 -31
- package/src/util-request-options/index.d.ts +0 -5
- package/src/util-request-options/request-options.d.ts +0 -8
- /package/src/auth-authentication-guard/{public-api.d.ts → index.ts} +0 -0
- /package/src/auth-authorization-guard/{public-api.d.ts → index.ts} +0 -0
- /package/src/auth-has-permission/{public-api.d.ts → index.ts} +0 -0
- /package/src/auth-service/{public-api.d.ts → index.ts} +0 -0
- /package/src/ui-alert/{public-api.d.ts → index.ts} +0 -0
- /package/src/ui-interceptor/{public-api.d.ts → index.ts} +0 -0
- /package/src/ui-notification-service/{public-api.d.ts → index.ts} +0 -0
- /package/src/ui-sidenav/{public-api.d.ts → index.ts} +0 -0
- /package/src/util-request-options/{public-api.d.ts → index.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const defaultEmptyFieldValue = '-';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-namespace */
|
|
2
|
+
// no-namespace rule is disabled because action hygiene prevents import pollution
|
|
3
|
+
|
|
4
|
+
import { CreateNotificationMessage } from './notification-message';
|
|
5
|
+
|
|
6
|
+
export namespace ApiInterceptorAction {
|
|
7
|
+
export class BeginActivity {
|
|
8
|
+
static readonly type = '[ApiInterceptor] Add Loading Activity';
|
|
9
|
+
constructor(public process: string) {}
|
|
10
|
+
}
|
|
11
|
+
export class EndActivity {
|
|
12
|
+
static readonly type = '[ApiInterceptor] Remove Loading Activity';
|
|
13
|
+
constructor(public process: string) {}
|
|
14
|
+
}
|
|
15
|
+
export class PublishError {
|
|
16
|
+
static readonly type = '[ApiInterceptor] Publish Error';
|
|
17
|
+
constructor(public message: CreateNotificationMessage) {}
|
|
18
|
+
}
|
|
19
|
+
export class SetRedirectUrl {
|
|
20
|
+
static readonly type = '[ApiInterceptor] Set Redirect Url';
|
|
21
|
+
constructor(public redirectUrl: string) {}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export namespace HeaderAction {
|
|
26
|
+
export class ToggleSidenav {
|
|
27
|
+
static readonly type = '[Header] Toggle Sidenav';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export class Logout {
|
|
31
|
+
static readonly type = '[Header] User Logout';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export * from './auth.actions';
|
|
2
|
+
export * from './configs';
|
|
3
|
+
export * from './constants';
|
|
2
4
|
export * from './core.actions';
|
|
3
5
|
export * from './notification-message';
|
|
4
6
|
export * from './permissions';
|
|
5
7
|
export * from './session-info';
|
|
6
8
|
export * from './tokens';
|
|
9
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export enum AlertLevel {
|
|
2
|
+
ERROR = 'warn',
|
|
3
|
+
INFO = 'accent',
|
|
4
|
+
SUCCESS = 'success',
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface CreateNotificationMessage {
|
|
8
|
+
duration?: number;
|
|
9
|
+
message: string;
|
|
10
|
+
link: string;
|
|
11
|
+
level: AlertLevel;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface NotificationMessage {
|
|
15
|
+
id: number;
|
|
16
|
+
duration?: number;
|
|
17
|
+
message: string;
|
|
18
|
+
link: string;
|
|
19
|
+
level: AlertLevel;
|
|
20
|
+
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
type Brand<K, T> = K & {
|
|
2
|
-
|
|
3
|
-
};
|
|
1
|
+
type Brand<K, T> = K & { __brand: T };
|
|
2
|
+
|
|
4
3
|
export type Permission = Brand<string, 'Permission'>;
|
|
5
4
|
export type Resource = Brand<string, 'Resource'>;
|
|
6
5
|
export type Domain = Brand<string, 'Domain'>;
|
|
7
6
|
export type FieldName = Brand<string, 'FieldName'>;
|
|
8
7
|
export type Method = Brand<string, 'Method'>;
|
|
9
8
|
export type DomainPermissions = Record<Domain, Record<Resource, Record<Permission, Permissions>>>;
|
|
9
|
+
|
|
10
10
|
export interface PermissionScope {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
resource: Resource;
|
|
12
|
+
permission: Permission;
|
|
13
|
+
domain: Domain;
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
export
|
|
17
|
-
export
|
|
15
|
+
|
|
16
|
+
export const ReadPermission = 'Read' as Permission;
|
|
17
|
+
export const UpdatePermission = 'Update' as Permission;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { DomainPermissions } from './permissions';
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* Session Information for a logged in user
|
|
4
5
|
*/
|
|
5
6
|
export interface SessionInfo {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
authenticated: boolean;
|
|
8
|
+
username: string;
|
|
9
|
+
permissions: DomainPermissions;
|
|
9
10
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { ResourceMeta } from './configs';
|
|
3
|
+
import { Domain, Permission, Resource } from './permissions';
|
|
4
|
+
|
|
5
|
+
export const BASE_URL = new InjectionToken<string>('BASE_URL');
|
|
6
|
+
export const API_URL = new InjectionToken<string>('API_URL');
|
|
7
|
+
export const PERMISSION_REQUIRED = new InjectionToken<(resource: Resource, permission: Permission) => boolean>(
|
|
8
|
+
'PERMISSION_REQUIRED',
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
export const AVAILABLE_PERMISSIONS = new InjectionToken<{
|
|
12
|
+
Create: Permission;
|
|
13
|
+
Delete: Permission;
|
|
14
|
+
List: Permission;
|
|
15
|
+
Read: Permission;
|
|
16
|
+
Update: Permission;
|
|
17
|
+
}>('AVAILABLE_PERMISSIONS');
|
|
18
|
+
export const AVAILABLE_DOMAINS = new InjectionToken<Record<string, Domain>[]>('AVAILABLE_DOMAINS');
|
|
19
|
+
|
|
20
|
+
export const RESOURCE_META = new InjectionToken<(resource: Resource) => ResourceMeta>('RESOURCE_META');
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<div class="alert" [ngClass]="error.level">
|
|
2
|
+
<div class="message">
|
|
3
|
+
<span>{{ error.message }}</span>
|
|
4
|
+
</div>
|
|
5
|
+
<div class="alert-end">
|
|
6
|
+
@if (error.link) {
|
|
7
|
+
<span [routerLink]="error.link" class="link">View</span>
|
|
8
|
+
}
|
|
9
|
+
<button (click)="dismissAlert()" mat-icon-button aria-label="Close Alert">
|
|
10
|
+
<mat-icon>close</mat-icon>
|
|
11
|
+
</button>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
.alert {
|
|
2
|
+
margin: auto;
|
|
3
|
+
border: 1px solid;
|
|
4
|
+
max-width: 450px;
|
|
5
|
+
border-radius: 5px;
|
|
6
|
+
background-color: lightgray;
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: row;
|
|
9
|
+
align-items: center;
|
|
10
|
+
justify-content: space-between;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.message {
|
|
14
|
+
padding-left: 15px;
|
|
15
|
+
max-width: 400px;
|
|
16
|
+
display: flex;
|
|
17
|
+
justify-content: space-between;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.alert-end {
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: row;
|
|
23
|
+
align-items: center;
|
|
24
|
+
gap: 5px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.link {
|
|
28
|
+
cursor: pointer;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.link:hover {
|
|
32
|
+
text-decoration: underline;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.warn {
|
|
36
|
+
border-color: red;
|
|
37
|
+
background-color: #fff5f4;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.accent {
|
|
41
|
+
border-color: #dfb51d;
|
|
42
|
+
background-color: #fff8e0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.success {
|
|
46
|
+
border-color: #4caf50;
|
|
47
|
+
background-color: #f0fff0;
|
|
48
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { AlertComponent } from './alert.component';
|
|
4
|
+
|
|
5
|
+
describe('AlertComponent', () => {
|
|
6
|
+
let component: AlertComponent;
|
|
7
|
+
let fixture: ComponentFixture<AlertComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
imports: [AlertComponent],
|
|
12
|
+
}).compileComponents();
|
|
13
|
+
|
|
14
|
+
fixture = TestBed.createComponent(AlertComponent);
|
|
15
|
+
component = fixture.componentInstance;
|
|
16
|
+
fixture.detectChanges();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should create', () => {
|
|
20
|
+
expect(component).toBeTruthy();
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import { Component, EventEmitter, Input, OnInit, Output, inject } from '@angular/core';
|
|
3
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
4
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
5
|
+
import { RouterModule } from '@angular/router';
|
|
6
|
+
import { NotificationMessage } from '@cccteam/ccc-lib/src/types';
|
|
7
|
+
import { NotificationService } from '@cccteam/ccc-lib/src/ui-notification-service';
|
|
8
|
+
|
|
9
|
+
@Component({
|
|
10
|
+
selector: 'ccc-alert',
|
|
11
|
+
templateUrl: './alert.component.html',
|
|
12
|
+
styleUrls: ['./alert.component.scss'],
|
|
13
|
+
imports: [MatIconModule, MatButtonModule, CommonModule, RouterModule],
|
|
14
|
+
})
|
|
15
|
+
export class AlertComponent implements OnInit {
|
|
16
|
+
@Input({ required: true }) error!: NotificationMessage;
|
|
17
|
+
@Output() dismiss = new EventEmitter();
|
|
18
|
+
|
|
19
|
+
errors = inject(NotificationService);
|
|
20
|
+
ngOnInit(): void {
|
|
21
|
+
if (this.error.duration === undefined) {
|
|
22
|
+
this.error.duration = 30000;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
setTimeout(() => {
|
|
26
|
+
this.dismissAlert();
|
|
27
|
+
}, this.error.duration);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
dismissAlert(): void {
|
|
31
|
+
if (this.error.id !== undefined) {
|
|
32
|
+
this.errors.dismissGlobalNotification(this.error);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ui-core.service';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { computed, inject, Injectable, signal } from '@angular/core';
|
|
2
|
+
import { CreateNotificationMessage } from '@cccteam/ccc-lib/src/types';
|
|
3
|
+
import { NotificationService } from '@cccteam/ccc-lib/src/ui-notification-service';
|
|
4
|
+
|
|
5
|
+
@Injectable({
|
|
6
|
+
providedIn: 'root',
|
|
7
|
+
})
|
|
8
|
+
export class UiCoreService {
|
|
9
|
+
notifications = inject(NotificationService);
|
|
10
|
+
loadingSignal = signal([] as string[]);
|
|
11
|
+
sidenavOpened = signal(true);
|
|
12
|
+
currentSidenavIdentifier = signal('');
|
|
13
|
+
|
|
14
|
+
private loading = this.loadingSignal.asReadonly();
|
|
15
|
+
isLoading = computed(() => this.loading().length > 0);
|
|
16
|
+
|
|
17
|
+
publishError(message: CreateNotificationMessage): void {
|
|
18
|
+
this.notifications.addGlobalNotification(message);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
beginActivity(process: string): void {
|
|
22
|
+
if (!this.loading().includes(process)) {
|
|
23
|
+
this.loadingSignal.update((current) => [...current, process]);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
endActivity(process: string): void {
|
|
28
|
+
this.loadingSignal.update((current) => current.filter((p) => p !== process));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
toggleSidenav(): void {
|
|
32
|
+
this.sidenavOpened.update((opened) => !opened);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { ApiInterceptor } from './api.interceptor';
|
|
4
|
+
|
|
5
|
+
xdescribe('ApiInterceptor', () => {
|
|
6
|
+
beforeEach(() =>
|
|
7
|
+
TestBed.configureTestingModule({
|
|
8
|
+
providers: [ApiInterceptor],
|
|
9
|
+
}),
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
it('should be created', () => {
|
|
13
|
+
const interceptor: ApiInterceptor = TestBed.inject(ApiInterceptor);
|
|
14
|
+
expect(interceptor).toBeTruthy();
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
|
|
2
|
+
import { inject, Injectable, NgZone } from '@angular/core';
|
|
3
|
+
import { Router } from '@angular/router';
|
|
4
|
+
import { AuthService } from '@cccteam/ccc-lib/src/auth-service';
|
|
5
|
+
import { AlertLevel, BASE_URL } 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, finalize, Observable, throwError } from 'rxjs';
|
|
9
|
+
|
|
10
|
+
@Injectable()
|
|
11
|
+
export class ApiInterceptor implements HttpInterceptor {
|
|
12
|
+
private ui = inject(UiCoreService);
|
|
13
|
+
private auth = inject(AuthService);
|
|
14
|
+
private router = inject(Router);
|
|
15
|
+
private ngZone = inject(NgZone);
|
|
16
|
+
private baseUrl = inject(BASE_URL);
|
|
17
|
+
|
|
18
|
+
intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
|
|
19
|
+
this.ui.beginActivity(request.method + ' ' + request.url);
|
|
20
|
+
|
|
21
|
+
return next.handle(request).pipe(
|
|
22
|
+
catchError((error: HttpErrorResponse): Observable<HttpEvent<unknown>> => {
|
|
23
|
+
if (error.status === 401) {
|
|
24
|
+
this.ngZone.run(() => {
|
|
25
|
+
this.auth.redirectUrl.set(this.baseUrl + this.router.url);
|
|
26
|
+
this.router.navigate(['/login']);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
if (!request.context.get(CUSTOM_HTTP_REQUEST_OPTIONS).suppressGlobalError) {
|
|
30
|
+
const message = error.error?.message ?? error.message ?? error.error;
|
|
31
|
+
this.ui.publishError({
|
|
32
|
+
message: message,
|
|
33
|
+
level: AlertLevel.ERROR,
|
|
34
|
+
link: '',
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return throwError(() => error);
|
|
39
|
+
}),
|
|
40
|
+
finalize(() => {
|
|
41
|
+
this.ui.endActivity(request.method + ' ' + request.url);
|
|
42
|
+
}),
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Injectable, signal } from '@angular/core';
|
|
2
|
+
import { CreateNotificationMessage, NotificationMessage } from '@cccteam/ccc-lib/src/types';
|
|
3
|
+
|
|
4
|
+
@Injectable({
|
|
5
|
+
providedIn: 'root',
|
|
6
|
+
})
|
|
7
|
+
export class NotificationService {
|
|
8
|
+
private notificationId = signal(0);
|
|
9
|
+
private _notifications = signal<NotificationMessage[]>([]);
|
|
10
|
+
notifications = this._notifications.asReadonly();
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Adds a new global notification.
|
|
14
|
+
* @param notification The notification message to add.
|
|
15
|
+
* @returns The unique ID assigned to the notification.
|
|
16
|
+
*/
|
|
17
|
+
addGlobalNotification(notification: CreateNotificationMessage): number {
|
|
18
|
+
this.notificationId.update((id) => id + 1);
|
|
19
|
+
const newNotification: NotificationMessage = {
|
|
20
|
+
...notification,
|
|
21
|
+
id: this.notificationId(),
|
|
22
|
+
};
|
|
23
|
+
const existingNotification = this._notifications().find((n) => n.message === newNotification.message);
|
|
24
|
+
if (existingNotification) {
|
|
25
|
+
this.updateNotification({ ...existingNotification, ...newNotification });
|
|
26
|
+
return existingNotification.id;
|
|
27
|
+
}
|
|
28
|
+
this._notifications.update((current) => [...current, newNotification]);
|
|
29
|
+
return newNotification.id;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Dismisses a global notification by its ID.
|
|
34
|
+
* @param notificationId The ID of the notification to dismiss.
|
|
35
|
+
*/
|
|
36
|
+
dismissGlobalNotificationById(notificationId: number): void {
|
|
37
|
+
this._notifications.update((current) => current.filter((notification) => notification.id !== notificationId));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Dismisses a specific global notification.
|
|
42
|
+
* @param notification The notification to dismiss.
|
|
43
|
+
*/
|
|
44
|
+
dismissGlobalNotification(notification: NotificationMessage): void {
|
|
45
|
+
this.dismissGlobalNotificationById(notification.id);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Updates an existing notification.
|
|
50
|
+
* @param updatedNotification The notification with updated information.
|
|
51
|
+
*/
|
|
52
|
+
updateNotification(updatedNotification: NotificationMessage): void {
|
|
53
|
+
this._notifications.update((current) =>
|
|
54
|
+
current.map((notification) =>
|
|
55
|
+
notification.id === updatedNotification.id ? { ...notification, ...updatedNotification } : notification,
|
|
56
|
+
),
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<div class="nav-container">
|
|
2
|
+
<nav>
|
|
3
|
+
@for (navItem of currentNav(); track navItem) {
|
|
4
|
+
<ng-container *ngTemplateOutlet="typeRendererTemplate; context: { navItem: navItem }"></ng-container>
|
|
5
|
+
}
|
|
6
|
+
</nav>
|
|
7
|
+
</div>
|
|
8
|
+
<ng-template #typeRendererTemplate let-navItem="navItem">
|
|
9
|
+
@switch (navItem.type) {
|
|
10
|
+
@case ('header') {
|
|
11
|
+
<ng-container [ngTemplateOutlet]="headerTemplate" [ngTemplateOutletContext]="{ navItem: navItem }"></ng-container>
|
|
12
|
+
}
|
|
13
|
+
@case ('link') {
|
|
14
|
+
<ng-container [ngTemplateOutlet]="linkTemplate" [ngTemplateOutletContext]="{ navItem: navItem }"></ng-container>
|
|
15
|
+
}
|
|
16
|
+
@case ('expandable') {
|
|
17
|
+
<ng-container
|
|
18
|
+
[ngTemplateOutlet]="expandableTemplate"
|
|
19
|
+
[ngTemplateOutletContext]="{ navItem: navItem }"></ng-container>
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
</ng-template>
|
|
23
|
+
<ng-template #headerTemplate let-navItem="navItem">
|
|
24
|
+
<div class="link-header">{{ navItem.label }}</div>
|
|
25
|
+
</ng-template>
|
|
26
|
+
<ng-template #linkTemplate let-navItem="navItem">
|
|
27
|
+
<a [routerLink]="navItem.routerLink" *cccHasPermission="navItem.permission">
|
|
28
|
+
<div class="nav-item" routerLinkActive="active-link">
|
|
29
|
+
<div class="link-button">
|
|
30
|
+
<div class="icon">
|
|
31
|
+
<mat-icon class="material-icons-outlined" [inline]="true">
|
|
32
|
+
{{ navItem.icon }}
|
|
33
|
+
</mat-icon>
|
|
34
|
+
</div>
|
|
35
|
+
<div class="text">
|
|
36
|
+
{{ navItem.label | titlecase }}
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
</a>
|
|
41
|
+
</ng-template>
|
|
42
|
+
<ng-template #expandableTemplate let-navItem="navItem">
|
|
43
|
+
<div class="nav-item" aria-hidden="true" (click)="navItem.isExpanded = !navItem.isExpanded">
|
|
44
|
+
<div class="link-button">
|
|
45
|
+
<div class="icon">
|
|
46
|
+
<mat-icon class="material-icons-outlined" [inline]="true">
|
|
47
|
+
{{ navItem.isExpanded ? 'expand_less' : 'expand_more' }}
|
|
48
|
+
</mat-icon>
|
|
49
|
+
</div>
|
|
50
|
+
<div class="text">{{ navItem.label }}</div>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
@if (navItem.isExpanded) {
|
|
54
|
+
<div class="expandable-links">
|
|
55
|
+
@for (navItemChild of navItem.children; track navItemChild) {
|
|
56
|
+
<ng-container *ngTemplateOutlet="typeRendererTemplate; context: { navItem: navItemChild }"> </ng-container>
|
|
57
|
+
}
|
|
58
|
+
</div>
|
|
59
|
+
}
|
|
60
|
+
</ng-template>
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
.nav-container {
|
|
2
|
+
padding: 0;
|
|
3
|
+
height: 100%;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
nav {
|
|
7
|
+
max-width: 100%;
|
|
8
|
+
margin: 0px 10px;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.nav-item {
|
|
12
|
+
width: 100%;
|
|
13
|
+
height: 48px;
|
|
14
|
+
font-size: 18px;
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
justify-content: center;
|
|
18
|
+
color: #003b49;
|
|
19
|
+
padding: 0px 15px;
|
|
20
|
+
position: relative;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.nav-item:hover {
|
|
24
|
+
background-color: rgba(0, 0, 0, 0.04);
|
|
25
|
+
transition: background-color 0.1s ease;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.nav-item:active {
|
|
29
|
+
background-color: rgba(0, 0, 0, 0.1);
|
|
30
|
+
transition: background-color 0.1s ease;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.link-header {
|
|
34
|
+
color: #003b49;
|
|
35
|
+
text-transform: uppercase;
|
|
36
|
+
font-weight: bold;
|
|
37
|
+
font-size: 12px;
|
|
38
|
+
margin: 20px 0px 0px 5px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.link-button {
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-direction: row;
|
|
44
|
+
width: 100%;
|
|
45
|
+
|
|
46
|
+
.icon {
|
|
47
|
+
min-width: 20px;
|
|
48
|
+
margin-right: 10px;
|
|
49
|
+
display: flex;
|
|
50
|
+
flex-direction: column;
|
|
51
|
+
justify-content: center;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.text {
|
|
55
|
+
margin-right: 10px;
|
|
56
|
+
text-align: left;
|
|
57
|
+
display: flex;
|
|
58
|
+
flex-direction: row;
|
|
59
|
+
justify-content: left;
|
|
60
|
+
text-decoration: capitalize;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.expandable-links {
|
|
65
|
+
display: flex;
|
|
66
|
+
flex-direction: column;
|
|
67
|
+
width: 100%;
|
|
68
|
+
padding-left: 30px;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
a:active {
|
|
72
|
+
color: #003b49 !important;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
a:link {
|
|
76
|
+
color: #003b49 !important;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
a:visited {
|
|
80
|
+
color: #003b49 !important;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
a {
|
|
84
|
+
text-decoration: none;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.active-link::before {
|
|
88
|
+
content: '';
|
|
89
|
+
position: absolute;
|
|
90
|
+
left: 3px;
|
|
91
|
+
width: 5px;
|
|
92
|
+
height: 38px;
|
|
93
|
+
background-color: #003b49;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.active-link {
|
|
97
|
+
background-color: rgba(0, 0, 0, 0.04);
|
|
98
|
+
position: relative;
|
|
99
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { SidenavComponent } from './sidenav.component';
|
|
4
|
+
|
|
5
|
+
describe('SidenavComponent', () => {
|
|
6
|
+
let component: SidenavComponent;
|
|
7
|
+
let fixture: ComponentFixture<SidenavComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
imports: [SidenavComponent],
|
|
12
|
+
}).compileComponents();
|
|
13
|
+
|
|
14
|
+
fixture = TestBed.createComponent(SidenavComponent);
|
|
15
|
+
component = fixture.componentInstance;
|
|
16
|
+
fixture.detectChanges();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should create', () => {
|
|
20
|
+
expect(component).toBeTruthy();
|
|
21
|
+
});
|
|
22
|
+
});
|