@rolatech/angular-authorization 20.0.0-beta.4

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.
Files changed (23) hide show
  1. package/README.md +7 -0
  2. package/fesm2022/rolatech-angular-authorization-clients.routes-CQFpI9Vf.mjs +441 -0
  3. package/fesm2022/rolatech-angular-authorization-clients.routes-CQFpI9Vf.mjs.map +1 -0
  4. package/fesm2022/rolatech-angular-authorization-endpoint.service-DJyp7eVK.mjs +42 -0
  5. package/fesm2022/rolatech-angular-authorization-endpoint.service-DJyp7eVK.mjs.map +1 -0
  6. package/fesm2022/rolatech-angular-authorization-endpoints.routes-CUD16YeI.mjs +107 -0
  7. package/fesm2022/rolatech-angular-authorization-endpoints.routes-CUD16YeI.mjs.map +1 -0
  8. package/fesm2022/rolatech-angular-authorization-permission.service-BatXKCSF.mjs +21 -0
  9. package/fesm2022/rolatech-angular-authorization-permission.service-BatXKCSF.mjs.map +1 -0
  10. package/fesm2022/rolatech-angular-authorization-permissions.routes-DqstP5Uo.mjs +316 -0
  11. package/fesm2022/rolatech-angular-authorization-permissions.routes-DqstP5Uo.mjs.map +1 -0
  12. package/fesm2022/rolatech-angular-authorization-role.service-Dj9w5oqG.mjs +26 -0
  13. package/fesm2022/rolatech-angular-authorization-role.service-Dj9w5oqG.mjs.map +1 -0
  14. package/fesm2022/rolatech-angular-authorization-roles.routes-D5eERcED.mjs +352 -0
  15. package/fesm2022/rolatech-angular-authorization-roles.routes-D5eERcED.mjs.map +1 -0
  16. package/fesm2022/rolatech-angular-authorization-settings.routes-CQcuOGIn.mjs +25 -0
  17. package/fesm2022/rolatech-angular-authorization-settings.routes-CQcuOGIn.mjs.map +1 -0
  18. package/fesm2022/rolatech-angular-authorization-users.routes-hiRqB2Tq.mjs +312 -0
  19. package/fesm2022/rolatech-angular-authorization-users.routes-hiRqB2Tq.mjs.map +1 -0
  20. package/fesm2022/rolatech-angular-authorization.mjs +57 -0
  21. package/fesm2022/rolatech-angular-authorization.mjs.map +1 -0
  22. package/index.d.ts +5 -0
  23. package/package.json +32 -0
