@flusys/ng-iam 1.1.1-beta → 2.0.0-rc.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.
- package/README.md +175 -24
- package/fesm2022/flusys-ng-iam-action-form-page.component-CVN8sV-c.mjs +389 -0
- package/fesm2022/flusys-ng-iam-action-form-page.component-CVN8sV-c.mjs.map +1 -0
- package/fesm2022/flusys-ng-iam-action-list-page.component-CQ6RazN0.mjs +262 -0
- package/fesm2022/flusys-ng-iam-action-list-page.component-CQ6RazN0.mjs.map +1 -0
- package/fesm2022/{flusys-ng-iam-flusys-ng-iam-DISrddPh.mjs → flusys-ng-iam-flusys-ng-iam-DrGHlTiz.mjs} +1016 -1585
- package/fesm2022/flusys-ng-iam-flusys-ng-iam-DrGHlTiz.mjs.map +1 -0
- package/fesm2022/flusys-ng-iam-iam-container.component-BToYxEej.mjs +92 -0
- package/fesm2022/flusys-ng-iam-iam-container.component-BToYxEej.mjs.map +1 -0
- package/fesm2022/flusys-ng-iam-permission-page.component-BS7xXmsn.mjs +137 -0
- package/fesm2022/flusys-ng-iam-permission-page.component-BS7xXmsn.mjs.map +1 -0
- package/fesm2022/{flusys-ng-iam-role-form-page.component-Cqziu_BM.mjs → flusys-ng-iam-role-form-page.component-BjPwXkip.mjs} +106 -148
- package/fesm2022/flusys-ng-iam-role-form-page.component-BjPwXkip.mjs.map +1 -0
- package/fesm2022/flusys-ng-iam-role-list-page.component-Cz-jk-R_.mjs +299 -0
- package/fesm2022/flusys-ng-iam-role-list-page.component-Cz-jk-R_.mjs.map +1 -0
- package/fesm2022/flusys-ng-iam.mjs +1 -1
- package/package.json +4 -4
- package/types/flusys-ng-iam.d.ts +75 -454
- 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.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.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 @@
|
|
|
1
|
+
{"version":3,"file":"flusys-ng-iam-role-form-page.component-BjPwXkip.mjs","sources":["../../../projects/ng-iam/pages/role/role-form-page.component.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, computed, effect, inject, signal } from '@angular/core';\nimport { toSignal } from '@angular/core/rxjs-interop';\nimport { form, FormField, required } from '@angular/forms/signals';\nimport { ActivatedRoute, Router } from '@angular/router';\nimport { APP_CONFIG, isCompanyFeatureEnabled } from '@flusys/ng-core';\nimport { LAYOUT_AUTH_STATE } from '@flusys/ng-layout';\nimport { AngularModule, PrimeModule } from '@flusys/ng-shared';\nimport { MessageService } from 'primeng/api';\nimport { firstValueFrom } from 'rxjs';\nimport { IRole } from '../../interfaces/role.interface';\nimport { RoleApiService } from '../../services/role-api.service';\n\ninterface IRoleFormModel {\n id: string;\n name: string;\n description: string;\n serial: string;\n isActive: boolean;\n}\n\n@Component({\n selector: 'lib-role-form-page',\n imports: [AngularModule, PrimeModule, FormField],\n changeDetection: ChangeDetectionStrategy.OnPush,\n template: `\n <div class=\"card\">\n <h3 class=\"text-lg sm:text-xl font-semibold mb-4\">\n {{ isEditMode() ? 'Edit Role' : 'New Role' }}\n </h3>\n\n <form (ngSubmit)=\"onSubmit()\" class=\"grid grid-cols-1 md:grid-cols-2 gap-4\">\n <!-- Name -->\n <div class=\"flex flex-col gap-2\">\n <label for=\"name\" class=\"font-medium\">Name *</label>\n <input\n pInputText\n id=\"name\"\n [formField]=\"roleForm.name\"\n placeholder=\"Enter role name\" />\n </div>\n\n <!-- Description -->\n <div class=\"flex flex-col gap-2\">\n <label for=\"description\" class=\"font-medium\">Description</label>\n <input\n pInputText\n id=\"description\"\n [formField]=\"roleForm.description\"\n placeholder=\"Enter description\" />\n </div>\n\n <!-- Order -->\n <div class=\"flex flex-col gap-2\">\n <label for=\"serial\" class=\"font-medium\">Display Order</label>\n <input\n pInputText\n id=\"serial\"\n type=\"number\"\n [formField]=\"roleForm.serial\"\n placeholder=\"Enter display order\" />\n </div>\n\n <!-- Is Active -->\n <div class=\"flex items-end gap-2 pb-1\">\n <p-checkbox\n [formField]=\"roleForm.isActive\"\n [binary]=\"true\"\n inputId=\"isActive\" />\n <label for=\"isActive\">Active</label>\n </div>\n\n <!-- Actions -->\n <div class=\"flex justify-end gap-2 md:col-span-2 pt-4\">\n <p-button\n label=\"Cancel\"\n severity=\"secondary\"\n [outlined]=\"true\"\n (onClick)=\"onBack()\" />\n <p-button\n [label]=\"isEditMode() ? 'Update' : 'Create'\"\n type=\"submit\"\n [loading]=\"isLoading()\"\n [disabled]=\"!isFormValid() || isLoading()\" />\n </div>\n </form>\n </div>\n `,\n})\nexport class RoleFormPageComponent {\n private readonly route = inject(ActivatedRoute);\n private readonly router = inject(Router);\n private readonly appConfig = inject(APP_CONFIG);\n private readonly companyContext = inject(LAYOUT_AUTH_STATE);\n private readonly roleApi = inject(RoleApiService);\n private readonly messageService = inject(MessageService);\n\n private readonly routeParams = toSignal(this.route.paramMap);\n private initialized = false;\n\n readonly isLoading = signal(false);\n readonly existingRole = signal<IRole | null>(null);\n readonly isEditMode = computed(() => !!this.existingRole());\n\n readonly formModel = signal<IRoleFormModel>({\n id: '',\n name: '',\n description: '',\n serial: '',\n isActive: true,\n });\n\n readonly roleForm = form(this.formModel, (f) => {\n required(f.name, { message: 'Name is required' });\n });\n\n readonly isFormValid = computed(() => {\n const model = this.formModel();\n return model.name.trim().length > 0;\n });\n\n constructor() {\n effect(() => {\n const params = this.routeParams();\n if (!params || this.initialized) return;\n\n this.initialized = true;\n const id = params.get('id');\n if (id && id !== 'new') {\n this.loadRole(id);\n }\n });\n }\n\n async loadRole(id: string): Promise<void> {\n this.isLoading.set(true);\n try {\n const response = await firstValueFrom(this.roleApi.findById(id));\n const role = response?.data;\n\n if (role) {\n this.existingRole.set(role);\n this.formModel.set({\n id: role.id,\n name: role.name,\n description: role.description ?? '',\n serial: role.serial?.toString() ?? '',\n isActive: role.isActive,\n });\n } else {\n // Error toast handled by global interceptor\n this.router.navigate(['/iam/roles']);\n }\n } catch {\n // Error toast handled by global interceptor\n this.router.navigate(['/iam/roles']);\n } finally {\n this.isLoading.set(false);\n }\n }\n\n async onSubmit(): Promise<void> {\n if (!this.isFormValid()) {\n this.messageService.add({\n severity: 'error',\n summary: 'Validation Error',\n detail: 'Please fill in all required fields.',\n });\n return;\n }\n\n this.isLoading.set(true);\n\n try {\n const formValue = this.formModel();\n\n // Get company context if feature enabled\n const companyId = isCompanyFeatureEnabled(this.appConfig)\n ? this.companyContext.currentCompanyInfo()?.id || undefined\n : undefined;\n\n // Convert empty strings to undefined for DTO compatibility\n const dto = {\n ...formValue,\n description: formValue.description || undefined,\n serial: formValue.serial ? parseInt(formValue.serial, 10) : undefined,\n companyId: this.isEditMode() ? undefined : companyId,\n };\n\n if (this.isEditMode()) {\n await this.roleApi.updateAsync(dto);\n this.messageService.add({\n severity: 'success',\n summary: 'Success',\n detail: 'Role updated successfully.',\n });\n } else {\n await this.roleApi.insertAsync(dto);\n this.messageService.add({\n severity: 'success',\n summary: 'Success',\n detail: 'Role created successfully.',\n });\n }\n\n this.router.navigate(['/iam/roles']);\n } catch {\n // Error toast handled by global interceptor\n }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A,CAAA,UAAA,EAAA,SAAA,EAAA,QAAA,CAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAAA,EAAA,CAAA,SAAA,EAAA,QAAA,EAAA,cAAA,EAAA,MAAA,EAAA,CAAA,UAAA,EAAA,aAAA,EAAA,cAAA,EAAA,oBAAA,EAAA,OAAA,EAAA,SAAA,EAAA,OAAA,EAAA,SAAA,CAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAAE,SAAS,EAAA,QAAA,EAAA,aAAA,EAAA,MAAA,EAAA,CAAA,WAAA,CAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;2FAkEpC,qBAAqB,EAAA,UAAA,EAAA,CAAA;kBApEjC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,oBAAoB;AAC9B,oBAAA,OAAO,EAAE,CAAC,aAAa,EAAE,WAAW,EAAE,SAAS,CAAC;oBAChD,eAAe,EAAE,uBAAuB,CAAC,MAAM;AAC/C,oBAAA,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DT,EAAA,CAAA;AACF,iBAAA;;;;;"}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, signal, computed, effect, untracked, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { Router } from '@angular/router';
|
|
4
|
+
import { APP_CONFIG, DEFAULT_APP_NAME, isCompanyFeatureEnabled } from '@flusys/ng-core';
|
|
5
|
+
import { LAYOUT_AUTH_STATE } from '@flusys/ng-layout';
|
|
6
|
+
import { ROLE_PERMISSIONS, AngularModule, PrimeModule, HasPermissionDirective } from '@flusys/ng-shared';
|
|
7
|
+
import { MessageService, ConfirmationService } from 'primeng/api';
|
|
8
|
+
import * as i5$1 from 'primeng/tag';
|
|
9
|
+
import { TagModule } from 'primeng/tag';
|
|
10
|
+
import { firstValueFrom } from 'rxjs';
|
|
11
|
+
import { R as RoleApiService } from './flusys-ng-iam-flusys-ng-iam-DrGHlTiz.mjs';
|
|
12
|
+
import * as i2 from 'primeng/button';
|
|
13
|
+
import * as i5 from 'primeng/table';
|
|
14
|
+
import * as i6 from 'primeng/tooltip';
|
|
15
|
+
|
|
16
|
+
class RoleListPageComponent {
|
|
17
|
+
ROLE_PERMISSIONS = ROLE_PERMISSIONS;
|
|
18
|
+
router = inject(Router);
|
|
19
|
+
appConfig = inject(APP_CONFIG);
|
|
20
|
+
companyContext = inject(LAYOUT_AUTH_STATE);
|
|
21
|
+
roleApi = inject(RoleApiService);
|
|
22
|
+
messageService = inject(MessageService);
|
|
23
|
+
confirmationService = inject(ConfirmationService);
|
|
24
|
+
roles = signal([], ...(ngDevMode ? [{ debugName: "roles" }] : []));
|
|
25
|
+
isLoading = signal(false, ...(ngDevMode ? [{ debugName: "isLoading" }] : []));
|
|
26
|
+
total = signal(0, ...(ngDevMode ? [{ debugName: "total" }] : []));
|
|
27
|
+
pageSize = signal(10, ...(ngDevMode ? [{ debugName: "pageSize" }] : []));
|
|
28
|
+
first = signal(0, ...(ngDevMode ? [{ debugName: "first" }] : []));
|
|
29
|
+
showCompanyInfo = computed(() => this.appConfig.enableCompanyFeature, ...(ngDevMode ? [{ debugName: "showCompanyInfo" }] : []));
|
|
30
|
+
currentCompanyName = computed(() => this.companyContext.currentCompanyInfo()?.name ?? DEFAULT_APP_NAME, ...(ngDevMode ? [{ debugName: "currentCompanyName" }] : []));
|
|
31
|
+
previousCompanyId = undefined;
|
|
32
|
+
constructor() {
|
|
33
|
+
effect(() => {
|
|
34
|
+
const currentCompanyId = this.companyContext.currentCompanyInfo()?.id ?? null;
|
|
35
|
+
if (this.previousCompanyId === undefined) {
|
|
36
|
+
this.previousCompanyId = currentCompanyId;
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (this.previousCompanyId === currentCompanyId)
|
|
40
|
+
return;
|
|
41
|
+
this.previousCompanyId = currentCompanyId;
|
|
42
|
+
untracked(() => {
|
|
43
|
+
this.first.set(0);
|
|
44
|
+
this.loadRoles();
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
async loadRoles() {
|
|
49
|
+
this.isLoading.set(true);
|
|
50
|
+
try {
|
|
51
|
+
const enableCompanyFeature = isCompanyFeatureEnabled(this.appConfig);
|
|
52
|
+
const companyId = enableCompanyFeature
|
|
53
|
+
? this.companyContext.currentCompanyInfo()?.id || undefined
|
|
54
|
+
: undefined;
|
|
55
|
+
const selectFields = ['id', 'name', 'description', 'isActive', 'readOnly', 'serial', 'createdAt', 'deletedAt'];
|
|
56
|
+
if (enableCompanyFeature) {
|
|
57
|
+
selectFields.push('companyId');
|
|
58
|
+
}
|
|
59
|
+
const response = await firstValueFrom(this.roleApi.getAll('', {
|
|
60
|
+
filter: companyId ? { companyId } : undefined,
|
|
61
|
+
pagination: {
|
|
62
|
+
currentPage: Math.floor(this.first() / this.pageSize()),
|
|
63
|
+
pageSize: this.pageSize(),
|
|
64
|
+
},
|
|
65
|
+
select: selectFields,
|
|
66
|
+
sort: { id: 'ASC' },
|
|
67
|
+
}));
|
|
68
|
+
this.roles.set(response?.data ?? []);
|
|
69
|
+
this.total.set(response?.meta?.total ?? 0);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
// Error toast handled by global interceptor
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
this.isLoading.set(false);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
onCreate() {
|
|
79
|
+
this.router.navigate(['/iam/roles/new']);
|
|
80
|
+
}
|
|
81
|
+
onEdit(role) {
|
|
82
|
+
this.router.navigate(['/iam/roles', role.id]);
|
|
83
|
+
}
|
|
84
|
+
onDelete(role) {
|
|
85
|
+
this.confirmationService.confirm({
|
|
86
|
+
message: `Are you sure you want to delete role "${role.name}"?`,
|
|
87
|
+
header: 'Confirm Delete',
|
|
88
|
+
icon: 'pi pi-exclamation-triangle',
|
|
89
|
+
accept: async () => {
|
|
90
|
+
try {
|
|
91
|
+
await this.roleApi.deleteAsync({ id: role.id, type: 'delete' });
|
|
92
|
+
this.roles.update((list) => list.filter((r) => r.id !== role.id));
|
|
93
|
+
this.total.update((t) => Math.max(0, t - 1));
|
|
94
|
+
this.messageService.add({
|
|
95
|
+
severity: 'success',
|
|
96
|
+
summary: 'Success',
|
|
97
|
+
detail: 'Role deleted successfully',
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
// Error toast handled by global interceptor
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
onLazyLoad(event) {
|
|
107
|
+
this.first.set(event.first ?? 0);
|
|
108
|
+
this.pageSize.set(event.rows ?? 10);
|
|
109
|
+
this.loadRoles();
|
|
110
|
+
}
|
|
111
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: RoleListPageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
112
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.3", type: RoleListPageComponent, isStandalone: true, selector: "lib-role-list-page", ngImport: i0, template: `
|
|
113
|
+
<div class="card">
|
|
114
|
+
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-3 mb-4">
|
|
115
|
+
<div>
|
|
116
|
+
<h3 class="text-lg sm:text-xl font-semibold">Roles</h3>
|
|
117
|
+
@if (showCompanyInfo()) {
|
|
118
|
+
<p class="text-sm text-muted-color mt-1">
|
|
119
|
+
Company: {{ currentCompanyName() }}
|
|
120
|
+
</p>
|
|
121
|
+
}
|
|
122
|
+
</div>
|
|
123
|
+
<p-button
|
|
124
|
+
*hasPermission="ROLE_PERMISSIONS.CREATE"
|
|
125
|
+
label="New Role"
|
|
126
|
+
icon="pi pi-plus"
|
|
127
|
+
(onClick)="onCreate()"
|
|
128
|
+
styleClass="w-full sm:w-auto" />
|
|
129
|
+
</div>
|
|
130
|
+
|
|
131
|
+
<div class="overflow-x-auto -mx-4 sm:mx-0">
|
|
132
|
+
<p-table
|
|
133
|
+
[value]="roles()"
|
|
134
|
+
[loading]="isLoading()"
|
|
135
|
+
[paginator]="total() > 0"
|
|
136
|
+
[rows]="pageSize()"
|
|
137
|
+
[first]="first()"
|
|
138
|
+
[totalRecords]="total()"
|
|
139
|
+
[lazy]="true"
|
|
140
|
+
(onLazyLoad)="onLazyLoad($event)"
|
|
141
|
+
[rowsPerPageOptions]="[10, 25, 50]"
|
|
142
|
+
[scrollable]="true"
|
|
143
|
+
styleClass="p-datatable-sm"
|
|
144
|
+
[tableStyle]="{ 'min-width': '40rem' }">
|
|
145
|
+
<ng-template #header>
|
|
146
|
+
<tr>
|
|
147
|
+
<th>Name</th>
|
|
148
|
+
<th class="hidden md:table-cell">Description</th>
|
|
149
|
+
<th>Active</th>
|
|
150
|
+
<th class="hidden sm:table-cell">Read Only</th>
|
|
151
|
+
<th class="w-[120px]">Actions</th>
|
|
152
|
+
</tr>
|
|
153
|
+
</ng-template>
|
|
154
|
+
<ng-template #body let-role>
|
|
155
|
+
<tr>
|
|
156
|
+
<td>{{ role.name }}</td>
|
|
157
|
+
<td class="hidden md:table-cell">{{ role.description ?? '-' }}</td>
|
|
158
|
+
<td>
|
|
159
|
+
<p-tag
|
|
160
|
+
[value]="role.isActive ? 'Active' : 'Inactive'"
|
|
161
|
+
[severity]="role.isActive ? 'success' : 'secondary'" />
|
|
162
|
+
</td>
|
|
163
|
+
<td class="hidden sm:table-cell">
|
|
164
|
+
<p-tag
|
|
165
|
+
[value]="role.readOnly ? 'Yes' : 'No'"
|
|
166
|
+
[severity]="role.readOnly ? 'warn' : 'secondary'" />
|
|
167
|
+
</td>
|
|
168
|
+
<td>
|
|
169
|
+
<div class="flex gap-1">
|
|
170
|
+
<p-button
|
|
171
|
+
*hasPermission="ROLE_PERMISSIONS.UPDATE"
|
|
172
|
+
icon="pi pi-pencil"
|
|
173
|
+
[text]="true"
|
|
174
|
+
severity="secondary"
|
|
175
|
+
size="small"
|
|
176
|
+
pTooltip="Edit"
|
|
177
|
+
(onClick)="onEdit(role)" />
|
|
178
|
+
<p-button
|
|
179
|
+
*hasPermission="ROLE_PERMISSIONS.DELETE"
|
|
180
|
+
icon="pi pi-trash"
|
|
181
|
+
[text]="true"
|
|
182
|
+
severity="danger"
|
|
183
|
+
size="small"
|
|
184
|
+
pTooltip="Delete"
|
|
185
|
+
[disabled]="role.readOnly"
|
|
186
|
+
(onClick)="onDelete(role)" />
|
|
187
|
+
</div>
|
|
188
|
+
</td>
|
|
189
|
+
</tr>
|
|
190
|
+
</ng-template>
|
|
191
|
+
<ng-template #emptymessage>
|
|
192
|
+
<tr>
|
|
193
|
+
<td colspan="5" class="text-center py-4 text-muted-color">No roles found.</td>
|
|
194
|
+
</tr>
|
|
195
|
+
</ng-template>
|
|
196
|
+
</p-table>
|
|
197
|
+
</div>
|
|
198
|
+
</div>
|
|
199
|
+
`, isInline: true, dependencies: [{ kind: "ngmodule", type: AngularModule }, { kind: "ngmodule", type: PrimeModule }, { kind: "component", type: i2.Button, selector: "p-button", inputs: ["hostName", "type", "badge", "disabled", "raised", "rounded", "text", "plain", "outlined", "link", "tabindex", "size", "variant", "style", "styleClass", "badgeClass", "badgeSeverity", "ariaLabel", "autofocus", "iconPos", "icon", "label", "loading", "loadingIcon", "severity", "buttonProps", "fluid"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "component", type: i5.Table, selector: "p-table", inputs: ["frozenColumns", "frozenValue", "styleClass", "tableStyle", "tableStyleClass", "paginator", "pageLinks", "rowsPerPageOptions", "alwaysShowPaginator", "paginatorPosition", "paginatorStyleClass", "paginatorDropdownAppendTo", "paginatorDropdownScrollHeight", "currentPageReportTemplate", "showCurrentPageReport", "showJumpToPageDropdown", "showJumpToPageInput", "showFirstLastIcon", "showPageLinks", "defaultSortOrder", "sortMode", "resetPageOnSort", "selectionMode", "selectionPageOnly", "contextMenuSelection", "contextMenuSelectionMode", "dataKey", "metaKeySelection", "rowSelectable", "rowTrackBy", "lazy", "lazyLoadOnInit", "compareSelectionBy", "csvSeparator", "exportFilename", "filters", "globalFilterFields", "filterDelay", "filterLocale", "expandedRowKeys", "editingRowKeys", "rowExpandMode", "scrollable", "rowGroupMode", "scrollHeight", "virtualScroll", "virtualScrollItemSize", "virtualScrollOptions", "virtualScrollDelay", "frozenWidth", "contextMenu", "resizableColumns", "columnResizeMode", "reorderableColumns", "loading", "loadingIcon", "showLoader", "rowHover", "customSort", "showInitialSortBadge", "exportFunction", "exportHeader", "stateKey", "stateStorage", "editMode", "groupRowsBy", "size", "showGridlines", "stripedRows", "groupRowsByOrder", "responsiveLayout", "breakpoint", "paginatorLocale", "value", "columns", "first", "rows", "totalRecords", "sortField", "sortOrder", "multiSortMeta", "selection", "selectAll"], outputs: ["contextMenuSelectionChange", "selectAllChange", "selectionChange", "onRowSelect", "onRowUnselect", "onPage", "onSort", "onFilter", "onLazyLoad", "onRowExpand", "onRowCollapse", "onContextMenuSelect", "onColResize", "onColReorder", "onRowReorder", "onEditInit", "onEditComplete", "onEditCancel", "onHeaderCheckboxToggle", "sortFunction", "firstChange", "rowsChange", "onStateSave", "onStateRestore"] }, { kind: "component", type: i5$1.Tag, selector: "p-tag", inputs: ["styleClass", "severity", "value", "icon", "rounded"] }, { kind: "directive", type: i6.Tooltip, selector: "[pTooltip]", inputs: ["tooltipPosition", "tooltipEvent", "positionStyle", "tooltipStyleClass", "tooltipZIndex", "escape", "showDelay", "hideDelay", "life", "positionTop", "positionLeft", "autoHide", "fitContent", "hideOnEscape", "showOnEllipsis", "pTooltip", "tooltipDisabled", "tooltipOptions", "appendTo", "ptTooltip", "pTooltipPT", "pTooltipUnstyled"] }, { kind: "ngmodule", type: TagModule }, { kind: "directive", type: HasPermissionDirective, selector: "[hasPermission]", inputs: ["hasPermission"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
200
|
+
}
|
|
201
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: RoleListPageComponent, decorators: [{
|
|
202
|
+
type: Component,
|
|
203
|
+
args: [{
|
|
204
|
+
selector: 'lib-role-list-page',
|
|
205
|
+
imports: [AngularModule, PrimeModule, TagModule, HasPermissionDirective],
|
|
206
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
207
|
+
template: `
|
|
208
|
+
<div class="card">
|
|
209
|
+
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-3 mb-4">
|
|
210
|
+
<div>
|
|
211
|
+
<h3 class="text-lg sm:text-xl font-semibold">Roles</h3>
|
|
212
|
+
@if (showCompanyInfo()) {
|
|
213
|
+
<p class="text-sm text-muted-color mt-1">
|
|
214
|
+
Company: {{ currentCompanyName() }}
|
|
215
|
+
</p>
|
|
216
|
+
}
|
|
217
|
+
</div>
|
|
218
|
+
<p-button
|
|
219
|
+
*hasPermission="ROLE_PERMISSIONS.CREATE"
|
|
220
|
+
label="New Role"
|
|
221
|
+
icon="pi pi-plus"
|
|
222
|
+
(onClick)="onCreate()"
|
|
223
|
+
styleClass="w-full sm:w-auto" />
|
|
224
|
+
</div>
|
|
225
|
+
|
|
226
|
+
<div class="overflow-x-auto -mx-4 sm:mx-0">
|
|
227
|
+
<p-table
|
|
228
|
+
[value]="roles()"
|
|
229
|
+
[loading]="isLoading()"
|
|
230
|
+
[paginator]="total() > 0"
|
|
231
|
+
[rows]="pageSize()"
|
|
232
|
+
[first]="first()"
|
|
233
|
+
[totalRecords]="total()"
|
|
234
|
+
[lazy]="true"
|
|
235
|
+
(onLazyLoad)="onLazyLoad($event)"
|
|
236
|
+
[rowsPerPageOptions]="[10, 25, 50]"
|
|
237
|
+
[scrollable]="true"
|
|
238
|
+
styleClass="p-datatable-sm"
|
|
239
|
+
[tableStyle]="{ 'min-width': '40rem' }">
|
|
240
|
+
<ng-template #header>
|
|
241
|
+
<tr>
|
|
242
|
+
<th>Name</th>
|
|
243
|
+
<th class="hidden md:table-cell">Description</th>
|
|
244
|
+
<th>Active</th>
|
|
245
|
+
<th class="hidden sm:table-cell">Read Only</th>
|
|
246
|
+
<th class="w-[120px]">Actions</th>
|
|
247
|
+
</tr>
|
|
248
|
+
</ng-template>
|
|
249
|
+
<ng-template #body let-role>
|
|
250
|
+
<tr>
|
|
251
|
+
<td>{{ role.name }}</td>
|
|
252
|
+
<td class="hidden md:table-cell">{{ role.description ?? '-' }}</td>
|
|
253
|
+
<td>
|
|
254
|
+
<p-tag
|
|
255
|
+
[value]="role.isActive ? 'Active' : 'Inactive'"
|
|
256
|
+
[severity]="role.isActive ? 'success' : 'secondary'" />
|
|
257
|
+
</td>
|
|
258
|
+
<td class="hidden sm:table-cell">
|
|
259
|
+
<p-tag
|
|
260
|
+
[value]="role.readOnly ? 'Yes' : 'No'"
|
|
261
|
+
[severity]="role.readOnly ? 'warn' : 'secondary'" />
|
|
262
|
+
</td>
|
|
263
|
+
<td>
|
|
264
|
+
<div class="flex gap-1">
|
|
265
|
+
<p-button
|
|
266
|
+
*hasPermission="ROLE_PERMISSIONS.UPDATE"
|
|
267
|
+
icon="pi pi-pencil"
|
|
268
|
+
[text]="true"
|
|
269
|
+
severity="secondary"
|
|
270
|
+
size="small"
|
|
271
|
+
pTooltip="Edit"
|
|
272
|
+
(onClick)="onEdit(role)" />
|
|
273
|
+
<p-button
|
|
274
|
+
*hasPermission="ROLE_PERMISSIONS.DELETE"
|
|
275
|
+
icon="pi pi-trash"
|
|
276
|
+
[text]="true"
|
|
277
|
+
severity="danger"
|
|
278
|
+
size="small"
|
|
279
|
+
pTooltip="Delete"
|
|
280
|
+
[disabled]="role.readOnly"
|
|
281
|
+
(onClick)="onDelete(role)" />
|
|
282
|
+
</div>
|
|
283
|
+
</td>
|
|
284
|
+
</tr>
|
|
285
|
+
</ng-template>
|
|
286
|
+
<ng-template #emptymessage>
|
|
287
|
+
<tr>
|
|
288
|
+
<td colspan="5" class="text-center py-4 text-muted-color">No roles found.</td>
|
|
289
|
+
</tr>
|
|
290
|
+
</ng-template>
|
|
291
|
+
</p-table>
|
|
292
|
+
</div>
|
|
293
|
+
</div>
|
|
294
|
+
`,
|
|
295
|
+
}]
|
|
296
|
+
}], ctorParameters: () => [] });
|
|
297
|
+
|
|
298
|
+
export { RoleListPageComponent };
|
|
299
|
+
//# sourceMappingURL=flusys-ng-iam-role-list-page.component-Cz-jk-R_.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flusys-ng-iam-role-list-page.component-Cz-jk-R_.mjs","sources":["../../../projects/ng-iam/pages/role/role-list-page.component.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, computed, effect, inject, signal, untracked } from '@angular/core';\nimport { Router } from '@angular/router';\nimport { APP_CONFIG, DEFAULT_APP_NAME, isCompanyFeatureEnabled } from '@flusys/ng-core';\nimport { LAYOUT_AUTH_STATE } from '@flusys/ng-layout';\nimport { AngularModule, HasPermissionDirective, PrimeModule, ROLE_PERMISSIONS } from '@flusys/ng-shared';\nimport { ConfirmationService, MessageService } from 'primeng/api';\nimport { TagModule } from 'primeng/tag';\nimport { firstValueFrom } from 'rxjs';\nimport { IRole } from '../../interfaces/role.interface';\nimport { RoleApiService } from '../../services/role-api.service';\n\n@Component({\n selector: 'lib-role-list-page',\n imports: [AngularModule, PrimeModule, TagModule, HasPermissionDirective],\n changeDetection: ChangeDetectionStrategy.OnPush,\n template: `\n <div class=\"card\">\n <div class=\"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-3 mb-4\">\n <div>\n <h3 class=\"text-lg sm:text-xl font-semibold\">Roles</h3>\n @if (showCompanyInfo()) {\n <p class=\"text-sm text-muted-color mt-1\">\n Company: {{ currentCompanyName() }}\n </p>\n }\n </div>\n <p-button\n *hasPermission=\"ROLE_PERMISSIONS.CREATE\"\n label=\"New Role\"\n icon=\"pi pi-plus\"\n (onClick)=\"onCreate()\"\n styleClass=\"w-full sm:w-auto\" />\n </div>\n\n <div class=\"overflow-x-auto -mx-4 sm:mx-0\">\n <p-table\n [value]=\"roles()\"\n [loading]=\"isLoading()\"\n [paginator]=\"total() > 0\"\n [rows]=\"pageSize()\"\n [first]=\"first()\"\n [totalRecords]=\"total()\"\n [lazy]=\"true\"\n (onLazyLoad)=\"onLazyLoad($event)\"\n [rowsPerPageOptions]=\"[10, 25, 50]\"\n [scrollable]=\"true\"\n styleClass=\"p-datatable-sm\"\n [tableStyle]=\"{ 'min-width': '40rem' }\">\n <ng-template #header>\n <tr>\n <th>Name</th>\n <th class=\"hidden md:table-cell\">Description</th>\n <th>Active</th>\n <th class=\"hidden sm:table-cell\">Read Only</th>\n <th class=\"w-[120px]\">Actions</th>\n </tr>\n </ng-template>\n <ng-template #body let-role>\n <tr>\n <td>{{ role.name }}</td>\n <td class=\"hidden md:table-cell\">{{ role.description ?? '-' }}</td>\n <td>\n <p-tag\n [value]=\"role.isActive ? 'Active' : 'Inactive'\"\n [severity]=\"role.isActive ? 'success' : 'secondary'\" />\n </td>\n <td class=\"hidden sm:table-cell\">\n <p-tag\n [value]=\"role.readOnly ? 'Yes' : 'No'\"\n [severity]=\"role.readOnly ? 'warn' : 'secondary'\" />\n </td>\n <td>\n <div class=\"flex gap-1\">\n <p-button\n *hasPermission=\"ROLE_PERMISSIONS.UPDATE\"\n icon=\"pi pi-pencil\"\n [text]=\"true\"\n severity=\"secondary\"\n size=\"small\"\n pTooltip=\"Edit\"\n (onClick)=\"onEdit(role)\" />\n <p-button\n *hasPermission=\"ROLE_PERMISSIONS.DELETE\"\n icon=\"pi pi-trash\"\n [text]=\"true\"\n severity=\"danger\"\n size=\"small\"\n pTooltip=\"Delete\"\n [disabled]=\"role.readOnly\"\n (onClick)=\"onDelete(role)\" />\n </div>\n </td>\n </tr>\n </ng-template>\n <ng-template #emptymessage>\n <tr>\n <td colspan=\"5\" class=\"text-center py-4 text-muted-color\">No roles found.</td>\n </tr>\n </ng-template>\n </p-table>\n </div>\n </div>\n `,\n})\nexport class RoleListPageComponent {\n readonly ROLE_PERMISSIONS = ROLE_PERMISSIONS;\n\n private readonly router = inject(Router);\n private readonly appConfig = inject(APP_CONFIG);\n private readonly companyContext = inject(LAYOUT_AUTH_STATE);\n private readonly roleApi = inject(RoleApiService);\n private readonly messageService = inject(MessageService);\n private readonly confirmationService = inject(ConfirmationService);\n\n readonly roles = signal<IRole[]>([]);\n readonly isLoading = signal(false);\n readonly total = signal(0);\n readonly pageSize = signal(10);\n readonly first = signal(0);\n readonly showCompanyInfo = computed(() => this.appConfig.enableCompanyFeature);\n readonly currentCompanyName = computed(() => this.companyContext.currentCompanyInfo()?.name ?? DEFAULT_APP_NAME);\n\n private previousCompanyId: string | undefined | null = undefined;\n\n constructor() {\n effect(() => {\n const currentCompanyId = this.companyContext.currentCompanyInfo()?.id ?? null;\n if (this.previousCompanyId === undefined) {\n this.previousCompanyId = currentCompanyId;\n return;\n }\n if (this.previousCompanyId === currentCompanyId) return;\n this.previousCompanyId = currentCompanyId;\n untracked(() => {\n this.first.set(0);\n this.loadRoles();\n });\n });\n }\n\n private async loadRoles(): Promise<void> {\n this.isLoading.set(true);\n try {\n const enableCompanyFeature = isCompanyFeatureEnabled(this.appConfig);\n const companyId = enableCompanyFeature\n ? this.companyContext.currentCompanyInfo()?.id || undefined\n : undefined;\n\n const selectFields = ['id', 'name', 'description', 'isActive', 'readOnly', 'serial', 'createdAt', 'deletedAt'];\n if (enableCompanyFeature) {\n selectFields.push('companyId');\n }\n\n const response = await firstValueFrom(\n this.roleApi.getAll('', {\n filter: companyId ? { companyId } : undefined,\n pagination: {\n currentPage: Math.floor(this.first() / this.pageSize()),\n pageSize: this.pageSize(),\n },\n select: selectFields,\n sort: { id: 'ASC' },\n })\n );\n\n this.roles.set(response?.data ?? []);\n this.total.set(response?.meta?.total ?? 0);\n } catch {\n // Error toast handled by global interceptor\n } finally {\n this.isLoading.set(false);\n }\n }\n\n onCreate(): void {\n this.router.navigate(['/iam/roles/new']);\n }\n\n onEdit(role: IRole): void {\n this.router.navigate(['/iam/roles', role.id]);\n }\n\n onDelete(role: IRole): void {\n this.confirmationService.confirm({\n message: `Are you sure you want to delete role \"${role.name}\"?`,\n header: 'Confirm Delete',\n icon: 'pi pi-exclamation-triangle',\n accept: async () => {\n try {\n await this.roleApi.deleteAsync({ id: role.id, type: 'delete' });\n\n this.roles.update((list) => list.filter((r) => r.id !== role.id));\n this.total.update((t) => Math.max(0, t - 1));\n\n this.messageService.add({\n severity: 'success',\n summary: 'Success',\n detail: 'Role deleted successfully',\n });\n } catch {\n // Error toast handled by global interceptor\n }\n },\n });\n }\n\n onLazyLoad(event: { first?: number | null; rows?: number | null }): void {\n this.first.set(event.first ?? 0);\n this.pageSize.set(event.rows ?? 10);\n this.loadRoles();\n }\n}\n"],"names":["i1","i2","i3","i4"],"mappings":";;;;;;;;;;;;;;;MAwGa,qBAAqB,CAAA;IACvB,gBAAgB,GAAG,gBAAgB;AAE3B,IAAA,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;AACvB,IAAA,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC;AAC9B,IAAA,cAAc,GAAG,MAAM,CAAC,iBAAiB,CAAC;AAC1C,IAAA,OAAO,GAAG,MAAM,CAAC,cAAc,CAAC;AAChC,IAAA,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;AACvC,IAAA,mBAAmB,GAAG,MAAM,CAAC,mBAAmB,CAAC;AAEzD,IAAA,KAAK,GAAG,MAAM,CAAU,EAAE,iDAAC;AAC3B,IAAA,SAAS,GAAG,MAAM,CAAC,KAAK,qDAAC;AACzB,IAAA,KAAK,GAAG,MAAM,CAAC,CAAC,iDAAC;AACjB,IAAA,QAAQ,GAAG,MAAM,CAAC,EAAE,oDAAC;AACrB,IAAA,KAAK,GAAG,MAAM,CAAC,CAAC,iDAAC;AAC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, L as LogicBuilderComponent, M as MAX_DROPDOWN_ITEMS, f as MyPermissionsApiService, P as PermissionApiService, g as PermissionStateService, h as ProfilePermissionProviderAdapter, b as RoleActionSelectorComponent, R as RoleApiService, d as UserActionSelectorComponent, U as UserRoleSelectorComponent, p as provideIamProviders } from './flusys-ng-iam-flusys-ng-iam-
|
|
1
|
+
export { A as ActionApiService, e as ActionPermissionLogicService, a as ActionType, C as CompanyActionSelectorComponent, I as IAM_ROUTES, L as LogicBuilderComponent, M as MAX_DROPDOWN_ITEMS, f as MyPermissionsApiService, P as PermissionApiService, g as PermissionStateService, h as ProfilePermissionProviderAdapter, b as RoleActionSelectorComponent, R as RoleApiService, d as UserActionSelectorComponent, U as UserRoleSelectorComponent, p as provideIamProviders } from './flusys-ng-iam-flusys-ng-iam-DrGHlTiz.mjs';
|
|
2
2
|
//# sourceMappingURL=flusys-ng-iam.mjs.map
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flusys/ng-iam",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-rc.0",
|
|
4
4
|
"description": "Identity and Access Management (IAM) for Angular - Independent from ng-auth through Provider Interface Pattern",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"@angular/common": "^21.0.0",
|
|
8
8
|
"@angular/core": "^21.0.0",
|
|
9
9
|
"@angular/forms": "^21.0.0",
|
|
10
|
-
"@flusys/ng-core": "^
|
|
11
|
-
"@flusys/ng-layout": "^
|
|
12
|
-
"@flusys/ng-shared": "^
|
|
10
|
+
"@flusys/ng-core": "^2.0.0-rc.0",
|
|
11
|
+
"@flusys/ng-layout": "^2.0.0-rc.0",
|
|
12
|
+
"@flusys/ng-shared": "^2.0.0-rc.0",
|
|
13
13
|
"@primeuix/themes": "^1.0.0",
|
|
14
14
|
"primeicons": "^7.0.0",
|
|
15
15
|
"primeng": "^21.0.0"
|