@juice-js/tenants 1.0.3 → 1.0.6-alpha.13
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/esm2020/juice-js-tenants.mjs +5 -0
- package/esm2020/lib/confirm-dialog/confirm-dialog.component.mjs +53 -0
- package/esm2020/lib/shared/custom-error-state-matcher.mjs +8 -0
- package/esm2020/lib/shared/material.module.mjs +124 -0
- package/esm2020/lib/shared/models/table.query-result.mjs +2 -0
- package/esm2020/lib/shared/models/tenant.create.model.mjs +17 -0
- package/esm2020/lib/shared/models/tenant.model.mjs +2 -0
- package/esm2020/lib/shared/models/tenant.setting.model.mjs +13 -0
- package/esm2020/lib/shared/models/tenant.status.mjs +42 -0
- package/esm2020/lib/shared/models/tenant.update.model.mjs +8 -0
- package/esm2020/lib/shared/services/tenant-admin.service.mjs +88 -0
- package/esm2020/lib/shared/tenant-configuration.mjs +11 -0
- package/esm2020/lib/tenant-create/tenant-create.component.mjs +69 -0
- package/esm2020/lib/tenant-detail/tenant-detail.component.mjs +36 -0
- package/esm2020/lib/tenant-summary/tenant-summary.component.mjs +30 -0
- package/esm2020/lib/tenant-update/tenant-update.component.mjs +77 -0
- package/esm2020/lib/tenants.component.mjs +502 -0
- package/esm2020/lib/tenants.module.mjs +86 -0
- package/esm2020/public-api.mjs +12 -0
- package/fesm2015/juice-js-tenants.mjs +1109 -0
- package/fesm2015/juice-js-tenants.mjs.map +1 -0
- package/fesm2020/juice-js-tenants.mjs +1101 -0
- package/fesm2020/juice-js-tenants.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/confirm-dialog/confirm-dialog.component.d.ts +29 -0
- package/lib/shared/custom-error-state-matcher.d.ts +6 -0
- package/lib/shared/material.module.d.ts +33 -0
- package/{src/lib/shared/models/table.query-result.ts → lib/shared/models/table.query-result.d.ts} +6 -7
- package/lib/shared/models/tenant.create.model.d.ts +12 -0
- package/{src/lib/shared/models/tenant.model.ts → lib/shared/models/tenant.model.d.ts} +13 -15
- package/lib/shared/models/tenant.setting.model.d.ts +7 -0
- package/lib/shared/models/tenant.status.d.ts +16 -0
- package/lib/shared/models/tenant.update.model.d.ts +5 -0
- package/lib/shared/services/tenant-admin.service.d.ts +34 -0
- package/lib/shared/tenant-configuration.d.ts +12 -0
- package/lib/tenant-create/tenant-create.component.d.ts +28 -0
- package/lib/tenant-detail/tenant-detail.component.d.ts +17 -0
- package/lib/tenant-summary/tenant-summary.component.d.ts +14 -0
- package/lib/tenant-update/tenant-update.component.d.ts +30 -0
- package/lib/tenants.component.d.ts +76 -0
- package/lib/tenants.module.d.ts +21 -0
- package/package.json +31 -6
- package/{src/public-api.ts → public-api.d.ts} +0 -4
- package/{src → theming}/_tenants.component-theme.scss +64 -64
- package/ng-package.json +0 -10
- package/src/lib/confirm-dialog/confirm-dialog.component.html +0 -10
- package/src/lib/confirm-dialog/confirm-dialog.component.scss +0 -9
- package/src/lib/confirm-dialog/confirm-dialog.component.spec.ts +0 -33
- package/src/lib/confirm-dialog/confirm-dialog.component.ts +0 -49
- package/src/lib/shared/custom-error-state-matcher.ts +0 -15
- package/src/lib/shared/material.module.ts +0 -62
- package/src/lib/shared/models/tenant.create.model.ts +0 -13
- package/src/lib/shared/models/tenant.setting.model.ts +0 -14
- package/src/lib/shared/models/tenant.status.ts +0 -32
- package/src/lib/shared/models/tenant.update.model.ts +0 -5
- package/src/lib/shared/services/tenant-admin.service.ts +0 -109
- package/src/lib/shared/services/tenant.service.spec.ts +0 -28
- package/src/lib/shared/tenant-configuration.ts +0 -18
- package/src/lib/shared/tenant-testing.ts +0 -44
- package/src/lib/tenant-create/tenant-create.component.css +0 -10
- package/src/lib/tenant-create/tenant-create.component.html +0 -45
- package/src/lib/tenant-create/tenant-create.component.spec.ts +0 -32
- package/src/lib/tenant-create/tenant-create.component.ts +0 -68
- package/src/lib/tenant-detail/tenant-detail.component.html +0 -50
- package/src/lib/tenant-detail/tenant-detail.component.scss +0 -3
- package/src/lib/tenant-detail/tenant-detail.component.spec.ts +0 -29
- package/src/lib/tenant-detail/tenant-detail.component.ts +0 -31
- package/src/lib/tenant-summary/tenant-summary.component.css +0 -4
- package/src/lib/tenant-summary/tenant-summary.component.html +0 -28
- package/src/lib/tenant-summary/tenant-summary.component.spec.ts +0 -29
- package/src/lib/tenant-summary/tenant-summary.component.ts +0 -28
- package/src/lib/tenant-update/tenant-update.component.html +0 -32
- package/src/lib/tenant-update/tenant-update.component.scss +0 -9
- package/src/lib/tenant-update/tenant-update.component.spec.ts +0 -29
- package/src/lib/tenant-update/tenant-update.component.ts +0 -77
- package/src/lib/tenants.component.html +0 -117
- package/src/lib/tenants.component.scss +0 -56
- package/src/lib/tenants.component.spec.ts +0 -30
- package/src/lib/tenants.component.ts +0 -565
- package/src/lib/tenants.module.ts +0 -60
- package/tsconfig.lib.json +0 -14
- package/tsconfig.lib.prod.json +0 -10
- package/tsconfig.spec.json +0 -14
|
@@ -1,565 +0,0 @@
|
|
|
1
|
-
import { Component, AfterViewInit, ViewChild } from '@angular/core';
|
|
2
|
-
import { TenantAdminService } from './shared/services/tenant-admin.service';
|
|
3
|
-
import { MatMultiSort, MatMultiSortTableDataSource, TableData } from 'ngx-mat-multi-sort';
|
|
4
|
-
import { MatPaginator } from '@angular/material/paginator';
|
|
5
|
-
import { TenantBasic } from './shared/models/tenant.model';
|
|
6
|
-
import { ActivatedRoute, Router, UrlSerializer } from '@angular/router';
|
|
7
|
-
import { Location } from '@angular/common';
|
|
8
|
-
import { TenantStatus, TenantStatusHelper } from './shared/models/tenant.status';
|
|
9
|
-
import { TableQueryResult } from './shared/models/table.query-result';
|
|
10
|
-
import { FormBuilder, FormGroup } from '@angular/forms';
|
|
11
|
-
import { MatDialog } from '@angular/material/dialog';
|
|
12
|
-
import { ConfirmDialogComponent, TenantCreateComponent, TenantDetailComponent, TenantUpdateComponent } from '../public-api';
|
|
13
|
-
import { DictBuilderComponent, KeyValue, ModelType } from '@juice-js/dict-builder';
|
|
14
|
-
import { MatSnackBar } from '@angular/material/snack-bar';
|
|
15
|
-
import { TranslateService } from '@ngx-translate/core';
|
|
16
|
-
import { TenantSetting } from './shared/models/tenant.setting.model';
|
|
17
|
-
import { TenantConfiguration } from './shared/tenant-configuration';
|
|
18
|
-
|
|
19
|
-
@Component({
|
|
20
|
-
selector: 'juice-tenants',
|
|
21
|
-
templateUrl: './tenants.component.html',
|
|
22
|
-
styleUrls: ['./tenants.component.scss']
|
|
23
|
-
})
|
|
24
|
-
export class TenantsComponent implements AfterViewInit{
|
|
25
|
-
|
|
26
|
-
displayedColumns: string[] = ['name', 'identifier', 'status', 'actions'];
|
|
27
|
-
table: TableData<TenantBasic>;
|
|
28
|
-
|
|
29
|
-
tenantStatus = TenantStatus;
|
|
30
|
-
statusHelper = TenantStatusHelper;
|
|
31
|
-
statusOptions = Object.values(TenantStatus).filter(value => typeof value === 'string')
|
|
32
|
-
.map(value => value as TenantStatus);
|
|
33
|
-
|
|
34
|
-
get statuses(){
|
|
35
|
-
return this.form.get("statuses");
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
get filterText(){
|
|
39
|
-
return this.form.get("filterText");
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
@ViewChild(MatPaginator) paginator!: MatPaginator;
|
|
43
|
-
@ViewChild(MatMultiSort) sort!: MatMultiSort;
|
|
44
|
-
|
|
45
|
-
form: FormGroup = new FormGroup({});
|
|
46
|
-
|
|
47
|
-
constructor(private tenantService: TenantAdminService,
|
|
48
|
-
private router: Router,
|
|
49
|
-
private route: ActivatedRoute,
|
|
50
|
-
private location: Location,
|
|
51
|
-
private serializer: UrlSerializer,
|
|
52
|
-
private fb: FormBuilder,
|
|
53
|
-
public dialog: MatDialog,
|
|
54
|
-
private snackBar: MatSnackBar,
|
|
55
|
-
private localizer: TranslateService,
|
|
56
|
-
private options: TenantConfiguration
|
|
57
|
-
) {
|
|
58
|
-
|
|
59
|
-
this.table = new TableData<TenantBasic>([
|
|
60
|
-
{ id: 'id', name: 'Id' },
|
|
61
|
-
{ id: 'name', name: 'Name' },
|
|
62
|
-
{ id: 'identifier', name: 'Identifier' },
|
|
63
|
-
{ id: 'status', name: 'Status' },
|
|
64
|
-
{ id: 'actions', name: 'Actions'}
|
|
65
|
-
]
|
|
66
|
-
);
|
|
67
|
-
this.table.dataSource = new MatMultiSortTableDataSource<TenantBasic>(new MatMultiSort(), false);
|
|
68
|
-
|
|
69
|
-
this.table.displayedColumns = this.displayedColumns;
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
ngOnInit(): void{
|
|
74
|
-
this.form = this.fb.group({
|
|
75
|
-
filterText: [],
|
|
76
|
-
statuses: []
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
let firstLoad = true;
|
|
80
|
-
this.route.queryParams.subscribe(params =>{
|
|
81
|
-
console.debug("route.queryParams.subscribe", params);
|
|
82
|
-
if(firstLoad){
|
|
83
|
-
firstLoad = false;
|
|
84
|
-
this.initFormAndTableEvents();
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
var q = params['q'] || "";
|
|
88
|
-
this.filterText?.setValue(q);
|
|
89
|
-
if(params['statuses']=='any'){
|
|
90
|
-
this.statuses?.setValue([]);
|
|
91
|
-
}else{
|
|
92
|
-
this.statuses?.setValue(params['statuses']?
|
|
93
|
-
Array.isArray(params['statuses']) ? params['statuses'] : [params['statuses']]
|
|
94
|
-
:[TenantStatus.Active, TenantStatus.PendingApproval, TenantStatus.PendingToActive]);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
this.table.pageSize = params['pageSize']? Number.parseInt(params['pageSize']): 10;
|
|
98
|
-
this.table.pageIndex = params['page']? Number.parseInt(params['page']): 0;
|
|
99
|
-
var sortParams = params['sortParams'];
|
|
100
|
-
var sortDirs = params['sortDirs'];
|
|
101
|
-
if(sortParams && sortDirs){
|
|
102
|
-
if(Array.isArray(sortParams) && Array.isArray(sortDirs)){
|
|
103
|
-
this.table.sortParams = sortParams;
|
|
104
|
-
this.table.sortDirs = sortDirs;
|
|
105
|
-
}else if(typeof sortParams == "string"
|
|
106
|
-
&& typeof (sortDirs) == "string"){
|
|
107
|
-
this.table.sortParams = [sortParams];
|
|
108
|
-
this.table.sortDirs = [sortDirs];
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
initFormAndTableEvents(){
|
|
115
|
-
this.table.nextObservable.subscribe(() => { this.getData(); });
|
|
116
|
-
this.table.sortObservable.subscribe((e) => { this.getData(); });
|
|
117
|
-
this.table.previousObservable.subscribe(() => { this.getData(); });
|
|
118
|
-
this.table.sizeObservable.subscribe(() => { this.getData(); });
|
|
119
|
-
|
|
120
|
-
this.form.controls['statuses'].valueChanges.subscribe(value => {
|
|
121
|
-
this.getData();
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
ngAfterViewInit(): void {
|
|
126
|
-
|
|
127
|
-
this.table.dataSource.sort = this.sort;
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
//#region filters
|
|
132
|
-
clearStatuses(){
|
|
133
|
-
this.statuses?.setValue([]);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
clearFilterText(){
|
|
137
|
-
this.filterText?.setValue("");
|
|
138
|
-
this.getData();
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
getData(fromRoute: boolean = false) {
|
|
142
|
-
var q = this.filterText?.value;
|
|
143
|
-
|
|
144
|
-
if(!fromRoute){
|
|
145
|
-
var statuses = this.statuses?.value;
|
|
146
|
-
if(!statuses || statuses.length == 0){
|
|
147
|
-
statuses = 'any';
|
|
148
|
-
}
|
|
149
|
-
const tree = this.router.createUrlTree([], { queryParams: {
|
|
150
|
-
q: q,
|
|
151
|
-
statuses: statuses,
|
|
152
|
-
page: this.table.pageIndex,
|
|
153
|
-
pageSize: this.table.pageSize,
|
|
154
|
-
sortParams: this.table.sortParams,
|
|
155
|
-
sortDirs: this.table.sortDirs
|
|
156
|
-
} });
|
|
157
|
-
|
|
158
|
-
this.location.go(this.serializer.serialize(tree));
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
this.tenantService.getTenants(q, this.statuses?.value||[],
|
|
162
|
-
this.table.sortParams, this.table.sortDirs, this.table.pageIndex, this.table.pageSize
|
|
163
|
-
)
|
|
164
|
-
.subscribe((rs : TableQueryResult<TenantBasic>)=> {
|
|
165
|
-
this.table.totalElements = rs.count;
|
|
166
|
-
this.table.pageIndex = rs.page-1;
|
|
167
|
-
this.table.pageSize = rs.pageSize;
|
|
168
|
-
this.table.data = rs.data;
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
//#endregion
|
|
173
|
-
|
|
174
|
-
//#region actions
|
|
175
|
-
add(){
|
|
176
|
-
const dialogRef = this.dialog.open(TenantCreateComponent, {
|
|
177
|
-
width: this.options.dialogWidth,
|
|
178
|
-
maxHeight: this.options.dialogMaxHeight,
|
|
179
|
-
data: {}
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
let instance = dialogRef.componentInstance;
|
|
183
|
-
instance.created.subscribe((id: string) => {
|
|
184
|
-
this.getData();
|
|
185
|
-
this.openSnackBar("Tenant was created!");
|
|
186
|
-
dialogRef.close();
|
|
187
|
-
});
|
|
188
|
-
instance.cancelled.subscribe(() => {
|
|
189
|
-
this.openSnackBar("Tenant creation was cancelled!");
|
|
190
|
-
dialogRef.close();
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
edit(id: string){
|
|
195
|
-
console.debug("edit", id);
|
|
196
|
-
const dialogRef = this.dialog.open(TenantUpdateComponent, {
|
|
197
|
-
width: this.options.dialogWidth,
|
|
198
|
-
maxHeight: this.options.dialogMaxHeight,
|
|
199
|
-
data: {id: id}
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
let instance = dialogRef.componentInstance;
|
|
203
|
-
instance.setId(id);
|
|
204
|
-
instance.updated.subscribe((id: string) => {
|
|
205
|
-
this.getData();
|
|
206
|
-
this.openSnackBar("Tenant was updated!");
|
|
207
|
-
dialogRef.close();
|
|
208
|
-
});
|
|
209
|
-
instance.cancelled.subscribe(() => {
|
|
210
|
-
this.openSnackBar("Tenant update was cancelled!");
|
|
211
|
-
dialogRef.close();
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
detail(id: string){
|
|
216
|
-
const dialogRef = this.dialog.open(TenantDetailComponent, {
|
|
217
|
-
width: this.options.dialogWidth,
|
|
218
|
-
maxHeight: this.options.dialogMaxHeight,
|
|
219
|
-
});
|
|
220
|
-
let instance = dialogRef.componentInstance;
|
|
221
|
-
instance.loadTenant(id);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
delete(id: string){
|
|
225
|
-
console.debug("delete", id);
|
|
226
|
-
this.confirm(this.doDelete.bind(this, id),
|
|
227
|
-
{
|
|
228
|
-
title: "Dangerous action!",
|
|
229
|
-
message: "Please confirm that you want to delete this tenant? All data will be deleted and this action cannot be undone.",
|
|
230
|
-
messageClasses: "warn-color",
|
|
231
|
-
buttonText:"Delete forever",
|
|
232
|
-
buttonColor:"warn"
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
doDelete(id: string){
|
|
237
|
-
this.tenantService.deleteTenant(id).subscribe({
|
|
238
|
-
complete: () => {
|
|
239
|
-
this.getData();
|
|
240
|
-
this.openSnackBar("Tenant was deleted!");
|
|
241
|
-
}, error: (error: any) => {
|
|
242
|
-
this.openSnackBar("Error deleting tenant!");
|
|
243
|
-
console.debug(error);
|
|
244
|
-
}});
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
activate(id: string){
|
|
248
|
-
console.debug("activate", id);
|
|
249
|
-
this.confirm(this.doActivate.bind(this, id),
|
|
250
|
-
{
|
|
251
|
-
message: "Please confirm that you want to activate this tenant.",
|
|
252
|
-
messageClasses: "success-color",
|
|
253
|
-
buttonText:"Activate",
|
|
254
|
-
buttonColor:"success"
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
doActivate(id: string){
|
|
259
|
-
this.tenantService.activateTenant(id).subscribe({
|
|
260
|
-
complete: () => {
|
|
261
|
-
this.getData();
|
|
262
|
-
this.openSnackBar("Tenant was activated!");
|
|
263
|
-
}, error: (error: any) => {
|
|
264
|
-
this.openSnackBar("Error activating tenant!");
|
|
265
|
-
console.debug(error);
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
reactivate(id: string){
|
|
271
|
-
console.debug("reactivate", id);
|
|
272
|
-
this.confirm(this.doReactivate.bind(this, id),
|
|
273
|
-
{
|
|
274
|
-
message: "Please confirm that you want to reactivate this tenant.",
|
|
275
|
-
messageClasses: "success-color",
|
|
276
|
-
buttonText:"Reactivate"
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
doReactivate(id: string){
|
|
281
|
-
this.tenantService.reactivateTenant(id).subscribe({
|
|
282
|
-
complete: () => {
|
|
283
|
-
this.getData();
|
|
284
|
-
this.openSnackBar("Tenant was reactivated!");
|
|
285
|
-
}, error: (error: any) => {
|
|
286
|
-
this.openSnackBar("Error reactivating tenant!");
|
|
287
|
-
console.debug(error);
|
|
288
|
-
}
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
deactivate(id: string){
|
|
293
|
-
console.debug("deactivate", id);
|
|
294
|
-
this.confirm(this.doDeactivate.bind(this, id),
|
|
295
|
-
{
|
|
296
|
-
message: "Please confirm that you want to deactivate this tenant. Users will not be able to login!",
|
|
297
|
-
messageClasses: "warn-color",
|
|
298
|
-
buttonText:"Deactivate",
|
|
299
|
-
buttonColor:"warn"
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
doDeactivate(id: string){
|
|
304
|
-
this.tenantService.deactivateTenant(id).subscribe({
|
|
305
|
-
complete: () => {
|
|
306
|
-
this.getData();
|
|
307
|
-
this.openSnackBar("Tenant was activated!");
|
|
308
|
-
}, error: (error: any) => {
|
|
309
|
-
this.openSnackBar("Error activating tenant!");
|
|
310
|
-
console.debug(error);
|
|
311
|
-
}
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
suspend(id: string){
|
|
316
|
-
console.debug("suspend", id);
|
|
317
|
-
this.confirm(this.doSuspend.bind(this, id),
|
|
318
|
-
{
|
|
319
|
-
message: "Please confirm that you want to suspend this tenant. Users will not be able to login!",
|
|
320
|
-
messageClasses: "warn-color",
|
|
321
|
-
buttonText:"Suspend",
|
|
322
|
-
buttonColor:"warn"
|
|
323
|
-
});
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
doSuspend(id: string){
|
|
327
|
-
this.tenantService.suspendTenant(id).subscribe({
|
|
328
|
-
complete: () => {
|
|
329
|
-
this.getData();
|
|
330
|
-
this.openSnackBar("Tenant was suspended!");
|
|
331
|
-
}, error: (error: any) => {
|
|
332
|
-
this.openSnackBar("Error suspending tenant!");
|
|
333
|
-
console.debug(error);
|
|
334
|
-
}
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
abandon(id: string){
|
|
339
|
-
console.debug("abandon", id);
|
|
340
|
-
this.confirm(this.doAbandon.bind(this, id),
|
|
341
|
-
{
|
|
342
|
-
message: "Please confirm that you want to abandon this tenant. All data will be deleted and this action cannot be undone.",
|
|
343
|
-
messageClasses: "warn-color",
|
|
344
|
-
buttonText:"Abandon",
|
|
345
|
-
buttonColor:"warn"
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
doAbandon(id: string){
|
|
350
|
-
this.tenantService.abandonTenant(id).subscribe({
|
|
351
|
-
complete: () => {
|
|
352
|
-
this.getData();
|
|
353
|
-
this.openSnackBar("Tenant was abandoned!");
|
|
354
|
-
}, error: (error: any) => {
|
|
355
|
-
this.openSnackBar("Error abandoning tenant!");
|
|
356
|
-
console.debug(error);
|
|
357
|
-
}
|
|
358
|
-
});
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
approve(id: string){
|
|
362
|
-
console.debug("approve", id);
|
|
363
|
-
this.confirm(this.doApprove.bind(this, id),
|
|
364
|
-
{
|
|
365
|
-
message: "Please confirm that you want to approve this tenant.",
|
|
366
|
-
messageClasses: "success-color",
|
|
367
|
-
buttonText:"Approve",
|
|
368
|
-
buttonColor:"success"
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
doApprove(id: string){
|
|
373
|
-
this.tenantService.approveTenant(id).subscribe({
|
|
374
|
-
complete: () => {
|
|
375
|
-
this.getData();
|
|
376
|
-
this.openSnackBar("Tenant was approved!");
|
|
377
|
-
}, error: (error: any) => {
|
|
378
|
-
this.openSnackBar("Error approving tenant!");
|
|
379
|
-
console.debug(error);
|
|
380
|
-
}
|
|
381
|
-
});
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
reject(id: string){
|
|
385
|
-
console.debug("reject", id);
|
|
386
|
-
this.confirm(this.doReject.bind(this, id),
|
|
387
|
-
{
|
|
388
|
-
message: "Please confirm that you want to reject this tenant.",
|
|
389
|
-
messageClasses: "warn-color",
|
|
390
|
-
buttonText:"Reject",
|
|
391
|
-
buttonColor:"warn"
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
doReject(id: string){
|
|
396
|
-
this.tenantService.rejectTenant(id).subscribe({
|
|
397
|
-
complete: () => {
|
|
398
|
-
this.getData();
|
|
399
|
-
this.openSnackBar("Tenant was rejected!");
|
|
400
|
-
}, error: (error: any) => {
|
|
401
|
-
this.openSnackBar("Error rejecting tenant!");
|
|
402
|
-
console.debug(error);
|
|
403
|
-
}
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
settings(id: string){
|
|
408
|
-
const dialogRef = this.dialog.open(DictBuilderComponent, {
|
|
409
|
-
width: this.options.dialogWidth,
|
|
410
|
-
maxHeight: this.options.dialogMaxHeight,
|
|
411
|
-
});
|
|
412
|
-
|
|
413
|
-
let instance = dialogRef.componentInstance;
|
|
414
|
-
instance.title = "Tenant settings";
|
|
415
|
-
instance.loading = true;
|
|
416
|
-
instance.type = ModelType.Configuration;
|
|
417
|
-
|
|
418
|
-
this.tenantService.getTenantSettings(id).subscribe({
|
|
419
|
-
next: (settings: TenantSetting[]) => {
|
|
420
|
-
instance.loading = false;
|
|
421
|
-
instance.models = settings.map(s => new KeyValue(s.key, s.value, s.inherited, s.overridden));
|
|
422
|
-
}, error: (error: any) => {
|
|
423
|
-
this.openSnackBar("Error getting tenant settings!");
|
|
424
|
-
console.debug(error);
|
|
425
|
-
}
|
|
426
|
-
});
|
|
427
|
-
|
|
428
|
-
instance.saved.subscribe((model: any) => {
|
|
429
|
-
var settings = instance.models.map(m => new TenantSetting(m.key, m.value, m.inherited));
|
|
430
|
-
this.tenantService.updateTenantSettings(id, settings).subscribe({
|
|
431
|
-
next: () => {
|
|
432
|
-
this.openSnackBar("Tenant settings was updated!");
|
|
433
|
-
dialogRef.close();
|
|
434
|
-
}, error: (error: any) => {
|
|
435
|
-
this.openSnackBar("Error updating tenant settings!");
|
|
436
|
-
console.debug(error);
|
|
437
|
-
}
|
|
438
|
-
});
|
|
439
|
-
});
|
|
440
|
-
instance.cancelled.subscribe(() => {
|
|
441
|
-
this.openSnackBar("Tenant setting was cancelled!");
|
|
442
|
-
dialogRef.close();
|
|
443
|
-
});
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
rootSettings(){
|
|
447
|
-
const dialogRef = this.dialog.open(DictBuilderComponent, {
|
|
448
|
-
width: this.options.dialogWidth,
|
|
449
|
-
maxHeight: this.options.dialogMaxHeight,
|
|
450
|
-
});
|
|
451
|
-
|
|
452
|
-
let instance = dialogRef.componentInstance;
|
|
453
|
-
instance.title = "Root settings";
|
|
454
|
-
instance.loading = true;
|
|
455
|
-
instance.type = ModelType.Configuration;
|
|
456
|
-
|
|
457
|
-
this.tenantService.getRootSettings().subscribe({
|
|
458
|
-
next: (settings: TenantSetting[]) => {
|
|
459
|
-
instance.loading = false;
|
|
460
|
-
instance.models = settings.map(s => new KeyValue(s.key, s.value, false, false));
|
|
461
|
-
}, error: (error: any) => {
|
|
462
|
-
this.openSnackBar("Error getting root settings!");
|
|
463
|
-
console.debug(error);
|
|
464
|
-
}
|
|
465
|
-
});
|
|
466
|
-
|
|
467
|
-
instance.saved.subscribe((model: any) => {
|
|
468
|
-
var settings = instance.models.map(m => new TenantSetting(m.key, m.value, false));
|
|
469
|
-
this.tenantService.updateRootSettings(settings).subscribe({
|
|
470
|
-
next: () => {
|
|
471
|
-
this.openSnackBar("Root settings was updated!");
|
|
472
|
-
dialogRef.close();
|
|
473
|
-
}, error: (error: any) => {
|
|
474
|
-
this.openSnackBar("Error updating root settings!");
|
|
475
|
-
console.debug(error);
|
|
476
|
-
}
|
|
477
|
-
});
|
|
478
|
-
});
|
|
479
|
-
instance.cancelled.subscribe(() => {
|
|
480
|
-
this.openSnackBar("Root setting was cancelled!");
|
|
481
|
-
dialogRef.close();
|
|
482
|
-
});
|
|
483
|
-
}
|
|
484
|
-
//#endregion
|
|
485
|
-
|
|
486
|
-
//#region status rules
|
|
487
|
-
canActivate(status: TenantStatus){
|
|
488
|
-
var s = (typeof status == "string" ? TenantStatus[status] : status) as TenantStatus;
|
|
489
|
-
return s == TenantStatus.New
|
|
490
|
-
|| s == TenantStatus.Initialized
|
|
491
|
-
|| s == TenantStatus.Approved
|
|
492
|
-
|| s == TenantStatus.PendingToActive;
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
canReactivate(status: TenantStatus){
|
|
496
|
-
var s = (typeof status == "string" ? TenantStatus[status] : status) as TenantStatus;
|
|
497
|
-
return s == TenantStatus.Inactive || s == TenantStatus.Suspended;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
canDeactivate(status: TenantStatus){
|
|
501
|
-
var s = (typeof status == "string" ? TenantStatus[status] : status) as TenantStatus;
|
|
502
|
-
return s == TenantStatus.Active;
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
canSuspend(status: TenantStatus){
|
|
506
|
-
var s = (typeof status == "string" ? TenantStatus[status] : status) as TenantStatus;
|
|
507
|
-
return s == TenantStatus.Active || s == TenantStatus.Inactive;
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
canDelete(status: TenantStatus){
|
|
511
|
-
var s = (typeof status == "string" ? TenantStatus[status] : status) as TenantStatus;
|
|
512
|
-
return s == TenantStatus.New
|
|
513
|
-
|| s == TenantStatus.Initialized
|
|
514
|
-
|| s == TenantStatus.Approved
|
|
515
|
-
|| s == TenantStatus.PendingToActive
|
|
516
|
-
|| s == TenantStatus.Inactive
|
|
517
|
-
|| s == TenantStatus.Suspended
|
|
518
|
-
|| s == TenantStatus.Abandoned;
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
canAbandon(status: TenantStatus){
|
|
522
|
-
var s = (typeof status == "string" ? TenantStatus[status] : status) as TenantStatus;
|
|
523
|
-
return s!= TenantStatus.Abandoned;
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
canApproval(status: TenantStatus){
|
|
527
|
-
var s = (typeof status == "string" ? TenantStatus[status] : status) as TenantStatus;
|
|
528
|
-
return s == TenantStatus.PendingApproval;
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
//#endregion
|
|
532
|
-
|
|
533
|
-
//#region common
|
|
534
|
-
|
|
535
|
-
statusCompareFn(o1: TenantStatus, o2: TenantStatus){
|
|
536
|
-
return o1 == o2 || (o1 == null && o2 == null) || (o1 == undefined && o2 == undefined)
|
|
537
|
-
|| (o1 == null && o2 == undefined) || (o1 == undefined && o2 == null);
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
confirm(callback: Function, options: any){
|
|
541
|
-
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
|
|
542
|
-
width: '350px',
|
|
543
|
-
data: options
|
|
544
|
-
});
|
|
545
|
-
|
|
546
|
-
let instance = dialogRef.componentInstance;
|
|
547
|
-
instance.confirmed.subscribe(() => {
|
|
548
|
-
dialogRef.close();
|
|
549
|
-
callback();
|
|
550
|
-
});
|
|
551
|
-
instance.cancelled.subscribe(() => {
|
|
552
|
-
dialogRef.close();
|
|
553
|
-
});
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
openSnackBar(message: string) {
|
|
557
|
-
this.localizer.get([message, "Close"]).subscribe((value: any) => {
|
|
558
|
-
this.snackBar.open(value[message], value["Close"], {
|
|
559
|
-
duration: 3000
|
|
560
|
-
});
|
|
561
|
-
});
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
//#endregion
|
|
565
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { NgModule, ModuleWithProviders } from '@angular/core';
|
|
2
|
-
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
3
|
-
import { CommonModule } from '@angular/common';
|
|
4
|
-
import { TranslateModule } from '@ngx-translate/core'
|
|
5
|
-
import { TenantsComponent } from './tenants.component';
|
|
6
|
-
import { TenantDetailComponent } from './tenant-detail/tenant-detail.component';
|
|
7
|
-
import { TenantAdminService } from './shared/services/tenant-admin.service';
|
|
8
|
-
import { TenantConfiguration, TenantConfigurationParams } from './shared/tenant-configuration';
|
|
9
|
-
import { MaterialModule } from './shared/material.module';
|
|
10
|
-
import { TenantSummaryComponent } from './tenant-summary/tenant-summary.component';
|
|
11
|
-
import { TenantCreateComponent } from './tenant-create/tenant-create.component';
|
|
12
|
-
import { TenantUpdateComponent } from './tenant-update/tenant-update.component';
|
|
13
|
-
import { ClipboardModule } from '@angular/cdk/clipboard';
|
|
14
|
-
import { MatMultiSortModule } from 'ngx-mat-multi-sort';
|
|
15
|
-
import { ConfirmDialogComponent } from './confirm-dialog/confirm-dialog.component';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
@NgModule({
|
|
19
|
-
declarations: [
|
|
20
|
-
TenantsComponent,
|
|
21
|
-
TenantDetailComponent,
|
|
22
|
-
TenantSummaryComponent,
|
|
23
|
-
TenantCreateComponent,
|
|
24
|
-
TenantUpdateComponent,
|
|
25
|
-
ConfirmDialogComponent
|
|
26
|
-
],
|
|
27
|
-
imports: [
|
|
28
|
-
TranslateModule,
|
|
29
|
-
FormsModule,
|
|
30
|
-
ReactiveFormsModule,
|
|
31
|
-
CommonModule,
|
|
32
|
-
MaterialModule,
|
|
33
|
-
ClipboardModule,
|
|
34
|
-
MatMultiSortModule
|
|
35
|
-
],
|
|
36
|
-
exports: [
|
|
37
|
-
TenantsComponent,
|
|
38
|
-
TenantDetailComponent,
|
|
39
|
-
TenantSummaryComponent,
|
|
40
|
-
TenantCreateComponent,
|
|
41
|
-
TenantUpdateComponent,
|
|
42
|
-
TranslateModule
|
|
43
|
-
]
|
|
44
|
-
})
|
|
45
|
-
export class TenantsModule {
|
|
46
|
-
|
|
47
|
-
public static forRoot(environment: TenantConfigurationParams): ModuleWithProviders<TenantsModule> {
|
|
48
|
-
|
|
49
|
-
return {
|
|
50
|
-
ngModule: TenantsModule,
|
|
51
|
-
providers: [
|
|
52
|
-
TenantAdminService,
|
|
53
|
-
{
|
|
54
|
-
provide: TenantConfiguration,
|
|
55
|
-
useValue: environment
|
|
56
|
-
}
|
|
57
|
-
]
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
}
|
package/tsconfig.lib.json
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
|
2
|
-
{
|
|
3
|
-
"extends": "../../../tsconfig.json",
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
"outDir": "../../../out-tsc/lib",
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"declarationMap": true,
|
|
8
|
-
"inlineSources": true,
|
|
9
|
-
"types": []
|
|
10
|
-
},
|
|
11
|
-
"exclude": [
|
|
12
|
-
"**/*.spec.ts"
|
|
13
|
-
]
|
|
14
|
-
}
|
package/tsconfig.lib.prod.json
DELETED
package/tsconfig.spec.json
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
|
2
|
-
{
|
|
3
|
-
"extends": "../../../tsconfig.json",
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
"outDir": "../../../out-tsc/spec",
|
|
6
|
-
"types": [
|
|
7
|
-
"jasmine"
|
|
8
|
-
]
|
|
9
|
-
},
|
|
10
|
-
"include": [
|
|
11
|
-
"**/*.spec.ts",
|
|
12
|
-
"**/*.d.ts"
|
|
13
|
-
]
|
|
14
|
-
}
|