@flusys/ng-iam 1.1.1-beta → 1.2.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -1027
- package/fesm2022/flusys-ng-iam-action-form-page.component-Vc5Toouu.mjs +502 -0
- package/fesm2022/flusys-ng-iam-action-form-page.component-Vc5Toouu.mjs.map +1 -0
- package/fesm2022/flusys-ng-iam-action-list-page.component-UGKclpFx.mjs +348 -0
- package/fesm2022/flusys-ng-iam-action-list-page.component-UGKclpFx.mjs.map +1 -0
- package/fesm2022/flusys-ng-iam-flusys-ng-iam-CrycDULz.mjs +4561 -0
- package/fesm2022/flusys-ng-iam-flusys-ng-iam-CrycDULz.mjs.map +1 -0
- package/fesm2022/flusys-ng-iam-iam-container.component-D0m8u6nu.mjs +105 -0
- package/fesm2022/flusys-ng-iam-iam-container.component-D0m8u6nu.mjs.map +1 -0
- package/fesm2022/flusys-ng-iam-permission-page.component-x88X4AgJ.mjs +143 -0
- package/fesm2022/flusys-ng-iam-permission-page.component-x88X4AgJ.mjs.map +1 -0
- package/fesm2022/flusys-ng-iam-role-form-page.component-InsxdriD.mjs +335 -0
- package/fesm2022/flusys-ng-iam-role-form-page.component-InsxdriD.mjs.map +1 -0
- package/fesm2022/flusys-ng-iam-role-list-page.component-8NGXCeSZ.mjs +389 -0
- package/fesm2022/flusys-ng-iam-role-list-page.component-8NGXCeSZ.mjs.map +1 -0
- package/fesm2022/flusys-ng-iam.mjs +1 -1
- package/package.json +11 -10
- package/types/flusys-ng-iam.d.ts +107 -686
- package/fesm2022/flusys-ng-iam-action-form-page.component-C1j10Qhw.mjs +0 -467
- package/fesm2022/flusys-ng-iam-action-form-page.component-C1j10Qhw.mjs.map +0 -1
- package/fesm2022/flusys-ng-iam-action-list-page.component-BCzSardO.mjs +0 -281
- package/fesm2022/flusys-ng-iam-action-list-page.component-BCzSardO.mjs.map +0 -1
- package/fesm2022/flusys-ng-iam-flusys-ng-iam-DISrddPh.mjs +0 -4940
- package/fesm2022/flusys-ng-iam-flusys-ng-iam-DISrddPh.mjs.map +0 -1
- package/fesm2022/flusys-ng-iam-iam-container.component-BkhqmzLi.mjs +0 -97
- package/fesm2022/flusys-ng-iam-iam-container.component-BkhqmzLi.mjs.map +0 -1
- package/fesm2022/flusys-ng-iam-permission-page.component-BSQFPt_N.mjs +0 -143
- package/fesm2022/flusys-ng-iam-permission-page.component-BSQFPt_N.mjs.map +0 -1
- package/fesm2022/flusys-ng-iam-role-form-page.component-Cqziu_BM.mjs +0 -314
- package/fesm2022/flusys-ng-iam-role-form-page.component-Cqziu_BM.mjs.map +0 -1
- package/fesm2022/flusys-ng-iam-role-list-page.component-BObCxHiB.mjs +0 -266
- package/fesm2022/flusys-ng-iam-role-list-page.component-BObCxHiB.mjs.map +0 -1
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, signal, effect, untracked, Component } from '@angular/core';
|
|
3
|
+
import { Router } from '@angular/router';
|
|
4
|
+
import { LAYOUT_AUTH_STATE } from '@flusys/ng-layout';
|
|
5
|
+
import * as i2 from '@flusys/ng-ui';
|
|
6
|
+
import { MessageService, ConfirmationService, UiModule } from '@flusys/ng-ui';
|
|
7
|
+
import { ACTION_PERMISSIONS, TranslateService, AngularModule, HasPermissionDirective, TranslatePipe } from '@flusys/ng-shared';
|
|
8
|
+
import { firstValueFrom } from 'rxjs';
|
|
9
|
+
import { A as ActionApiService, a as ActionType, c as convertActionToTreeNode } from './flusys-ng-iam-flusys-ng-iam-CrycDULz.mjs';
|
|
10
|
+
|
|
11
|
+
class ActionListPageComponent {
|
|
12
|
+
ACTION_PERMISSIONS = ACTION_PERMISSIONS;
|
|
13
|
+
router = inject(Router);
|
|
14
|
+
companyContext = inject(LAYOUT_AUTH_STATE);
|
|
15
|
+
actionApi = inject(ActionApiService);
|
|
16
|
+
messageService = inject(MessageService);
|
|
17
|
+
confirmationService = inject(ConfirmationService);
|
|
18
|
+
translateAdapter = inject(TranslateService, {
|
|
19
|
+
optional: true,
|
|
20
|
+
});
|
|
21
|
+
isLoading = signal(false, /* @ts-ignore */
|
|
22
|
+
...(ngDevMode ? [{ debugName: "isLoading" }] : /* istanbul ignore next */ []));
|
|
23
|
+
treeNodes = signal([], /* @ts-ignore */
|
|
24
|
+
...(ngDevMode ? [{ debugName: "treeNodes" }] : /* istanbul ignore next */ []));
|
|
25
|
+
translate(key, vars) {
|
|
26
|
+
return this.translateAdapter?.translate(key, vars) ?? key;
|
|
27
|
+
}
|
|
28
|
+
static TYPE_SEVERITIES = {
|
|
29
|
+
[ActionType.BACKEND]: 'info',
|
|
30
|
+
[ActionType.FRONTEND]: 'success',
|
|
31
|
+
[ActionType.BOTH]: 'warn',
|
|
32
|
+
};
|
|
33
|
+
static TYPE_LABEL_KEYS = {
|
|
34
|
+
[ActionType.BACKEND]: 'iam.action.type.backend',
|
|
35
|
+
[ActionType.FRONTEND]: 'iam.action.type.frontend',
|
|
36
|
+
[ActionType.BOTH]: 'iam.action.type.both',
|
|
37
|
+
};
|
|
38
|
+
constructor() {
|
|
39
|
+
effect(() => {
|
|
40
|
+
this.companyContext.currentCompanyInfo();
|
|
41
|
+
untracked(() => this.loadActions());
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
async loadActions() {
|
|
45
|
+
this.isLoading.set(true);
|
|
46
|
+
try {
|
|
47
|
+
const response = await firstValueFrom(this.actionApi.getTree());
|
|
48
|
+
this.treeNodes.set(convertActionToTreeNode(response?.success ? (response.data ?? []) : []));
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// Handled by global interceptor
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
this.isLoading.set(false);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
getActionTypeLabel(type) {
|
|
58
|
+
const key = ActionListPageComponent.TYPE_LABEL_KEYS[type] ?? 'shared.unknown';
|
|
59
|
+
return this.translate(key);
|
|
60
|
+
}
|
|
61
|
+
getActionTypeSeverity(type) {
|
|
62
|
+
return ActionListPageComponent.TYPE_SEVERITIES[type] ?? 'info';
|
|
63
|
+
}
|
|
64
|
+
onCreate() {
|
|
65
|
+
this.router.navigate(['/iam/actions/new']);
|
|
66
|
+
}
|
|
67
|
+
onEdit(action) {
|
|
68
|
+
this.router.navigate(['/iam/actions', action.id]);
|
|
69
|
+
}
|
|
70
|
+
onDelete(action) {
|
|
71
|
+
if (!action?.id || !action?.name)
|
|
72
|
+
return;
|
|
73
|
+
this.confirmationService.confirm({
|
|
74
|
+
message: this.translate('shared.confirm.delete.item', {
|
|
75
|
+
name: action.name,
|
|
76
|
+
}),
|
|
77
|
+
header: this.translate('iam.action.delete.title'),
|
|
78
|
+
icon: 'exclamation-triangle',
|
|
79
|
+
accept: async () => {
|
|
80
|
+
try {
|
|
81
|
+
const response = await this.actionApi.delete({
|
|
82
|
+
id: action.id,
|
|
83
|
+
type: 'delete',
|
|
84
|
+
});
|
|
85
|
+
await this.loadActions();
|
|
86
|
+
this.messageService.add({
|
|
87
|
+
severity: 'success',
|
|
88
|
+
summary: this.translate('shared.success'),
|
|
89
|
+
detail: response?.messageKey
|
|
90
|
+
? this.translate(response.messageKey, response.messageVariables)
|
|
91
|
+
: (response?.message ?? ''),
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
// Handled by global interceptor
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ActionListPageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
101
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.6", type: ActionListPageComponent, isStandalone: true, selector: "lib-action-list-page", ngImport: i0, template: `
|
|
102
|
+
<div class="card">
|
|
103
|
+
<div
|
|
104
|
+
class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-3 mb-4"
|
|
105
|
+
>
|
|
106
|
+
<h3 class="text-lg sm:text-xl font-semibold">
|
|
107
|
+
{{ 'iam.action.title' | translate }}
|
|
108
|
+
</h3>
|
|
109
|
+
<button
|
|
110
|
+
fButton
|
|
111
|
+
*hasPermission="ACTION_PERMISSIONS.CREATE"
|
|
112
|
+
(click)="onCreate()"
|
|
113
|
+
class="w-full sm:w-auto"
|
|
114
|
+
>
|
|
115
|
+
<ui-icon pButtonIcon name="plus"></ui-icon>
|
|
116
|
+
<span pButtonLabel>{{ 'iam.action.new' | translate }}</span>
|
|
117
|
+
</button>
|
|
118
|
+
</div>
|
|
119
|
+
|
|
120
|
+
<div class="overflow-x-auto -mx-4 sm:mx-0">
|
|
121
|
+
<f-treetable
|
|
122
|
+
[value]="treeNodes()"
|
|
123
|
+
[loading]="isLoading()"
|
|
124
|
+
dataKey="id"
|
|
125
|
+
[tableStyle]="{ 'min-width': '50rem' }"
|
|
126
|
+
>
|
|
127
|
+
<ng-template #header>
|
|
128
|
+
<tr>
|
|
129
|
+
<th>{{ 'iam.action.name' | translate }}</th>
|
|
130
|
+
<th class="hidden md:table-cell">
|
|
131
|
+
{{ 'iam.action.code' | translate }}
|
|
132
|
+
</th>
|
|
133
|
+
<th>{{ 'iam.action.type' | translate }}</th>
|
|
134
|
+
<th class="hidden sm:table-cell">
|
|
135
|
+
{{ 'shared.active' | translate }}
|
|
136
|
+
</th>
|
|
137
|
+
<th class="hidden lg:table-cell">
|
|
138
|
+
{{ 'shared.read.only' | translate }}
|
|
139
|
+
</th>
|
|
140
|
+
<th class="w-[100px]">{{ 'shared.actions' | translate }}</th>
|
|
141
|
+
</tr>
|
|
142
|
+
</ng-template>
|
|
143
|
+
<ng-template #body let-rowNode let-rowData="rowData">
|
|
144
|
+
<tr>
|
|
145
|
+
<td>
|
|
146
|
+
<f-treetabletoggler [rowNode]="rowNode" />
|
|
147
|
+
{{ rowData.name }}
|
|
148
|
+
</td>
|
|
149
|
+
<td class="hidden md:table-cell">{{ rowData.code ?? '-' }}</td>
|
|
150
|
+
<td>
|
|
151
|
+
<f-tag
|
|
152
|
+
[value]="getActionTypeLabel(rowData.actionType)"
|
|
153
|
+
[severity]="getActionTypeSeverity(rowData.actionType)"
|
|
154
|
+
/>
|
|
155
|
+
</td>
|
|
156
|
+
<td class="hidden sm:table-cell">
|
|
157
|
+
<f-tag
|
|
158
|
+
[value]="
|
|
159
|
+
rowData.isActive
|
|
160
|
+
? ('shared.active' | translate)
|
|
161
|
+
: ('shared.inactive' | translate)
|
|
162
|
+
"
|
|
163
|
+
[severity]="rowData.isActive ? 'success' : 'secondary'"
|
|
164
|
+
/>
|
|
165
|
+
</td>
|
|
166
|
+
<td class="hidden lg:table-cell">
|
|
167
|
+
<f-tag
|
|
168
|
+
[value]="
|
|
169
|
+
rowData.readOnly
|
|
170
|
+
? ('shared.yes' | translate)
|
|
171
|
+
: ('shared.no' | translate)
|
|
172
|
+
"
|
|
173
|
+
[severity]="rowData.readOnly ? 'warn' : 'secondary'"
|
|
174
|
+
/>
|
|
175
|
+
</td>
|
|
176
|
+
<td>
|
|
177
|
+
<div class="flex gap-1">
|
|
178
|
+
<button
|
|
179
|
+
fButton
|
|
180
|
+
*hasPermission="ACTION_PERMISSIONS.UPDATE"
|
|
181
|
+
[text]="true"
|
|
182
|
+
severity="secondary"
|
|
183
|
+
size="small"
|
|
184
|
+
[disabled]="rowData.readOnly"
|
|
185
|
+
[fTooltip]="'shared.edit' | translate"
|
|
186
|
+
(click)="onEdit(rowData)"
|
|
187
|
+
>
|
|
188
|
+
<ui-icon pButtonIcon name="pencil"></ui-icon>
|
|
189
|
+
</button>
|
|
190
|
+
<button
|
|
191
|
+
fButton
|
|
192
|
+
*hasPermission="ACTION_PERMISSIONS.DELETE"
|
|
193
|
+
[text]="true"
|
|
194
|
+
severity="danger"
|
|
195
|
+
size="small"
|
|
196
|
+
[fTooltip]="'shared.delete' | translate"
|
|
197
|
+
[disabled]="rowData.readOnly"
|
|
198
|
+
(click)="onDelete(rowData)"
|
|
199
|
+
>
|
|
200
|
+
<ui-icon pButtonIcon name="trash"></ui-icon>
|
|
201
|
+
</button>
|
|
202
|
+
</div>
|
|
203
|
+
</td>
|
|
204
|
+
</tr>
|
|
205
|
+
</ng-template>
|
|
206
|
+
<ng-template #emptymessage>
|
|
207
|
+
<tr>
|
|
208
|
+
<td colspan="6" class="text-center py-4 text-muted-color">
|
|
209
|
+
{{ 'iam.action.no.actions' | translate }}
|
|
210
|
+
</td>
|
|
211
|
+
</tr>
|
|
212
|
+
</ng-template>
|
|
213
|
+
</f-treetable>
|
|
214
|
+
</div>
|
|
215
|
+
</div>
|
|
216
|
+
`, isInline: true, dependencies: [{ kind: "ngmodule", type: AngularModule }, { kind: "ngmodule", type: UiModule }, { kind: "directive", type: i2.FButtonDirective, selector: "[fButton]", inputs: ["severity", "text", "outlined", "link", "variant", "rounded", "raised", "fluid", "disabled", "loading", "loadingIcon", "size", "label", "icon", "iconPos", "ariaLabel", "plain"] }, { kind: "component", type: i2.TagComponent, selector: "f-tag", inputs: ["value", "severity", "icon", "rounded", "color", "styleClass", "style"] }, { kind: "directive", type: i2.TooltipDirective, selector: "[fTooltip]", inputs: ["fTooltip", "tooltipPosition", "positionStyle", "tooltipStyleClass", "disabled", "tooltipEvent", "showDelay", "hideDelay", "life", "autoHide", "positionTop", "positionLeft", "escape"] }, { kind: "component", type: i2.TreeTableComponent, selector: "f-treetable", inputs: ["value", "loading", "dataKey", "styleClass", "tableStyle", "scrollable", "scrollHeight", "resizableColumns", "lazy", "totalRecords", "paginator", "first", "rows", "rowsPerPageOptions", "showCurrentPageReport", "currentPageReportTemplate", "globalFilterFields", "filterDelay", "selectionMode", "sortMode", "virtualScroll", "virtualScrollItemSize", "sortField", "sortOrder", "multiSortMeta", "filters", "selection", "contextMenuSelection"], outputs: ["sortFieldChange", "sortOrderChange", "multiSortMetaChange", "filtersChange", "selectionChange", "contextMenuSelectionChange", "onLazyLoad", "onSort", "onFilter", "onNodeExpand", "onNodeCollapse", "onNodeSelect", "onNodeUnselect", "onRowContextMenu"] }, { kind: "component", type: i2.TreeTableTogglerComponent, selector: "f-treetabletoggler", inputs: ["rowNode"] }, { kind: "component", type: i2.UiIconComponent, selector: "ui-icon", inputs: ["name", "size", "spin", "fill", "severity"] }, { kind: "directive", type: HasPermissionDirective, selector: "[hasPermission]", inputs: ["hasPermission"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }] });
|
|
217
|
+
}
|
|
218
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ActionListPageComponent, decorators: [{
|
|
219
|
+
type: Component,
|
|
220
|
+
args: [{
|
|
221
|
+
selector: 'lib-action-list-page',
|
|
222
|
+
imports: [
|
|
223
|
+
AngularModule,
|
|
224
|
+
UiModule,
|
|
225
|
+
HasPermissionDirective,
|
|
226
|
+
TranslatePipe,
|
|
227
|
+
],
|
|
228
|
+
template: `
|
|
229
|
+
<div class="card">
|
|
230
|
+
<div
|
|
231
|
+
class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-3 mb-4"
|
|
232
|
+
>
|
|
233
|
+
<h3 class="text-lg sm:text-xl font-semibold">
|
|
234
|
+
{{ 'iam.action.title' | translate }}
|
|
235
|
+
</h3>
|
|
236
|
+
<button
|
|
237
|
+
fButton
|
|
238
|
+
*hasPermission="ACTION_PERMISSIONS.CREATE"
|
|
239
|
+
(click)="onCreate()"
|
|
240
|
+
class="w-full sm:w-auto"
|
|
241
|
+
>
|
|
242
|
+
<ui-icon pButtonIcon name="plus"></ui-icon>
|
|
243
|
+
<span pButtonLabel>{{ 'iam.action.new' | translate }}</span>
|
|
244
|
+
</button>
|
|
245
|
+
</div>
|
|
246
|
+
|
|
247
|
+
<div class="overflow-x-auto -mx-4 sm:mx-0">
|
|
248
|
+
<f-treetable
|
|
249
|
+
[value]="treeNodes()"
|
|
250
|
+
[loading]="isLoading()"
|
|
251
|
+
dataKey="id"
|
|
252
|
+
[tableStyle]="{ 'min-width': '50rem' }"
|
|
253
|
+
>
|
|
254
|
+
<ng-template #header>
|
|
255
|
+
<tr>
|
|
256
|
+
<th>{{ 'iam.action.name' | translate }}</th>
|
|
257
|
+
<th class="hidden md:table-cell">
|
|
258
|
+
{{ 'iam.action.code' | translate }}
|
|
259
|
+
</th>
|
|
260
|
+
<th>{{ 'iam.action.type' | translate }}</th>
|
|
261
|
+
<th class="hidden sm:table-cell">
|
|
262
|
+
{{ 'shared.active' | translate }}
|
|
263
|
+
</th>
|
|
264
|
+
<th class="hidden lg:table-cell">
|
|
265
|
+
{{ 'shared.read.only' | translate }}
|
|
266
|
+
</th>
|
|
267
|
+
<th class="w-[100px]">{{ 'shared.actions' | translate }}</th>
|
|
268
|
+
</tr>
|
|
269
|
+
</ng-template>
|
|
270
|
+
<ng-template #body let-rowNode let-rowData="rowData">
|
|
271
|
+
<tr>
|
|
272
|
+
<td>
|
|
273
|
+
<f-treetabletoggler [rowNode]="rowNode" />
|
|
274
|
+
{{ rowData.name }}
|
|
275
|
+
</td>
|
|
276
|
+
<td class="hidden md:table-cell">{{ rowData.code ?? '-' }}</td>
|
|
277
|
+
<td>
|
|
278
|
+
<f-tag
|
|
279
|
+
[value]="getActionTypeLabel(rowData.actionType)"
|
|
280
|
+
[severity]="getActionTypeSeverity(rowData.actionType)"
|
|
281
|
+
/>
|
|
282
|
+
</td>
|
|
283
|
+
<td class="hidden sm:table-cell">
|
|
284
|
+
<f-tag
|
|
285
|
+
[value]="
|
|
286
|
+
rowData.isActive
|
|
287
|
+
? ('shared.active' | translate)
|
|
288
|
+
: ('shared.inactive' | translate)
|
|
289
|
+
"
|
|
290
|
+
[severity]="rowData.isActive ? 'success' : 'secondary'"
|
|
291
|
+
/>
|
|
292
|
+
</td>
|
|
293
|
+
<td class="hidden lg:table-cell">
|
|
294
|
+
<f-tag
|
|
295
|
+
[value]="
|
|
296
|
+
rowData.readOnly
|
|
297
|
+
? ('shared.yes' | translate)
|
|
298
|
+
: ('shared.no' | translate)
|
|
299
|
+
"
|
|
300
|
+
[severity]="rowData.readOnly ? 'warn' : 'secondary'"
|
|
301
|
+
/>
|
|
302
|
+
</td>
|
|
303
|
+
<td>
|
|
304
|
+
<div class="flex gap-1">
|
|
305
|
+
<button
|
|
306
|
+
fButton
|
|
307
|
+
*hasPermission="ACTION_PERMISSIONS.UPDATE"
|
|
308
|
+
[text]="true"
|
|
309
|
+
severity="secondary"
|
|
310
|
+
size="small"
|
|
311
|
+
[disabled]="rowData.readOnly"
|
|
312
|
+
[fTooltip]="'shared.edit' | translate"
|
|
313
|
+
(click)="onEdit(rowData)"
|
|
314
|
+
>
|
|
315
|
+
<ui-icon pButtonIcon name="pencil"></ui-icon>
|
|
316
|
+
</button>
|
|
317
|
+
<button
|
|
318
|
+
fButton
|
|
319
|
+
*hasPermission="ACTION_PERMISSIONS.DELETE"
|
|
320
|
+
[text]="true"
|
|
321
|
+
severity="danger"
|
|
322
|
+
size="small"
|
|
323
|
+
[fTooltip]="'shared.delete' | translate"
|
|
324
|
+
[disabled]="rowData.readOnly"
|
|
325
|
+
(click)="onDelete(rowData)"
|
|
326
|
+
>
|
|
327
|
+
<ui-icon pButtonIcon name="trash"></ui-icon>
|
|
328
|
+
</button>
|
|
329
|
+
</div>
|
|
330
|
+
</td>
|
|
331
|
+
</tr>
|
|
332
|
+
</ng-template>
|
|
333
|
+
<ng-template #emptymessage>
|
|
334
|
+
<tr>
|
|
335
|
+
<td colspan="6" class="text-center py-4 text-muted-color">
|
|
336
|
+
{{ 'iam.action.no.actions' | translate }}
|
|
337
|
+
</td>
|
|
338
|
+
</tr>
|
|
339
|
+
</ng-template>
|
|
340
|
+
</f-treetable>
|
|
341
|
+
</div>
|
|
342
|
+
</div>
|
|
343
|
+
`,
|
|
344
|
+
}]
|
|
345
|
+
}], ctorParameters: () => [] });
|
|
346
|
+
|
|
347
|
+
export { ActionListPageComponent };
|
|
348
|
+
//# sourceMappingURL=flusys-ng-iam-action-list-page.component-UGKclpFx.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flusys-ng-iam-action-list-page.component-UGKclpFx.mjs","sources":["../../../projects/ng-iam/pages/action/action-list-page.component.ts"],"sourcesContent":["import { Component, effect, inject, signal, untracked } from '@angular/core';\nimport { Router } from '@angular/router';\nimport { LAYOUT_AUTH_STATE } from '@flusys/ng-layout';\nimport { ConfirmationService, MessageService, TreeNode } from '@flusys/ng-ui';\nimport {\n ACTION_PERMISSIONS,\n AngularModule,\n HasPermissionDirective,\n TranslatePipe,\n TranslateService,\n} from '@flusys/ng-shared';\nimport { firstValueFrom } from 'rxjs';\nimport { ActionType, IAction } from '../../interfaces/action.interface';\nimport { ActionApiService } from '../../services/action-api.service';\nimport { convertActionToTreeNode } from '../../utils/tree-utils';\nimport { UiModule } from '@flusys/ng-ui';\n\n@Component({\n selector: 'lib-action-list-page',\n imports: [\n AngularModule,\n UiModule,\n HasPermissionDirective,\n TranslatePipe,\n ],\n template: `\n <div class=\"card\">\n <div\n class=\"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-3 mb-4\"\n >\n <h3 class=\"text-lg sm:text-xl font-semibold\">\n {{ 'iam.action.title' | translate }}\n </h3>\n <button\n fButton\n *hasPermission=\"ACTION_PERMISSIONS.CREATE\"\n (click)=\"onCreate()\"\n class=\"w-full sm:w-auto\"\n >\n <ui-icon pButtonIcon name=\"plus\"></ui-icon>\n <span pButtonLabel>{{ 'iam.action.new' | translate }}</span>\n </button>\n </div>\n\n <div class=\"overflow-x-auto -mx-4 sm:mx-0\">\n <f-treetable\n [value]=\"treeNodes()\"\n [loading]=\"isLoading()\"\n dataKey=\"id\"\n [tableStyle]=\"{ 'min-width': '50rem' }\"\n >\n <ng-template #header>\n <tr>\n <th>{{ 'iam.action.name' | translate }}</th>\n <th class=\"hidden md:table-cell\">\n {{ 'iam.action.code' | translate }}\n </th>\n <th>{{ 'iam.action.type' | translate }}</th>\n <th class=\"hidden sm:table-cell\">\n {{ 'shared.active' | translate }}\n </th>\n <th class=\"hidden lg:table-cell\">\n {{ 'shared.read.only' | translate }}\n </th>\n <th class=\"w-[100px]\">{{ 'shared.actions' | translate }}</th>\n </tr>\n </ng-template>\n <ng-template #body let-rowNode let-rowData=\"rowData\">\n <tr>\n <td>\n <f-treetabletoggler [rowNode]=\"rowNode\" />\n {{ rowData.name }}\n </td>\n <td class=\"hidden md:table-cell\">{{ rowData.code ?? '-' }}</td>\n <td>\n <f-tag\n [value]=\"getActionTypeLabel(rowData.actionType)\"\n [severity]=\"getActionTypeSeverity(rowData.actionType)\"\n />\n </td>\n <td class=\"hidden sm:table-cell\">\n <f-tag\n [value]=\"\n rowData.isActive\n ? ('shared.active' | translate)\n : ('shared.inactive' | translate)\n \"\n [severity]=\"rowData.isActive ? 'success' : 'secondary'\"\n />\n </td>\n <td class=\"hidden lg:table-cell\">\n <f-tag\n [value]=\"\n rowData.readOnly\n ? ('shared.yes' | translate)\n : ('shared.no' | translate)\n \"\n [severity]=\"rowData.readOnly ? 'warn' : 'secondary'\"\n />\n </td>\n <td>\n <div class=\"flex gap-1\">\n <button\n fButton\n *hasPermission=\"ACTION_PERMISSIONS.UPDATE\"\n [text]=\"true\"\n severity=\"secondary\"\n size=\"small\"\n [disabled]=\"rowData.readOnly\"\n [fTooltip]=\"'shared.edit' | translate\"\n (click)=\"onEdit(rowData)\"\n >\n <ui-icon pButtonIcon name=\"pencil\"></ui-icon>\n </button>\n <button\n fButton\n *hasPermission=\"ACTION_PERMISSIONS.DELETE\"\n [text]=\"true\"\n severity=\"danger\"\n size=\"small\"\n [fTooltip]=\"'shared.delete' | translate\"\n [disabled]=\"rowData.readOnly\"\n (click)=\"onDelete(rowData)\"\n >\n <ui-icon pButtonIcon name=\"trash\"></ui-icon>\n </button>\n </div>\n </td>\n </tr>\n </ng-template>\n <ng-template #emptymessage>\n <tr>\n <td colspan=\"6\" class=\"text-center py-4 text-muted-color\">\n {{ 'iam.action.no.actions' | translate }}\n </td>\n </tr>\n </ng-template>\n </f-treetable>\n </div>\n </div>\n `,\n})\nexport class ActionListPageComponent {\n readonly ACTION_PERMISSIONS = ACTION_PERMISSIONS;\n\n private readonly router = inject(Router);\n private readonly companyContext = inject(LAYOUT_AUTH_STATE);\n private readonly actionApi = inject(ActionApiService);\n private readonly messageService = inject(MessageService);\n private readonly confirmationService = inject(ConfirmationService);\n private readonly translateAdapter = inject(TranslateService, {\n optional: true,\n });\n\n readonly isLoading = signal(false);\n readonly treeNodes = signal<TreeNode<IAction>[]>([]);\n\n private translate(\n key: string,\n vars?: Record<string, string | number>,\n ): string {\n return this.translateAdapter?.translate(key, vars) ?? key;\n }\n\n private static readonly TYPE_SEVERITIES: Record<\n ActionType,\n 'info' | 'success' | 'warn'\n > = {\n [ActionType.BACKEND]: 'info',\n [ActionType.FRONTEND]: 'success',\n [ActionType.BOTH]: 'warn',\n };\n\n private static readonly TYPE_LABEL_KEYS: Record<ActionType, string> = {\n [ActionType.BACKEND]: 'iam.action.type.backend',\n [ActionType.FRONTEND]: 'iam.action.type.frontend',\n [ActionType.BOTH]: 'iam.action.type.both',\n };\n\n constructor() {\n effect(() => {\n this.companyContext.currentCompanyInfo();\n untracked(() => this.loadActions());\n });\n }\n\n private async loadActions(): Promise<void> {\n this.isLoading.set(true);\n try {\n const response = await firstValueFrom(this.actionApi.getTree());\n this.treeNodes.set(\n convertActionToTreeNode(response?.success ? (response.data ?? []) : []),\n );\n } catch {\n // Handled by global interceptor\n } finally {\n this.isLoading.set(false);\n }\n }\n\n getActionTypeLabel(type: ActionType): string {\n const key =\n ActionListPageComponent.TYPE_LABEL_KEYS[type] ?? 'shared.unknown';\n return this.translate(key);\n }\n\n getActionTypeSeverity(type: ActionType): 'info' | 'success' | 'warn' {\n return ActionListPageComponent.TYPE_SEVERITIES[type] ?? 'info';\n }\n\n onCreate(): void {\n this.router.navigate(['/iam/actions/new']);\n }\n\n onEdit(action: IAction): void {\n this.router.navigate(['/iam/actions', action.id]);\n }\n\n onDelete(action: IAction): void {\n if (!action?.id || !action?.name) return;\n\n this.confirmationService.confirm({\n message: this.translate('shared.confirm.delete.item', {\n name: action.name,\n }),\n header: this.translate('iam.action.delete.title'),\n icon: 'exclamation-triangle',\n accept: async () => {\n try {\n const response = await this.actionApi.delete({\n id: action.id,\n type: 'delete',\n });\n await this.loadActions();\n this.messageService.add({\n severity: 'success',\n summary: this.translate('shared.success'),\n detail: response?.messageKey\n ? this.translate(\n response.messageKey,\n response.messageVariables as Record<string, string | number>,\n )\n : (response?.message ?? ''),\n });\n } catch {\n // Handled by global interceptor\n }\n },\n });\n }\n}\n"],"names":["i1"],"mappings":";;;;;;;;;;MA8Ia,uBAAuB,CAAA;IACzB,kBAAkB,GAAG,kBAAkB;AAE/B,IAAA,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;AACvB,IAAA,cAAc,GAAG,MAAM,CAAC,iBAAiB,CAAC;AAC1C,IAAA,SAAS,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACpC,IAAA,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;AACvC,IAAA,mBAAmB,GAAG,MAAM,CAAC,mBAAmB,CAAC;AACjD,IAAA,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,EAAE;AAC3D,QAAA,QAAQ,EAAE,IAAI;AACf,KAAA,CAAC;IAEO,SAAS,GAAG,MAAM,CAAC,KAAK;kFAAC;IACzB,SAAS,GAAG,MAAM,CAAsB,EAAE;kFAAC;IAE5C,SAAS,CACf,GAAW,EACX,IAAsC,EAAA;AAEtC,QAAA,OAAO,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,GAAG;IAC3D;IAEQ,OAAgB,eAAe,GAGnC;AACF,QAAA,CAAC,UAAU,CAAC,OAAO,GAAG,MAAM;AAC5B,QAAA,CAAC,UAAU,CAAC,QAAQ,GAAG,SAAS;AAChC,QAAA,CAAC,UAAU,CAAC,IAAI,G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