@firestitch/app-acl 9.0.18 → 12.1.0

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 (100) hide show
  1. package/app/components/acl-entries/acl-entries.component.d.ts +32 -27
  2. package/app/components/acl-entry/acl-entry.component.d.ts +29 -23
  3. package/app/components/acl-object-roles/acl-object-roles.component.d.ts +18 -14
  4. package/app/components/acl-permission-popover/acl-permission-popover.component.d.ts +12 -9
  5. package/app/components/acl-role/acl-role.component.d.ts +46 -42
  6. package/app/components/acl-role-popover/acl-role-popover.component.d.ts +13 -10
  7. package/app/components/acl-roles/acl-roles.component.d.ts +35 -31
  8. package/app/consts/acl-role-accesses.d.ts +5 -5
  9. package/app/enums/acl-role-access.d.ts +6 -6
  10. package/app/fs-app-acl.module.d.ts +31 -4
  11. package/app/injectors/app-acl-config.injector.d.ts +2 -2
  12. package/app/interfaces/acl-entry-data.d.ts +11 -11
  13. package/app/interfaces/acl-entry.d.ts +18 -18
  14. package/app/interfaces/acl-level.d.ts +3 -3
  15. package/app/interfaces/acl-object-entry.d.ts +11 -11
  16. package/app/interfaces/acl-object-role.d.ts +6 -6
  17. package/app/interfaces/acl-object.d.ts +4 -4
  18. package/app/interfaces/acl-permission.d.ts +7 -7
  19. package/app/interfaces/acl-role.d.ts +15 -15
  20. package/app/interfaces/app-acl-config.d.ts +7 -7
  21. package/app/interfaces/name-value.d.ts +4 -4
  22. package/app/services/app-acl.service.d.ts +18 -13
  23. package/bundles/firestitch-app-acl.umd.js +1210 -1076
  24. package/bundles/firestitch-app-acl.umd.js.map +1 -1
  25. package/esm2015/app/components/acl-entries/acl-entries.component.js +166 -177
  26. package/esm2015/app/components/acl-entry/acl-entry.component.js +93 -88
  27. package/esm2015/app/components/acl-object-roles/acl-object-roles.component.js +57 -63
  28. package/esm2015/app/components/acl-permission-popover/acl-permission-popover.component.js +33 -35
  29. package/esm2015/app/components/acl-role/acl-role.component.js +202 -187
  30. package/esm2015/app/components/acl-role-popover/acl-role-popover.component.js +38 -41
  31. package/esm2015/app/components/acl-roles/acl-roles.component.js +146 -158
  32. package/esm2015/app/consts/acl-role-accesses.js +8 -8
  33. package/esm2015/app/enums/acl-role-access.js +8 -8
  34. package/esm2015/app/fs-app-acl.module.js +124 -82
  35. package/esm2015/app/injectors/app-acl-config.injector.js +3 -3
  36. package/esm2015/app/interfaces/acl-entry-data.js +2 -1
  37. package/esm2015/app/interfaces/acl-entry.js +2 -1
  38. package/esm2015/app/interfaces/acl-level.js +2 -1
  39. package/esm2015/app/interfaces/acl-object-entry.js +2 -1
  40. package/esm2015/app/interfaces/acl-object-role.js +2 -1
  41. package/esm2015/app/interfaces/acl-object.js +2 -1
  42. package/esm2015/app/interfaces/acl-permission.js +2 -1
  43. package/esm2015/app/interfaces/acl-role.js +2 -1
  44. package/esm2015/app/interfaces/app-acl-config.js +2 -1
  45. package/esm2015/app/interfaces/name-value.js +2 -1
  46. package/esm2015/app/services/app-acl.service.js +78 -81
  47. package/esm2015/firestitch-app-acl.js +5 -11
  48. package/esm2015/public_api.js +11 -6
  49. package/fesm2015/firestitch-app-acl.js +831 -836
  50. package/fesm2015/firestitch-app-acl.js.map +1 -1
  51. package/firestitch-app-acl.d.ts +5 -11
  52. package/package.json +5 -9
  53. package/public_api.d.ts +20 -6
  54. package/app/components/acl-entry/index.d.ts +0 -1
  55. package/app/components/acl-permission-popover/index.d.ts +0 -1
  56. package/app/enums/index.d.ts +0 -1
  57. package/app/injectors/index.d.ts +0 -1
  58. package/app/interfaces/index.d.ts +0 -11
  59. package/app/services/index.d.ts +0 -1
  60. package/bundles/firestitch-app-acl.umd.min.js +0 -16
  61. package/bundles/firestitch-app-acl.umd.min.js.map +0 -1
  62. package/esm2015/app/components/acl-entry/index.js +0 -2
  63. package/esm2015/app/components/acl-permission-popover/index.js +0 -2
  64. package/esm2015/app/enums/index.js +0 -4
  65. package/esm2015/app/injectors/index.js +0 -4
  66. package/esm2015/app/interfaces/index.js +0 -2
  67. package/esm2015/app/services/index.js +0 -2
  68. package/esm5/app/components/acl-entries/acl-entries.component.js +0 -180
  69. package/esm5/app/components/acl-entry/acl-entry.component.js +0 -93
  70. package/esm5/app/components/acl-entry/index.js +0 -2
  71. package/esm5/app/components/acl-object-roles/acl-object-roles.component.js +0 -64
  72. package/esm5/app/components/acl-permission-popover/acl-permission-popover.component.js +0 -37
  73. package/esm5/app/components/acl-permission-popover/index.js +0 -2
  74. package/esm5/app/components/acl-role/acl-role.component.js +0 -197
  75. package/esm5/app/components/acl-role-popover/acl-role-popover.component.js +0 -43
  76. package/esm5/app/components/acl-roles/acl-roles.component.js +0 -163
  77. package/esm5/app/consts/acl-role-accesses.js +0 -8
  78. package/esm5/app/enums/acl-role-access.js +0 -8
  79. package/esm5/app/enums/index.js +0 -4
  80. package/esm5/app/fs-app-acl.module.js +0 -86
  81. package/esm5/app/injectors/app-acl-config.injector.js +0 -3
  82. package/esm5/app/injectors/index.js +0 -4
  83. package/esm5/app/interfaces/acl-entry-data.js +0 -1
  84. package/esm5/app/interfaces/acl-entry.js +0 -1
  85. package/esm5/app/interfaces/acl-level.js +0 -1
  86. package/esm5/app/interfaces/acl-object-entry.js +0 -1
  87. package/esm5/app/interfaces/acl-object-role.js +0 -1
  88. package/esm5/app/interfaces/acl-object.js +0 -1
  89. package/esm5/app/interfaces/acl-permission.js +0 -1
  90. package/esm5/app/interfaces/acl-role.js +0 -1
  91. package/esm5/app/interfaces/app-acl-config.js +0 -1
  92. package/esm5/app/interfaces/index.js +0 -2
  93. package/esm5/app/interfaces/name-value.js +0 -1
  94. package/esm5/app/services/app-acl.service.js +0 -86
  95. package/esm5/app/services/index.js +0 -2
  96. package/esm5/firestitch-app-acl.js +0 -11
  97. package/esm5/public_api.js +0 -6
  98. package/fesm5/firestitch-app-acl.js +0 -915
  99. package/fesm5/firestitch-app-acl.js.map +0 -1
  100. package/firestitch-app-acl.metadata.json +0 -1
@@ -1,878 +1,873 @@
1
- import { __decorate, __param, __metadata } from 'tslib';
2
1
  import { FlexLayoutModule } from '@angular/flex-layout';
2
+ import * as i18 from '@angular/material/input';
3
3
  import { MatInputModule } from '@angular/material/input';
4
+ import * as i8 from '@angular/material/radio';
4
5
  import { MatRadioModule } from '@angular/material/radio';
6
+ import * as i13 from '@angular/material/button';
5
7
  import { MatButtonModule } from '@angular/material/button';
8
+ import * as i10 from '@angular/material/select';
6
9
  import { MatSelectModule } from '@angular/material/select';
10
+ import * as i9 from '@angular/material/checkbox';
7
11
  import { MatCheckboxModule } from '@angular/material/checkbox';
8
- import { MatDialogRef, MAT_DIALOG_DATA, MatDialog, MatDialogModule } from '@angular/material/dialog';
9
- import { InjectionToken, Inject, ɵɵdefineInjectable, ɵɵinject, Injectable, ViewChild, Component, QueryList, ChangeDetectorRef, Input, ViewChildren, ChangeDetectionStrategy, EventEmitter, Output, NgModule } from '@angular/core';
12
+ import * as i2 from '@angular/material/dialog';
13
+ import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
14
+ import * as i0 from '@angular/core';
15
+ import { InjectionToken, Injectable, Inject, Component, ChangeDetectionStrategy, ViewChild, Input, QueryList, ViewChildren, EventEmitter, Output, NgModule } from '@angular/core';
16
+ import * as i7$1 from '@angular/common';
10
17
  import { CommonModule } from '@angular/common';
18
+ import * as i12 from '@firestitch/list';
11
19
  import { FsListComponent, FsListModule } from '@firestitch/list';
20
+ import * as i2$1 from '@firestitch/popover';
12
21
  import { FsPopoverModule } from '@firestitch/popover';
22
+ import * as i4 from '@firestitch/dialog';
13
23
  import { FsDialogModule } from '@firestitch/dialog';
24
+ import * as i15 from '@firestitch/form';
14
25
  import { FsFormModule } from '@firestitch/form';
26
+ import * as i6 from '@firestitch/label';
15
27
  import { FsLabelModule } from '@firestitch/label';
28
+ import * as i7 from '@firestitch/radiogroup';
16
29
  import { FsRadioGroupModule } from '@firestitch/radiogroup';
30
+ import * as i5$1 from '@firestitch/badge';
17
31
  import { FsBadgeModule } from '@firestitch/badge';
32
+ import * as i1 from '@firestitch/checkboxgroup';
18
33
  import { FsCheckboxGroupModule } from '@firestitch/checkboxgroup';
19
34
  import { map, tap, takeUntil, filter } from 'rxjs/operators';
20
35
  import { ItemType } from '@firestitch/filter';
21
36
  import { list } from '@firestitch/common';
22
37
  import { ReplaySubject, Subject, forkJoin, of, Observable } from 'rxjs';
23
- import { FsMessage } from '@firestitch/message';
38
+ import * as i3 from '@firestitch/message';
24
39
  import { isArray, groupBy, forOwn, sortBy } from 'lodash-es';
25
40
  import * as _snakecaseKeys from 'snakecase-keys';
26
41
  import * as _camelcaseKeys from 'camelcase-keys';
27
- import { FsPrompt } from '@firestitch/prompt';
28
- import { ControlContainer, NgForm, FormsModule } from '@angular/forms';
42
+ import * as i5 from '@angular/material/form-field';
29
43
  import { MatFormFieldModule } from '@angular/material/form-field';
44
+ import * as i11 from '@angular/material/core';
45
+ import * as i14 from '@angular/forms';
46
+ import { ControlContainer, NgForm, FormsModule } from '@angular/forms';
47
+ import * as i17 from '@angular/flex-layout/flex';
48
+ import * as i3$1 from '@firestitch/prompt';
30
49
 