@@ -0,0 +1,26 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable } from '@angular/core';
3
+ import { BaseService } from '@rolatech/angular-services';
4
+
5
+ class RoleService extends BaseService {
6
+ init() {
7
+ this.endpoint = 'auth/roles';
8
+ super.init();
9
+ }
10
+ updatePermissions(id, data) {
11
+ return this.http.put(`${this.actionUrl}/${id}/permissions`, data, {
12
+ withCredentials: true,
13
+ });
14
+ }
15
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: RoleService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
16
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: RoleService, providedIn: 'root' });
17
+ }
18
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: RoleService, decorators: [{
19
+ type: Injectable,
20
+ args: [{
21
+ providedIn: 'root',
22
+ }]
23
+ }] });
24
+
25
+ export { RoleService as R };
26
+ //# sourceMappingURL=rolatech-angular-authorization-role.service-Dj9w5oqG.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rolatech-angular-authorization-role.service-Dj9w5oqG.mjs","sources":["../tmp-esm2022/lib/services/role.service.js"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport { BaseService } from '@rolatech/angular-services';\nimport * as i0 from \"@angular/core\";\nexport class RoleService extends BaseService {\n init() {\n this.endpoint = 'auth/roles';\n super.init();\n }\n updatePermissions(id, data) {\n return this.http.put(`${this.actionUrl}/${id}/permissions`, data, {\n withCredentials: true,\n });\n }\n static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: \"12.0.0\", version: \"20.0.3\", ngImport: i0, type: RoleService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });\n static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: \"12.0.0\", version: \"20.0.3\", ngImport: i0, type: RoleService, providedIn: 'root' });\n}\ni0.ɵɵngDeclareClassMetadata({ minVersion: \"12.0.0\", version: \"20.0.3\", ngImport: i0, type: RoleService, decorators: [{\n type: Injectable,\n args: [{\n providedIn: 'root',\n }]\n }] });\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicm9sZS5zZXJ2aWNlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvYW5ndWxhci1hdXRob3JpemF0aW9uL3NyYy9saWIvc2VydmljZXMvcm9sZS5zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFDM0MsT0FBTyxFQUFFLFdBQVcsRUFBRSxNQUFNLDRCQUE0QixDQUFDOztBQU16RCxNQUFNLE9BQU8sV0FBWSxTQUFRLFdBQVc7SUFDakMsSUFBSTtRQUNYLElBQUksQ0FBQyxRQUFRLEdBQUcsWUFBWSxDQUFDO1FBQzdCLEtBQUssQ0FBQyxJQUFJLEVBQUUsQ0FBQztJQUNmLENBQUM7SUFDRCxpQkFBaUIsQ0FBQyxFQUFVLEVBQUUsSUFBUztRQUNyQyxPQUFPLElBQUksQ0FBQyxJQUFJLENBQUMsR0FBRyxDQUFDLEdBQUcsSUFBSSxDQUFDLFNBQVMsSUFBSSxFQUFFLGNBQWMsRUFBRSxJQUFJLEVBQUU7WUFDaEUsZUFBZSxFQUFFLElBQUk7U0FDdEIsQ0FBQyxDQUFDO0lBQ0wsQ0FBQzt1R0FUVSxXQUFXOzJHQUFYLFdBQVcsY0FGVixNQUFNOzsyRkFFUCxXQUFXO2tCQUh2QixVQUFVO21CQUFDO29CQUNWLFVBQVUsRUFBRSxNQUFNO2lCQUNuQiIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IEluamVjdGFibGUgfSBmcm9tICdAYW5ndWxhci9jb3JlJztcbmltcG9ydCB7IEJhc2VTZXJ2aWNlIH0gZnJvbSAnQHJvbGF0ZWNoL2FuZ3VsYXItc2VydmljZXMnO1xuaW1wb3J0IHsgT2JzZXJ2YWJsZSB9IGZyb20gJ3J4anMnO1xuXG5ASW5qZWN0YWJsZSh7XG4gIHByb3ZpZGVkSW46ICdyb290Jyxcbn0pXG5leHBvcnQgY2xhc3MgUm9sZVNlcnZpY2UgZXh0ZW5kcyBCYXNlU2VydmljZSB7XG4gIG92ZXJyaWRlIGluaXQoKSB7XG4gICAgdGhpcy5lbmRwb2ludCA9ICdhdXRoL3JvbGVzJztcbiAgICBzdXBlci5pbml0KCk7XG4gIH1cbiAgdXBkYXRlUGVybWlzc2lvbnMoaWQ6IHN0cmluZywgZGF0YTogYW55KTogT2JzZXJ2YWJsZTxhbnk+IHtcbiAgICByZXR1cm4gdGhpcy5odHRwLnB1dChgJHt0aGlzLmFjdGlvblVybH0vJHtpZH0vcGVybWlzc2lvbnNgLCBkYXRhLCB7XG4gICAgICB3aXRoQ3JlZGVudGlhbHM6IHRydWUsXG4gICAgfSk7XG4gIH1cbn1cbiJdfQ=="],"names":[],"mappings":";;;;AAGO,MAAM,WAAW,SAAS,WAAW,CAAC;AAC7C,IAAI,IAAI,GAAG;AACX,QAAQ,IAAI,CAAC,QAAQ,GAAG,YAAY;AACpC,QAAQ,KAAK,CAAC,IAAI,EAAE;AACpB;AACA,IAAI,iBAAiB,CAAC,EAAE,EAAE,IAAI,EAAE;AAChC,QAAQ,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE;AAC1E,YAAY,eAAe,EAAE,IAAI;AACjC,SAAS,CAAC;AACV;AACA,IAAI,OAAO,IAAI,GAAG,EAAE,CAAC,kBAAkB,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,eAAe,CAAC,UAAU,EAAE,CAAC;AACxK,IAAI,OAAO,KAAK,GAAG,EAAE,CAAC,qBAAqB,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;AAC7I;AACA,EAAE,CAAC,wBAAwB,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;AACrH,YAAY,IAAI,EAAE,UAAU;AAC5B,YAAY,IAAI,EAAE,CAAC;AACnB,oBAAoB,UAAU,EAAE,MAAM;AACtC,iBAAiB;AACjB,SAAS,CAAC,EAAE,CAAC;;;;"}
@@ -0,0 +1,352 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Component, inject, model, output, viewChild } from '@angular/core';
3
+ import * as i1 from '@angular/forms';
4
+ import { Validators, FormBuilder } from '@angular/forms';
5
+ import * as i3 from '@angular/material/snack-bar';
6
+ import { R as RoleService } from './rolatech-angular-authorization-role.service-Dj9w5oqG.mjs';
7
+ import { AngularCommonModule } from '@rolatech/angular-common';
8
+ import { AngularComponentsModule, ToolbarComponent, BaseComponent, PanelComponent, PanelHeaderComponent, SpinnerComponent } from '@rolatech/angular-components';
9
+ import * as i2 from '@angular/material/button';
10
+ import * as i3$1 from '@angular/material/form-field';
11
+ import * as i6 from '@angular/material/input';
12
+ import { P as PermissionService } from './rolatech-angular-authorization-permission.service-BatXKCSF.mjs';
13
+ import { groupBy, forEach, keys, values, map, find, assign, some } from 'lodash';
14
+ import * as i3$2 from '@angular/material/checkbox';
15
+ import * as i4 from '@angular/material/icon';
16
+ import * as i7 from '@angular/material/paginator';
17
+ import { MatPaginator } from '@angular/material/paginator';
18
+ import * as i8 from '@angular/material/table';
19
+ import { MatTableDataSource } from '@angular/material/table';
20
+ import * as i1$1 from '@angular/router';
21
+ import * as i6$1 from '@angular/material/menu';
22
+
23
+ class CreateComponent {
24
+ roleService;
25
+ formBuilder;
26
+ snackBar;
27
+ fileName = '';
28
+ uploadProgress = 0;
29
+ file;
30
+ url = '';
31
+ roleCreateForm;
32
+ constructor(roleService, formBuilder, snackBar) {
33
+ this.roleService = roleService;
34
+ this.formBuilder = formBuilder;
35
+ this.snackBar = snackBar;
36
+ }
37
+ ngOnInit() {
38
+ this.roleCreateForm = this.formBuilder.group({
39
+ name: [null, Validators.required],
40
+ description: [null, Validators.required],
41
+ });
42
+ }
43
+ submit() {
44
+ if (!this.roleCreateForm.valid) {
45
+ return;
46
+ }
47
+ this.roleService.create(this.roleCreateForm.value).subscribe({
48
+ next: (res) => {
49
+ this.snackBar.open('Success');
50
+ },
51
+ error: (error) => {
52
+ this.snackBar.open(error.message);
53
+ },
54
+ });
55
+ }
56
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: CreateComponent, deps: [{ token: RoleService }, { token: i1.FormBuilder }, { token: i3.MatSnackBar }], target: i0.ɵɵFactoryTarget.Component });
57
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.0.3", type: CreateComponent, isStandalone: true, selector: "authorization-create", ngImport: i0, template: "<rolatech-toolbar title=\"Create Role\" link=\"../\"></rolatech-toolbar>\n<div class=\"p-4\">\n <form [formGroup]=\"roleCreateForm\" (submit)=\"submit()\">\n <div class=\"flex flex-col lg:w-1/2\">\n <!-- name -->\n <h2 class=\"mb-3\">Info</h2>\n <mat-form-field appearance=\"fill\">\n <mat-label> Name </mat-label>\n <input matInput formControlName=\"name\" required />\n </mat-form-field>\n <mat-form-field appearance=\"fill\">\n <mat-label> Description </mat-label>\n <input matInput formControlName=\"description\" required />\n </mat-form-field>\n </div>\n <button mat-flat-button type=\"submit\">Save</button>\n </form>\n</div>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: AngularCommonModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "ngmodule", type: AngularComponentsModule }, { kind: "component", type: i2.MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }, { kind: "component", type: i3$1.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3$1.MatLabel, selector: "mat-label" }, { kind: "directive", type: i6.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "component", type: ToolbarComponent, selector: "rolatech-toolbar", inputs: ["title", "subtitle", "back", "link", "large", "divider"] }] });
58
+ }
59
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: CreateComponent, decorators: [{
60
+ type: Component,
61
+ args: [{ imports: [AngularCommonModule, AngularComponentsModule, ToolbarComponent], selector: 'authorization-create', template: "<rolatech-toolbar title=\"Create Role\" link=\"../\"></rolatech-toolbar>\n<div class=\"p-4\">\n <form [formGroup]=\"roleCreateForm\" (submit)=\"submit()\">\n <div class=\"flex flex-col lg:w-1/2\">\n <!-- name -->\n <h2 class=\"mb-3\">Info</h2>\n <mat-form-field appearance=\"fill\">\n <mat-label> Name </mat-label>\n <input matInput formControlName=\"name\" required />\n </mat-form-field>\n <mat-form-field appearance=\"fill\">\n <mat-label> Description </mat-label>\n <input matInput formControlName=\"description\" required />\n </mat-form-field>\n </div>\n <button mat-flat-button type=\"submit\">Save</button>\n </form>\n</div>\n" }]
62
+ }], ctorParameters: () => [{ type: RoleService }, { type: i1.FormBuilder }, { type: i3.MatSnackBar }] });
63
+
64
+ class RoleUpdateComponent {
65
+ formBuilder = inject(FormBuilder);
66
+ roleUpdateForm;
67
+ role = model();
68
+ output = output();
69
+ ngOnInit() {
70
+ this.roleUpdateForm = this.formBuilder.group({
71
+ name: [null, Validators.required],
72
+ description: [null, Validators.required],
73
+ });
74
+ if (this.role()) {
75
+ const { name, description } = this.role();
76
+ this.roleUpdateForm.setValue({
77
+ name,
78
+ description,
79
+ });
80
+ }
81
+ }
82
+ ngDoCheck() {
83
+ this.output.emit(this.roleUpdateForm.value);
84
+ }
85
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: RoleUpdateComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
86
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.0.3", type: RoleUpdateComponent, isStandalone: true, selector: "authorization-role-update", inputs: { role: { classPropertyName: "role", publicName: "role", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { role: "roleChange", output: "output" }, ngImport: i0, template: "<div>\n <form [formGroup]=\"roleUpdateForm\">\n <mat-form-field appearance=\"fill\">\n <mat-label i18n> Name </mat-label>\n <input matInput formControlName=\"name\" required />\n </mat-form-field>\n <mat-form-field appearance=\"fill\">\n <mat-label i18n> Description </mat-label>\n <input matInput formControlName=\"description\" required />\n </mat-form-field>\n </form>\n</div>\n", styles: ["mat-form-field{width:100%}\n"], dependencies: [{ kind: "ngmodule", type: AngularCommonModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "ngmodule", type: AngularComponentsModule }, { kind: "component", type: i3$1.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3$1.MatLabel, selector: "mat-label" }, { kind: "directive", type: i6.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }] });
87
+ }
88
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: RoleUpdateComponent, decorators: [{
89
+ type: Component,
90
+ args: [{ selector: 'authorization-role-update', imports: [AngularCommonModule, AngularComponentsModule], template: "<div>\n <form [formGroup]=\"roleUpdateForm\">\n <mat-form-field appearance=\"fill\">\n <mat-label i18n> Name </mat-label>\n <input matInput formControlName=\"name\" required />\n </mat-form-field>\n <mat-form-field appearance=\"fill\">\n <mat-label i18n> Description </mat-label>\n <input matInput formControlName=\"description\" required />\n </mat-form-field>\n </form>\n</div>\n", styles: ["mat-form-field{width:100%}\n"] }]
91
+ }] });
92
+
93
+ class DetailsComponent extends BaseComponent {
94
+ roleService = inject(RoleService);
95
+ permissionservice = inject(PermissionService);
96
+ permissions = [];
97
+ rolePermissions = [];
98
+ allComplete = false;
99
+ isLoading = false;
100
+ formattedPermissions = [];
101
+ role;
102
+ detail;
103
+ ngOnInit() {
104
+ this.findById(this.id);
105
+ }
106
+ findAllPermissions() {
107
+ this.isLoading = true;
108
+ this.permissionservice.find({ limit: 600 }).subscribe({
109
+ next: (res) => {
110
+ this.permissions = res.data;
111
+ const tmp = groupBy(this.permissions, 'resource');
112
+ forEach(keys(tmp), (item) => {
113
+ this.formattedPermissions.push({
114
+ name: item,
115
+ completed: false,
116
+ values: values(tmp[item]),
117
+ });
118
+ });
119
+ // this.isLoading = false;
120
+ },
121
+ complete: () => {
122
+ this.initRoleFormat();
123
+ },
124
+ error: (error) => {
125
+ this.isLoading = false;
126
+ this.snackBarService.open(error.message);
127
+ },
128
+ });
129
+ }
130
+ findById(id) {
131
+ this.roleService.get(id, {}).subscribe({
132
+ next: (res) => {
133
+ this.role = res.data;
134
+ this.rolePermissions = res.data.permissions;
135
+ this.findAllPermissions();
136
+ },
137
+ error: (error) => {
138
+ this.snackBarService.open(error.message);
139
+ },
140
+ complete: () => { },
141
+ });
142
+ }
143
+ update() {
144
+ const options = {
145
+ title: 'Update role',
146
+ cancelText: 'Cancel',
147
+ confirmText: 'Confirm',
148
+ component: RoleUpdateComponent,
149
+ data: {
150
+ role: this.role,
151
+ },
152
+ };
153
+ this.dialogService.open(options);
154
+ this.dialogService.confirmed().subscribe({
155
+ next: (result) => {
156
+ if (result) {
157
+ this.roleService.update(this.role.id, result).subscribe({
158
+ next: (res) => {
159
+ this.role = res.data;
160
+ this.snackBarService.open('Update successfully');
161
+ },
162
+ error: (error) => {
163
+ this.snackBarService.open(error.message);
164
+ },
165
+ });
166
+ }
167
+ },
168
+ });
169
+ }
170
+ save() {
171
+ const results = [];
172
+ this.formattedPermissions.forEach((item) => {
173
+ forEach(item.values, (v) => {
174
+ if (v.completed) {
175
+ results.push({ id: v.id });
176
+ }
177
+ });
178
+ });
179
+ this.roleService.updatePermissions(this.id, { permissions: results }).subscribe((res) => {
180
+ this.snackBarService.open('Update successfully');
181
+ });
182
+ }
183
+ initRoleFormat() {
184
+ if (this.rolePermissions) {
185
+ this.rolePermissions.forEach((p) => {
186
+ map(this.formattedPermissions, (item) => {
187
+ const a = find(item.values, (v) => v.id === p.id);
188
+ if (a) {
189
+ assign(a, { completed: true });
190
+ }
191
+ // this.someComplete(item);
192
+ return a;
193
+ });
194
+ });
195
+ this.formattedPermissions.forEach((item) => {
196
+ item.completed = some(item.values, (t) => !t.completed) ? false : true;
197
+ });
198
+ this.isLoading = false;
199
+ }
200
+ }
201
+ updateAllComplete(item) {
202
+ item.completed = item.values != null && item.values.every((t) => t.completed);
203
+ }
204
+ someComplete(item) {
205
+ if (item.values == null || item.values === '') {
206
+ return false;
207
+ }
208
+ return item.values.filter((t) => t.completed).length > 0 && !item.completed;
209
+ }
210
+ setAll(item, completed) {
211
+ item.completed = completed;
212
+ if (item.values == null) {
213
+ return;
214
+ }
215
+ item.values.forEach((t) => (t.completed = completed));
216
+ }
217
+ onMouseover(item) {
218
+ this.detail = item;
219
+ }
220
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: DetailsComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
221
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.0.3", type: DetailsComponent, isStandalone: true, selector: "authorization-details", usesInheritance: true, ngImport: i0, template: "<rolatech-toolbar [title]=\"role.name + ' Management'\">\n <button mat-icon-button (click)=\"update()\">\n <mat-icon>edit</mat-icon>\n </button>\n <button mat-icon-button (click)=\"save()\">\n <mat-icon>save</mat-icon>\n </button>\n</rolatech-toolbar>\n<div class=\"flex flex-row\">\n <div class=\"p-3 w-1/3 h-[calc(100vh-128px)] overflow-scroll\">\n @for (item of formattedPermissions; track item) {\n <div class=\"p-1\">\n <rolatech-panel>\n <rolatech-panel-header>\n <div class=\"px-2\">\n <mat-checkbox\n class=\"text-lg font-medium\"\n [checked]=\"item.completed\"\n [indeterminate]=\"someComplete(item)\"\n (click)=\"$event.stopPropagation()\"\n (change)=\"setAll(item, $event.checked)\"\n >\n {{ item.name }}\n </mat-checkbox>\n </div>\n </rolatech-panel-header>\n <div class=\"pl-6\">\n <div>\n @for (sub of item.values; track sub) {\n <div class=\"p-2 flex justify-between hover:bg-[--rt-raised-background]\" (mouseover)=\"onMouseover(sub)\">\n <div class=\"pb-3\">\n <mat-checkbox [(ngModel)]=\"sub.completed\" (ngModelChange)=\"updateAllComplete(item)\">\n {{ sub.name }}\n </mat-checkbox>\n <div class=\"pl-6 text-[--rt-text-secondary]\">\n {{ sub.description }}\n </div>\n </div>\n <!-- <div>\n <mat-icon>info</mat-icon>\n </div> -->\n </div>\n }\n </div>\n </div>\n </rolatech-panel>\n </div>\n }\n </div>\n <div class=\"p-3\">\n <div>{{ detail?.name }}</div>\n <div>{{ detail?.description }}</div>\n <div>{{ detail?.code }}</div>\n <div>{{ detail?.pattern }}</div>\n <div>{{ detail?.method }}</div>\n </div>\n</div>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: AngularCommonModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: AngularComponentsModule }, { kind: "component", type: i2.MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "component", type: i3$2.MatCheckbox, selector: "mat-checkbox", inputs: ["aria-label", "aria-labelledby", "aria-describedby", "aria-expanded", "aria-controls", "aria-owns", "id", "required", "labelPosition", "name", "value", "disableRipple", "tabIndex", "color", "disabledInteractive", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { kind: "component", type: i4.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: ToolbarComponent, selector: "rolatech-toolbar", inputs: ["title", "subtitle", "back", "link", "large", "divider"] }, { kind: "component", type: PanelComponent, selector: "rolatech-panel", inputs: ["border", "divider", "expanded", "title", "subtitle"], outputs: ["expandedChange"] }, { kind: "component", type: PanelHeaderComponent, selector: "rolatech-panel-header" }] });
222
+ }
223
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: DetailsComponent, decorators: [{
224
+ type: Component,
225
+ args: [{ imports: [AngularCommonModule, AngularComponentsModule, ToolbarComponent, PanelComponent, PanelHeaderComponent], selector: 'authorization-details', template: "<rolatech-toolbar [title]=\"role.name + ' Management'\">\n <button mat-icon-button (click)=\"update()\">\n <mat-icon>edit</mat-icon>\n </button>\n <button mat-icon-button (click)=\"save()\">\n <mat-icon>save</mat-icon>\n </button>\n</rolatech-toolbar>\n<div class=\"flex flex-row\">\n <div class=\"p-3 w-1/3 h-[calc(100vh-128px)] overflow-scroll\">\n @for (item of formattedPermissions; track item) {\n <div class=\"p-1\">\n <rolatech-panel>\n <rolatech-panel-header>\n <div class=\"px-2\">\n <mat-checkbox\n class=\"text-lg font-medium\"\n [checked]=\"item.completed\"\n [indeterminate]=\"someComplete(item)\"\n (click)=\"$event.stopPropagation()\"\n (change)=\"setAll(item, $event.checked)\"\n >\n {{ item.name }}\n </mat-checkbox>\n </div>\n </rolatech-panel-header>\n <div class=\"pl-6\">\n <div>\n @for (sub of item.values; track sub) {\n <div class=\"p-2 flex justify-between hover:bg-[--rt-raised-background]\" (mouseover)=\"onMouseover(sub)\">\n <div class=\"pb-3\">\n <mat-checkbox [(ngModel)]=\"sub.completed\" (ngModelChange)=\"updateAllComplete(item)\">\n {{ sub.name }}\n </mat-checkbox>\n <div class=\"pl-6 text-[--rt-text-secondary]\">\n {{ sub.description }}\n </div>\n </div>\n <!-- <div>\n <mat-icon>info</mat-icon>\n </div> -->\n </div>\n }\n </div>\n </div>\n </rolatech-panel>\n </div>\n }\n </div>\n <div class=\"p-3\">\n <div>{{ detail?.name }}</div>\n <div>{{ detail?.description }}</div>\n <div>{{ detail?.code }}</div>\n <div>{{ detail?.pattern }}</div>\n <div>{{ detail?.method }}</div>\n </div>\n</div>\n" }]
226
+ }] });
227
+
228
+ class IndexComponent extends BaseComponent {
229
+ pageEvent;
230
+ isLoading = false;
231
+ isSearch = false;
232
+ length = 100;
233
+ pageSize = 15;
234
+ pageSizeOptions = [5, 10, 25, 100];
235
+ roles = [];
236
+ displayedColumns = ['name', 'description', 'actions'];
237
+ paginator = viewChild(MatPaginator);
238
+ orderOptions = [
239
+ {
240
+ key: 'createdAt',
241
+ value: 'Created At',
242
+ icon: 'arrow_upward',
243
+ sort: 'asc',
244
+ },
245
+ {
246
+ key: 'createdAt',
247
+ value: 'Created At',
248
+ icon: 'arrow_downward',
249
+ sort: 'desc',
250
+ },
251
+ ];
252
+ orderString = 'createdAt desc';
253
+ dataSource = new MatTableDataSource();
254
+ searchWord;
255
+ roleService = inject(RoleService);
256
+ ngOnInit() {
257
+ this.findAll(null);
258
+ }
259
+ onClick(item) {
260
+ this.orderString = item.key + ' ' + item.sort;
261
+ this.paginator()?.firstPage();
262
+ this.findAll(null);
263
+ }
264
+ findAll(event) {
265
+ this.isLoading = true;
266
+ this.isSearch = false;
267
+ const page = event ? event.pageIndex + 1 : 1;
268
+ const limit = event ? event.pageSize : 15;
269
+ const sort = this.orderString;
270
+ const options = {
271
+ page,
272
+ limit,
273
+ sort,
274
+ };
275
+ this.roleService.find(options).subscribe({
276
+ next: (res) => {
277
+ this.roles = res.data;
278
+ this.dataSource.data = this.roles;
279
+ this.length = res.meta.pagination.count;
280
+ this.isLoading = false;
281
+ },
282
+ error: (error) => {
283
+ this.isLoading = false;
284
+ this.snackBarService.open(error.message);
285
+ },
286
+ });
287
+ }
288
+ search(e) {
289
+ this.isLoading = true;
290
+ const word = e.target.value;
291
+ const options = {
292
+ filter: `name:${word}`,
293
+ };
294
+ this.roleService.find(options).subscribe({
295
+ next: (res) => {
296
+ this.roles = res.data;
297
+ this.dataSource.data = this.roles;
298
+ this.length = res.meta.pagination.count;
299
+ this.isLoading = false;
300
+ },
301
+ error: (error) => {
302
+ this.isLoading = false;
303
+ this.snackBarService.open(error.message);
304
+ },
305
+ });
306
+ }
307
+ delete(item, index) {
308
+ const data = {
309
+ title: '删除确认',
310
+ message: '确定删除选中角色吗',
311
+ };
312
+ this.dialogService.open(data);
313
+ this.dialogService.confirmed().subscribe((confirmed) => {
314
+ if (confirmed) {
315
+ this.roleService.delete(item.id).subscribe({
316
+ next: (res) => {
317
+ this.snackBarService.open('Delete successfully');
318
+ this.roles.splice(index, 1);
319
+ this.dataSource.data = this.roles;
320
+ },
321
+ error: (error) => {
322
+ this.snackBarService.open(error.message);
323
+ },
324
+ });
325
+ }
326
+ });
327
+ }
328
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: IndexComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
329
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.0.3", type: IndexComponent, isStandalone: true, selector: "authorization-index", viewQueries: [{ propertyName: "paginator", first: true, predicate: MatPaginator, descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<rolatech-toolbar title=\"Roles\">\n <button mat-icon-button routerLink=\"./create\">\n <mat-icon>add</mat-icon>\n </button>\n <button mat-icon-button (click)=\"isSearch = true\">\n <mat-icon>search</mat-icon>\n </button>\n <button mat-icon-button [matMenuTriggerFor]=\"beforeMenu\">\n <mat-icon>reorder</mat-icon>\n </button>\n <mat-menu #beforeMenu=\"matMenu\" xPosition=\"before\">\n @for (item of orderOptions; track item) {\n <button mat-menu-item (click)=\"onClick(item)\">\n <span>{{ item.value }}</span>\n <mat-icon>{{ item.icon }}</mat-icon>\n </button>\n }\n </mat-menu>\n</rolatech-toolbar>\n@if (isSearch) {\n <mat-form-field floatLabel=\"auto\">\n <input type=\"text\" matInput placeholder=\"Name\" (keyup.enter)=\"search($event)\" />\n <button matSuffix mat-icon-button (click)=\"findAll(null); isSearch = false\">\n <mat-icon>close</mat-icon>\n </button>\n </mat-form-field>\n}\n<div class=\"py-3\">\n <rolatech-spinner></rolatech-spinner>\n <table mat-table [dataSource]=\"dataSource\">\n <!-- name Column -->\n <ng-container matColumnDef=\"name\">\n <th mat-header-cell *matHeaderCellDef>Name</th>\n <td mat-cell *matCellDef=\"let item\">{{ item.name }}</td>\n </ng-container>\n\n <!-- description Column -->\n <ng-container matColumnDef=\"description\">\n <th mat-header-cell *matHeaderCellDef>Description</th>\n <td mat-cell *matCellDef=\"let item\">{{ item.description }}</td>\n </ng-container>\n\n <!-- actions Column -->\n <ng-container matColumnDef=\"actions\" stickyEnd>\n <th mat-header-cell *matHeaderCellDef class=\"actions\"></th>\n <td mat-cell *matCellDef=\"let item\" class=\"actions\">\n <mat-icon>navigate_next</mat-icon>\n </td>\n </ng-container>\n\n <tr mat-header-row *matHeaderRowDef=\"displayedColumns\"></tr>\n <tr\n mat-row\n *matRowDef=\"let row; columns: displayedColumns\"\n class=\"cursor-pointer hover:bg-[--rt-raised-background]\"\n [routerLink]=\"['./', row.id]\"\n ></tr>\n </table>\n</div>\n<mat-paginator\n #paginator\n [length]=\"length\"\n [pageSize]=\"pageSize\"\n [pageSizeOptions]=\"pageSizeOptions\"\n (page)=\"pageEvent = findAll($event)\"\n hidePageSize\n showFirstLastButtons\n>\n</mat-paginator>\n", styles: ["mat-form-field{width:100%}table{width:100%}td.mat-column-actions{text-align:right;min-width:80px;font-size:.8rem;padding:0 28px}.mat-mdc-header-cell.actions{text-align:right;max-width:120px;width:120px;padding:0 28px}mat-cell:last-of-type,mat-header-cell:last-of-type,mat-footer-cell:last-of-type{text-align:right;padding-right:8px!important}\n"], dependencies: [{ kind: "ngmodule", type: AngularCommonModule }, { kind: "directive", type: i1$1.RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "ngmodule", type: AngularComponentsModule }, { kind: "component", type: i2.MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "component", type: i4.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i3$1.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3$1.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "directive", type: i6.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "component", type: i6$1.MatMenu, selector: "mat-menu", inputs: ["backdropClass", "aria-label", "aria-labelledby", "aria-describedby", "xPosition", "yPosition", "overlapTrigger", "hasBackdrop", "class", "classList"], outputs: ["closed", "close"], exportAs: ["matMenu"] }, { kind: "component", type: i6$1.MatMenuItem, selector: "[mat-menu-item]", inputs: ["role", "disabled", "disableRipple"], exportAs: ["matMenuItem"] }, { kind: "directive", type: i6$1.MatMenuTrigger, selector: "[mat-menu-trigger-for], [matMenuTriggerFor]", inputs: ["mat-menu-trigger-for", "matMenuTriggerFor", "matMenuTriggerData", "matMenuTriggerRestoreFocus"], outputs: ["menuOpened", "onMenuOpen", "menuClosed", "onMenuClose"], exportAs: ["matMenuTrigger"] }, { kind: "component", type: i7.MatPaginator, selector: "mat-paginator", inputs: ["color", "pageIndex", "length", "pageSize", "pageSizeOptions", "hidePageSize", "showFirstLastButtons", "selectConfig", "disabled"], outputs: ["page"], exportAs: ["matPaginator"] }, { kind: "component", type: i8.MatTable, selector: "mat-table, table[mat-table]", exportAs: ["matTable"] }, { kind: "directive", type: i8.MatHeaderCellDef, selector: "[matHeaderCellDef]" }, { kind: "directive", type: i8.MatHeaderRowDef, selector: "[matHeaderRowDef]", inputs: ["matHeaderRowDef", "matHeaderRowDefSticky"] }, { kind: "directive", type: i8.MatColumnDef, selector: "[matColumnDef]", inputs: ["matColumnDef"] }, { kind: "directive", type: i8.MatCellDef, selector: "[matCellDef]" }, { kind: "directive", type: i8.MatRowDef, selector: "[matRowDef]", inputs: ["matRowDefColumns", "matRowDefWhen"] }, { kind: "directive", type: i8.MatHeaderCell, selector: "mat-header-cell, th[mat-header-cell]" }, { kind: "directive", type: i8.MatCell, selector: "mat-cell, td[mat-cell]" }, { kind: "component", type: i8.MatHeaderRow, selector: "mat-header-row, tr[mat-header-row]", exportAs: ["matHeaderRow"] }, { kind: "component", type: i8.MatRow, selector: "mat-row, tr[mat-row]", exportAs: ["matRow"] }, { kind: "component", type: SpinnerComponent, selector: "rolatech-spinner", inputs: ["title"] }, { kind: "component", type: ToolbarComponent, selector: "rolatech-toolbar", inputs: ["title", "subtitle", "back", "link", "large", "divider"] }] });
330
+ }
331
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: IndexComponent, decorators: [{
332
+ type: Component,
333
+ args: [{ imports: [AngularCommonModule, AngularComponentsModule, SpinnerComponent, ToolbarComponent], selector: 'authorization-index', template: "<rolatech-toolbar title=\"Roles\">\n <button mat-icon-button routerLink=\"./create\">\n <mat-icon>add</mat-icon>\n </button>\n <button mat-icon-button (click)=\"isSearch = true\">\n <mat-icon>search</mat-icon>\n </button>\n <button mat-icon-button [matMenuTriggerFor]=\"beforeMenu\">\n <mat-icon>reorder</mat-icon>\n </button>\n <mat-menu #beforeMenu=\"matMenu\" xPosition=\"before\">\n @for (item of orderOptions; track item) {\n <button mat-menu-item (click)=\"onClick(item)\">\n <span>{{ item.value }}</span>\n <mat-icon>{{ item.icon }}</mat-icon>\n </button>\n }\n </mat-menu>\n</rolatech-toolbar>\n@if (isSearch) {\n <mat-form-field floatLabel=\"auto\">\n <input type=\"text\" matInput placeholder=\"Name\" (keyup.enter)=\"search($event)\" />\n <button matSuffix mat-icon-button (click)=\"findAll(null); isSearch = false\">\n <mat-icon>close</mat-icon>\n </button>\n </mat-form-field>\n}\n<div class=\"py-3\">\n <rolatech-spinner></rolatech-spinner>\n <table mat-table [dataSource]=\"dataSource\">\n <!-- name Column -->\n <ng-container matColumnDef=\"name\">\n <th mat-header-cell *matHeaderCellDef>Name</th>\n <td mat-cell *matCellDef=\"let item\">{{ item.name }}</td>\n </ng-container>\n\n <!-- description Column -->\n <ng-container matColumnDef=\"description\">\n <th mat-header-cell *matHeaderCellDef>Description</th>\n <td mat-cell *matCellDef=\"let item\">{{ item.description }}</td>\n </ng-container>\n\n <!-- actions Column -->\n <ng-container matColumnDef=\"actions\" stickyEnd>\n <th mat-header-cell *matHeaderCellDef class=\"actions\"></th>\n <td mat-cell *matCellDef=\"let item\" class=\"actions\">\n <mat-icon>navigate_next</mat-icon>\n </td>\n </ng-container>\n\n <tr mat-header-row *matHeaderRowDef=\"displayedColumns\"></tr>\n <tr\n mat-row\n *matRowDef=\"let row; columns: displayedColumns\"\n class=\"cursor-pointer hover:bg-[--rt-raised-background]\"\n [routerLink]=\"['./', row.id]\"\n ></tr>\n </table>\n</div>\n<mat-paginator\n #paginator\n [length]=\"length\"\n [pageSize]=\"pageSize\"\n [pageSizeOptions]=\"pageSizeOptions\"\n (page)=\"pageEvent = findAll($event)\"\n hidePageSize\n showFirstLastButtons\n>\n</mat-paginator>\n", styles: ["mat-form-field{width:100%}table{width:100%}td.mat-column-actions{text-align:right;min-width:80px;font-size:.8rem;padding:0 28px}.mat-mdc-header-cell.actions{text-align:right;max-width:120px;width:120px;padding:0 28px}mat-cell:last-of-type,mat-header-cell:last-of-type,mat-footer-cell:last-of-type{text-align:right;padding-right:8px!important}\n"] }]
334
+ }] });
335
+
336
+ const routes = [
337
+ {
338
+ path: '',
339
+ component: IndexComponent,
340
+ },
341
+ {
342
+ path: 'create',
343
+ component: CreateComponent,
344
+ },
345
+ {
346
+ path: ':id',
347
+ component: DetailsComponent,
348
+ },
349
+ ];
350
+
351
+ export { routes as default };
352
+ //# sourceMappingURL=rolatech-angular-authorization-roles.routes-D5eERcED.mjs.map