@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
package/eslint.config.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
const tseslint = require("typescript-eslint");
|
|
3
|
-
const rootConfig = require("../../eslint.config.js");
|
|
4
|
-
|
|
5
|
-
module.exports = tseslint.config(
|
|
6
|
-
...rootConfig,
|
|
7
|
-
{
|
|
8
|
-
files: ["**/*.ts"],
|
|
9
|
-
rules: {
|
|
10
|
-
"@angular-eslint/directive-selector": [
|
|
11
|
-
"error",
|
|
12
|
-
{
|
|
13
|
-
type: "attribute",
|
|
14
|
-
prefix: "ccc",
|
|
15
|
-
style: "camelCase",
|
|
16
|
-
},
|
|
17
|
-
],
|
|
18
|
-
"@angular-eslint/component-selector": [
|
|
19
|
-
"error",
|
|
20
|
-
{
|
|
21
|
-
type: "element",
|
|
22
|
-
prefix: "ccc",
|
|
23
|
-
style: "kebab-case",
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
files: ["**/*.html"],
|
|
30
|
-
rules: {},
|
|
31
|
-
}
|
|
32
|
-
);
|
package/ng-package.json
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { inject } from '@angular/core';
|
|
2
|
-
import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
|
|
3
|
-
import { AuthService } from '@cccteam/ccc-lib/src/auth-service';
|
|
4
|
-
import { BASE_URL } from '@cccteam/ccc-lib/src/types';
|
|
5
|
-
import { Observable, of } from 'rxjs';
|
|
6
|
-
import { catchError, map } from 'rxjs/operators';
|
|
7
|
-
|
|
8
|
-
export const AuthenticationGuard = (
|
|
9
|
-
route: ActivatedRouteSnapshot,
|
|
10
|
-
routerState: RouterStateSnapshot,
|
|
11
|
-
): Observable<boolean> => {
|
|
12
|
-
const authService = inject(AuthService);
|
|
13
|
-
const baseUrl = inject(BASE_URL);
|
|
14
|
-
|
|
15
|
-
const authenticate = (): void => {
|
|
16
|
-
const url = routerState.url;
|
|
17
|
-
const absoluteUrl = baseUrl + (!url.toString().startsWith('/') ? '/' + url : url);
|
|
18
|
-
const encodedUrl = encodeURIComponent(absoluteUrl);
|
|
19
|
-
window.location.href = `${authService.loginRoute()}?returnUrl=${encodedUrl}`;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
if (authService.authenticated()) {
|
|
23
|
-
return of(true);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return authService.checkUserSession().pipe(
|
|
27
|
-
map((sessionInfo) => {
|
|
28
|
-
if (sessionInfo?.authenticated) {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
authenticate();
|
|
33
|
-
return false;
|
|
34
|
-
}),
|
|
35
|
-
catchError(() => {
|
|
36
|
-
authenticate();
|
|
37
|
-
return of(false);
|
|
38
|
-
}),
|
|
39
|
-
);
|
|
40
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './authentication.guard';
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { computed, inject, Signal } from '@angular/core';
|
|
2
|
-
import { ActivatedRouteSnapshot, Router } from '@angular/router';
|
|
3
|
-
import { AuthService } from '@cccteam/ccc-lib/src/auth-service';
|
|
4
|
-
|
|
5
|
-
export const AuthorizationGuard = (route: ActivatedRouteSnapshot): Signal<boolean> => {
|
|
6
|
-
const router = inject(Router);
|
|
7
|
-
const auth = inject(AuthService);
|
|
8
|
-
return computed(() => {
|
|
9
|
-
const hasPermission = auth.hasPermission(route.data['scope']);
|
|
10
|
-
if (hasPermission) {
|
|
11
|
-
return true;
|
|
12
|
-
} else {
|
|
13
|
-
router.navigate(['/']);
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './authorization.guard';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<p>ccc-field works!</p>
|
|
File without changes
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
|
|
3
|
-
import { CccInputFieldComponent } from './ccc-field.component';
|
|
4
|
-
|
|
5
|
-
describe('CccFieldComponent', () => {
|
|
6
|
-
let component: CccInputFieldComponent;
|
|
7
|
-
let fixture: ComponentFixture<CccInputFieldComponent>;
|
|
8
|
-
|
|
9
|
-
beforeEach(async () => {
|
|
10
|
-
await TestBed.configureTestingModule({
|
|
11
|
-
imports: [CccInputFieldComponent],
|
|
12
|
-
}).compileComponents();
|
|
13
|
-
|
|
14
|
-
fixture = TestBed.createComponent(CccInputFieldComponent);
|
|
15
|
-
component = fixture.componentInstance;
|
|
16
|
-
fixture.detectChanges();
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('should create', () => {
|
|
20
|
-
expect(component).toBeTruthy();
|
|
21
|
-
});
|
|
22
|
-
});
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { Component, computed, inject, input, OnInit, signal, Signal } from '@angular/core';
|
|
2
|
-
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
3
|
-
import { MatInputModule } from '@angular/material/input';
|
|
4
|
-
import { AuthService } from '@cccteam/ccc-lib/src/auth-service';
|
|
5
|
-
import { Domain, ReadPermission, Resource, UpdatePermission } from '@cccteam/ccc-lib/src/types';
|
|
6
|
-
|
|
7
|
-
export enum InputMode {
|
|
8
|
-
Read = 'read',
|
|
9
|
-
Edit = 'edit',
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
@Component({
|
|
13
|
-
selector: 'ccc-input-field',
|
|
14
|
-
imports: [MatFormFieldModule, MatInputModule],
|
|
15
|
-
template: `
|
|
16
|
-
<mat-form-field [class]="className()">
|
|
17
|
-
<mat-label>{{ name() }}</mat-label>
|
|
18
|
-
<input matInput [disabled]="mode() === inputMode.Edit && canEdit()" [value]="value()" />
|
|
19
|
-
</mat-form-field>
|
|
20
|
-
`,
|
|
21
|
-
styleUrl: './ccc-field.component.scss',
|
|
22
|
-
})
|
|
23
|
-
export class CccInputFieldComponent implements OnInit {
|
|
24
|
-
auth = inject(AuthService);
|
|
25
|
-
className = input();
|
|
26
|
-
mode = input.required<InputMode>();
|
|
27
|
-
resource = input.required<Resource>();
|
|
28
|
-
domain = input.required<Domain>();
|
|
29
|
-
value = input.required();
|
|
30
|
-
name = input.required<string>();
|
|
31
|
-
|
|
32
|
-
inputMode = InputMode;
|
|
33
|
-
|
|
34
|
-
canEdit: Signal<boolean> = signal(false);
|
|
35
|
-
canEditSelector = false;
|
|
36
|
-
|
|
37
|
-
canRead: Signal<boolean> = signal(false);
|
|
38
|
-
canReadSelector = false;
|
|
39
|
-
|
|
40
|
-
ngOnInit(): void {
|
|
41
|
-
this.canEditSelector = this.auth.hasPermission({
|
|
42
|
-
resource: this.resource(),
|
|
43
|
-
permission: ReadPermission,
|
|
44
|
-
domain: this.domain(),
|
|
45
|
-
});
|
|
46
|
-
this.canReadSelector = this.auth.hasPermission({
|
|
47
|
-
resource: this.resource(),
|
|
48
|
-
permission: UpdatePermission,
|
|
49
|
-
domain: this.domain(),
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
this.canRead = computed(() => {
|
|
53
|
-
const res = this.resource();
|
|
54
|
-
if (!res) {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
if (AuthService.requiresPermission(this.resource(), ReadPermission)) {
|
|
58
|
-
return this.canReadSelector;
|
|
59
|
-
}
|
|
60
|
-
return false;
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
this.canEdit = computed(() => {
|
|
64
|
-
const res = this.resource();
|
|
65
|
-
if (!res) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
if (AuthService.requiresPermission(this.resource(), UpdatePermission)) {
|
|
69
|
-
return this.canEditSelector;
|
|
70
|
-
}
|
|
71
|
-
return false;
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { FormArray, FormGroup } from '@angular/forms';
|
|
2
|
-
import { isEqual } from 'lodash-es';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Accepts a FormGroup and compares it to an object to return the dirty form values
|
|
6
|
-
* as a sparse object
|
|
7
|
-
* @param form - FormGroup
|
|
8
|
-
* @param compareData - object to compare form values against
|
|
9
|
-
* @returns Partial<T>
|
|
10
|
-
* @example sparseFormData<UserCreate>(this.userForm, initUser)
|
|
11
|
-
*/
|
|
12
|
-
export function sparseFormData<T>(form: FormGroup, compareData: T): T {
|
|
13
|
-
const sparseFormData: T = {} as T;
|
|
14
|
-
|
|
15
|
-
for (const [key, control] of Object.entries(form.controls)) {
|
|
16
|
-
const controlValue = control.value;
|
|
17
|
-
const compareValue = compareData[key as keyof T];
|
|
18
|
-
|
|
19
|
-
if (!isEqual(controlValue, compareValue)) {
|
|
20
|
-
sparseFormData[key as keyof T] = controlValue as T[keyof T];
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return sparseFormData;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Accepts a FormArray and removes empty strings
|
|
29
|
-
* @param formArray - FormArray
|
|
30
|
-
* @returns FormArray
|
|
31
|
-
*/
|
|
32
|
-
export function cleanStringFormArray(formArray: FormArray): FormArray {
|
|
33
|
-
for (let i = formArray.controls.length - 1; i >= 0; i--) {
|
|
34
|
-
if (formArray.at(i).value === '') {
|
|
35
|
-
formArray.removeAt(i);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return formArray;
|
|
39
|
-
}
|
package/src/auth-forms/index.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Directive, Input, TemplateRef, ViewContainerRef, effect, inject, signal } from '@angular/core';
|
|
2
|
-
import { AuthService } from '@cccteam/ccc-lib/src/auth-service';
|
|
3
|
-
import { PermissionScope } from '@cccteam/ccc-lib/src/types';
|
|
4
|
-
|
|
5
|
-
@Directive({
|
|
6
|
-
selector: '[cccHasPermission]',
|
|
7
|
-
standalone: true,
|
|
8
|
-
})
|
|
9
|
-
export class HasPermissionDirective {
|
|
10
|
-
private auth = inject(AuthService);
|
|
11
|
-
private templateRef = inject(TemplateRef<unknown>);
|
|
12
|
-
private viewContainer = inject(ViewContainerRef);
|
|
13
|
-
|
|
14
|
-
private scope = signal<PermissionScope | undefined>(undefined);
|
|
15
|
-
|
|
16
|
-
@Input()
|
|
17
|
-
set cccHasPermission(scope: PermissionScope) {
|
|
18
|
-
this.scope.set(scope);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
constructor() {
|
|
22
|
-
effect(() => {
|
|
23
|
-
const scope = this.scope();
|
|
24
|
-
|
|
25
|
-
if (this.auth.hasPermission(scope) && this.auth.authenticated()) {
|
|
26
|
-
if (!this.viewContainer.get(0)) {
|
|
27
|
-
this.viewContainer.createEmbeddedView(this.templateRef);
|
|
28
|
-
}
|
|
29
|
-
} else {
|
|
30
|
-
this.viewContainer.clear();
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './has-permission.directive';
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { HttpClient } from '@angular/common/http';
|
|
2
|
-
import { inject, Inject, Injectable, signal } from '@angular/core';
|
|
3
|
-
import {
|
|
4
|
-
API_URL,
|
|
5
|
-
Permission,
|
|
6
|
-
PERMISSION_REQUIRED,
|
|
7
|
-
PermissionScope,
|
|
8
|
-
Resource,
|
|
9
|
-
SessionInfo,
|
|
10
|
-
} from '@cccteam/ccc-lib/src/types';
|
|
11
|
-
import { errorOptions } from '@cccteam/ccc-lib/src/util-request-options';
|
|
12
|
-
import { map, Observable, tap } from 'rxjs';
|
|
13
|
-
|
|
14
|
-
const routes = {
|
|
15
|
-
login: (rootUrl: string): string => `${rootUrl}/user/login`,
|
|
16
|
-
session: (rootUrl: string): string => `${rootUrl}/user/session`,
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
@Injectable({
|
|
20
|
-
providedIn: 'root',
|
|
21
|
-
})
|
|
22
|
-
export class AuthService {
|
|
23
|
-
http = inject(HttpClient);
|
|
24
|
-
private authenticatedSignal = signal(false);
|
|
25
|
-
private sessionInfoSignal = signal({} as SessionInfo);
|
|
26
|
-
|
|
27
|
-
redirectUrl = signal('');
|
|
28
|
-
authenticated = this.authenticatedSignal.asReadonly();
|
|
29
|
-
sessionInfo = this.sessionInfoSignal.asReadonly();
|
|
30
|
-
|
|
31
|
-
constructor(@Inject(API_URL) private apiUrl: string) {
|
|
32
|
-
this.initializePermissionFn();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
private static permissionFn: (resource: Resource, permission: Permission) => boolean;
|
|
36
|
-
|
|
37
|
-
hasPermission(scope?: PermissionScope): boolean {
|
|
38
|
-
if (!scope) return true;
|
|
39
|
-
const resourcePermissions = this.sessionInfo().permissions?.[scope.domain]?.[scope.resource];
|
|
40
|
-
return Array.isArray(resourcePermissions) && resourcePermissions.includes(scope.permission);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
static requiresPermission(resource: Resource, permission: Permission): boolean {
|
|
44
|
-
if (!AuthService.permissionFn) {
|
|
45
|
-
throw new Error(
|
|
46
|
-
`AuthState has not been initialized. Ensure AuthState is provided in your module or instantiated at least once.`,
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
return AuthService.permissionFn(resource, permission);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
private initializePermissionFn(): void {
|
|
53
|
-
if (!AuthService.permissionFn) {
|
|
54
|
-
AuthService.permissionFn = inject(PERMISSION_REQUIRED);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Logs a user out.
|
|
60
|
-
*
|
|
61
|
-
* @returns Observable with a boolean indicating whether they were logged out.
|
|
62
|
-
*/
|
|
63
|
-
logout(): Observable<boolean> {
|
|
64
|
-
return this.http
|
|
65
|
-
.delete(routes.session(this.apiUrl), errorOptions(false))
|
|
66
|
-
.pipe(map(() => true))
|
|
67
|
-
.pipe(
|
|
68
|
-
tap(() => {
|
|
69
|
-
this.authenticatedSignal.set(false);
|
|
70
|
-
this.sessionInfoSignal.set({} as SessionInfo);
|
|
71
|
-
}),
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Checks a user's session with the server.
|
|
77
|
-
*
|
|
78
|
-
* @returns Observable with the user session info
|
|
79
|
-
*/
|
|
80
|
-
checkUserSession(): Observable<SessionInfo> {
|
|
81
|
-
return this.http.get<SessionInfo>(routes.session(this.apiUrl), errorOptions(false)).pipe(
|
|
82
|
-
tap((sessionInfo) => {
|
|
83
|
-
this.authenticatedSignal.set(!!sessionInfo?.authenticated);
|
|
84
|
-
this.sessionInfoSignal.set(sessionInfo);
|
|
85
|
-
}),
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
loginRoute(): string {
|
|
90
|
-
return routes.login(this.apiUrl);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './auth.service';
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Pipe, PipeTransform } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
@Pipe({
|
|
4
|
-
name: 'camelCaseToTitle',
|
|
5
|
-
})
|
|
6
|
-
export class CamelCaseToTitlePipe implements PipeTransform {
|
|
7
|
-
transform(value: string): string {
|
|
8
|
-
if (!value) {
|
|
9
|
-
return value;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
if (value === value.toUpperCase() && !/[0-9]/.test(value)) {
|
|
13
|
-
return value;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
let transformed = value.replace(/([A-Z])/g, ' $1');
|
|
17
|
-
transformed = transformed.replace(/([a-zA-Z])([0-9])/g, '$1 $2');
|
|
18
|
-
transformed = transformed.trim();
|
|
19
|
-
transformed = transformed.charAt(0).toUpperCase() + transformed.slice(1);
|
|
20
|
-
|
|
21
|
-
return transformed;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './camel-case-to-title.pipe';
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { CommonModule } from '@angular/common';
|
|
2
|
-
import { Component, computed, input, output, TemplateRef } from '@angular/core';
|
|
3
|
-
import { MatIconButton } from '@angular/material/button';
|
|
4
|
-
import { MatIconModule } from '@angular/material/icon';
|
|
5
|
-
import { MatTooltipModule } from '@angular/material/tooltip';
|
|
6
|
-
import { RouterModule } from '@angular/router';
|
|
7
|
-
import { CamelCaseToTitlePipe } from '@cccteam/ccc-lib/src/ccc-camel-case-to-title';
|
|
8
|
-
import { ColumnConfig, RecordData } from '@cccteam/ccc-lib/src/types';
|
|
9
|
-
import { GridModule, SelectableMode, SelectableSettings } from '@progress/kendo-angular-grid';
|
|
10
|
-
import { TableButtonComponent } from './table-button/table-button.component';
|
|
11
|
-
|
|
12
|
-
@Component({
|
|
13
|
-
selector: 'ccc-grid',
|
|
14
|
-
standalone: true,
|
|
15
|
-
imports: [
|
|
16
|
-
GridModule,
|
|
17
|
-
CommonModule,
|
|
18
|
-
TableButtonComponent,
|
|
19
|
-
CamelCaseToTitlePipe,
|
|
20
|
-
RouterModule,
|
|
21
|
-
MatIconButton,
|
|
22
|
-
MatIconModule,
|
|
23
|
-
MatTooltipModule,
|
|
24
|
-
],
|
|
25
|
-
template: `
|
|
26
|
-
<kendo-grid
|
|
27
|
-
[kendoGridBinding]="rowData()"
|
|
28
|
-
filterable="menu"
|
|
29
|
-
[sortable]="true"
|
|
30
|
-
scrollable="none"
|
|
31
|
-
[selectable]="selectionMode()"
|
|
32
|
-
[selectedKeys]="selectedKeys"
|
|
33
|
-
kendoGridSelectBy="id"
|
|
34
|
-
(selectedKeysChange)="onSelectedKeysChange($event)">
|
|
35
|
-
@if (selectionMode() !== false) {
|
|
36
|
-
<kendo-grid-checkbox-column
|
|
37
|
-
[width]="40"
|
|
38
|
-
[showSelectAll]="selectionType() === 'multiple'"></kendo-grid-checkbox-column>
|
|
39
|
-
}
|
|
40
|
-
@for (col of columnDefs(); track col.id + col.header) {
|
|
41
|
-
@if (col.buttonConfig) {
|
|
42
|
-
<kendo-grid-column
|
|
43
|
-
[field]="col.id"
|
|
44
|
-
[filterable]="false"
|
|
45
|
-
[sortable]="false"
|
|
46
|
-
[width]="66"
|
|
47
|
-
[resizable]="col.resizable ?? true">
|
|
48
|
-
<ng-template kendoGridHeaderTemplate> </ng-template>
|
|
49
|
-
<ng-template kendoGridCellTemplate let-dataItem>
|
|
50
|
-
@if (col.buttonConfig.actionType === 'link' && col.buttonConfig.viewRoute) {
|
|
51
|
-
<a
|
|
52
|
-
mat-icon-button
|
|
53
|
-
[routerLink]="['/', col.buttonConfig.viewRoute, dataItem['id']]"
|
|
54
|
-
[matTooltip]="col.buttonConfig.label || ''"
|
|
55
|
-
[matTooltipPosition]="col.tooltipPosition || 'above'">
|
|
56
|
-
<mat-icon>{{ col.buttonConfig.icon || 'arrow_forward' }}</mat-icon>
|
|
57
|
-
</a>
|
|
58
|
-
} @else {
|
|
59
|
-
<ccc-table-button
|
|
60
|
-
[config]="col.buttonConfig"
|
|
61
|
-
[rowData]="dataItem"
|
|
62
|
-
[tooltipPosition]="col.tooltipPosition || 'above'"
|
|
63
|
-
[viewRoute]="col.buttonConfig.viewRoute || ''"
|
|
64
|
-
[id]="dataItem['id']">
|
|
65
|
-
</ccc-table-button>
|
|
66
|
-
}
|
|
67
|
-
</ng-template>
|
|
68
|
-
</kendo-grid-column>
|
|
69
|
-
} @else {
|
|
70
|
-
@if (col.width) {
|
|
71
|
-
<kendo-grid-column [field]="col.id" [width]="col.width" [resizable]="col.resizable ?? true">
|
|
72
|
-
<ng-template kendoGridHeaderTemplate>
|
|
73
|
-
@if (!col.hideHeader) {
|
|
74
|
-
<span class="col-header">{{ col.header || col.id | camelCaseToTitle }}</span>
|
|
75
|
-
}
|
|
76
|
-
</ng-template>
|
|
77
|
-
<ng-template kendoGridCellTemplate let-dataItem>{{ dataItem[col.id] }} </ng-template>
|
|
78
|
-
</kendo-grid-column>
|
|
79
|
-
} @else {
|
|
80
|
-
<kendo-grid-column [field]="col.id" [resizable]="col.resizable ?? true">
|
|
81
|
-
<ng-template kendoGridHeaderTemplate>
|
|
82
|
-
@if (!col.hideHeader) {
|
|
83
|
-
<span class="col-header">{{ col.header || col.id | camelCaseToTitle }}</span>
|
|
84
|
-
}
|
|
85
|
-
</ng-template>
|
|
86
|
-
<ng-template kendoGridCellTemplate let-dataItem>{{ dataItem[col.id] }} </ng-template>
|
|
87
|
-
</kendo-grid-column>
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
<ng-template kendoGridNoRecordsTemplate>
|
|
92
|
-
<div style="text-align: center; padding: 20px;">No records found</div>
|
|
93
|
-
</ng-template>
|
|
94
|
-
</kendo-grid>
|
|
95
|
-
`,
|
|
96
|
-
styles: [
|
|
97
|
-
`
|
|
98
|
-
:host {
|
|
99
|
-
display: block;
|
|
100
|
-
height: 100%;
|
|
101
|
-
}
|
|
102
|
-
kendo-grid {
|
|
103
|
-
height: 100%;
|
|
104
|
-
}
|
|
105
|
-
.col-header {
|
|
106
|
-
font-weight: bold;
|
|
107
|
-
}
|
|
108
|
-
ccc-table-button {
|
|
109
|
-
position: relative;
|
|
110
|
-
z-index: 10;
|
|
111
|
-
}
|
|
112
|
-
a[mat-button] {
|
|
113
|
-
position: relative;
|
|
114
|
-
z-index: 11;
|
|
115
|
-
}
|
|
116
|
-
::ng-deep .k-grid .k-grid-aria-root {
|
|
117
|
-
overflow-x: auto; /* Allow horizontal scrolling */
|
|
118
|
-
overflow-y: hidden; /* Keep vertical behavior as needed */
|
|
119
|
-
}
|
|
120
|
-
`,
|
|
121
|
-
],
|
|
122
|
-
})
|
|
123
|
-
export class AppGridComponent {
|
|
124
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
125
|
-
rowData = input<any[]>([]);
|
|
126
|
-
columnDefs = input<ColumnConfig[]>([]);
|
|
127
|
-
masterDetail = input<boolean>(false);
|
|
128
|
-
detailTemplate = input<TemplateRef<unknown>>();
|
|
129
|
-
selectionType = input<'multiple' | 'single' | 'none'>('none');
|
|
130
|
-
selectedRows = output<RecordData[]>();
|
|
131
|
-
|
|
132
|
-
public selectedKeys: number[] = [];
|
|
133
|
-
|
|
134
|
-
onSelectedKeysChange(keys: number[]): void {
|
|
135
|
-
this.selectedKeys = keys;
|
|
136
|
-
const selectedRows = this.rowData().filter((row: any) => keys.includes(row.id));
|
|
137
|
-
this.selectedRows.emit(selectedRows);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
selectionMode = computed(() => {
|
|
141
|
-
if (this.selectionType() === 'none') {
|
|
142
|
-
return false;
|
|
143
|
-
} else if (this.selectionType() === 'single') {
|
|
144
|
-
return {
|
|
145
|
-
mode: 'single' as SelectableMode,
|
|
146
|
-
checkboxOnly: true,
|
|
147
|
-
} as SelectableSettings;
|
|
148
|
-
} else {
|
|
149
|
-
return {
|
|
150
|
-
mode: 'multiple' as SelectableMode,
|
|
151
|
-
checkboxOnly: true,
|
|
152
|
-
} as SelectableSettings;
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
}
|
package/src/ccc-grid/index.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<span
|
|
2
|
-
[matTooltip]="disabled() ? config().disabledLabel : config().label"
|
|
3
|
-
[matTooltipPosition]="tooltipPosition()"
|
|
4
|
-
class="parent">
|
|
5
|
-
@if (config().actionType === 'link') {
|
|
6
|
-
<a [routerLink]="viewRoute()">
|
|
7
|
-
<button mat-icon-button [disabled]="disabled()" [color]="config().color">
|
|
8
|
-
<mat-icon>{{ config().icon }}</mat-icon>
|
|
9
|
-
</button>
|
|
10
|
-
</a>
|
|
11
|
-
} @else if (config().actionType === 'function') {
|
|
12
|
-
<button mat-icon-button (click)="callAction()" [disabled]="disabled()" [color]="color()">
|
|
13
|
-
<mat-icon>{{ config().icon }}</mat-icon>
|
|
14
|
-
</button>
|
|
15
|
-
}
|
|
16
|
-
</span>
|