31
- var AclRoleAccess;
32
- (function (AclRoleAccess) {
33
- AclRoleAccess[AclRoleAccess["None"] = 0] = "None";
34
- AclRoleAccess[AclRoleAccess["Read"] = 5] = "Read";
35
- AclRoleAccess[AclRoleAccess["Write"] = 10] = "Write";
36
- AclRoleAccess[AclRoleAccess["Full"] = 15] = "Full";
50
+ var AclRoleAccess;
51
+ (function (AclRoleAccess) {
52
+ AclRoleAccess[AclRoleAccess["None"] = 0] = "None";
53
+ AclRoleAccess[AclRoleAccess["Read"] = 5] = "Read";
54
+ AclRoleAccess[AclRoleAccess["Write"] = 10] = "Write";
55
+ AclRoleAccess[AclRoleAccess["Full"] = 15] = "Full";
37
56
  })(AclRoleAccess || (AclRoleAccess = {}));
38
57
 
39
- // start:ng42.barrel
40
- // end:ng42.barrel
41
-
42
- const AclRoleAccesses = [
43
- { name: 'None', value: AclRoleAccess.None },
44
- { name: 'Read', value: AclRoleAccess.Read },
45
- { name: 'Write', value: AclRoleAccess.Write },
46
- { name: 'Full', value: AclRoleAccess.Full }
58
+ const AclRoleAccesses = [
59
+ { name: 'None', value: AclRoleAccess.None },
60
+ { name: 'Read', value: AclRoleAccess.Read },
61
+ { name: 'Write', value: AclRoleAccess.Write },
62
+ { name: 'Full', value: AclRoleAccess.Full }
47
63
  ];
48
64
 
49
65
  const FS_APP_ACL_CONFIG = new InjectionToken('fs-app-acl-config');
50
66
 
51
- const snakecaseKeys = _snakecaseKeys;
52
- const camelcaseKeys = _camelcaseKeys;
53
- let FsAppAclService = class FsAppAclService {
54
- constructor(_appAclConfig) {
55
- this._appAclConfig = _appAclConfig;
56
- }
57
- getPermissions() {
58
- if (!this._permissions$) {
59
- this._permissions$ = new ReplaySubject();
60
- this._appAclConfig.permissions
61
- .pipe(map((data) => this.input(data)))
62
- .subscribe((permissions) => {
63
- this._permissions$.next(permissions);
64
- this._permissions$.complete();
65
- });
66
- }
67
- return this._permissions$;
68
- }
69
- getLevels() {
70
- if (!this._levels$) {
71
- this._levels$ = new ReplaySubject();
72
- this._appAclConfig.levels
73
- .pipe(map((data) => this.input(data)))
74
- .subscribe((levels) => {
75
- this._levels$.next(levels);
76
- this._levels$.complete();
77
- });
78
- }
79
- return this._levels$;
80
- }
81
- getIndexedLevels() {
82
- return this.getLevels()
83
- .pipe(map((data) => {
84
- return list(data, 'name', 'value');
85
- }));
86
- }
87
- input(data) {
88
- if (isArray(data)) {
89
- return data.map(item => {
90
- return this._appAclConfig.case === 'snake' ? camelcaseKeys(item, { deep: true }) : item;
91
- });
92
- }
93
- else {
94
- return this._appAclConfig.case === 'snake' ? camelcaseKeys(data, { deep: true }) : data;
95
- }
96
- }
97
- output(data) {
98
- if (isArray(data)) {
99
- return data.map(item => {
100
- return this._appAclConfig.case === 'snake' ? snakecaseKeys(item, { deep: true }) : item;
101
- });
102
- }
103
- else {
104
- return this._appAclConfig.case === 'snake' ? snakecaseKeys(data, { deep: true }) : data;
105
- }
106
- }
107
- };
108
- FsAppAclService.ctorParameters = () => [
109
- { type: undefined, decorators: [{ type: Inject, args: [FS_APP_ACL_CONFIG,] }] }
110
- ];
111
- FsAppAclService.ɵprov = ɵɵdefineInjectable({ factory: function FsAppAclService_Factory() { return new FsAppAclService(ɵɵinject(FS_APP_ACL_CONFIG)); }, token: FsAppAclService, providedIn: "root" });
112
- FsAppAclService = __decorate([
113
- Injectable({
114
- providedIn: 'root',
115
- }),
116
- __param(0, Inject(FS_APP_ACL_CONFIG)),
117
- __metadata("design:paramtypes", [Object])
118
- ], FsAppAclService);
119
-
120
- let FsAclRoleComponent = class FsAclRoleComponent {
121
- constructor(_appAclService, _dialogRef, _message, _data) {
122
- this._appAclService = _appAclService;
123
- this._dialogRef = _dialogRef;
124
- this._message = _message;
125
- this._data = _data;
126
- this.aclRole = null;
127
- this.permissions = [];
128
- this.levelPermissions = [];
129
- this.AclRoleAccesses = AclRoleAccesses;
130
- this.indexedAccesses = {};
131
- this.aclLevels = [];
132
- this.indexedAclLevels = {};
133
- this.onlyFullAccess = false;
134
- this.AclLevels = {};
135
- this.aclRoleConfigs = [];
136
- this.levelAclRoleConfigs = [];
137
- this._destroy$ = new Subject();
138
- this.save = () => {
139
- const aclRole = Object.assign(Object.assign({}, this.aclRole), { permissions: this.levelPermissions.map((permission) => {
140
- return {
141
- value: permission.value,
142
- access: this.aclRole.permissions[permission.value] || 0,
143
- };
144
- }), aclRoleConfigs: this.levelAclRoleConfigs.map((item) => {
145
- return {
146
- id: item.id,
147
- value: item.value,
148
- data: item.data,
149
- };
150
- }) });
151
- return this._data.saveAclRole(this._appAclService.output(aclRole))
152
- .pipe(tap((response) => {
153
- this._message.success('Saved Changes');
154
- this.close(response);
155
- }));
156
- };
157
- }
158
- ngOnInit() {
159
- forkJoin(this.getRole(), this._appAclService.getPermissions())
160
- .pipe(takeUntil(this._destroy$))
161
- .subscribe(([aclRole, aclPermissions,]) => {
162
- this.permissions = aclPermissions;
163
- this.aclLevels = this._data.aclLevels;
164
- this.indexedAclLevels = list(this.aclLevels, 'name', 'value');
165
- this.indexedAccesses = list(AclRoleAccesses, 'name', 'value');
166
- this.aclRole = Object.assign({
167
- aclPermissions: [],
168
- allPermissions: true,
169
- aclRoleConfigs: [],
170
- permissions: {},
171
- level: this.aclLevels[0].value,
172
- }, aclRole);
173
- if (this.aclRole.id) {
174
- this.permissions.forEach((permission) => {
175
- let access = 0;
176
- const aclPermission = this.aclRole.aclPermissions.find((item) => {
177
- return item.permission === permission.value;
178
- });
179
- if (aclPermission) {
180
- access = aclPermission.access;
181
- }
182
- this.aclRole.permissions[permission.value] = access;
183
- });
184
- }
185
- if (this.aclRole.allPermissions) {
186
- this._applyMaxPermissionAccess();
187
- }
188
- this._updatePermissions();
189
- this._updateAclRoleConfigs();
190
- });
191
- this.listConfig = {
192
- status: false,
193
- paging: false,
194
- noResults: {
195
- message: '',
196
- },
197
- group: {
198
- initialExpand: true,
199
- groupBy: (data) => {
200
- return data;
201
- },
202
- compareBy: (data) => {
203
- return data.category || 'General';
204
- },
205
- },
206
- fetch: () => {
207
- return of({
208
- data: this.levelPermissions.sort((a, b) => {
209
- a = a.name.toUpperCase();
210
- b = b.name.toUpperCase();
211
- if (a < b) {
212
- return -1;
213
- }
214
- else if (a > b) {
215
- return 1;
216
- }
217
- return 0;
218
- }),
219
- });
220
- },
221
- };
222
- }
223
- levelChange() {
224
- this._updatePermissions();
225
- this._updateAclRoleConfigs();
226
- setTimeout(() => {
227
- this.list.reload();
228
- });
229
- }
230
- getRole() {
231
- if (!this._data.aclRole.id) {
232
- return of(this._data.aclRole);
233
- }
234
- const query = {
235
- aclPermissions: true,
236
- aclRoleConfigs: true,
237
- };
238
- if (!this.environment) {
239
- query.environmentId = null;
240
- }
241
- return this._data.loadAclRole(this._data.aclRole, query)
242
- .pipe(map((data) => this._appAclService.input(data)));
243
- }
244
- close(data = null) {
245
- this._dialogRef.close(data);
246
- }
247
- allPermissionsChange(all) {
248
- this._updatePermissions();
249
- if (all) {
250
- this._applyMaxPermissionAccess();
251
- }
252
- }
253
- ngOnDestroy() {
254
- this._destroy$.next();
255
- this._destroy$.complete();
256
- }
257
- _updatePermissions() {
258
- this.levelPermissions = this.permissions.filter((permission) => {
259
- return permission.levels.some((item) => {
260
- return item === this.aclRole.level;
261
- });
262
- });
263
- }
264
- _updateAclRoleConfigs() {
265
- this.levelAclRoleConfigs = this.aclRoleConfigs.filter((item) => {
266
- return this.aclRole.level === item.level;
267
- });
268
- }
269
- _applyMaxPermissionAccess() {
270
- this.permissions.forEach((permission) => {
271
- this.aclRole.permissions[permission.value] = Math.max(...permission.accesses);
272
- });
273
- }
274
- };
275
- FsAclRoleComponent.ctorParameters = () => [
276
- { type: FsAppAclService },
277
- { type: MatDialogRef },
278
- { type: FsMessage },
279
- { type: undefined, decorators: [{ type: Inject, args: [MAT_DIALOG_DATA,] }] }
280
- ];
281
- __decorate([
282
- ViewChild(FsListComponent),
283
- __metadata("design:type", FsListComponent)
284
- ], FsAclRoleComponent.prototype, "list", void 0);
285
- FsAclRoleComponent = __decorate([
286
- Component({
287
- template: "<form fsForm [submit]=\"save\">\n <fs-dialog>\n <ng-container *ngIf=\"aclRole\">\n <div mat-dialog-title>{{ aclRole.id ? 'Edit' : 'Create' }} Role</div>\n <mat-dialog-content>\n <div fxLayout=\"row\" fxLayout.lt-md=\"column\" fxLayoutGap=\"40px\" fxLayoutGap.lt-md=\"0\">\n <div fxLayout=\"column\" fxFlex fxFlex.lt-md=\"0\">\n <mat-form-field>\n <input matInput placeholder=\"Name\" [(ngModel)]=\"aclRole.name\" name=\"name\" fsFormRequired>\n </mat-form-field>\n\n <fs-label-field *ngIf=\"aclRole.id || aclLevels.length === 1; else levels\">\n <fs-label>Level</fs-label>\n {{indexedAclLevels[aclRole.level]}}\n </fs-label-field>\n\n <ng-template #levels>\n <div class=\"level\">\n <fs-radio-group\n [(ngModel)]=\"aclRole.level\"\n (ngModelChange)=\"levelChange()\"\n fsFormRequired\n label=\"Level\"\n orientation=\"vertical\"\n name=\"level\">\n <mat-radio-button\n *ngFor=\"let item of aclLevels\"\n [value]=\"item.value\"\n [disabled]=\"!!aclRole.protected\">\n {{ item.name }}\n </mat-radio-button>\n </fs-radio-group>\n </div>\n </ng-template>\n\n <fs-label-field *ngIf=\"levelPermissions.length\">\n <fs-label>All Permissions</fs-label>\n <mat-checkbox\n [(ngModel)]=\"aclRole.allPermissions\"\n (ngModelChange)=\"allPermissionsChange($event)\"\n [disabled]=\"!!aclRole.protected\"\n name=\"allPermissions\">\n </mat-checkbox>\n </fs-label-field>\n\n <div fxLayout=\"column\" *ngFor=\"let config of levelAclRoleConfigs\">\n <fs-label-field *ngIf=\"config.interface === 'checkbox'\">\n <fs-label>{{config.name}}</fs-label>\n <mat-checkbox\n [(ngModel)]=\"config.data\"\n [name]=\"config.name\">\n </mat-checkbox>\n <fs-label-message>\n <mat-hint>{{config.description}}</mat-hint>\n </fs-label-message>\n </fs-label-field>\n\n <mat-form-field *ngIf=\"config.interface === 'select'\">\n <mat-select\n [(ngModel)]=\"config.data\"\n [name]=\"config.value\"\n [required]=\"config.required\"\n [placeholder]=\"config.name\">\n <mat-option\n *ngFor=\"let item of config.values\"\n [value]=\"item.value\">\n {{ item.name }}\n </mat-option>\n </mat-select>\n <mat-hint>{{config.description}}</mat-hint>\n </mat-form-field>\n </div>\n </div>\n\n <div fxLayout=\"column\" fxFlex=\"65\" fxFlex.lt-md=\"0\" *ngIf=\"aclRole.level\" [hidden]=\"!levelPermissions.length\" class=\"permissions\">\n\n <fs-list [config]=\"listConfig\">\n <fs-list-column title=\"Permissions\">\n <ng-template colspan=\"2\" fs-list-group-cell let-row=\"row\" class=\"permission-group\">\n <small><b>{{row.category || 'General'}}</b></small>\n </ng-template>\n <ng-template fs-list-cell let-row=\"row\">\n <div class=\"permission\">{{ row.name }}</div>\n <div class=\"description small\">{{ row.description }}</div>\n </ng-template>\n </fs-list-column>\n <fs-list-column title=\"Access\" width=\"1%\" class=\"access\">\n <ng-template fs-list-cell let-row=\"permission\" let-permission=\"row\">\n <span *ngIf=\"aclRole.allPermissions; else elseAll\">\n {{ indexedAccesses[aclRole.permissions[permission.value]] }}\n </span>\n <ng-template #elseAll>\n <mat-form-field>\n <mat-select\n [(ngModel)]=\"aclRole.permissions[permission.value]\"\n [disabled]=\"!!aclRole.protected\"\n fsFormRequired\n name=\"access-{{ permission.value }}\">\n <ng-container *ngFor=\"let access of AclRoleAccesses\">\n <mat-option\n *ngIf=\"access.value === 0 || permission.accesses.indexOf(access.value) !== -1\"\n [value]=\"access.value\">\n {{ access.name }}\n </mat-option>\n </ng-container>\n </mat-select>\n </mat-form-field>\n </ng-template>\n </ng-template>\n </fs-list-column>\n </fs-list>\n </div>\n </div>\n </mat-dialog-content>\n <mat-dialog-actions>\n <button mat-button type=\"submit\" color=\"primary\">{{ aclRole.id ? 'Save' : 'Create' }}</button>\n <button mat-button [mat-dialog-close]=\"null\" type=\"button\">Cancel</button>\n </mat-dialog-actions>\n </ng-container>\n </fs-dialog>\n</form>\n",
288
- styles: [":host .permissions ::ng-deep .fs-list-row-group{background-color:#f6f6f6}:host .permissions ::ng-deep fs-list .access{white-space:nowrap}:host .permissions ::ng-deep .mat-form-field{width:100px}:host .permissions ::ng-deep .mat-form-field .mat-form-field-wrapper{padding-bottom:0}:host .permissions ::ng-deep .mat-form-field .mat-form-field-infix{border-top:0}:host .permissions ::ng-deep .mat-form-field .mat-form-field-underline{bottom:0}:host ::ng-deep fs-radio-group{width:100%}:host ::ng-deep fs-label-field{width:100%}:host .level{width:100%}"]
289
- }),
290
- __param(3, Inject(MAT_DIALOG_DATA)),
291
- __metadata("design:paramtypes", [FsAppAclService,
292
- MatDialogRef,
293
- FsMessage, Object])
294
- ], FsAclRoleComponent);
67
+ const snakecaseKeys = _snakecaseKeys;
68
+ const camelcaseKeys = _camelcaseKeys;
69
+ class FsAppAclService {
70
+ constructor(_appAclConfig) {
71
+ this._appAclConfig = _appAclConfig;
72
+ }
73
+ getPermissions() {
74
+ if (!this._permissions$) {
75
+ this._permissions$ = new ReplaySubject();
76
+ this._appAclConfig.permissions
77
+ .pipe(map((data) => this.input(data)))
78
+ .subscribe((permissions) => {
79
+ this._permissions$.next(permissions);
80
+ this._permissions$.complete();
81
+ });
82
+ }
83
+ return this._permissions$;
84
+ }
85
+ getLevels() {
86
+ if (!this._levels$) {
87
+ this._levels$ = new ReplaySubject();
88
+ this._appAclConfig.levels
89
+ .pipe(map((data) => this.input(data)))
90
+ .subscribe((levels) => {
91
+ this._levels$.next(levels);
92
+ this._levels$.complete();
93
+ });
94
+ }
95
+ return this._levels$;
96
+ }
97
+ getIndexedLevels() {
98
+ return this.getLevels()
99
+ .pipe(map((data) => {
100
+ return list(data, 'name', 'value');
101
+ }));
102
+ }
103
+ input(data) {
104
+ if (isArray(data)) {
105
+ return data.map(item => {
106
+ return this._appAclConfig.case === 'snake' ? camelcaseKeys(item, { deep: true }) : item;
107
+ });
108
+ }
109
+ else {
110
+ return this._appAclConfig.case === 'snake' ? camelcaseKeys(data, { deep: true }) : data;
111
+ }
112
+ }
113
+ output(data) {
114
+ if (isArray(data)) {
115
+ return data.map(item => {
116
+ return this._appAclConfig.case === 'snake' ? snakecaseKeys(item, { deep: true }) : item;
117
+ });
118
+ }
119
+ else {
120
+ return this._appAclConfig.case === 'snake' ? snakecaseKeys(data, { deep: true }) : data;
121
+ }
122
+ }
123
+ }
124
+ FsAppAclService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsAppAclService, deps: [{ token: FS_APP_ACL_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable });
125
+ FsAppAclService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsAppAclService, providedIn: 'root' });
126
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsAppAclService, decorators: [{
127
+ type: Injectable,
128
+ args: [{
129
+ providedIn: 'root',
130
+ }]
131
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
132
+ type: Inject,
133
+ args: [FS_APP_ACL_CONFIG]
134
+ }] }]; } });
295
135
 
