@rolatech/angular-authorization 20.0.6 → 20.0.8
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/fesm2022/{rolatech-angular-authorization-clients.routes-DHpYdtCv.mjs → rolatech-angular-authorization-clients.routes-kEMc6wBR.mjs} +12 -12
- package/fesm2022/{rolatech-angular-authorization-clients.routes-DHpYdtCv.mjs.map → rolatech-angular-authorization-clients.routes-kEMc6wBR.mjs.map} +1 -1
- package/fesm2022/{rolatech-angular-authorization-endpoints.routes-Cnsod_XI.mjs → rolatech-angular-authorization-endpoints.routes-DMOEhndY.mjs} +4 -4
- package/fesm2022/{rolatech-angular-authorization-endpoints.routes-Cnsod_XI.mjs.map → rolatech-angular-authorization-endpoints.routes-DMOEhndY.mjs.map} +1 -1
- package/fesm2022/{rolatech-angular-authorization-permissions.routes-Dv4sWYaz.mjs → rolatech-angular-authorization-permissions.routes-Di0MHJHq.mjs} +5 -5
- package/fesm2022/{rolatech-angular-authorization-permissions.routes-Dv4sWYaz.mjs.map → rolatech-angular-authorization-permissions.routes-Di0MHJHq.mjs.map} +1 -1
- package/fesm2022/{rolatech-angular-authorization-roles.routes-D0etCD7p.mjs → rolatech-angular-authorization-roles.routes-BmPpoHBF.mjs} +13 -18
- package/fesm2022/rolatech-angular-authorization-roles.routes-BmPpoHBF.mjs.map +1 -0
- package/fesm2022/rolatech-angular-authorization-users.routes-DGeI-_y0.mjs +361 -0
- package/fesm2022/rolatech-angular-authorization-users.routes-DGeI-_y0.mjs.map +1 -0
- package/fesm2022/rolatech-angular-authorization.mjs +5 -5
- package/package.json +1 -1
- package/fesm2022/rolatech-angular-authorization-roles.routes-D0etCD7p.mjs.map +0 -1
- package/fesm2022/rolatech-angular-authorization-users.routes-DVtcTaWv.mjs +0 -305
- package/fesm2022/rolatech-angular-authorization-users.routes-DVtcTaWv.mjs.map +0 -1
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable, inject, viewChild, Component, model, output } from '@angular/core';
|
|
3
|
+
import * as i7 from '@angular/material/paginator';
|
|
4
|
+
import { MatPaginator } from '@angular/material/paginator';
|
|
5
|
+
import * as i8 from '@angular/material/table';
|
|
6
|
+
import { MatTableDataSource } from '@angular/material/table';
|
|
7
|
+
import { AuthUserService } from '@rolatech/angular-auth';
|
|
8
|
+
import { APP_CONFIG, AngularCommonModule } from '@rolatech/angular-common';
|
|
9
|
+
import { BaseComponent, AngularComponentsModule, SpinnerComponent, ToolbarComponent, IconButtonComponent } from '@rolatech/angular-components';
|
|
10
|
+
import { BaseService, SnackBarService, NavigationService } from '@rolatech/angular-services';
|
|
11
|
+
import * as i1 from '@angular/router';
|
|
12
|
+
import * as i2 from '@angular/material/button';
|
|
13
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
14
|
+
import * as i3 from '@angular/material/icon';
|
|
15
|
+
import { MatIcon } from '@angular/material/icon';
|
|
16
|
+
import * as i3$1 from '@angular/material/form-field';
|
|
17
|
+
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
18
|
+
import * as i5 from '@angular/material/input';
|
|
19
|
+
import { MatInputModule } from '@angular/material/input';
|
|
20
|
+
import * as i6 from '@angular/material/menu';
|
|
21
|
+
import { R as RoleService } from './rolatech-angular-authorization-role.service-C-U-KnqY.mjs';
|
|
22
|
+
import * as i1$1 from '@angular/forms';
|
|
23
|
+
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
24
|
+
import * as i4 from '@angular/material/select';
|
|
25
|
+
import { MatSelectModule } from '@angular/material/select';
|
|
26
|
+
import * as i7$1 from '@angular/cdk/clipboard';
|
|
27
|
+
import { ClipboardModule } from '@angular/cdk/clipboard';
|
|
28
|
+
import * as i2$1 from '@angular/material/autocomplete';
|
|
29
|
+
import { Location } from '@angular/common';
|
|
30
|
+
|
|
31
|
+
class UserService extends BaseService {
|
|
32
|
+
init() {
|
|
33
|
+
this.endpoint = 'auth/users';
|
|
34
|
+
super.init();
|
|
35
|
+
}
|
|
36
|
+
updateRoles(id, data) {
|
|
37
|
+
return this.http.put(`${this.actionUrl}/${id}/roles`, data, {
|
|
38
|
+
withCredentials: true,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.0", ngImport: i0, type: UserService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
42
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.2.0", ngImport: i0, type: UserService, providedIn: 'root' });
|
|
43
|
+
}
|
|
44
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.0", ngImport: i0, type: UserService, decorators: [{
|
|
45
|
+
type: Injectable,
|
|
46
|
+
args: [{
|
|
47
|
+
providedIn: 'root',
|
|
48
|
+
}]
|
|
49
|
+
}] });
|
|
50
|
+
|
|
51
|
+
class UserIndex extends BaseComponent {
|
|
52
|
+
environment = inject(APP_CONFIG);
|
|
53
|
+
pageEvent;
|
|
54
|
+
isLoading = false;
|
|
55
|
+
isSearch = false;
|
|
56
|
+
length = 100;
|
|
57
|
+
pageSize = 15;
|
|
58
|
+
pageSizeOptions = [5, 10, 25, 100];
|
|
59
|
+
users = [];
|
|
60
|
+
displayedColumns = ['name', 'email', 'createdAt', 'actions'];
|
|
61
|
+
paginator = viewChild(MatPaginator, ...(ngDevMode ? [{ debugName: "paginator" }] : []));
|
|
62
|
+
orderOptions = [
|
|
63
|
+
{
|
|
64
|
+
key: 'createdAt',
|
|
65
|
+
value: 'Created At',
|
|
66
|
+
icon: 'arrow_upward',
|
|
67
|
+
sort: 'asc',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
key: 'createdAt',
|
|
71
|
+
value: 'Created At',
|
|
72
|
+
icon: 'arrow_downward',
|
|
73
|
+
sort: 'desc',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
key: 'status',
|
|
77
|
+
value: 'Status',
|
|
78
|
+
icon: 'arrow_upward',
|
|
79
|
+
sort: 'asc',
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
key: 'status',
|
|
83
|
+
value: 'Status',
|
|
84
|
+
icon: 'arrow_downward',
|
|
85
|
+
sort: 'desc',
|
|
86
|
+
},
|
|
87
|
+
];
|
|
88
|
+
orderString = 'createdAt desc';
|
|
89
|
+
dataSource = new MatTableDataSource();
|
|
90
|
+
searchWord;
|
|
91
|
+
userService = inject(UserService);
|
|
92
|
+
authUserService = inject(AuthUserService);
|
|
93
|
+
ngOnInit() {
|
|
94
|
+
this.findAll(null);
|
|
95
|
+
}
|
|
96
|
+
onClick(item) {
|
|
97
|
+
this.orderString = item.key + ' ' + item.sort;
|
|
98
|
+
this.paginator()?.firstPage();
|
|
99
|
+
this.findAll(null);
|
|
100
|
+
}
|
|
101
|
+
findAll(event) {
|
|
102
|
+
this.isLoading = true;
|
|
103
|
+
this.isSearch = false;
|
|
104
|
+
const page = event ? event.pageIndex + 1 : 1;
|
|
105
|
+
const limit = event ? event.pageSize : 15;
|
|
106
|
+
const sort = this.orderString;
|
|
107
|
+
const options = {
|
|
108
|
+
page,
|
|
109
|
+
limit,
|
|
110
|
+
sort,
|
|
111
|
+
};
|
|
112
|
+
this.userService.find(options).subscribe({
|
|
113
|
+
next: (res) => {
|
|
114
|
+
this.users = res.data;
|
|
115
|
+
this.dataSource.data = this.users;
|
|
116
|
+
this.length = res.meta.pagination.count;
|
|
117
|
+
this.isLoading = false;
|
|
118
|
+
},
|
|
119
|
+
error: (error) => {
|
|
120
|
+
this.isLoading = false;
|
|
121
|
+
this.snackBarService.open(error.message);
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
search(e) {
|
|
126
|
+
this.isLoading = true;
|
|
127
|
+
const options = {
|
|
128
|
+
filter: `phone:${e.target.value}`,
|
|
129
|
+
};
|
|
130
|
+
this.authUserService.findAll(options).subscribe({
|
|
131
|
+
next: (res) => {
|
|
132
|
+
this.users = res.data;
|
|
133
|
+
this.dataSource.data = this.users;
|
|
134
|
+
this.length = res.meta.pagination.count;
|
|
135
|
+
this.isLoading = false;
|
|
136
|
+
},
|
|
137
|
+
error: (error) => {
|
|
138
|
+
this.isLoading = false;
|
|
139
|
+
this.snackBarService.open(error.message);
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.0", ngImport: i0, type: UserIndex, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
144
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.2.0", type: UserIndex, isStandalone: true, selector: "rolatech-user-index", viewQueries: [{ propertyName: "paginator", first: true, predicate: MatPaginator, descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<rolatech-toolbar title=\"Users\">\n <rolatech-icon-button routerLink=\"./create\">add</rolatech-icon-button>\n <rolatech-icon-button (click)=\"isSearch = !isSearch\">search</rolatech-icon-button>\n <rolatech-icon-button [matMenuTriggerFor]=\"beforeMenu\">reorder</rolatech-icon-button>\n <!-- <button mat-icon-button [matMenuTriggerFor]=\"beforeMenu\">\n <mat-icon>reorder</mat-icon>\n </button> -->\n <mat-menu #beforeMenu=\"matMenu\" xPosition=\"before\">\n @for (item of orderOptions; track item) {\n <button mat-menu-item (click)=\"onClick(item)\">\n <span>{{ item.value }}</span>\n <mat-icon>{{ item.icon }}</mat-icon>\n </button>\n }\n </mat-menu>\n</rolatech-toolbar>\n@if (isSearch) {\n<mat-form-field floatLabel=\"auto\">\n <input type=\"text\" matInput placeholder=\"Phone\" (keyup.enter)=\"search($event)\" />\n <button matSuffix mat-icon-button (click)=\"findAll(null); isSearch = false\">\n <mat-icon>close</mat-icon>\n </button>\n</mat-form-field>\n}\n<div class=\"py-3\">\n <rolatech-spinner></rolatech-spinner>\n <table mat-table [dataSource]=\"dataSource\">\n <!-- name Column -->\n <ng-container matColumnDef=\"name\">\n <th mat-header-cell *matHeaderCellDef>Name</th>\n <td mat-cell *matCellDef=\"let item\">{{ item.name ? item.name : item.firstName + ',' + item.lastName }}</td>\n </ng-container>\n\n <!-- email Column -->\n <ng-container matColumnDef=\"email\">\n <th mat-header-cell *matHeaderCellDef>Email</th>\n <td mat-cell *matCellDef=\"let item\">{{ item.email }}</td>\n </ng-container>\n\n <!-- createdAt Column -->\n <ng-container matColumnDef=\"createdAt\">\n <th mat-header-cell *matHeaderCellDef>Created At</th>\n <td mat-cell *matCellDef=\"let item\">{{ item.createdAt }}</td>\n </ng-container>\n\n <!-- actions Column -->\n <ng-container matColumnDef=\"actions\" stickyEnd>\n <th mat-header-cell *matHeaderCellDef class=\"actions\"></th>\n <td mat-cell *matCellDef=\"let item\" class=\"actions\">\n <mat-icon>navigate_next</mat-icon>\n </td>\n </ng-container>\n\n <tr mat-header-row *matHeaderRowDef=\"displayedColumns\"></tr>\n <tr\n class=\"cursor-pointer hover:bg-[--rt-raised-background]\"\n mat-row\n *matRowDef=\"let row; columns: displayedColumns\"\n [routerLink]=\"['./', '@' + row.username]\"\n ></tr>\n </table>\n</div>\n<mat-paginator\n #paginator\n [length]=\"length\"\n [pageSize]=\"pageSize\"\n [pageSizeOptions]=\"pageSizeOptions\"\n (page)=\"pageEvent = findAll($event)\"\n hidePageSize\n showFirstLastButtons\n>\n</mat-paginator>\n", styles: ["mat-form-field{width:100%}table{width:100%}td.mat-column-actions{text-align:right;min-width:80px;font-size:.8rem;padding:0 28px}.mat-mdc-header-cell.actions{text-align:right;max-width:120px;width:120px;padding:0 28px}.mat-mdc-cell:nth-last-child(2),.mat-mdc-header-cell:nth-last-child(2),.mat-mdc-footer-cell:nth-last-child(2){text-align:right;max-width:180px;width:180px}mat-cell:last-of-type,mat-header-cell:last-of-type,mat-footer-cell:last-of-type{text-align:right;padding-right:8px!important}.withdraw-button{background:var(--rt-brand-color);color:#fff!important;width:100px}\n"], dependencies: [{ kind: "ngmodule", type: AngularCommonModule }, { kind: "directive", type: i1.RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "ngmodule", type: AngularComponentsModule }, { kind: "component", type: i2.MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i3$1.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3$1.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "directive", type: i5.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "component", type: i6.MatMenu, selector: "mat-menu", inputs: ["backdropClass", "aria-label", "aria-labelledby", "aria-describedby", "xPosition", "yPosition", "overlapTrigger", "hasBackdrop", "class", "classList"], outputs: ["closed", "close"], exportAs: ["matMenu"] }, { kind: "component", type: i6.MatMenuItem, selector: "[mat-menu-item]", inputs: ["role", "disabled", "disableRipple"], exportAs: ["matMenuItem"] }, { kind: "directive", type: i6.MatMenuTrigger, selector: "[mat-menu-trigger-for], [matMenuTriggerFor]", inputs: ["mat-menu-trigger-for", "matMenuTriggerFor", "matMenuTriggerData", "matMenuTriggerRestoreFocus"], outputs: ["menuOpened", "onMenuOpen", "menuClosed", "onMenuClose"], exportAs: ["matMenuTrigger"] }, { kind: "component", type: i7.MatPaginator, selector: "mat-paginator", inputs: ["color", "pageIndex", "length", "pageSize", "pageSizeOptions", "hidePageSize", "showFirstLastButtons", "selectConfig", "disabled"], outputs: ["page"], exportAs: ["matPaginator"] }, { kind: "component", type: i8.MatTable, selector: "mat-table, table[mat-table]", exportAs: ["matTable"] }, { kind: "directive", type: i8.MatHeaderCellDef, selector: "[matHeaderCellDef]" }, { kind: "directive", type: i8.MatHeaderRowDef, selector: "[matHeaderRowDef]", inputs: ["matHeaderRowDef", "matHeaderRowDefSticky"] }, { kind: "directive", type: i8.MatColumnDef, selector: "[matColumnDef]", inputs: ["matColumnDef"] }, { kind: "directive", type: i8.MatCellDef, selector: "[matCellDef]" }, { kind: "directive", type: i8.MatRowDef, selector: "[matRowDef]", inputs: ["matRowDefColumns", "matRowDefWhen"] }, { kind: "directive", type: i8.MatHeaderCell, selector: "mat-header-cell, th[mat-header-cell]" }, { kind: "directive", type: i8.MatCell, selector: "mat-cell, td[mat-cell]" }, { kind: "component", type: i8.MatHeaderRow, selector: "mat-header-row, tr[mat-header-row]", exportAs: ["matHeaderRow"] }, { kind: "component", type: i8.MatRow, selector: "mat-row, tr[mat-row]", exportAs: ["matRow"] }, { kind: "component", type: SpinnerComponent, selector: "rolatech-spinner", inputs: ["title"] }, { kind: "component", type: ToolbarComponent, selector: "rolatech-toolbar", inputs: ["title", "subtitle", "back", "link", "large", "divider"] }, { kind: "component", type: IconButtonComponent, selector: "rolatech-icon-button" }] });
|
|
145
|
+
}
|
|
146
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.0", ngImport: i0, type: UserIndex, decorators: [{
|
|
147
|
+
type: Component,
|
|
148
|
+
args: [{ selector: 'rolatech-user-index', imports: [AngularCommonModule, AngularComponentsModule, SpinnerComponent, ToolbarComponent, IconButtonComponent], template: "<rolatech-toolbar title=\"Users\">\n <rolatech-icon-button routerLink=\"./create\">add</rolatech-icon-button>\n <rolatech-icon-button (click)=\"isSearch = !isSearch\">search</rolatech-icon-button>\n <rolatech-icon-button [matMenuTriggerFor]=\"beforeMenu\">reorder</rolatech-icon-button>\n <!-- <button mat-icon-button [matMenuTriggerFor]=\"beforeMenu\">\n <mat-icon>reorder</mat-icon>\n </button> -->\n <mat-menu #beforeMenu=\"matMenu\" xPosition=\"before\">\n @for (item of orderOptions; track item) {\n <button mat-menu-item (click)=\"onClick(item)\">\n <span>{{ item.value }}</span>\n <mat-icon>{{ item.icon }}</mat-icon>\n </button>\n }\n </mat-menu>\n</rolatech-toolbar>\n@if (isSearch) {\n<mat-form-field floatLabel=\"auto\">\n <input type=\"text\" matInput placeholder=\"Phone\" (keyup.enter)=\"search($event)\" />\n <button matSuffix mat-icon-button (click)=\"findAll(null); isSearch = false\">\n <mat-icon>close</mat-icon>\n </button>\n</mat-form-field>\n}\n<div class=\"py-3\">\n <rolatech-spinner></rolatech-spinner>\n <table mat-table [dataSource]=\"dataSource\">\n <!-- name Column -->\n <ng-container matColumnDef=\"name\">\n <th mat-header-cell *matHeaderCellDef>Name</th>\n <td mat-cell *matCellDef=\"let item\">{{ item.name ? item.name : item.firstName + ',' + item.lastName }}</td>\n </ng-container>\n\n <!-- email Column -->\n <ng-container matColumnDef=\"email\">\n <th mat-header-cell *matHeaderCellDef>Email</th>\n <td mat-cell *matCellDef=\"let item\">{{ item.email }}</td>\n </ng-container>\n\n <!-- createdAt Column -->\n <ng-container matColumnDef=\"createdAt\">\n <th mat-header-cell *matHeaderCellDef>Created At</th>\n <td mat-cell *matCellDef=\"let item\">{{ item.createdAt }}</td>\n </ng-container>\n\n <!-- actions Column -->\n <ng-container matColumnDef=\"actions\" stickyEnd>\n <th mat-header-cell *matHeaderCellDef class=\"actions\"></th>\n <td mat-cell *matCellDef=\"let item\" class=\"actions\">\n <mat-icon>navigate_next</mat-icon>\n </td>\n </ng-container>\n\n <tr mat-header-row *matHeaderRowDef=\"displayedColumns\"></tr>\n <tr\n class=\"cursor-pointer hover:bg-[--rt-raised-background]\"\n mat-row\n *matRowDef=\"let row; columns: displayedColumns\"\n [routerLink]=\"['./', '@' + row.username]\"\n ></tr>\n </table>\n</div>\n<mat-paginator\n #paginator\n [length]=\"length\"\n [pageSize]=\"pageSize\"\n [pageSizeOptions]=\"pageSizeOptions\"\n (page)=\"pageEvent = findAll($event)\"\n hidePageSize\n showFirstLastButtons\n>\n</mat-paginator>\n", styles: ["mat-form-field{width:100%}table{width:100%}td.mat-column-actions{text-align:right;min-width:80px;font-size:.8rem;padding:0 28px}.mat-mdc-header-cell.actions{text-align:right;max-width:120px;width:120px;padding:0 28px}.mat-mdc-cell:nth-last-child(2),.mat-mdc-header-cell:nth-last-child(2),.mat-mdc-footer-cell:nth-last-child(2){text-align:right;max-width:180px;width:180px}mat-cell:last-of-type,mat-header-cell:last-of-type,mat-footer-cell:last-of-type{text-align:right;padding-right:8px!important}.withdraw-button{background:var(--rt-brand-color);color:#fff!important;width:100px}\n"] }]
|
|
149
|
+
}] });
|
|
150
|
+
|
|
151
|
+
class UserCreate {
|
|
152
|
+
roleService = inject(RoleService);
|
|
153
|
+
authUserService = inject(AuthUserService);
|
|
154
|
+
snackBarService = inject(SnackBarService);
|
|
155
|
+
roles = [];
|
|
156
|
+
selectedRoles = [];
|
|
157
|
+
isLoading = false;
|
|
158
|
+
user = {
|
|
159
|
+
name: '',
|
|
160
|
+
email: '',
|
|
161
|
+
phone: ''
|
|
162
|
+
};
|
|
163
|
+
newUser = false;
|
|
164
|
+
password = '222';
|
|
165
|
+
ngOnInit() {
|
|
166
|
+
this.findRoles();
|
|
167
|
+
}
|
|
168
|
+
findRoles() {
|
|
169
|
+
this.isLoading = true;
|
|
170
|
+
this.roleService.find({ limit: 600 }).subscribe({
|
|
171
|
+
next: (res) => {
|
|
172
|
+
this.roles = res.data;
|
|
173
|
+
this.isLoading = false;
|
|
174
|
+
},
|
|
175
|
+
complete: () => { },
|
|
176
|
+
error: (error) => {
|
|
177
|
+
this.isLoading = false;
|
|
178
|
+
this.snackBarService.open(error.message);
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
onSelectionChange(event) {
|
|
183
|
+
this.selectedRoles = event.value;
|
|
184
|
+
}
|
|
185
|
+
save() {
|
|
186
|
+
const roles = [];
|
|
187
|
+
this.selectedRoles.forEach((item) => {
|
|
188
|
+
roles.push({ id: item.id, name: item.name });
|
|
189
|
+
});
|
|
190
|
+
const data = {
|
|
191
|
+
name: this.user.name,
|
|
192
|
+
email: this.user.email,
|
|
193
|
+
phone: this.user.phone,
|
|
194
|
+
roles
|
|
195
|
+
};
|
|
196
|
+
this.authUserService.createUserByAdmin(data).subscribe({
|
|
197
|
+
next: res => {
|
|
198
|
+
this.newUser = true;
|
|
199
|
+
this.password = res.data.password;
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.0", ngImport: i0, type: UserCreate, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
204
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.2.0", type: UserCreate, isStandalone: true, selector: "rolatech-user-create", ngImport: i0, template: "<rolatech-toolbar title=\"Create User\" link=\"../\"></rolatech-toolbar>\n<div class=\"p-4\">\n <div class=\"flex flex-col lg:w-1/2\">\n <mat-form-field appearance=\"fill\">\n <mat-label> Name </mat-label>\n <input matInput [(ngModel)]=\"user.name\" required />\n </mat-form-field>\n <mat-form-field appearance=\"fill\">\n <mat-label> Email </mat-label>\n <input matInput [(ngModel)]=\"user.email\" required />\n </mat-form-field>\n <mat-form-field appearance=\"fill\">\n <mat-label> Phone </mat-label>\n <input matInput [(ngModel)]=\"user.phone\" required />\n </mat-form-field>\n <mat-form-field appearance=\"fill\">\n <mat-label>Role</mat-label>\n <mat-select (selectionChange)=\"onSelectionChange($event)\" [(ngModel)]=\"selectedRoles\" multiple>\n @for (item of roles; track item) {\n <mat-option [value]=\"item\"> {{ item.name }} </mat-option>\n }\n </mat-select>\n </mat-form-field>\n @if (newUser) {\n <div class=\"mb-3\">\n <div class=\"font-bold mb-2\">Copy password</div>\n <mat-form-field appearance=\"fill\" subscriptSizing=\"dynamic\">\n <input matInput type=\"password\" [value]=\"password\" readonly />\n <button matIconButton matSuffix [cdkCopyToClipboard]=\"password\">\n <mat-icon>content_copy</mat-icon>\n </button>\n </mat-form-field>\n </div>\n }\n </div>\n\n <button mat-flat-button (click)=\"save()\">Save</button>\n</div>\n", styles: ["mat-form-field{width:100%}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: ToolbarComponent, selector: "rolatech-toolbar", inputs: ["title", "subtitle", "back", "link", "large", "divider"] }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i3$1.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3$1.MatLabel, selector: "mat-label" }, { kind: "directive", type: i3$1.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i5.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "ngmodule", type: MatSelectModule }, { kind: "component", type: i4.MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth", "canSelectNullableOptions"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "component", type: i2$1.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i2.MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }, { kind: "component", type: i2.MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "ngmodule", type: ClipboardModule }, { kind: "directive", type: i7$1.CdkCopyToClipboard, selector: "[cdkCopyToClipboard]", inputs: ["cdkCopyToClipboard", "cdkCopyToClipboardAttempts"], outputs: ["cdkCopyToClipboardCopied"] }, { kind: "component", type: MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }] });
|
|
205
|
+
}
|
|
206
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.0", ngImport: i0, type: UserCreate, decorators: [{
|
|
207
|
+
type: Component,
|
|
208
|
+
args: [{ selector: 'rolatech-user-create', imports: [FormsModule, ToolbarComponent,
|
|
209
|
+
MatFormFieldModule, MatInputModule, ReactiveFormsModule,
|
|
210
|
+
MatSelectModule, MatButtonModule, ClipboardModule, MatIcon
|
|
211
|
+
], template: "<rolatech-toolbar title=\"Create User\" link=\"../\"></rolatech-toolbar>\n<div class=\"p-4\">\n <div class=\"flex flex-col lg:w-1/2\">\n <mat-form-field appearance=\"fill\">\n <mat-label> Name </mat-label>\n <input matInput [(ngModel)]=\"user.name\" required />\n </mat-form-field>\n <mat-form-field appearance=\"fill\">\n <mat-label> Email </mat-label>\n <input matInput [(ngModel)]=\"user.email\" required />\n </mat-form-field>\n <mat-form-field appearance=\"fill\">\n <mat-label> Phone </mat-label>\n <input matInput [(ngModel)]=\"user.phone\" required />\n </mat-form-field>\n <mat-form-field appearance=\"fill\">\n <mat-label>Role</mat-label>\n <mat-select (selectionChange)=\"onSelectionChange($event)\" [(ngModel)]=\"selectedRoles\" multiple>\n @for (item of roles; track item) {\n <mat-option [value]=\"item\"> {{ item.name }} </mat-option>\n }\n </mat-select>\n </mat-form-field>\n @if (newUser) {\n <div class=\"mb-3\">\n <div class=\"font-bold mb-2\">Copy password</div>\n <mat-form-field appearance=\"fill\" subscriptSizing=\"dynamic\">\n <input matInput type=\"password\" [value]=\"password\" readonly />\n <button matIconButton matSuffix [cdkCopyToClipboard]=\"password\">\n <mat-icon>content_copy</mat-icon>\n </button>\n </mat-form-field>\n </div>\n }\n </div>\n\n <button mat-flat-button (click)=\"save()\">Save</button>\n</div>\n", styles: ["mat-form-field{width:100%}\n"] }]
|
|
212
|
+
}] });
|
|
213
|
+
|
|
214
|
+
class UserRolesUpdateDialogComponent {
|
|
215
|
+
roles = model(...(ngDevMode ? [undefined, { debugName: "roles" }] : []));
|
|
216
|
+
selectedRoles = model(...(ngDevMode ? [undefined, { debugName: "selectedRoles" }] : []));
|
|
217
|
+
selected = model(...(ngDevMode ? [undefined, { debugName: "selected" }] : []));
|
|
218
|
+
output = output();
|
|
219
|
+
onSelectionChange(event) {
|
|
220
|
+
this.selectedRoles = event.value;
|
|
221
|
+
this.output.emit(this.selectedRoles);
|
|
222
|
+
}
|
|
223
|
+
compareFn(o1, o2) {
|
|
224
|
+
return o1.id === o2.id;
|
|
225
|
+
}
|
|
226
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.0", ngImport: i0, type: UserRolesUpdateDialogComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
227
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.2.0", type: UserRolesUpdateDialogComponent, isStandalone: true, selector: "rolatech-authorization-user-roles-update-dialog", inputs: { roles: { classPropertyName: "roles", publicName: "roles", isSignal: true, isRequired: false, transformFunction: null }, selectedRoles: { classPropertyName: "selectedRoles", publicName: "selectedRoles", isSignal: true, isRequired: false, transformFunction: null }, selected: { classPropertyName: "selected", publicName: "selected", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { roles: "rolesChange", selectedRoles: "selectedRolesChange", selected: "selectedChange", output: "output" }, ngImport: i0, template: "<div>\n <mat-form-field appearance=\"fill\">\n <mat-label>Role</mat-label>\n <mat-select [compareWith]=\"compareFn\" (selectionChange)=\"onSelectionChange($event)\" [(ngModel)]=\"selectedRoles\" multiple>\n @for (item of roles(); track item) {\n <mat-option [value]=\"item\">\n {{ item.name }}\n </mat-option>\n }\n </mat-select>\n </mat-form-field>\n</div>\n", styles: ["mat-form-field{width:100%}\n"], dependencies: [{ kind: "ngmodule", type: AngularCommonModule }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: AngularComponentsModule }, { kind: "component", type: i2$1.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "component", type: i3$1.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3$1.MatLabel, selector: "mat-label" }, { kind: "component", type: i4.MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth", "canSelectNullableOptions"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }] });
|
|
228
|
+
}
|
|
229
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.0", ngImport: i0, type: UserRolesUpdateDialogComponent, decorators: [{
|
|
230
|
+
type: Component,
|
|
231
|
+
args: [{ imports: [AngularCommonModule, AngularComponentsModule], selector: 'rolatech-authorization-user-roles-update-dialog', template: "<div>\n <mat-form-field appearance=\"fill\">\n <mat-label>Role</mat-label>\n <mat-select [compareWith]=\"compareFn\" (selectionChange)=\"onSelectionChange($event)\" [(ngModel)]=\"selectedRoles\" multiple>\n @for (item of roles(); track item) {\n <mat-option [value]=\"item\">\n {{ item.name }}\n </mat-option>\n }\n </mat-select>\n </mat-form-field>\n</div>\n", styles: ["mat-form-field{width:100%}\n"] }]
|
|
232
|
+
}] });
|
|
233
|
+
|
|
234
|
+
class UserDetails extends BaseComponent {
|
|
235
|
+
user;
|
|
236
|
+
isLoading = false;
|
|
237
|
+
roles = [];
|
|
238
|
+
selectedRoleIds = [];
|
|
239
|
+
selectedRoles = [];
|
|
240
|
+
userService = inject(UserService);
|
|
241
|
+
authUserService = inject(AuthUserService);
|
|
242
|
+
roleService = inject(RoleService);
|
|
243
|
+
location = inject(Location);
|
|
244
|
+
navigationService = inject(NavigationService);
|
|
245
|
+
username = this.route.snapshot.params['username'];
|
|
246
|
+
ngOnInit() {
|
|
247
|
+
this.findByUsername();
|
|
248
|
+
this.findAllRoles();
|
|
249
|
+
}
|
|
250
|
+
back() {
|
|
251
|
+
this.navigationService.back();
|
|
252
|
+
}
|
|
253
|
+
findById() {
|
|
254
|
+
this.userService.get(this.id, {}).subscribe({
|
|
255
|
+
next: (res) => {
|
|
256
|
+
this.user = res.data;
|
|
257
|
+
if (res.data.roles) {
|
|
258
|
+
res.data.roles.forEach((item) => {
|
|
259
|
+
this.selectedRoles.push({ id: item.id, name: item.name });
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
findByUsername() {
|
|
266
|
+
this.authUserService.findByUsername(this.username.substring(1)).subscribe({
|
|
267
|
+
next: (res) => {
|
|
268
|
+
this.user = res.data;
|
|
269
|
+
if (res.data.roles) {
|
|
270
|
+
res.data.roles.forEach((item) => {
|
|
271
|
+
this.selectedRoles.push({ id: item.id, name: item.name });
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
findAllRoles() {
|
|
278
|
+
this.isLoading = true;
|
|
279
|
+
this.roleService.find({ limit: 600 }).subscribe({
|
|
280
|
+
next: (res) => {
|
|
281
|
+
this.roles = res.data;
|
|
282
|
+
this.isLoading = false;
|
|
283
|
+
},
|
|
284
|
+
complete: () => { },
|
|
285
|
+
error: (error) => {
|
|
286
|
+
this.isLoading = false;
|
|
287
|
+
this.snackBarService.open(error.message);
|
|
288
|
+
},
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
onSelectionChange(event) {
|
|
292
|
+
this.selectedRoleIds = event.value;
|
|
293
|
+
}
|
|
294
|
+
updateRoles() {
|
|
295
|
+
this.roleService.find({}).subscribe({
|
|
296
|
+
next: (res) => {
|
|
297
|
+
const roles = [];
|
|
298
|
+
res.data.forEach((element) => {
|
|
299
|
+
roles.push({ id: element.id, name: element.name });
|
|
300
|
+
});
|
|
301
|
+
const options = {
|
|
302
|
+
title: 'Update Roles',
|
|
303
|
+
cancelText: 'Cancel',
|
|
304
|
+
confirmText: 'Ok',
|
|
305
|
+
component: UserRolesUpdateDialogComponent,
|
|
306
|
+
data: {
|
|
307
|
+
selectedRoles: this.selectedRoles,
|
|
308
|
+
roles: roles,
|
|
309
|
+
},
|
|
310
|
+
};
|
|
311
|
+
this.dialogService.open(options);
|
|
312
|
+
this.dialogService.confirmed().subscribe({
|
|
313
|
+
next: (result) => {
|
|
314
|
+
if (result) {
|
|
315
|
+
const data = {
|
|
316
|
+
roles: result,
|
|
317
|
+
};
|
|
318
|
+
this.selectedRoles = [];
|
|
319
|
+
result.forEach((item) => {
|
|
320
|
+
this.selectedRoles.push({ id: item.id, name: item.name });
|
|
321
|
+
});
|
|
322
|
+
this.userService.updateRoles(this.user.id, data).subscribe({
|
|
323
|
+
next: (res) => {
|
|
324
|
+
this.user.roles = result;
|
|
325
|
+
this.snackBarService.open('Update successfully');
|
|
326
|
+
},
|
|
327
|
+
error: (error) => {
|
|
328
|
+
this.snackBarService.open(error.message);
|
|
329
|
+
},
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
});
|
|
334
|
+
},
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.0", ngImport: i0, type: UserDetails, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
338
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.2.0", type: UserDetails, isStandalone: true, selector: "rolatech-user-details", usesInheritance: true, ngImport: i0, template: "@if (user) {\n<rolatech-toolbar [title]=\"user.name\" link=\"../\"></rolatech-toolbar>\n<div class=\"p-3\">\n <div class=\"flex gap-3 py-3\">\n <div>\n @if (user.avatar) {\n <img class=\"w-32 h-32 rounded-md object-cover\" [src]=\"user.avatar\" alt />\n } @else {\n <div class=\"w-32 h-32 rounded-md bg-[--rt-raised-background]\"></div>\n }\n </div>\n <div>\n <div class=\"text-lg font-medium\">{{ user.name }}</div>\n <div>@{{ user.username }}</div>\n <div>{{ user.phone }}</div>\n </div>\n </div>\n <div class=\"flex flex-row items-center flex-wrap\">\n <span class=\"mr-2\">Roles: </span>\n @for (item of user.roles; track item) {\n <a class=\"mr-4 underline\" [href]=\"['/roles/' + item.id]\">{{ item.name }}</a>\n }\n <button mat-flat-button (click)=\"updateRoles()\" class=\"cursor-pointer\">Update</button>\n </div>\n</div>\n}\n", styles: [""], dependencies: [{ kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i2.MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }, { kind: "component", type: ToolbarComponent, selector: "rolatech-toolbar", inputs: ["title", "subtitle", "back", "link", "large", "divider"] }] });
|
|
339
|
+
}
|
|
340
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.0", ngImport: i0, type: UserDetails, decorators: [{
|
|
341
|
+
type: Component,
|
|
342
|
+
args: [{ selector: 'rolatech-user-details', imports: [MatButtonModule, ToolbarComponent], template: "@if (user) {\n<rolatech-toolbar [title]=\"user.name\" link=\"../\"></rolatech-toolbar>\n<div class=\"p-3\">\n <div class=\"flex gap-3 py-3\">\n <div>\n @if (user.avatar) {\n <img class=\"w-32 h-32 rounded-md object-cover\" [src]=\"user.avatar\" alt />\n } @else {\n <div class=\"w-32 h-32 rounded-md bg-[--rt-raised-background]\"></div>\n }\n </div>\n <div>\n <div class=\"text-lg font-medium\">{{ user.name }}</div>\n <div>@{{ user.username }}</div>\n <div>{{ user.phone }}</div>\n </div>\n </div>\n <div class=\"flex flex-row items-center flex-wrap\">\n <span class=\"mr-2\">Roles: </span>\n @for (item of user.roles; track item) {\n <a class=\"mr-4 underline\" [href]=\"['/roles/' + item.id]\">{{ item.name }}</a>\n }\n <button mat-flat-button (click)=\"updateRoles()\" class=\"cursor-pointer\">Update</button>\n </div>\n</div>\n}\n" }]
|
|
343
|
+
}] });
|
|
344
|
+
|
|
345
|
+
const usersRoutes = [
|
|
346
|
+
{
|
|
347
|
+
path: '',
|
|
348
|
+
component: UserIndex,
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
path: 'create',
|
|
352
|
+
component: UserCreate,
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
path: ':username',
|
|
356
|
+
component: UserDetails,
|
|
357
|
+
},
|
|
358
|
+
];
|
|
359
|
+
|
|
360
|
+
export { usersRoutes as default };
|
|
361
|
+
//# sourceMappingURL=rolatech-angular-authorization-users.routes-DGeI-_y0.mjs.map
|