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