296
- let FsAclRolesComponent = class FsAclRolesComponent {
297
- constructor(_appAclService, _dialog, _cdRef) {
298
- this._appAclService = _appAclService;
299
- this._dialog = _dialog;
300
- this._cdRef = _cdRef;
301
- this.aclLevels = [];
302
- this.list = new QueryList();
303
- this.indexedAclRoleLevels = {};
304
- this._destroy$ = new Subject();
305
- }
306
- ngOnInit() {
307
- new Observable(observer => {
308
- if (this.aclLevels.length) {
309
- observer.next(this.aclLevels);
310
- observer.complete();
311
- }
312
- else {
313
- this._appAclService.getLevels()
314
- .subscribe((aclLevels) => {
315
- observer.next(aclLevels);
316
- observer.complete();
317
- });
318
- }
319
- })
320
- .subscribe((aclLevels) => {
321
- this.aclLevels = aclLevels;
322
- this.indexedAclRoleLevels = list(this.aclLevels, 'name', 'value');
323
- this._loadListConfig();
324
- });
325
- }
326
- openDialog(aclRole = { id: null }) {
327
- const dialogRef = this._dialog.open(FsAclRoleComponent, {
328
- width: '70%',
329
- data: {
330
- aclRole,
331
- aclLevels: this.aclLevels,
332
- loadAclRole: this.loadAclRole,
333
- saveAclRole: this.saveAclRole,
334
- },
335
- });
336
- dialogRef.afterClosed()
337
- .pipe(takeUntil(this._destroy$), filter((response) => !!response))
338
- .subscribe((response) => {
339
- this.list.forEach((list) => {
340
- list.reload();
341
- });
342
- });
343
- }
344
- ngOnDestroy() {
345
- this._destroy$.next();
346
- this._destroy$.complete();
347
- }
348
- _loadListConfig() {
349
- this.listConfig = {
350
- sort: { value: 'hierarchy' },
351
- filters: [
352
- {
353
- name: 'keyword',
354
- type: ItemType.Keyword,
355
- label: 'Search',
356
- },
357
- {
358
- name: 'level',
359
- label: 'Level',
360
- type: ItemType.Select,
361
- values: this.aclLevels,
362
- hide: this.aclLevels.length <= 1
363
- },
364
- {
365
- name: 'state',
366
- label: 'Show Deleted',
367
- type: ItemType.Checkbox,
368
- unchecked: 'active',
369
- checked: 'deleted',
370
- },
371
- ],
372
- actions: [
373
- {
374
- click: (event) => {
375
- this.openDialog();
376
- },
377
- label: 'Create',
378
- },
379
- ],
380
- rowActions: [
381
- {
382
- click: (data) => {
383
- return this.deleteAclRole(this._appAclService.output(data));
384
- },
385
- remove: {
386
- title: 'Confirm',
387
- template: 'Are you sure you would like to delete this role?',
388
- },
389
- menu: true,
390
- label: 'Delete',
391
- show: (row) => row.state !== 'deleted',
392
- },
393
- ],
394
- fetch: (query) => {
395
- query.permissions = true;
396
- return this.loadAclRoles(query)
397
- .pipe(map((data) => this._appAclService.input(data)));
398
- },
399
- };
400
- }
401
- };
402
- FsAclRolesComponent.ctorParameters = () => [
403
- { type: FsAppAclService },
404
- { type: MatDialog },
405
- { type: ChangeDetectorRef }
406
- ];
407
- __decorate([
408
- Input(),
409
- __metadata("design:type", Function)
410
- ], FsAclRolesComponent.prototype, "deleteAclRole", void 0);
411
- __decorate([
412
- Input(),
413
- __metadata("design:type", Function)
414
- ], FsAclRolesComponent.prototype, "saveAclRole", void 0);
415
- __decorate([
416
- Input(),
417
- __metadata("design:type", Function)
418
- ], FsAclRolesComponent.prototype, "loadAclRoles", void 0);
419
- __decorate([
420
- Input(),
421
- __metadata("design:type", Function)
422
- ], FsAclRolesComponent.prototype, "loadAclRole", void 0);
423
- __decorate([
424
- Input(),
425
- __metadata("design:type", Array)
426
- ], FsAclRolesComponent.prototype, "aclLevels", void 0);
427
- __decorate([
428
- ViewChildren(FsListComponent),
429
- __metadata("design:type", Object)
430
- ], FsAclRolesComponent.prototype, "list", void 0);
431
- FsAclRolesComponent = __decorate([
432
- Component({
433
- selector: 'fs-acl-roles',
434
- template: "<fs-list [config]=\"listConfig\" *ngIf=\"listConfig\">\n <fs-list-column title=\"Name\" name=\"name\" [sortable]=\"true\">\n <ng-template fs-list-cell let-row=\"row\">\n <a (click)=\"openDialog(row)\">{{ row.name }}</a>\n </ng-template>\n </fs-list-column>\n <fs-list-column name=\"hierarchy\" title=\"Level\" [sortable]=\"true\">\n <ng-template fs-list-cell let-row=\"row\">\n {{ indexedAclRoleLevels[row.level] }}\n </ng-template>\n </fs-list-column>\n <fs-list-column title=\"Permissions\">\n <ng-template fs-list-cell let-row=\"row\">\n <div class=\"permissions\">\n <ng-container *ngFor=\"let permission of row.permissions\">\n <span *ngIf=\"permission.access\" class=\"permission\">\n <acl-permission-popover [permission]=\"permission\">{{permission.name}}</acl-permission-popover>\n </span>\n </ng-container>\n </div>\n </ng-template>\n </fs-list-column>\n</fs-list>\n",
435
- changeDetection: ChangeDetectionStrategy.OnPush,
436
- styles: [".permissions .permission+.permission::before{content:\", \"}"]
437
- }),
438
- __metadata("design:paramtypes", [FsAppAclService,
439
- MatDialog,
440
- ChangeDetectorRef])
441
- ], FsAclRolesComponent);
136
+ class FsAclRoleComponent {
137
+ constructor(_appAclService, _dialogRef, _message, _data, _cdRef) {
138
+ this._appAclService = _appAclService;
139
+ this._dialogRef = _dialogRef;
140
+ this._message = _message;
141
+ this._data = _data;
142
+ this._cdRef = _cdRef;
143
+ this.aclRole = null;
144
+ this.permissions = [];
145
+ this.levelPermissions = [];
146
+ this.AclRoleAccesses = AclRoleAccesses;
147
+ this.indexedAccesses = {};
148
+ this.aclLevels = [];
149
+ this.indexedAclLevels = {};
150
+ this.onlyFullAccess = false;
151
+ this.AclLevels = {};
152
+ this.aclRoleConfigs = [];
153
+ this.levelAclRoleConfigs = [];
154
+ this._destroy$ = new Subject();
155
+ this.save = () => {
156
+ const aclRole = Object.assign(Object.assign({}, this.aclRole), { permissions: this.levelPermissions.map((permission) => {
157
+ return {
158
+ value: permission.value,
159
+ access: this.aclRole.permissions[permission.value] || 0,
160
+ };
161
+ }), aclRoleConfigs: this.levelAclRoleConfigs.map((item) => {
162
+ return {
163
+ id: item.id,
164
+ value: item.value,
165
+ data: item.data,
166
+ };
167
+ }) });
168
+ return this._data.saveAclRole(this._appAclService.output(aclRole))
169
+ .pipe(tap((response) => {
170
+ this._message.success('Saved Changes');
171
+ this.close(response);
172
+ }));
173
+ };
174
+ }
175
+ ngOnInit() {
176
+ forkJoin(this.getRole(), this._appAclService.getPermissions())
177
+ .pipe(takeUntil(this._destroy$))
178
+ .subscribe(([aclRole, aclPermissions,]) => {
179
+ this.permissions = aclPermissions;
180
+ this.aclLevels = this._data.aclLevels;
181
+ this.indexedAclLevels = list(this.aclLevels, 'name', 'value');
182
+ this.indexedAccesses = list(AclRoleAccesses, 'name', 'value');
183
+ this.aclRole = Object.assign({
184
+ aclPermissions: [],
185
+ allPermissions: true,
186
+ aclRoleConfigs: [],
187
+ permissions: {},
188
+ level: this.aclLevels[0].value,
189
+ }, aclRole);
190
+ if (this.aclRole.id) {
191
+ this.permissions.forEach((permission) => {
192
+ let access = 0;
193
+ const aclPermission = this.aclRole.aclPermissions.find((item) => {
194
+ return item.permission === permission.value;
195
+ });
196
+ if (aclPermission) {
197
+ access = aclPermission.access;
198
+ }
199
+ this.aclRole.permissions[permission.value] = access;
200
+ });
201
+ }
202
+ if (this.aclRole.allPermissions) {
203
+ this._applyMaxPermissionAccess();
204
+ }
205
+ this._updatePermissions();
206
+ this._updateAclRoleConfigs();
207
+ this._cdRef.markForCheck();
208
+ });
209
+ this.listConfig = {
210
+ status: false,
211
+ paging: false,
212
+ noResults: {
213
+ message: '',
214
+ },
215
+ group: {
216
+ initialExpand: true,
217
+ groupBy: (data) => {
218
+ return data;
219
+ },
220
+ compareBy: (data) => {
221
+ return data.category || 'General';
222
+ },
223
+ },
224
+ fetch: () => {
225
+ return of({
226
+ data: this.levelPermissions.sort((a, b) => {
227
+ a = a.name.toUpperCase();
228
+ b = b.name.toUpperCase();
229
+ if (a < b) {
230
+ return -1;
231
+ }
232
+ else if (a > b) {
233
+ return 1;
234
+ }
235
+ return 0;
236
+ }),
237
+ });
238
+ },
239
+ };
240
+ }
241
+ levelChange() {
242
+ this._updatePermissions();
243
+ this._updateAclRoleConfigs();
244
+ setTimeout(() => {
245
+ this.list.reload();
246
+ });
247
+ }
248
+ getRole() {
249
+ if (!this._data.aclRole.id) {
250
+ return of(this._data.aclRole);
251
+ }
252
+ const query = {
253
+ aclPermissions: true,
254
+ aclRoleConfigs: true,
255
+ };
256
+ if (!this.environment) {
257
+ query.environmentId = null;
258
+ }
259
+ return this._data.loadAclRole(this._data.aclRole, query)
260
+ .pipe(map((data) => this._appAclService.input(data)));
261
+ }
262
+ close(data = null) {
263
+ this._dialogRef.close(data);
264
+ }
265
+ allPermissionsChange(all) {
266
+ this._updatePermissions();
267
+ if (all) {
268
+ this._applyMaxPermissionAccess();
269
+ }
270
+ }
271
+ ngOnDestroy() {
272
+ this._destroy$.next();
273
+ this._destroy$.complete();
274
+ }
275
+ _updatePermissions() {
276
+ this.levelPermissions = this.permissions.filter((permission) => {
277
+ return permission.levels.some((item) => {
278
+ return item === this.aclRole.level;
279
+ });
280
+ });
281
+ }
282
+ _updateAclRoleConfigs() {
283
+ this.levelAclRoleConfigs = this.aclRoleConfigs.filter((item) => {
284
+ return this.aclRole.level === item.level;
285
+ });
286
+ }
287
+ _applyMaxPermissionAccess() {
288
+ this.permissions.forEach((permission) => {
289
+ this.aclRole.permissions[permission.value] = Math.max(...permission.accesses);
290
+ });
291
+ }
292
+ }
293
+ FsAclRoleComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsAclRoleComponent, deps: [{ token: FsAppAclService }, { token: i2.MatDialogRef }, { token: i3.FsMessage }, { token: MAT_DIALOG_DATA }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
294
+ FsAclRoleComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: FsAclRoleComponent, selector: "ng-component", viewQueries: [{ propertyName: "list", first: true, predicate: FsListComponent, descendants: true }], ngImport: i0, template: "<form fsForm [submit]=\"save\">\n <fs-dialog>\n <ng-container *ngIf=\"aclRole\">\n <div mat-dialog-title>{{ aclRole.id ? 'Edit' : 'Create' }} Role</div>\n <mat-dialog-content>\n <div fxLayout=\"row\" fxLayout.lt-md=\"column\" fxLayoutGap=\"40px\" fxLayoutGap.lt-md=\"0\">\n <div fxLayout=\"column\" fxFlex fxFlex.lt-md=\"0\">\n <mat-form-field>\n <input matInput placeholder=\"Name\" [(ngModel)]=\"aclRole.name\" name=\"name\" fsFormRequired>\n </mat-form-field>\n\n <fs-label-field *ngIf=\"aclRole.id || aclLevels.length === 1; else levels\">\n <fs-label>Level</fs-label>\n {{indexedAclLevels[aclRole.level]}}\n </fs-label-field>\n\n <ng-template #levels>\n <div class=\"level\">\n <fs-radio-group\n [(ngModel)]=\"aclRole.level\"\n (ngModelChange)=\"levelChange()\"\n fsFormRequired\n label=\"Level\"\n orientation=\"vertical\"\n name=\"level\">\n <mat-radio-button\n *ngFor=\"let item of aclLevels\"\n [value]=\"item.value\"\n [disabled]=\"!!aclRole.protected\">\n {{ item.name }}\n </mat-radio-button>\n </fs-radio-group>\n </div>\n </ng-template>\n\n <fs-label-field *ngIf=\"levelPermissions.length\">\n <fs-label>All Permissions</fs-label>\n <mat-checkbox\n [(ngModel)]=\"aclRole.allPermissions\"\n (ngModelChange)=\"allPermissionsChange($event)\"\n [disabled]=\"!!aclRole.protected\"\n name=\"allPermissions\">\n </mat-checkbox>\n </fs-label-field>\n\n <div fxLayout=\"column\" *ngFor=\"let config of levelAclRoleConfigs\">\n <fs-label-field *ngIf=\"config.interface === 'checkbox'\">\n <fs-label>{{config.name}}</fs-label>\n <mat-checkbox\n [(ngModel)]=\"config.data\"\n [name]=\"config.name\">\n </mat-checkbox>\n <fs-label-message>\n <mat-hint>{{config.description}}</mat-hint>\n </fs-label-message>\n </fs-label-field>\n\n <mat-form-field *ngIf=\"config.interface === 'select'\">\n <mat-select\n [(ngModel)]=\"config.data\"\n [name]=\"config.value\"\n [required]=\"config.required\"\n [placeholder]=\"config.name\">\n <mat-option\n *ngFor=\"let item of config.values\"\n [value]=\"item.value\">\n {{ item.name }}\n </mat-option>\n </mat-select>\n <mat-hint>{{config.description}}</mat-hint>\n </mat-form-field>\n </div>\n </div>\n\n <div fxLayout=\"column\" fxFlex=\"65\" fxFlex.lt-md=\"0\" *ngIf=\"aclRole.level\" [hidden]=\"!levelPermissions.length\" class=\"permissions\">\n\n <fs-list [config]=\"listConfig\">\n <fs-list-column title=\"Permissions\">\n <ng-template colspan=\"2\" fs-list-group-cell let-row=\"row\" class=\"permission-group\">\n <small><b>{{row.category || 'General'}}</b></small>\n </ng-template>\n <ng-template fs-list-cell let-row=\"row\">\n <div class=\"permission\">{{ row.name }}</div>\n <div class=\"description small\">{{ row.description }}</div>\n </ng-template>\n </fs-list-column>\n <fs-list-column title=\"Access\" width=\"1%\" class=\"access\">\n <ng-template fs-list-cell let-row=\"permission\" let-permission=\"row\">\n <span *ngIf=\"aclRole.allPermissions; else elseAll\">\n {{ indexedAccesses[aclRole.permissions[permission.value]] }}\n </span>\n <ng-template #elseAll>\n <mat-form-field>\n <mat-select\n [(ngModel)]=\"aclRole.permissions[permission.value]\"\n [disabled]=\"!!aclRole.protected\"\n fsFormRequired\n name=\"access-{{ permission.value }}\">\n <ng-container *ngFor=\"let access of AclRoleAccesses\">\n <mat-option\n *ngIf=\"access.value === 0 || permission.accesses.indexOf(access.value) !== -1\"\n [value]=\"access.value\">\n {{ access.name }}\n </mat-option>\n </ng-container>\n </mat-select>\n </mat-form-field>\n </ng-template>\n </ng-template>\n </fs-list-column>\n </fs-list>\n </div>\n </div>\n </mat-dialog-content>\n <mat-dialog-actions>\n <button mat-button type=\"submit\" color=\"primary\">{{ aclRole.id ? 'Save' : 'Create' }}</button>\n <button mat-button [mat-dialog-close]=\"null\" type=\"button\">Cancel</button>\n </mat-dialog-actions>\n </ng-container>\n </fs-dialog>\n</form>\n", styles: [":host .permissions ::ng-deep .fs-list-row-group{background-color:#f6f6f6}:host .permissions ::ng-deep fs-list .access{white-space:nowrap}:host .permissions ::ng-deep .mat-form-field{width:100px}:host .permissions ::ng-deep .mat-form-field .mat-form-field-wrapper{padding-bottom:0}:host .permissions ::ng-deep .mat-form-field .mat-form-field-infix{border-top:0}:host .permissions ::ng-deep .mat-form-field .mat-form-field-underline{bottom:0}:host ::ng-deep fs-radio-group{width:100%}:host ::ng-deep fs-label-field{width:100%}:host .level{width:100%}\n"], components: [{ type: i4.FsDialogComponent, selector: "fs-dialog", inputs: ["mobileMode"] }, { type: i5.MatFormField, selector: "mat-form-field", inputs: ["color", "floatLabel", "appearance", "hideRequiredMarker", "hintLabel"], exportAs: ["matFormField"] }, { type: i6.FsLabelFieldComponent, selector: "fs-label-field", inputs: ["bottomMargin", "topMargin", "labelMargin"] }, { type: i6.FsLabelComponent, selector: "fs-label" }, { type: i7.FsRadioGroupComponent, selector: "fs-radio-group", inputs: ["orientation", "label", "name", "disabled", "radioPosition", "compareWith", "required"] }, { type: i8.MatRadioButton, selector: "mat-radio-button", inputs: ["disableRipple", "tabIndex"], exportAs: ["matRadioButton"] }, { type: i9.MatCheckbox, selector: "mat-checkbox", inputs: ["disableRipple", "color", "tabIndex", "aria-label", "aria-labelledby", "id", "labelPosition", "name", "required", "checked", "disabled", "indeterminate", "aria-describedby", "value"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { type: i6.FsLabelMessageComponent, selector: "fs-label-message" }, { type: i10.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { type: i11.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { type: i12.FsListComponent, selector: "fs-list", inputs: ["config", "loaderLines"], outputs: ["filtersReady"] }, { type: i13.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i14.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i14.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i14.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i15.FsFormDirective, selector: "[fsForm]", inputs: ["wrapperSelector", "messageSelector", "hintSelector", "labelSelector", "autocomplete", "shortcuts", "confirm", "confirmDialog", "confirmDrawer", "confirmBrowser", "confirmTabs", "dirtySubmitButton", "submit", "successDelay", "errorDelay", "tabGroup"], outputs: ["fsForm", "invalid", "valid", "submitted", "reseted", "cleared"] }, { type: i7$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { type: i2.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { type: i17.DefaultLayoutDirective, selector: " [fxLayout], [fxLayout.xs], [fxLayout.sm], [fxLayout.md], [fxLayout.lg], [fxLayout.xl], [fxLayout.lt-sm], [fxLayout.lt-md], [fxLayout.lt-lg], [fxLayout.lt-xl], [fxLayout.gt-xs], [fxLayout.gt-sm], [fxLayout.gt-md], [fxLayout.gt-lg]", inputs: ["fxLayout", "fxLayout.xs", "fxLayout.sm", "fxLayout.md", "fxLayout.lg", "fxLayout.xl", "fxLayout.lt-sm", "fxLayout.lt-md", "fxLayout.lt-lg", "fxLayout.lt-xl", "fxLayout.gt-xs", "fxLayout.gt-sm", "fxLayout.gt-md", "fxLayout.gt-lg"] }, { type: i17.DefaultLayoutGapDirective, selector: " [fxLayoutGap], [fxLayoutGap.xs], [fxLayoutGap.sm], [fxLayoutGap.md], [fxLayoutGap.lg], [fxLayoutGap.xl], [fxLayoutGap.lt-sm], [fxLayoutGap.lt-md], [fxLayoutGap.lt-lg], [fxLayoutGap.lt-xl], [fxLayoutGap.gt-xs], [fxLayoutGap.gt-sm], [fxLayoutGap.gt-md], [fxLayoutGap.gt-lg]", inputs: ["fxLayoutGap", "fxLayoutGap.xs", "fxLayoutGap.sm", "fxLayoutGap.md", "fxLayoutGap.lg", "fxLayoutGap.xl", "fxLayoutGap.lt-sm", "fxLayoutGap.lt-md", "fxLayoutGap.lt-lg", "fxLayoutGap.lt-xl", "fxLayoutGap.gt-xs", "fxLayoutGap.gt-sm", "fxLayoutGap.gt-md", "fxLayoutGap.gt-lg"] }, { type: i17.DefaultFlexDirective, selector: " [fxFlex], [fxFlex.xs], [fxFlex.sm], [fxFlex.md], [fxFlex.lg], [fxFlex.xl], [fxFlex.lt-sm], [fxFlex.lt-md], [fxFlex.lt-lg], [fxFlex.lt-xl], [fxFlex.gt-xs], [fxFlex.gt-sm], [fxFlex.gt-md], [fxFlex.gt-lg]", inputs: ["fxFlex", "fxFlex.xs", "fxFlex.sm", "fxFlex.md", "fxFlex.lg", "fxFlex.xl", "fxFlex.lt-sm", "fxFlex.lt-md", "fxFlex.lt-lg", "fxFlex.lt-xl", "fxFlex.gt-xs", "fxFlex.gt-sm", "fxFlex.gt-md", "fxFlex.gt-lg"] }, { type: i18.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["id", "disabled", "required", "type", "value", "readonly", "placeholder", "errorStateMatcher", "aria-describedby"], exportAs: ["matInput"] }, { type: i14.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i15.FsFormRequiredDirective, selector: "[fsFormRequired],[ngModel][required]", inputs: ["fsFormRequired", "required", "fsFormRequiredMessage"] }, { type: i14.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i14.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i7$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i5.MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { type: i14.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i12.FsListColumnDirective, selector: "fs-list-column", inputs: ["title", "name", "show", "customize", "sortable", "sortableDefault", "direction", "align", "width", "class"] }, { type: i12.FsListGroupCellDirective, selector: "[fs-list-group-cell]" }, { type: i12.FsListCellDirective, selector: "[fs-list-cell]", inputs: ["colspan", "align", "class"] }, { type: i2.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]" }, { type: i15.FsSubmitButtonDirective, selector: "button[type=\"submit\"]", inputs: ["name", "dirtySubmit"] }, { type: i2.MatDialogClose, selector: "[mat-dialog-close], [matDialogClose]", inputs: ["type", "mat-dialog-close", "aria-label", "matDialogClose"], exportAs: ["matDialogClose"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
295
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsAclRoleComponent, decorators: [{
296
+ type: Component,
297
+ args: [{
298
+ templateUrl: './acl-role.component.html',
299
+ styleUrls: ['./acl-role.component.scss'],
300
+ changeDetection: ChangeDetectionStrategy.OnPush,
301
+ }]
302
+ }], ctorParameters: function () { return [{ type: FsAppAclService }, { type: i2.MatDialogRef }, { type: i3.FsMessage }, { type: undefined, decorators: [{
303
+ type: Inject,
304
+ args: [MAT_DIALOG_DATA]
305
+ }] }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { list: [{
306
+ type: ViewChild,
307
+ args: [FsListComponent]
308
+ }] } });
442
309
 
443
- let FsAclPermissionPopoverComponent = class FsAclPermissionPopoverComponent {
444
- constructor(_appAclService) {
445
- this._appAclService = _appAclService;
446
- }
447
- ngOnInit() {
448
- this._appAclService.getPermissions()
449
- .subscribe(permissions => {
450
- this.description = permissions.filter(item => {
451
- return item.value === this.permission.value;
452
- }).map(item => {
453
- return item.description;
454
- })[0];
455
- });
456
- }
457
- };
458
- FsAclPermissionPopoverComponent.ctorParameters = () => [
459
- { type: FsAppAclService }
460
- ];
461
- __decorate([
462
- Input(),
463
- __metadata("design:type", Object)
464
- ], FsAclPermissionPopoverComponent.prototype, "permission", void 0);
465
- FsAclPermissionPopoverComponent = __decorate([
466
- Component({
467
- selector: 'acl-permission-popover',
468
- template: "\n<fs-popover [template]=\"popover\" maxWidth=\"400\">\n <ng-content></ng-content>\n</fs-popover>\n\n<ng-template #popover>\n {{permission.name}}\n <div class=\"small\">{{description}}</div>\n</ng-template>\n\n",
469
- styles: [":host{cursor:pointer}"]
470
- }),
471
- __metadata("design:paramtypes", [FsAppAclService])
472
- ], FsAclPermissionPopoverComponent);
310
+ class FsAclPermissionPopoverComponent {
311
+ constructor(_appAclService) {
312
+ this._appAclService = _appAclService;
313
+ }
314
+ ngOnInit() {
315
+ this._appAclService.getPermissions()
316
+ .subscribe(permissions => {
317
+ this.description = permissions.filter(item => {
318
+ return item.value === this.permission.value;
319
+ }).map(item => {
320
+ return item.description;
321
+ })[0];
322
+ });
323
+ }
324
+ }
325
+ FsAclPermissionPopoverComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsAclPermissionPopoverComponent, deps: [{ token: FsAppAclService }], target: i0.ɵɵFactoryTarget.Component });
326
+ FsAclPermissionPopoverComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: FsAclPermissionPopoverComponent, selector: "acl-permission-popover", inputs: { permission: "permission" }, ngImport: i0, template: "\n<fs-popover [template]=\"popover\" maxWidth=\"400\">\n <ng-content></ng-content>\n</fs-popover>\n\n<ng-template #popover>\n {{permission.name}}\n <div class=\"small\">{{description}}</div>\n</ng-template>\n\n", styles: [":host{cursor:pointer}\n"], components: [{ type: i2$1.FsPopoverComponent, selector: "fs-popover", inputs: ["template", "data", "leaveDelay", "showDelay", "maxWidth", "wrapperClass", "autoShow", "autoClose", "loadingDiameter", "loading", "indication", "position", "theme", "size", "trigger"] }] });
327
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsAclPermissionPopoverComponent, decorators: [{
328
+ type: Component,
329
+ args: [{
330
+ selector: 'acl-permission-popover',
331
+ templateUrl: './acl-permission-popover.component.html',
332
+ styleUrls: ['./acl-permission-popover.component.scss']
333
+ }]
334
+ }], ctorParameters: function () { return [{ type: FsAppAclService }]; }, propDecorators: { permission: [{
335
+ type: Input
336
+ }] } });
473
337
 
474
- let FsAclRolePopoverComponent = class FsAclRolePopoverComponent {
475
- constructor(_appAclService) {
476
- this._appAclService = _appAclService;
477
- this.permissions = [];
478
- }
479
- ngOnInit() {
480
- const aclRolePermissions = this.aclRole.permissions || [];
481
- this._appAclService.getPermissions()
482
- .subscribe((response) => {
483
- this.permissions = response.filter(item => {
484
- return aclRolePermissions.some(permission => {
485
- return item.value === permission.value;
486
- });
487
- });
488
- });
489
- }
490
- };
491
- FsAclRolePopoverComponent.ctorParameters = () => [
492
- { type: FsAppAclService }
493
- ];
494
- __decorate([
495
- Input(),
496
- __metadata("design:type", Object)
497
- ], FsAclRolePopoverComponent.prototype, "aclRole", void 0);
498
- __decorate([
499
- Input(),
500
- __metadata("design:type", Object)
501
- ], FsAclRolePopoverComponent.prototype, "objectName", void 0);
502
- FsAclRolePopoverComponent = __decorate([
503
- Component({
504
- selector: 'fs-acl-role-popover',
505
- template: "\n<fs-popover [template]=\"popover\" maxWidth=\"400\">\n <ng-content></ng-content>\n</fs-popover>\n\n<ng-template #popover>\n <div class=\"name small\">{{aclRole.name}}<span *ngIf=\"objectName\">: {{objectName}}</span></div>\n\n <ng-container *ngIf=\"permissions.length; else nonePermission\">\n <div *ngFor=\"let permission of permissions\" class=\"permission\">\n <div>{{permission.name}}</div>\n <div class=\"small\">{{permission.description}}</div>\n </div>\n </ng-container>\n\n <ng-template #nonePermission>\n None\n </ng-template>\n</ng-template>\n",
506
- styles: [".name{padding-bottom:10px}.permission+.permission{padding-top:5px}:host{cursor:pointer}"]
507
- }),
508
- __metadata("design:paramtypes", [FsAppAclService])
509
- ], FsAclRolePopoverComponent);
338
+ class FsAclRolesComponent {
339
+ constructor(_appAclService, _dialog, _cdRef) {
340
+ this._appAclService = _appAclService;
341
+ this._dialog = _dialog;
342
+ this._cdRef = _cdRef;
343
+ this.aclLevels = [];
344
+ this.list = new QueryList();
345
+ this.indexedAclRoleLevels = {};
346
+ this._destroy$ = new Subject();
347
+ }
348
+ ngOnInit() {
349
+ new Observable(observer => {
350
+ if (this.aclLevels.length) {
351
+ observer.next(this.aclLevels);
352
+ observer.complete();
353
+ }
354
+ else {
355
+ this._appAclService.getLevels()
356
+ .subscribe((aclLevels) => {
357
+ observer.next(aclLevels);
358
+ observer.complete();
359
+ });
360
+ }
361
+ })
362
+ .subscribe((aclLevels) => {
363
+ this.aclLevels = aclLevels;
364
+ this.indexedAclRoleLevels = list(this.aclLevels, 'name', 'value');
365
+ this._loadListConfig();
366
+ });
367
+ }
368
+ openDialog(aclRole = { id: null }) {
369
+ const dialogRef = this._dialog.open(FsAclRoleComponent, {
370
+ width: '70%',
371
+ data: {
372
+ aclRole,
373
+ aclLevels: this.aclLevels,
374
+ loadAclRole: this.loadAclRole,
375
+ saveAclRole: this.saveAclRole,
376
+ },
377
+ });
378
+ dialogRef.afterClosed()
379
+ .pipe(takeUntil(this._destroy$), filter((response) => !!response))
380
+ .subscribe((response) => {
381
+ this.list.forEach((list) => {
382
+ list.reload();
383
+ });
384
+ });
385
+ }
386
+ ngOnDestroy() {
387
+ this._destroy$.next();
388
+ this._destroy$.complete();
389
+ }
390
+ _loadListConfig() {
391
+ this.listConfig = {
392
+ sort: { value: 'hierarchy' },
393
+ filters: [
394
+ {
395
+ name: 'keyword',
396
+ type: ItemType.Keyword,
397
+ label: 'Search',
398
+ },
399
+ {
400
+ name: 'level',
401
+ label: 'Level',
402
+ type: ItemType.Select,
403
+ values: this.aclLevels,
404
+ hide: this.aclLevels.length <= 1
405
+ },
406
+ {
407
+ name: 'state',
408
+ label: 'Show Deleted',
409
+ type: ItemType.Checkbox,
410
+ unchecked: 'active',
411
+ checked: 'deleted',
412
+ },
413
+ ],
414
+ actions: [
415
+ {
416
+ click: (event) => {
417
+ this.openDialog();
418
+ },
419
+ label: 'Create',
420
+ },
421
+ ],
422
+ rowActions: [
423
+ {
424
+ click: (data) => {
425
+ return this.deleteAclRole(this._appAclService.output(data));
426
+ },
427
+ remove: {
428
+ title: 'Confirm',
429
+ template: 'Are you sure you would like to delete this role?',
430
+ },
431
+ menu: true,
432
+ label: 'Delete',
433
+ show: (row) => row.state !== 'deleted',
434
+ },
435
+ ],
436
+ fetch: (query) => {
437
+ query.permissions = true;
438
+ return this.loadAclRoles(query)
439
+ .pipe(map((data) => this._appAclService.input(data)));
440
+ },
441
+ };
442
+ }
443
+ }
444
+ FsAclRolesComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsAclRolesComponent, deps: [{ token: FsAppAclService }, { token: i2.MatDialog }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
445
+ FsAclRolesComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: FsAclRolesComponent, selector: "fs-acl-roles", inputs: { deleteAclRole: "deleteAclRole", saveAclRole: "saveAclRole", loadAclRoles: "loadAclRoles", loadAclRole: "loadAclRole", aclLevels: "aclLevels" }, viewQueries: [{ propertyName: "list", predicate: FsListComponent, descendants: true }], ngImport: i0, template: "<fs-list [config]=\"listConfig\" *ngIf=\"listConfig\">\n <fs-list-column title=\"Name\" name=\"name\" [sortable]=\"true\">\n <ng-template fs-list-cell let-row=\"row\">\n <a (click)=\"openDialog(row)\">{{ row.name }}</a>\n </ng-template>\n </fs-list-column>\n <fs-list-column name=\"hierarchy\" title=\"Level\" [sortable]=\"true\">\n <ng-template fs-list-cell let-row=\"row\">\n {{ indexedAclRoleLevels[row.level] }}\n </ng-template>\n </fs-list-column>\n <fs-list-column title=\"Permissions\">\n <ng-template fs-list-cell let-row=\"row\">\n <div class=\"permissions\">\n <ng-container *ngFor=\"let permission of row.permissions\">\n <span *ngIf=\"permission.access\" class=\"permission\">\n <acl-permission-popover [permission]=\"permission\">{{permission.name}}</acl-permission-popover>\n </span>\n </ng-container>\n </div>\n </ng-template>\n </fs-list-column>\n</fs-list>\n", styles: [".permissions .permission+.permission:before{content:\", \"}\n"], components: [{ type: i12.FsListComponent, selector: "fs-list", inputs: ["config", "loaderLines"], outputs: ["filtersReady"] }, { type: FsAclPermissionPopoverComponent, selector: "acl-permission-popover", inputs: ["permission"] }], directives: [{ type: i7$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i12.FsListColumnDirective, selector: "fs-list-column", inputs: ["title", "name", "show", "customize", "sortable", "sortableDefault", "direction", "align", "width", "class"] }, { type: i12.FsListCellDirective, selector: "[fs-list-cell]", inputs: ["colspan", "align", "class"] }, { type: i7$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
446
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsAclRolesComponent, decorators: [{
447
+ type: Component,
448
+ args: [{
449
+ selector: 'fs-acl-roles',
450
+ templateUrl: 'acl-roles.component.html',
451
+ styleUrls: ['acl-roles.component.scss'],
452
+ changeDetection: ChangeDetectionStrategy.OnPush,
453
+ }]
454
+ }], ctorParameters: function () { return [{ type: FsAppAclService }, { type: i2.MatDialog }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { deleteAclRole: [{
455
+ type: Input
456
+ }], saveAclRole: [{
457
+ type: Input
458
+ }], loadAclRoles: [{
459
+ type: Input
460
+ }], loadAclRole: [{
461
+ type: Input
462
+ }], aclLevels: [{
463
+ type: Input
464
+ }], list: [{
465
+ type: ViewChildren,
466
+ args: [FsListComponent]
467
+ }] } });
510
468
 
511
- let FsAclEntryComponent = class FsAclEntryComponent {
512
- constructor(_appAclService, _dialogRef, _message, _data) {
513
- var _a;
514
- this._appAclService = _appAclService;
515
- this._dialogRef = _dialogRef;
516
- this._message = _message;
517
- this._data = _data;
518
- this.aclRoles = [];
519
- this.indexedAclRoleLevels = {};
520
- this.titleEdit = 'Edit Roles';
521
- this.titleAdd = 'Assign Roles';
522
- this.required = true;
523
- this.save = () => {
524
- return this._data.saveAclObjectEntry(this._appAclService.output(this.aclObjectEntry))
525
- .subscribe((data) => {
526
- this._message.success('Saved Changes');
527
- this.close(data);
528
- });
529
- };
530
- this.aclObjectEntry = Object.assign({}, _data.aclObjectEntry);
531
- this.required = (_a = _data.required, (_a !== null && _a !== void 0 ? _a : true));
532
- if (_data.titleEdit) {
533
- this.titleEdit = _data.titleEdit;
534
- }
535
- if (_data.titleAdd) {
536
- this.titleAdd = _data.titleAdd;
537
- }
538
- }
539
- ngOnInit() {
540
- forkJoin(this._data.loadAclRoles({
541
- level: this.aclObjectEntry.level,
542
- environmentId: this.aclObjectEntry.environmentId,
543
- })
544
- .pipe(map((data) => this._appAclService.input(data))), this._appAclService.getIndexedLevels())
545
- .subscribe(([aclRoles, levels,]) => {
546
- this.aclRoles = aclRoles;
547
- this.indexedAclRoleLevels = levels;
548
- this.aclObjectRole = {
549
- object: this.aclObjectEntry.object,
550
- aclRoles: this.aclObjectEntry.aclEntries
551
- .map((aclEntry) => {
552
- return aclEntry.aclRole;
553
- })
554
- };
555
- });
556
- }
557
- aclObjectRoleChange(aclObjectRoles) {
558
- this.aclObjectEntry.aclEntries = aclObjectRoles.reduce((aclEntries, aclObjectRole) => {
559
- aclObjectRole.aclRoles.forEach(aclRole => {
560
- aclEntries.push({
561
- aclRoleId: aclRole.id,
562
- aclRole: aclRole,
563
- objectId: aclObjectRole.object ? aclObjectRole.object.id : null,
564
- object: aclObjectRole.object || null
565
- });
566
- });
567
- return aclEntries;
568
- }, []);
569
- }
570
- close(data = null) {
571
- this._dialogRef.close(data);
572
- }
573
- };
574
- FsAclEntryComponent.ctorParameters = () => [
575
- { type: FsAppAclService },
576
- { type: MatDialogRef },
577
- { type: FsMessage },
578
- { type: undefined, decorators: [{ type: Inject, args: [MAT_DIALOG_DATA,] }] }
579
- ];
580
- FsAclEntryComponent = __decorate([
581
- Component({
582
- template: "<form fsForm [submit]=\"save\">\n <fs-dialog>\n <div mat-dialog-title>{{ titleEdit? titleEdit : titleAdd }}</div>\n <mat-dialog-content>\n <div *ngIf=\"aclObjectRole\">\n <fs-label-field *ngIf=\"aclObjectEntry.object\">\n <fs-label>{{indexedAclRoleLevels[aclObjectEntry.level]}}</fs-label>\n {{aclObjectEntry.object.name}}\n </fs-label-field>\n\n <fs-acl-object-roles\n [aclRoles]=\"aclRoles\"\n [aclObjectRoles]=\"[aclObjectRole]\"\n [required]=\"required\"\n (change)=\"aclObjectRoleChange($event)\">\n </fs-acl-object-roles>\n </div>\n </mat-dialog-content>\n <mat-dialog-actions>\n <button mat-button type=\"submit\" color=\"primary\">Save</button>\n <button mat-button mat-dialog-close type=\"button\">Cancel</button>\n </mat-dialog-actions>\n </fs-dialog>\n</form>\n",
583
- styles: ["::ng-deep .account-roles-autocomplete-panel .mat-option{line-height:normal}::ng-deep .account-roles-autocomplete-panel .mat-option .mat-option-text{display:flex;flex-direction:row;align-items:center}::ng-deep .account-roles-autocomplete-panel .mat-option .mat-option-text fs-badge{margin-right:5px}"]
584
- }),
585
- __param(3, Inject(MAT_DIALOG_DATA)),
586
- __metadata("design:paramtypes", [FsAppAclService,
587
- MatDialogRef,
588
- FsMessage, Object])
589
- ], FsAclEntryComponent);
469
+ class FsAclRolePopoverComponent {
470
+ constructor(_appAclService) {
471
+ this._appAclService = _appAclService;
472
+ this.permissions = [];
473
+ }
474
+ ngOnInit() {
475
+ const aclRolePermissions = this.aclRole.permissions || [];
476
+ this._appAclService.getPermissions()
477
+ .subscribe((response) => {
478
+ this.permissions = response.filter(item => {
479
+ return aclRolePermissions.some(permission => {
480
+ return item.value === permission.value;
481
+ });
482
+ });
483
+ });
484
+ }
485
+ }
486
+ FsAclRolePopoverComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsAclRolePopoverComponent, deps: [{ token: FsAppAclService }], target: i0.ɵɵFactoryTarget.Component });
487
+ FsAclRolePopoverComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: FsAclRolePopoverComponent, selector: "fs-acl-role-popover", inputs: { aclRole: "aclRole", objectName: "objectName" }, ngImport: i0, template: "\n<fs-popover [template]=\"popover\" maxWidth=\"400\">\n <ng-content></ng-content>\n</fs-popover>\n\n<ng-template #popover>\n <div class=\"name small\">{{aclRole.name}}<span *ngIf=\"objectName\">: {{objectName}}</span></div>\n\n <ng-container *ngIf=\"permissions.length; else nonePermission\">\n <div *ngFor=\"let permission of permissions\" class=\"permission\">\n <div>{{permission.name}}</div>\n <div class=\"small\">{{permission.description}}</div>\n </div>\n </ng-container>\n\n <ng-template #nonePermission>\n None\n </ng-template>\n</ng-template>\n", styles: [".name{padding-bottom:10px}.permission+.permission{padding-top:5px}:host{cursor:pointer}\n"], components: [{ type: i2$1.FsPopoverComponent, selector: "fs-popover", inputs: ["template", "data", "leaveDelay", "showDelay", "maxWidth", "wrapperClass", "autoShow", "autoClose", "loadingDiameter", "loading", "indication", "position", "theme", "size", "trigger"] }], directives: [{ type: i7$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i7$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
488
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsAclRolePopoverComponent, decorators: [{
489
+ type: Component,
490
+ args: [{
491
+ selector: 'fs-acl-role-popover',
492
+ templateUrl: './acl-role-popover.component.html',
493
+ styleUrls: ['./acl-role-popover.component.scss']
494
+ }]
495
+ }], ctorParameters: function () { return [{ type: FsAppAclService }]; }, propDecorators: { aclRole: [{
496
+ type: Input
497
+ }], objectName: [{
498
+ type: Input
499
+ }] } });
590
500
 
591
- let FsAclEntriesComponent = class FsAclEntriesComponent {
592
- constructor(_appAclService, _dialog, _confirm) {
593
- this._appAclService = _appAclService;
594
- this._dialog = _dialog;
595
- this._confirm = _confirm;
596
- this.environmentShow = true;
597
- this.environmentLabel = 'Environment';
598
- this.actions = [];
599
- this.aclEntriesList = null;
600
- this.aclEntriesConfig = null;
601
- this.permissions = [];
602
- this._destroy$ = new Subject();
603
- }
604
- ngOnInit() {
605
- this._appAclService.getPermissions()
606
- .subscribe(response => {
607
- this.permissions = response;
608
- });
609
- this.aclEntriesConfig = {
610
- status: false,
611
- paging: false,
612
- actions: this.actions,
613
- rowActions: [
614
- {
615
- label: 'Remove All Roles',
616
- click: (aclObjectEntry) => {
617
- this._confirm
618
- .confirm({
619
- title: 'Remove All Roles',
620
- template: 'Are you sure you would like to remove all roles?',
621
- }).subscribe(() => {
622
- const data = this._appAclService.output(Object.assign(Object.assign({}, aclObjectEntry), { aclEntries: [] }));
623
- this.saveAclObjectEntry(data)
624
- .subscribe(() => {
625
- this.aclEntriesList.reload();
626
- });
627
- });
628
- }
629
- }
630
- ],
631
- fetch: () => {
632
- return new Observable((observer) => {
633
- this.loadAclEntries({
634
- aclRoles: true,
635
- aclRolePermissions: true,
636
- objects: true,
637
- aclRoleState: 'active',
638
- })
639
- .pipe(map((response) => this._appAclService.input(response)))
640
- .subscribe((aclEntries) => {
641
- const objects = aclEntries.reduce((items, item) => {
642
- if (item.object) {
643
- items[item.object.id] = item.object;
644
- }
645
- return items;
646
- }, {});
647
- const environments = aclEntries.reduce((items, item) => {
648
- if (item.environment) {
649
- items[item.environment.id] = item.environment;
650
- }
651
- return items;
652
- }, {});
653
- let aclObjectEntry = [];
654
- const grouped = groupBy(aclEntries, (item) => {
655
- return [item.aclRole.level, item.environmentId, item.objectId];
656
- });
657
- forOwn(grouped, (group, key) => {
658
- key = key.split(',');
659
- aclObjectEntry.push({
660
- object: objects[key[2]],
661
- level: key[0],
662
- environmentId: key[1] ? parseInt(key[1]) : null,
663
- environment: environments[key[1]],
664
- aclEntries: group,
665
- });
666
- });
667
- const hasApp = aclObjectEntry.some((item) => {
668
- return item.aclEntries.some((entry) => {
669
- return !entry.objectId;
670
- });
671
- });
672
- if (!hasApp) {
673
- aclObjectEntry.unshift({
674
- object: null, aclEntries: [],
675
- level: 'app',
676
- environmentId: null,
677
- });
678
- }
679
- aclObjectEntry = sortBy(aclObjectEntry, (item) => {
680
- return item.object ? item.level : '';
681
- });
682
- observer.next({ data: aclObjectEntry });
683
- observer.complete();
684
- });
685
- });
686
- },
687
- };
688
- }
689
- update(aclObjectEntry) {
690
- const data = {
691
- aclObjectEntry: aclObjectEntry,
692
- required: false,
693
- loadAclRoles: this.loadAclRoles,
694
- saveAclObjectEntry: this.saveAclObjectEntry
695
- };
696
- this._dialog.open(FsAclEntryComponent, {
697
- data: data
698
- })
699
- .afterClosed()
700
- .pipe(takeUntil(this._destroy$))
701
- .subscribe(() => {
702
- this.aclEntriesList.reload();
703
- });
704
- }
705
- ngOnDestroy() {
706
- this._destroy$.next();
707
- this._destroy$.complete();
708
- }
709
- reload() {
710
- this.aclEntriesList.reload();
711
- }
712
- };
713
- FsAclEntriesComponent.ctorParameters = () => [
714
- { type: FsAppAclService },
715
- { type: MatDialog },
716
- { type: FsPrompt }
717
- ];
718
- __decorate([
719
- Input(),
720
- __metadata("design:type", Function)
721
- ], FsAclEntriesComponent.prototype, "loadAclEntries", void 0);
722
- __decorate([
723
- Input(),
724
- __metadata("design:type", Function)
725
- ], FsAclEntriesComponent.prototype, "loadAclRoles", void 0);
726
- __decorate([
727
- Input(),
728
- __metadata("design:type", Function)
729
- ], FsAclEntriesComponent.prototype, "saveAclObjectEntry", void 0);
730
- __decorate([
731
- Input(),
732
- __metadata("design:type", Object)
733
- ], FsAclEntriesComponent.prototype, "environmentShow", void 0);
734
- __decorate([
735
- Input(),
736
- __metadata("design:type", Object)
737
- ], FsAclEntriesComponent.prototype, "environmentLabel", void 0);
738
- __decorate([
739
- Input(),
740
- __metadata("design:type", Array)
741
- ], FsAclEntriesComponent.prototype, "actions", void 0);
742
- __decorate([
743
- ViewChild(FsListComponent),
744
- __metadata("design:type", FsListComponent)
745
- ], FsAclEntriesComponent.prototype, "aclEntriesList", void 0);
746
- FsAclEntriesComponent = __decorate([
747
- Component({
748
- selector: 'fs-acl-entries',
749
- template: "\n<fs-list [config]=\"aclEntriesConfig\">\n <fs-list-column>\n <ng-template fs-list-header>Context</ng-template>\n <ng-template fs-list-cell let-row=\"row\">\n <div\n *ngIf=\"row.object; else elseObject\"\n fxLayout=\"row\"\n fxLayoutAlign=\"start center\"\n fxLayoutGap=\"10px\">\n <fs-badge *ngIf=\"row.object.imageUrl\" shape=\"circle\" image=\"{{ row.object.imageUrl }}\"></fs-badge>\n <span>\n <div><small>{{ row.object.className }}</small></div>\n <a (click)=\"update(row)\">{{ row.object.name }}</a>\n </span>\n </div>\n\n <ng-template #elseObject>\n <a (click)=\"update(row)\">App</a>\n </ng-template>\n </ng-template>\n </fs-list-column>\n\n <fs-list-column [show]=\"environmentShow\">\n <ng-template fs-list-header>{{environmentLabel}}</ng-template>\n <ng-template fs-list-cell let-row=\"row\">\n {{row.environment?.name}}\n </ng-template>\n </fs-list-column>\n\n <fs-list-column>\n <ng-template fs-list-header>Roles</ng-template>\n <ng-template fs-list-cell let-row=\"row\">\n <div fxLayout=\"column\" fxLayoutGap=\"10px\">\n <div div *ngFor=\"let aclEntry of row.aclEntries\">\n <ng-container [ngSwitch]=\"row.level\">\n <ng-container *ngSwitchCase=\"'app'\">\n <fs-acl-role-popover [aclRole]=\"aclEntry.aclRole\" objectName=\"App\">{{aclEntry.aclRole.name}}</fs-acl-role-popover>\n </ng-container>\n <ng-container *ngSwitchDefault>\n <ng-container *ngIf=\"row.object\">\n <fs-acl-role-popover [aclRole]=\"aclEntry.aclRole\">{{aclEntry.aclRole.name}}</fs-acl-role-popover>\n </ng-container>\n </ng-container>\n </ng-container>\n </div>\n </div>\n </ng-template>\n </fs-list-column>\n</fs-list>\n",
750
- styles: [""]
751
- }),
752
- __metadata("design:paramtypes", [FsAppAclService,
753
- MatDialog,
754
- FsPrompt])
755
- ], FsAclEntriesComponent);
501
+ class FsAclObjectRolesComponent {
502
+ constructor() {
503
+ this.aclRoles = [];
504
+ this.required = false;
505
+ this.multiple = false;
506
+ this.disabled = false;
507
+ this.aclObjectRoles = [];
508
+ this.rolesLabel = 'Roles';
509
+ this.levelLabel = '';
510
+ this.change = new EventEmitter();
511
+ this.compareAclRole = (o1, o2) => {
512
+ return o1 && o2 && o1.id === o2.id;
513
+ };
514
+ }
515
+ changed() {
516
+ this.change.emit(this.aclObjectRoles);
517
+ }
518
+ }
519
+ FsAclObjectRolesComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsAclObjectRolesComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
520
+ FsAclObjectRolesComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: FsAclObjectRolesComponent, selector: "fs-acl-object-roles", inputs: { aclRoles: "aclRoles", required: "required", multiple: "multiple", disabled: "disabled", aclObjectRoles: "aclObjectRoles", rolesLabel: "rolesLabel", levelLabel: "levelLabel" }, outputs: { change: "change" }, ngImport: i0, template: "<ng-container *ngIf=\"!multiple\">\n <ng-container *ngFor=\"let aclObjectRole of aclObjectRoles\">\n <fs-checkbox-group\n [(ngModel)]=\"aclObjectRole.aclRoles\"\n (ngModelChange)=\"changed()\"\n name=\"roles\"\n [compareWith]=\"compareAclRole\"\n [disabled]=\"disabled\"\n [label]=\"rolesLabel\"\n [fsFormRequired]=\"required\"\n orientation=\"vertical\">\n <mat-checkbox [disabled]=\"disabled\" *ngFor=\"let aclRole of aclRoles\" [value]=\"aclRole\">\n {{ aclRole.name }}\n </mat-checkbox>\n </fs-checkbox-group>\n </ng-container>\n</ng-container>\n\n<ng-container *ngIf=\"multiple\">\n <table>\n <tr>\n <td>\n <small>{{levelLabel}}</small>\n </td>\n <td>\n <small>{{rolesLabel}}</small>\n </td>\n </tr>\n <tr *ngFor=\"let aclObjectRole of aclObjectRoles\">\n <td>{{aclObjectRole.object.name}}</td>\n <td>\n <mat-form-field class=\"form-field-padless\">\n <mat-select\n [(ngModel)]=\"aclObjectRole.aclRoles\"\n multiple=\"true\"\n [disabled]=\"disabled\"\n [compareWith]=\"compareAclRole\"\n (ngModelChange)=\"changed()\"\n name=\"aclRole_{{ aclObjectRole.object.id }}\">\n <mat-option *ngFor=\"let aclRole of aclRoles\" [value]=\"aclRole\">\n {{ aclRole.name }}\n </mat-option>\n </mat-select>\n </mat-form-field>\n </td>\n </tr>\n </table>\n</ng-container>\n", styles: ["table tr td:first-child{padding-right:15px}\n"], components: [{ type: i1.FsCheckboxGroupComponent, selector: "fs-checkbox-group", inputs: ["orientation", "position", "label", "disabled", "compareWith"], outputs: ["change"] }, { type: i9.MatCheckbox, selector: "mat-checkbox", inputs: ["disableRipple", "color", "tabIndex", "aria-label", "aria-labelledby", "id", "labelPosition", "name", "required", "checked", "disabled", "indeterminate", "aria-describedby", "value"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { type: i5.MatFormField, selector: "mat-form-field", inputs: ["color", "floatLabel", "appearance", "hideRequiredMarker", "hintLabel"], exportAs: ["matFormField"] }, { type: i10.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { type: i11.MatOption, selector: "mat-option", exportAs: ["matOption"] }], directives: [{ type: i7$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i7$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i14.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i14.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i15.FsFormRequiredDirective, selector: "[fsFormRequired],[ngModel][required]", inputs: ["fsFormRequired", "required", "fsFormRequiredMessage"] }], viewProviders: [{ provide: ControlContainer, useExisting: NgForm }] });
521
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsAclObjectRolesComponent, decorators: [{
522
+ type: Component,
523
+ args: [{
524
+ selector: 'fs-acl-object-roles',
525
+ templateUrl: './acl-object-roles.component.html',
526
+ styleUrls: ['./acl-object-roles.component.scss'],
527
+ viewProviders: [{ provide: ControlContainer, useExisting: NgForm }]
528
+ }]
529
+ }], propDecorators: { aclRoles: [{
530
+ type: Input
531
+ }], required: [{
532
+ type: Input
533
+ }], multiple: [{
534
+ type: Input
535
+ }], disabled: [{
536
+ type: Input
537
+ }], aclObjectRoles: [{
538
+ type: Input
539
+ }], rolesLabel: [{
540
+ type: Input
541
+ }], levelLabel: [{
542
+ type: Input
543
+ }], change: [{
544
+ type: Output
545
+ }] } });
756
546
 
757
- let FsAclObjectRolesComponent = class FsAclObjectRolesComponent {
758
- constructor() {
759
- this.aclRoles = [];
760
- this.required = false;
761
- this.multiple = false;
762
- this.disabled = false;
763
- this.aclObjectRoles = [];
764
- this.rolesLabel = 'Roles';
765
- this.levelLabel = '';
766
- this.change = new EventEmitter();
767
- this.compareAclRole = (o1, o2) => {
768
- return o1 && o2 && o1.id === o2.id;
769
- };
770
- }
771
- changed() {
772
- this.change.emit(this.aclObjectRoles);
773
- }
774
- };
775
- __decorate([
776
- Input(),
777
- __metadata("design:type", Array)
778
- ], FsAclObjectRolesComponent.prototype, "aclRoles", void 0);
779
- __decorate([
780
- Input(),
781
- __metadata("design:type", Object)
782
- ], FsAclObjectRolesComponent.prototype, "required", void 0);
783
- __decorate([
784
- Input(),
785
- __metadata("design:type", Object)
786
- ], FsAclObjectRolesComponent.prototype, "multiple", void 0);
787
- __decorate([
788
- Input(),
789
- __metadata("design:type", Object)
790
- ], FsAclObjectRolesComponent.prototype, "disabled", void 0);
791
- __decorate([
792
- Input(),
793
- __metadata("design:type", Array)
794
- ], FsAclObjectRolesComponent.prototype, "aclObjectRoles", void 0);
795
- __decorate([
796
- Input(),
797
- __metadata("design:type", Object)
798
- ], FsAclObjectRolesComponent.prototype, "rolesLabel", void 0);
799
- __decorate([
800
- Input(),
801
- __metadata("design:type", Object)
802
- ], FsAclObjectRolesComponent.prototype, "levelLabel", void 0);
803
- __decorate([
804
- Output(),
805
- __metadata("design:type", Object)
806
- ], FsAclObjectRolesComponent.prototype, "change", void 0);
807
- FsAclObjectRolesComponent = __decorate([
808
- Component({
809
- selector: 'fs-acl-object-roles',
810
- template: "<ng-container *ngIf=\"!multiple\">\n <ng-container *ngFor=\"let aclObjectRole of aclObjectRoles\">\n <fs-checkbox-group\n [(ngModel)]=\"aclObjectRole.aclRoles\"\n (ngModelChange)=\"changed()\"\n name=\"roles\"\n [compareWith]=\"compareAclRole\"\n [disabled]=\"disabled\"\n [label]=\"rolesLabel\"\n [fsFormRequired]=\"required\"\n orientation=\"vertical\">\n <mat-checkbox [disabled]=\"disabled\" *ngFor=\"let aclRole of aclRoles\" [value]=\"aclRole\">\n {{ aclRole.name }}\n </mat-checkbox>\n </fs-checkbox-group>\n </ng-container>\n</ng-container>\n\n<ng-container *ngIf=\"multiple\">\n <table>\n <tr>\n <td>\n <small>{{levelLabel}}</small>\n </td>\n <td>\n <small>{{rolesLabel}}</small>\n </td>\n </tr>\n <tr *ngFor=\"let aclObjectRole of aclObjectRoles\">\n <td>{{aclObjectRole.object.name}}</td>\n <td>\n <mat-form-field class=\"form-field-padless\">\n <mat-select\n [(ngModel)]=\"aclObjectRole.aclRoles\"\n multiple=\"true\"\n [disabled]=\"disabled\"\n [compareWith]=\"compareAclRole\"\n (ngModelChange)=\"changed()\"\n name=\"aclRole_{{ aclObjectRole.object.id }}\">\n <mat-option *ngFor=\"let aclRole of aclRoles\" [value]=\"aclRole\">\n {{ aclRole.name }}\n </mat-option>\n </mat-select>\n </mat-form-field>\n </td>\n </tr>\n </table>\n</ng-container>\n",
811
- viewProviders: [{ provide: ControlContainer, useExisting: NgForm }],
812
- styles: ["table tr td:first-child{padding-right:15px}"]
813
- })
814
- ], FsAclObjectRolesComponent);
547
+ class FsAclEntryComponent {
548
+ constructor(_appAclService, _dialogRef, _message, _data) {
549
+ var _a;
550
+ this._appAclService = _appAclService;
551
+ this._dialogRef = _dialogRef;
552
+ this._message = _message;
553
+ this._data = _data;
554
+ this.aclRoles = [];
555
+ this.indexedAclRoleLevels = {};
556
+ this.titleEdit = 'Edit Roles';
557
+ this.titleAdd = 'Assign Roles';
558
+ this.required = true;
559
+ this.save = () => {
560
+ return this._data.saveAclObjectEntry(this._appAclService.output(this.aclObjectEntry))
561
+ .subscribe((data) => {
562
+ this._message.success('Saved Changes');
563
+ this.close(data);
564
+ });
565
+ };
566
+ this.aclObjectEntry = Object.assign({}, _data.aclObjectEntry);
567
+ this.required = (_a = _data.required) !== null && _a !== void 0 ? _a : true;
568
+ if (_data.titleEdit) {
569
+ this.titleEdit = _data.titleEdit;
570
+ }
571
+ if (_data.titleAdd) {
572
+ this.titleAdd = _data.titleAdd;
573
+ }
574
+ }
575
+ ngOnInit() {
576
+ forkJoin(this._data.loadAclRoles({
577
+ level: this.aclObjectEntry.level,
578
+ environmentId: this.aclObjectEntry.environmentId,
579
+ })
580
+ .pipe(map((data) => this._appAclService.input(data))), this._appAclService.getIndexedLevels())
581
+ .subscribe(([aclRoles, levels,]) => {
582
+ this.aclRoles = aclRoles;
583
+ this.indexedAclRoleLevels = levels;
584
+ this.aclObjectRole = {
585
+ object: this.aclObjectEntry.object,
586
+ aclRoles: this.aclObjectEntry.aclEntries
587
+ .map((aclEntry) => {
588
+ return aclEntry.aclRole;
589
+ })
590
+ };
591
+ });
592
+ }
593
+ aclObjectRoleChange(aclObjectRoles) {
594
+ this.aclObjectEntry.aclEntries = aclObjectRoles.reduce((aclEntries, aclObjectRole) => {
595
+ aclObjectRole.aclRoles.forEach(aclRole => {
596
+ aclEntries.push({
597
+ aclRoleId: aclRole.id,
598
+ aclRole: aclRole,
599
+ objectId: aclObjectRole.object ? aclObjectRole.object.id : null,
600
+ object: aclObjectRole.object || null
601
+ });
602
+ });
603
+ return aclEntries;
604
+ }, []);
605
+ }
606
+ close(data = null) {
607
+ this._dialogRef.close(data);
608
+ }
609
+ }
610
+ FsAclEntryComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsAclEntryComponent, deps: [{ token: FsAppAclService }, { token: i2.MatDialogRef }, { token: i3.FsMessage }, { token: MAT_DIALOG_DATA }], target: i0.ɵɵFactoryTarget.Component });
611
+ FsAclEntryComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: FsAclEntryComponent, selector: "ng-component", ngImport: i0, template: "<form fsForm [submit]=\"save\">\n <fs-dialog>\n <div mat-dialog-title>{{ titleEdit? titleEdit : titleAdd }}</div>\n <mat-dialog-content>\n <div *ngIf=\"aclObjectRole\">\n <fs-label-field *ngIf=\"aclObjectEntry.object\">\n <fs-label>{{indexedAclRoleLevels[aclObjectEntry.level]}}</fs-label>\n {{aclObjectEntry.object.name}}\n </fs-label-field>\n\n <fs-acl-object-roles\n [aclRoles]=\"aclRoles\"\n [aclObjectRoles]=\"[aclObjectRole]\"\n [required]=\"required\"\n (change)=\"aclObjectRoleChange($event)\">\n </fs-acl-object-roles>\n </div>\n </mat-dialog-content>\n <mat-dialog-actions>\n <button mat-button type=\"submit\" color=\"primary\">Save</button>\n <button mat-button mat-dialog-close type=\"button\">Cancel</button>\n </mat-dialog-actions>\n </fs-dialog>\n</form>\n", styles: ["::ng-deep .account-roles-autocomplete-panel .mat-option{line-height:normal}::ng-deep .account-roles-autocomplete-panel .mat-option .mat-option-text{display:flex;flex-direction:row;align-items:center}::ng-deep .account-roles-autocomplete-panel .mat-option .mat-option-text fs-badge{margin-right:5px}\n"], components: [{ type: i4.FsDialogComponent, selector: "fs-dialog", inputs: ["mobileMode"] }, { type: i6.FsLabelFieldComponent, selector: "fs-label-field", inputs: ["bottomMargin", "topMargin", "labelMargin"] }, { type: i6.FsLabelComponent, selector: "fs-label" }, { type: FsAclObjectRolesComponent, selector: "fs-acl-object-roles", inputs: ["aclRoles", "required", "multiple", "disabled", "aclObjectRoles", "rolesLabel", "levelLabel"], outputs: ["change"] }, { type: i13.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i14.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i14.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i14.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i15.FsFormDirective, selector: "[fsForm]", inputs: ["wrapperSelector", "messageSelector", "hintSelector", "labelSelector", "autocomplete", "shortcuts", "confirm", "confirmDialog", "confirmDrawer", "confirmBrowser", "confirmTabs", "dirtySubmitButton", "submit", "successDelay", "errorDelay", "tabGroup"], outputs: ["fsForm", "invalid", "valid", "submitted", "reseted", "cleared"] }, { type: i2.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { type: i2.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { type: i7$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]" }, { type: i15.FsSubmitButtonDirective, selector: "button[type=\"submit\"]", inputs: ["name", "dirtySubmit"] }, { type: i2.MatDialogClose, selector: "[mat-dialog-close], [matDialogClose]", inputs: ["type", "mat-dialog-close", "aria-label", "matDialogClose"], exportAs: ["matDialogClose"] }] });
612
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsAclEntryComponent, decorators: [{
613
+ type: Component,
614
+ args: [{
615
+ templateUrl: './acl-entry.component.html',
616
+ styleUrls: ['./acl-entry.component.scss'],
617
+ }]
618
+ }], ctorParameters: function () { return [{ type: FsAppAclService }, { type: i2.MatDialogRef }, { type: i3.FsMessage }, { type: undefined, decorators: [{
619
+ type: Inject,
620
+ args: [MAT_DIALOG_DATA]
621
+ }] }]; } });
815
622
 
816
- var FsAppAclModule_1;
817
- let FsAppAclModule = FsAppAclModule_1 = class FsAppAclModule {
818
- static forRoot() {
819
- return {
820
- ngModule: FsAppAclModule_1,
821
- };
822
- }
823
- };
824
- FsAppAclModule = FsAppAclModule_1 = __decorate([
825
- NgModule({
826
- imports: [
827
- CommonModule,
828
- FormsModule,
829
- MatDialogModule,
830
- MatFormFieldModule,
831
- MatCheckboxModule,
832
- MatSelectModule,
833
- MatButtonModule,
834
- MatRadioModule,
835
- MatInputModule,
836
- FlexLayoutModule,
837
- FsListModule,
838
- FsPopoverModule,
839
- FsDialogModule,
840
- FsFormModule,
841
- FsLabelModule,
842
- FsRadioGroupModule,
843
- FsBadgeModule,
844
- FsCheckboxGroupModule,
845
- ],
846
- declarations: [
847
- FsAclRolesComponent,
848
- FsAclPermissionPopoverComponent,
849
- FsAclRoleComponent,
850
- FsAclEntriesComponent,
851
- FsAclRolePopoverComponent,
852
- FsAclObjectRolesComponent,
853
- FsAclEntryComponent,
854
- ],
855
- exports: [
856
- FsAclRolesComponent,
857
- FsAclPermissionPopoverComponent,
858
- FsAclRoleComponent,
859
- FsAclEntriesComponent,
860
- FsAclRolePopoverComponent,
861
- FsAclObjectRolesComponent,
862
- FsAclEntryComponent,
863
- ],
864
- entryComponents: [
865
- FsAclRoleComponent
866
- ]
867
- })
868
- ], FsAppAclModule);
623
+ class FsAclEntriesComponent {
624
+ constructor(_appAclService, _dialog, _confirm) {
625
+ this._appAclService = _appAclService;
626
+ this._dialog = _dialog;
627
+ this._confirm = _confirm;
628
+ this.environmentShow = true;
629
+ this.environmentLabel = 'Environment';
630
+ this.actions = [];
631
+ this.aclEntriesList = null;
632
+ this.aclEntriesConfig = null;
633
+ this.permissions = [];
634
+ this._destroy$ = new Subject();
635
+ }
636
+ ngOnInit() {
637
+ this._appAclService.getPermissions()
638
+ .subscribe(response => {
639
+ this.permissions = response;
640
+ });
641
+ this.aclEntriesConfig = {
642
+ status: false,
643
+ paging: false,
644
+ actions: this.actions,
645
+ rowActions: [
646
+ {
647
+ label: 'Remove All Roles',
648
+ click: (aclObjectEntry) => {
649
+ this._confirm
650
+ .confirm({
651
+ title: 'Remove All Roles',
652
+ template: 'Are you sure you would like to remove all roles?',
653
+ }).subscribe(() => {
654
+ const data = this._appAclService.output(Object.assign(Object.assign({}, aclObjectEntry), { aclEntries: [] }));
655
+ this.saveAclObjectEntry(data)
656
+ .subscribe(() => {
657
+ this.aclEntriesList.reload();
658
+ });
659
+ });
660
+ }
661
+ }
662
+ ],
663
+ fetch: () => {
664
+ return new Observable((observer) => {
665
+ this.loadAclEntries({
666
+ aclRoles: true,
667
+ aclRolePermissions: true,
668
+ objects: true,
669
+ aclRoleState: 'active',
670
+ })
671
+ .pipe(map((response) => this._appAclService.input(response)))
672
+ .subscribe((aclEntries) => {
673
+ const objects = aclEntries.reduce((items, item) => {
674
+ if (item.object) {
675
+ items[item.object.id] = item.object;
676
+ }
677
+ return items;
678
+ }, {});
679
+ const environments = aclEntries.reduce((items, item) => {
680
+ if (item.environment) {
681
+ items[item.environment.id] = item.environment;
682
+ }
683
+ return items;
684
+ }, {});
685
+ let aclObjectEntry = [];
686
+ const grouped = groupBy(aclEntries, (item) => {
687
+ return [item.aclRole.level, item.environmentId, item.objectId];
688
+ });
689
+ forOwn(grouped, (group, key) => {
690
+ key = key.split(',');
691
+ aclObjectEntry.push({
692
+ object: objects[key[2]],
693
+ level: key[0],
694
+ environmentId: key[1] ? parseInt(key[1]) : null,
695
+ environment: environments[key[1]],
696
+ aclEntries: group,
697
+ });
698
+ });
699
+ const hasApp = aclObjectEntry.some((item) => {
700
+ return item.aclEntries.some((entry) => {
701
+ return !entry.objectId;
702
+ });
703
+ });
704
+ if (!hasApp) {
705
+ aclObjectEntry.unshift({
706
+ object: null, aclEntries: [],
707
+ level: 'app',
708
+ environmentId: null,
709
+ });
710
+ }
711
+ aclObjectEntry = sortBy(aclObjectEntry, (item) => {
712
+ return item.object ? item.level : '';
713
+ });
714
+ observer.next({ data: aclObjectEntry });
715
+ observer.complete();
716
+ });
717
+ });
718
+ },
719
+ };
720
+ }
721
+ update(aclObjectEntry) {
722
+ const data = {
723
+ aclObjectEntry: aclObjectEntry,
724
+ required: false,
725
+ loadAclRoles: this.loadAclRoles,
726
+ saveAclObjectEntry: this.saveAclObjectEntry
727
+ };
728
+ this._dialog.open(FsAclEntryComponent, {
729
+ data: data
730
+ })
731
+ .afterClosed()
732
+ .pipe(takeUntil(this._destroy$))
733
+ .subscribe(() => {
734
+ this.aclEntriesList.reload();
735
+ });
736
+ }
737
+ ngOnDestroy() {
738
+ this._destroy$.next();
739
+ this._destroy$.complete();
740
+ }
741
+ reload() {
742
+ this.aclEntriesList.reload();
743
+ }
744
+ }
745
+ FsAclEntriesComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsAclEntriesComponent, deps: [{ token: FsAppAclService }, { token: i2.MatDialog }, { token: i3$1.FsPrompt }], target: i0.ɵɵFactoryTarget.Component });
746
+ FsAclEntriesComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: FsAclEntriesComponent, selector: "fs-acl-entries", inputs: { loadAclEntries: "loadAclEntries", loadAclRoles: "loadAclRoles", saveAclObjectEntry: "saveAclObjectEntry", environmentShow: "environmentShow", environmentLabel: "environmentLabel", actions: "actions" }, viewQueries: [{ propertyName: "aclEntriesList", first: true, predicate: FsListComponent, descendants: true }], ngImport: i0, template: "\n<fs-list [config]=\"aclEntriesConfig\">\n <fs-list-column>\n <ng-template fs-list-header>Context</ng-template>\n <ng-template fs-list-cell let-row=\"row\">\n <div\n *ngIf=\"row.object; else elseObject\"\n fxLayout=\"row\"\n fxLayoutAlign=\"start center\"\n fxLayoutGap=\"10px\">\n <fs-badge *ngIf=\"row.object.imageUrl\" shape=\"circle\" image=\"{{ row.object.imageUrl }}\"></fs-badge>\n <span>\n <div><small>{{ row.object.className }}</small></div>\n <a (click)=\"update(row)\">{{ row.object.name }}</a>\n </span>\n </div>\n\n <ng-template #elseObject>\n <a (click)=\"update(row)\">App</a>\n </ng-template>\n </ng-template>\n </fs-list-column>\n\n <fs-list-column [show]=\"environmentShow\">\n <ng-template fs-list-header>{{environmentLabel}}</ng-template>\n <ng-template fs-list-cell let-row=\"row\">\n {{row.environment?.name}}\n </ng-template>\n </fs-list-column>\n\n <fs-list-column>\n <ng-template fs-list-header>Roles</ng-template>\n <ng-template fs-list-cell let-row=\"row\">\n <div fxLayout=\"column\" fxLayoutGap=\"10px\">\n <div div *ngFor=\"let aclEntry of row.aclEntries\">\n <ng-container [ngSwitch]=\"row.level\">\n <ng-container *ngSwitchCase=\"'app'\">\n <fs-acl-role-popover [aclRole]=\"aclEntry.aclRole\" objectName=\"App\">{{aclEntry.aclRole.name}}</fs-acl-role-popover>\n </ng-container>\n <ng-container *ngSwitchDefault>\n <ng-container *ngIf=\"row.object\">\n <fs-acl-role-popover [aclRole]=\"aclEntry.aclRole\">{{aclEntry.aclRole.name}}</fs-acl-role-popover>\n </ng-container>\n </ng-container>\n </ng-container>\n </div>\n </div>\n </ng-template>\n </fs-list-column>\n</fs-list>\n", styles: [""], components: [{ type: i12.FsListComponent, selector: "fs-list", inputs: ["config", "loaderLines"], outputs: ["filtersReady"] }, { type: i5$1.FsBadgeComponent, selector: "fs-badge", inputs: ["color", "text", "tooltip", "size", "shape", "image", "icon", "iconSize", "iconColor", "backgroundSize"] }, { type: FsAclRolePopoverComponent, selector: "fs-acl-role-popover", inputs: ["aclRole", "objectName"] }], directives: [{ type: i12.FsListColumnDirective, selector: "fs-list-column", inputs: ["title", "name", "show", "customize", "sortable", "sortableDefault", "direction", "align", "width", "class"] }, { type: i12.FsListHeaderDirective, selector: "[fs-list-header]", inputs: ["colspan", "align", "class"] }, { type: i12.FsListCellDirective, selector: "[fs-list-cell]", inputs: ["colspan", "align", "class"] }, { type: i7$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i17.DefaultLayoutDirective, selector: " [fxLayout], [fxLayout.xs], [fxLayout.sm], [fxLayout.md], [fxLayout.lg], [fxLayout.xl], [fxLayout.lt-sm], [fxLayout.lt-md], [fxLayout.lt-lg], [fxLayout.lt-xl], [fxLayout.gt-xs], [fxLayout.gt-sm], [fxLayout.gt-md], [fxLayout.gt-lg]", inputs: ["fxLayout", "fxLayout.xs", "fxLayout.sm", "fxLayout.md", "fxLayout.lg", "fxLayout.xl", "fxLayout.lt-sm", "fxLayout.lt-md", "fxLayout.lt-lg", "fxLayout.lt-xl", "fxLayout.gt-xs", "fxLayout.gt-sm", "fxLayout.gt-md", "fxLayout.gt-lg"] }, { type: i17.DefaultLayoutAlignDirective, selector: " [fxLayoutAlign], [fxLayoutAlign.xs], [fxLayoutAlign.sm], [fxLayoutAlign.md], [fxLayoutAlign.lg], [fxLayoutAlign.xl], [fxLayoutAlign.lt-sm], [fxLayoutAlign.lt-md], [fxLayoutAlign.lt-lg], [fxLayoutAlign.lt-xl], [fxLayoutAlign.gt-xs], [fxLayoutAlign.gt-sm], [fxLayoutAlign.gt-md], [fxLayoutAlign.gt-lg]", inputs: ["fxLayoutAlign", "fxLayoutAlign.xs", "fxLayoutAlign.sm", "fxLayoutAlign.md", "fxLayoutAlign.lg", "fxLayoutAlign.xl", "fxLayoutAlign.lt-sm", "fxLayoutAlign.lt-md", "fxLayoutAlign.lt-lg", "fxLayoutAlign.lt-xl", "fxLayoutAlign.gt-xs", "fxLayoutAlign.gt-sm", "fxLayoutAlign.gt-md", "fxLayoutAlign.gt-lg"] }, { type: i17.DefaultLayoutGapDirective, selector: " [fxLayoutGap], [fxLayoutGap.xs], [fxLayoutGap.sm], [fxLayoutGap.md], [fxLayoutGap.lg], [fxLayoutGap.xl], [fxLayoutGap.lt-sm], [fxLayoutGap.lt-md], [fxLayoutGap.lt-lg], [fxLayoutGap.lt-xl], [fxLayoutGap.gt-xs], [fxLayoutGap.gt-sm], [fxLayoutGap.gt-md], [fxLayoutGap.gt-lg]", inputs: ["fxLayoutGap", "fxLayoutGap.xs", "fxLayoutGap.sm", "fxLayoutGap.md", "fxLayoutGap.lg", "fxLayoutGap.xl", "fxLayoutGap.lt-sm", "fxLayoutGap.lt-md", "fxLayoutGap.lt-lg", "fxLayoutGap.lt-xl", "fxLayoutGap.gt-xs", "fxLayoutGap.gt-sm", "fxLayoutGap.gt-md", "fxLayoutGap.gt-lg"] }, { type: i7$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i7$1.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i7$1.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i7$1.NgSwitchDefault, selector: "[ngSwitchDefault]" }] });
747
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsAclEntriesComponent, decorators: [{
748
+ type: Component,
749
+ args: [{
750
+ selector: 'fs-acl-entries',
751
+ templateUrl: './acl-entries.component.html',
752
+ styleUrls: ['./acl-entries.component.scss']
753
+ }]
754
+ }], ctorParameters: function () { return [{ type: FsAppAclService }, { type: i2.MatDialog }, { type: i3$1.FsPrompt }]; }, propDecorators: { loadAclEntries: [{
755
+ type: Input
756
+ }], loadAclRoles: [{
757
+ type: Input
758
+ }], saveAclObjectEntry: [{
759
+ type: Input
760
+ }], environmentShow: [{
761
+ type: Input
762
+ }], environmentLabel: [{
763
+ type: Input
764
+ }], actions: [{
765
+ type: Input
766
+ }], aclEntriesList: [{
767
+ type: ViewChild,
768
+ args: [FsListComponent]
769
+ }] } });
869
770
 
870
- // start:ng42.barrel
871
- // end:ng42.barrel
771
+ class FsAppAclModule {
772
+ }
773
+ FsAppAclModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsAppAclModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
774
+ FsAppAclModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsAppAclModule, declarations: [FsAclRolesComponent,
775
+ FsAclPermissionPopoverComponent,
776
+ FsAclRoleComponent,
777
+ FsAclEntriesComponent,
778
+ FsAclRolePopoverComponent,
779
+ FsAclObjectRolesComponent,
780
+ FsAclEntryComponent], imports: [CommonModule,
781
+ FormsModule,
782
+ MatDialogModule,
783
+ MatFormFieldModule,
784
+ MatCheckboxModule,
785
+ MatSelectModule,
786
+ MatButtonModule,
787
+ MatRadioModule,
788
+ MatInputModule,
789
+ FlexLayoutModule,
790
+ FsListModule,
791
+ FsPopoverModule,
792
+ FsDialogModule,
793
+ FsFormModule,
794
+ FsLabelModule,
795
+ FsRadioGroupModule,
796
+ FsBadgeModule,
797
+ FsCheckboxGroupModule], exports: [FsAclRolesComponent,
798
+ FsAclPermissionPopoverComponent,
799
+ FsAclRoleComponent,
800
+ FsAclEntriesComponent,
801
+ FsAclRolePopoverComponent,
802
+ FsAclObjectRolesComponent,
803
+ FsAclEntryComponent] });
804
+ FsAppAclModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsAppAclModule, imports: [[
805
+ CommonModule,
806
+ FormsModule,
807
+ MatDialogModule,
808
+ MatFormFieldModule,
809
+ MatCheckboxModule,
810
+ MatSelectModule,
811
+ MatButtonModule,
812
+ MatRadioModule,
813
+ MatInputModule,
814
+ FlexLayoutModule,
815
+ FsListModule,
816
+ FsPopoverModule,
817
+ FsDialogModule,
818
+ FsFormModule,
819
+ FsLabelModule,
820
+ FsRadioGroupModule,
821
+ FsBadgeModule,
822
+ FsCheckboxGroupModule,
823
+ ]] });
824
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsAppAclModule, decorators: [{
825
+ type: NgModule,
826
+ args: [{
827
+ imports: [
828
+ CommonModule,
829
+ FormsModule,
830
+ MatDialogModule,
831
+ MatFormFieldModule,
832
+ MatCheckboxModule,
833
+ MatSelectModule,
834
+ MatButtonModule,
835
+ MatRadioModule,
836
+ MatInputModule,
837
+ FlexLayoutModule,
838
+ FsListModule,
839
+ FsPopoverModule,
840
+ FsDialogModule,
841
+ FsFormModule,
842
+ FsLabelModule,
843
+ FsRadioGroupModule,
844
+ FsBadgeModule,
845
+ FsCheckboxGroupModule,
846
+ ],
847
+ declarations: [
848
+ FsAclRolesComponent,
849
+ FsAclPermissionPopoverComponent,
850
+ FsAclRoleComponent,
851
+ FsAclEntriesComponent,
852
+ FsAclRolePopoverComponent,
853
+ FsAclObjectRolesComponent,
854
+ FsAclEntryComponent,
855
+ ],
856
+ exports: [
857
+ FsAclRolesComponent,
858
+ FsAclPermissionPopoverComponent,
859
+ FsAclRoleComponent,
860
+ FsAclEntriesComponent,
861
+ FsAclRolePopoverComponent,
862
+ FsAclObjectRolesComponent,
863
+ FsAclEntryComponent,
864
+ ],
865
+ }]
866
+ }] });
872
867
 
873
- /**
874
- * Generated bundle index. Do not edit.
868
+ /**
869
+ * Generated bundle index. Do not edit.
875
870
  */
876
871
 
877
- export { FS_APP_ACL_CONFIG, FsAclEntriesComponent, FsAclRolesComponent, FsAppAclModule, FsAppAclService, FsAppAclService as ɵa, FsAclPermissionPopoverComponent as ɵb, FsAclRoleComponent as ɵc, FsAclRolePopoverComponent as ɵd, FsAclObjectRolesComponent as ɵe, FsAclEntryComponent as ɵf };
872
+ export { FS_APP_ACL_CONFIG, FsAclEntriesComponent, FsAclEntryComponent, FsAclObjectRolesComponent, FsAclPermissionPopoverComponent, FsAclRoleComponent, FsAclRolePopoverComponent, FsAclRolesComponent, FsAppAclModule, FsAppAclService };
878
873
  //# sourceMappingURL=firestitch-app-acl.js.map