@juice-js/tenants 1.0.1 → 1.0.3
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/package.json +3 -2
- package/src/_tenants.component-theme.scss +26 -6
- package/src/lib/shared/material.module.ts +0 -14
- package/src/lib/shared/models/tenant.setting.model.ts +14 -0
- package/src/lib/shared/services/{tenant.service.ts → tenant-admin.service.ts} +20 -3
- package/src/lib/shared/services/tenant.service.spec.ts +5 -5
- package/src/lib/shared/{api-configuration.ts → tenant-configuration.ts} +6 -2
- package/src/lib/shared/tenant-testing.ts +5 -5
- package/src/lib/tenant-create/tenant-create.component.spec.ts +1 -1
- package/src/lib/tenant-create/tenant-create.component.ts +3 -3
- package/src/lib/tenant-detail/tenant-detail.component.ts +2 -2
- package/src/lib/tenant-summary/tenant-summary.component.ts +2 -2
- package/src/lib/tenant-update/tenant-update.component.ts +2 -2
- package/src/lib/tenants.component.html +35 -27
- package/src/lib/tenants.component.scss +7 -2
- package/src/lib/tenants.component.ts +123 -31
- package/src/lib/tenants.module.ts +5 -8
- package/src/public-api.ts +1 -2
- package/src/lib/dict-builder/dict-builder.component.css +0 -10
- package/src/lib/dict-builder/dict-builder.component.html +0 -43
- package/src/lib/dict-builder/dict-builder.component.spec.ts +0 -47
- package/src/lib/dict-builder/dict-builder.component.ts +0 -164
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juice-js/tenants",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Juice tenants admin module",
|
|
5
5
|
"author": "jack@creatorflow.io",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"@angular/core": "^16.1.1",
|
|
14
14
|
"@angular/material": "^16.1.1",
|
|
15
15
|
"@ngx-translate/core": "^14.0.0",
|
|
16
|
-
"ngx-mat-multi-sort": "^0.10.2"
|
|
16
|
+
"ngx-mat-multi-sort": "^0.10.2",
|
|
17
|
+
"@juice-js/dict-builder": "^1.0.2"
|
|
17
18
|
},
|
|
18
19
|
"dependencies": {
|
|
19
20
|
"tslib": "^2.3.0"
|
|
@@ -9,36 +9,56 @@
|
|
|
9
9
|
$accent-palette: map.get($color-config, 'accent');
|
|
10
10
|
$warn-palette: map.get($color-config, 'warn');
|
|
11
11
|
$green-palette: mat.define-palette(mat.$green-palette, 500, 300, 700);
|
|
12
|
-
.
|
|
12
|
+
.color-primary {
|
|
13
|
+
color: mat.get-color-from-palette($primary-palette, 'darker') !important;
|
|
14
|
+
.mdc-list-item__primary-text{
|
|
15
|
+
color: mat.get-color-from-palette($primary-palette, 'darker') !important;
|
|
16
|
+
}
|
|
17
|
+
&.mat-mdc-menu-item .mat-icon-no-color{
|
|
18
|
+
color: mat.get-color-from-palette($primary-palette, 'darker') !important;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.color-accent {
|
|
13
23
|
color: mat.get-color-from-palette($accent-palette, 'darker') !important;
|
|
14
24
|
.mdc-list-item__primary-text{
|
|
15
25
|
color: mat.get-color-from-palette($accent-palette, 'darker') !important;
|
|
16
26
|
}
|
|
27
|
+
&.mat-mdc-menu-item .mat-icon-no-color{
|
|
28
|
+
color: mat.get-color-from-palette($accent-palette, 'darker') !important;
|
|
29
|
+
}
|
|
17
30
|
}
|
|
18
31
|
|
|
19
|
-
.warn
|
|
32
|
+
.color-warn {
|
|
20
33
|
color: mat.get-color-from-palette($warn-palette, 'darker') !important;
|
|
21
34
|
.mdc-list-item__primary-text{
|
|
22
35
|
color: mat.get-color-from-palette($warn-palette, 'darker') !important;
|
|
23
36
|
}
|
|
37
|
+
&.mat-mdc-menu-item .mat-icon-no-color{
|
|
38
|
+
color: mat.get-color-from-palette($warn-palette, 'darker') !important;
|
|
39
|
+
}
|
|
24
40
|
}
|
|
25
41
|
|
|
26
|
-
.success
|
|
42
|
+
.color-success,
|
|
43
|
+
.mat-success.mat-mdc-button:not(:disabled){
|
|
27
44
|
color: mat.get-color-from-palette($green-palette, 'darker') !important;
|
|
28
45
|
.mdc-list-item__primary-text{
|
|
29
46
|
color: mat.get-color-from-palette($green-palette, 'darker') !important;
|
|
30
47
|
}
|
|
48
|
+
&.mat-mdc-menu-item .mat-icon-no-color{
|
|
49
|
+
color: mat.get-color-from-palette($green-palette, 'darker') !important;
|
|
50
|
+
}
|
|
31
51
|
}
|
|
32
52
|
|
|
33
|
-
.accent
|
|
53
|
+
.bg-accent {
|
|
34
54
|
background-color: mat.get-color-from-palette($accent-palette, 'lighter') !important;
|
|
35
55
|
}
|
|
36
56
|
|
|
37
|
-
.warn
|
|
57
|
+
.bg-warn {
|
|
38
58
|
background-color: mat.get-color-from-palette($warn-palette, 'lighter') !important;
|
|
39
59
|
}
|
|
40
60
|
|
|
41
|
-
.success
|
|
61
|
+
.bg-success{
|
|
42
62
|
background-color: mat.get-color-from-palette($green-palette, 'lighter') !important;
|
|
43
63
|
}
|
|
44
64
|
}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import {NgModule} from '@angular/core';
|
|
2
|
-
import {MatAutocompleteModule} from '@angular/material/autocomplete';
|
|
3
|
-
import {MatBadgeModule} from '@angular/material/badge';
|
|
4
|
-
import {MatBottomSheetModule} from '@angular/material/bottom-sheet';
|
|
5
2
|
import {MatButtonModule} from '@angular/material/button';
|
|
6
|
-
import {MatButtonToggleModule} from '@angular/material/button-toggle';
|
|
7
3
|
import {MatCardModule} from '@angular/material/card';
|
|
8
4
|
import {MatCheckboxModule} from '@angular/material/checkbox';
|
|
9
|
-
import {MatChipsModule} from '@angular/material/chips';
|
|
10
|
-
import {MatStepperModule} from '@angular/material/stepper';
|
|
11
5
|
import {MatDatepickerModule} from '@angular/material/datepicker';
|
|
12
6
|
import {MatDialogModule} from '@angular/material/dialog';
|
|
13
7
|
import {MatDividerModule} from '@angular/material/divider';
|
|
@@ -23,7 +17,6 @@ import {MatProgressBarModule} from '@angular/material/progress-bar';
|
|
|
23
17
|
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';
|
|
24
18
|
import {MatRadioModule} from '@angular/material/radio';
|
|
25
19
|
import {MatSelectModule} from '@angular/material/select';
|
|
26
|
-
import {MatSidenavModule} from '@angular/material/sidenav';
|
|
27
20
|
import {MatSliderModule} from '@angular/material/slider';
|
|
28
21
|
import {MatSlideToggleModule} from '@angular/material/slide-toggle';
|
|
29
22
|
import {MatSnackBarModule} from '@angular/material/snack-bar';
|
|
@@ -36,15 +29,9 @@ import {MatTreeModule} from '@angular/material/tree';
|
|
|
36
29
|
|
|
37
30
|
@NgModule({
|
|
38
31
|
exports: [
|
|
39
|
-
MatAutocompleteModule,
|
|
40
|
-
MatBadgeModule,
|
|
41
|
-
MatBottomSheetModule,
|
|
42
32
|
MatButtonModule,
|
|
43
|
-
MatButtonToggleModule,
|
|
44
33
|
MatCardModule,
|
|
45
34
|
MatCheckboxModule,
|
|
46
|
-
MatChipsModule,
|
|
47
|
-
MatStepperModule,
|
|
48
35
|
MatDatepickerModule,
|
|
49
36
|
MatDialogModule,
|
|
50
37
|
MatDividerModule,
|
|
@@ -61,7 +48,6 @@ import {MatTreeModule} from '@angular/material/tree';
|
|
|
61
48
|
MatRadioModule,
|
|
62
49
|
MatRippleModule,
|
|
63
50
|
MatSelectModule,
|
|
64
|
-
MatSidenavModule,
|
|
65
51
|
MatSliderModule,
|
|
66
52
|
MatSlideToggleModule,
|
|
67
53
|
MatSnackBarModule,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
export class TenantSetting{
|
|
3
|
+
public key: string = "";
|
|
4
|
+
public value: string = "";
|
|
5
|
+
public inherited: boolean = false;
|
|
6
|
+
public overridden: boolean = false;
|
|
7
|
+
|
|
8
|
+
constructor(key: string, value: string, inherited: boolean = false, overridden: boolean = false){
|
|
9
|
+
this.key = key;
|
|
10
|
+
this.value = value;
|
|
11
|
+
this.inherited = inherited;
|
|
12
|
+
this.overridden = overridden;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { Injectable, Inject } from '@angular/core';
|
|
2
2
|
import { HttpClient, HttpParams } from '@angular/common/http';
|
|
3
|
-
import {
|
|
3
|
+
import { TenantConfiguration } from '../tenant-configuration';
|
|
4
4
|
import { Tenant, TenantBasic } from '../models/tenant.model';
|
|
5
5
|
import { TenantCreate, TenantCreated } from '../models/tenant.create.model';
|
|
6
6
|
import { TenantUpdate } from '../models/tenant.update.model';
|
|
7
7
|
import { TenantStatus } from '../models/tenant.status';
|
|
8
8
|
import { TableQueryResult } from '../models/table.query-result';
|
|
9
9
|
import { Observable } from 'rxjs';
|
|
10
|
+
import { TenantSetting } from '../models/tenant.setting.model';
|
|
10
11
|
|
|
11
12
|
@Injectable({
|
|
12
13
|
providedIn: 'root'
|
|
13
14
|
})
|
|
14
|
-
export class
|
|
15
|
+
export class TenantAdminService {
|
|
15
16
|
|
|
16
|
-
constructor(private http: HttpClient, private options:
|
|
17
|
+
constructor(private http: HttpClient, private options: TenantConfiguration) {
|
|
17
18
|
|
|
18
19
|
}
|
|
19
20
|
|
|
@@ -89,4 +90,20 @@ export class TenantService {
|
|
|
89
90
|
public abandonTenant(id: string) {
|
|
90
91
|
return this.http.put(`${this.options.apiEndpoint}/api/v${this.options.apiVersion}/admin/${id}/abandon`, null);
|
|
91
92
|
}
|
|
93
|
+
|
|
94
|
+
public getTenantSettings(id: string) {
|
|
95
|
+
return this.http.get<TenantSetting[]>(`${this.options.apiEndpoint}/api/v${this.options.apiVersion}/admin/${id}/settings`);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public updateTenantSettings(id: string, settings: TenantSetting[]) {
|
|
99
|
+
return this.http.put(`${this.options.apiEndpoint}/api/v${this.options.apiVersion}/admin/${id}/settings`, settings);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
public getRootSettings() {
|
|
103
|
+
return this.http.get<TenantSetting[]>(`${this.options.apiEndpoint}/api/v${this.options.apiVersion}/settings`);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
public updateRootSettings(settings: TenantSetting[]){
|
|
107
|
+
return this.http.put(`${this.options.apiEndpoint}/api/v${this.options.apiVersion}/settings`, settings);
|
|
108
|
+
}
|
|
92
109
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { TestBed } from '@angular/core/testing';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { TenantAdminService } from './tenant-admin.service';
|
|
4
4
|
import { HttpClientModule } from '@angular/common/http';
|
|
5
|
-
import {
|
|
5
|
+
import { TenantConfiguration } from '../tenant-configuration';
|
|
6
6
|
|
|
7
7
|
describe('TenantsService', () => {
|
|
8
|
-
let service:
|
|
8
|
+
let service: TenantAdminService;
|
|
9
9
|
|
|
10
10
|
beforeEach(() => {
|
|
11
11
|
TestBed.configureTestingModule({
|
|
@@ -14,12 +14,12 @@ describe('TenantsService', () => {
|
|
|
14
14
|
],
|
|
15
15
|
providers: [
|
|
16
16
|
{
|
|
17
|
-
provide:
|
|
17
|
+
provide: TenantConfiguration,
|
|
18
18
|
useValue: {}
|
|
19
19
|
}
|
|
20
20
|
]
|
|
21
21
|
});
|
|
22
|
-
service = TestBed.inject(
|
|
22
|
+
service = TestBed.inject(TenantAdminService);
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
it('should be created', () => {
|
|
@@ -3,12 +3,16 @@
|
|
|
3
3
|
// export const TENANT_OPTIONS_TOKEN = new InjectionToken<TenantConfiguration>('tenant.options');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
export class
|
|
6
|
+
export class TenantConfiguration {
|
|
7
7
|
apiEndpoint: string = "";
|
|
8
8
|
apiVersion: string = "2";
|
|
9
|
+
dialogWidth: string = "800px";
|
|
10
|
+
dialogMaxHeight: string = "600px";
|
|
9
11
|
}
|
|
10
12
|
|
|
11
|
-
export interface
|
|
13
|
+
export interface TenantConfigurationParams {
|
|
12
14
|
apiEndpoint?: string;
|
|
13
15
|
apiVersion?: string;
|
|
16
|
+
dialogWidth?: string;
|
|
17
|
+
dialogMaxHeight?: string;
|
|
14
18
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { NgModule, ModuleWithProviders } from '@angular/core';
|
|
2
2
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
3
3
|
import { CommonModule } from '@angular/common';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { TenantAdminService } from './services/tenant-admin.service';
|
|
5
|
+
import { TenantConfiguration, TenantConfigurationParams } from './tenant-configuration';
|
|
6
6
|
import { MaterialModule } from './material.module';
|
|
7
7
|
import { HttpClientModule } from '@angular/common/http';
|
|
8
8
|
import { BrowserModule } from '@angular/platform-browser';
|
|
@@ -28,14 +28,14 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
|
|
28
28
|
})
|
|
29
29
|
export class TenantsTestingModule {
|
|
30
30
|
|
|
31
|
-
public static forTest(environment:
|
|
31
|
+
public static forTest(environment: TenantConfigurationParams): ModuleWithProviders<TenantsTestingModule> {
|
|
32
32
|
|
|
33
33
|
return {
|
|
34
34
|
ngModule: TenantsTestingModule,
|
|
35
35
|
providers: [
|
|
36
|
-
|
|
36
|
+
TenantAdminService,
|
|
37
37
|
{
|
|
38
|
-
provide:
|
|
38
|
+
provide: TenantConfiguration,
|
|
39
39
|
useValue: environment
|
|
40
40
|
}
|
|
41
41
|
]
|
|
@@ -2,7 +2,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
|
2
2
|
|
|
3
3
|
import { TenantCreateComponent } from './tenant-create.component';
|
|
4
4
|
import { HttpClientModule } from '@angular/common/http';
|
|
5
|
-
import {
|
|
5
|
+
import { TenantConfiguration } from '../shared/tenant-configuration';
|
|
6
6
|
import { MaterialModule } from '../shared/material.module';
|
|
7
7
|
import { TranslateModule } from '@ngx-translate/core';
|
|
8
8
|
import { TenantsTestingModule } from '../shared/tenant-testing';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Component, OnInit, Output, EventEmitter, Input } from '@angular/core';
|
|
2
2
|
|
|
3
3
|
import { TenantCreate, TenantCreated } from '../shared/models/tenant.create.model';
|
|
4
|
-
import {
|
|
4
|
+
import { TenantAdminService } from '../../public-api';
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
FormControl,
|
|
@@ -33,7 +33,7 @@ export class TenantCreateComponent implements OnInit{
|
|
|
33
33
|
@Output() created = new EventEmitter<TenantCreated>();
|
|
34
34
|
@Output() cancelled = new EventEmitter();
|
|
35
35
|
|
|
36
|
-
constructor(private tenantService:
|
|
36
|
+
constructor(private tenantService: TenantAdminService) { }
|
|
37
37
|
|
|
38
38
|
ngOnInit(): void {
|
|
39
39
|
|
|
@@ -57,7 +57,7 @@ export class TenantCreateComponent implements OnInit{
|
|
|
57
57
|
this.model = new TenantCreate();
|
|
58
58
|
},
|
|
59
59
|
error:(err) => {
|
|
60
|
-
|
|
60
|
+
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
63
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component, OnInit, Input, OnChanges } from '@angular/core';
|
|
2
|
-
import {
|
|
2
|
+
import { TenantAdminService } from '../shared/services/tenant-admin.service';
|
|
3
3
|
import { Tenant } from '../shared/models/tenant.model';
|
|
4
4
|
import { TenantStatusHelper } from '../shared/models/tenant.status';
|
|
5
5
|
|
|
@@ -16,7 +16,7 @@ export class TenantDetailComponent implements OnChanges {
|
|
|
16
16
|
properties: any;
|
|
17
17
|
statusHelper = TenantStatusHelper;
|
|
18
18
|
|
|
19
|
-
constructor(private tenantService:
|
|
19
|
+
constructor(private tenantService: TenantAdminService) { }
|
|
20
20
|
|
|
21
21
|
public loadTenant(identifier: string){
|
|
22
22
|
this.tenantService.getTenant(identifier).subscribe(tenant => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Component, Input, OnChanges } from '@angular/core';
|
|
2
2
|
import { TenantBasic } from '../shared/models/tenant.model';
|
|
3
|
-
import {
|
|
3
|
+
import { TenantAdminService } from '../shared/services/tenant-admin.service';
|
|
4
4
|
|
|
5
5
|
@Component({
|
|
6
6
|
selector: 'juice-tenant-summary',
|
|
@@ -14,7 +14,7 @@ export class TenantSummaryComponent implements OnChanges{
|
|
|
14
14
|
|
|
15
15
|
tenant!: TenantBasic;
|
|
16
16
|
|
|
17
|
-
constructor(private tenantService:
|
|
17
|
+
constructor(private tenantService: TenantAdminService) { }
|
|
18
18
|
|
|
19
19
|
public loadTenant(identifier: string){
|
|
20
20
|
this.tenantService.getSummary(identifier).subscribe(tenant => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Component, Input, Output, EventEmitter, OnInit } from '@angular/core';
|
|
2
2
|
import { TenantUpdate } from '../shared/models/tenant.update.model';
|
|
3
|
-
import {
|
|
3
|
+
import { TenantAdminService } from '../../public-api';
|
|
4
4
|
import {
|
|
5
5
|
FormControl,
|
|
6
6
|
FormGroup,
|
|
@@ -35,7 +35,7 @@ export class TenantUpdateComponent{
|
|
|
35
35
|
@Output() updated = new EventEmitter<string>();
|
|
36
36
|
@Output() cancelled = new EventEmitter<string>();
|
|
37
37
|
|
|
38
|
-
constructor(private tenantService:
|
|
38
|
+
constructor(private tenantService: TenantAdminService) { }
|
|
39
39
|
|
|
40
40
|
ngOnChanges(): void {
|
|
41
41
|
this.tenantService.getTenant(this.id).subscribe((result) => {
|
|
@@ -21,9 +21,12 @@
|
|
|
21
21
|
</mat-option>
|
|
22
22
|
</mat-select>
|
|
23
23
|
</mat-form-field>
|
|
24
|
-
<
|
|
24
|
+
<div style="flex: 1 auto; text-align: right;">
|
|
25
|
+
<button mat-button (click)="rootSettings()">
|
|
26
|
+
<mat-icon>settings</mat-icon>{{'Settings' | translate}}
|
|
27
|
+
</button>
|
|
25
28
|
<button type="button" mat-button (click)="add()" color="primary"><mat-icon>add</mat-icon> {{ 'New Organization'}}</button>
|
|
26
|
-
</
|
|
29
|
+
</div>
|
|
27
30
|
</form>
|
|
28
31
|
<table mat-table [dataSource]="table.dataSource" matMultiSort (matSortChange)="table.onSortEvent()">
|
|
29
32
|
|
|
@@ -53,20 +56,22 @@
|
|
|
53
56
|
|
|
54
57
|
<ng-container matColumnDef="actions">
|
|
55
58
|
<th mat-header-cell *matHeaderCellDef style="text-align: center;"> {{'Actions'|translate}} </th>
|
|
56
|
-
<td mat-cell *matCellDef="let row"
|
|
57
|
-
<
|
|
58
|
-
<mat-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
<mat-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
<mat-icon
|
|
69
|
-
|
|
59
|
+
<td mat-cell *matCellDef="let row" >
|
|
60
|
+
<div class="actions-cell">
|
|
61
|
+
<button mat-button (click)="settings(row.id)">
|
|
62
|
+
<mat-icon>settings</mat-icon>{{'Settings' | translate}}
|
|
63
|
+
</button>
|
|
64
|
+
<button mat-button (click)="detail(row.id)">
|
|
65
|
+
<mat-icon>info</mat-icon>{{'Detail' | translate}}
|
|
66
|
+
</button>
|
|
67
|
+
<button mat-button (click)="edit(row.id)">
|
|
68
|
+
<mat-icon>edit</mat-icon>{{'Edit' | translate}}
|
|
69
|
+
</button>
|
|
70
|
+
|
|
71
|
+
<button mat-icon-button [matMenuTriggerFor]="appMenu" [matMenuTriggerData]="{id: row.id, status: row.status}">
|
|
72
|
+
<mat-icon>more_vert</mat-icon>
|
|
73
|
+
</button>
|
|
74
|
+
</div>
|
|
70
75
|
</td>
|
|
71
76
|
</ng-container>
|
|
72
77
|
|
|
@@ -84,26 +89,29 @@
|
|
|
84
89
|
</div>
|
|
85
90
|
<mat-menu #appMenu="matMenu" class="minimum-density">
|
|
86
91
|
<ng-template matMenuContent let-id="id" let-status="status">
|
|
87
|
-
<button *ngIf="canApproval(status)" class="success
|
|
92
|
+
<button *ngIf="canApproval(status)" class="color-success" mat-menu-item (click)="approve(id)">
|
|
88
93
|
<mat-icon>check_circle_outline</mat-icon>{{'Approve' | translate}}
|
|
89
94
|
</button>
|
|
90
|
-
<button *ngIf="canApproval(status)" class="warn
|
|
95
|
+
<button *ngIf="canApproval(status)" class="color-warn" mat-menu-item (click)="reject(id)">
|
|
91
96
|
<mat-icon>highlight_off</mat-icon>{{'Reject' | translate}}
|
|
92
97
|
</button>
|
|
93
|
-
<button *ngIf="canActivate(status)" class="success
|
|
98
|
+
<button *ngIf="canActivate(status)" class="color-success" mat-menu-item (click)="activate(id)">
|
|
94
99
|
<mat-icon>present_to_all</mat-icon>{{'Activate' | translate}}
|
|
95
100
|
</button>
|
|
96
|
-
<button *ngIf="canReactivate(status)" class="success
|
|
97
|
-
<mat-icon>present_to_all</mat-icon>{{'Activate' | translate}}
|
|
101
|
+
<button *ngIf="canReactivate(status)" class="color-success" mat-menu-item (click)="reactivate(id)">
|
|
102
|
+
<mat-icon >present_to_all</mat-icon>{{'Activate' | translate}}
|
|
103
|
+
</button>
|
|
104
|
+
<button *ngIf="canDeactivate(status)" class="color-warn" mat-menu-item (click)="deactivate(id)">
|
|
105
|
+
<mat-icon >cancel_presentation</mat-icon>{{'Deactivate' | translate}}
|
|
98
106
|
</button>
|
|
99
|
-
<button *ngIf="
|
|
100
|
-
<mat-icon>cancel_presentation</mat-icon>{{'
|
|
107
|
+
<button *ngIf="canSuspend(status)" class="color-warn" mat-menu-item (click)="suspend(id)">
|
|
108
|
+
<mat-icon >cancel_presentation</mat-icon>{{'Suspend' | translate}}
|
|
101
109
|
</button>
|
|
102
|
-
<button
|
|
103
|
-
<mat-icon>
|
|
110
|
+
<button [disabled]="!canAbandon(status)" mat-menu-item (click)="abandon(id)" class="color-warn">
|
|
111
|
+
<mat-icon >delete</mat-icon>{{'Abandon' | translate}}
|
|
104
112
|
</button>
|
|
105
|
-
<button *ngIf="canDelete(status)" class="warn
|
|
106
|
-
<mat-icon>delete</mat-icon>{{'Delete' | translate}}
|
|
113
|
+
<button *ngIf="canDelete(status)" class="color-warn" mat-menu-item (click)="delete(id)">
|
|
114
|
+
<mat-icon >delete</mat-icon>{{'Delete' | translate}}
|
|
107
115
|
</button>
|
|
108
116
|
</ng-template>
|
|
109
117
|
</mat-menu>
|
|
@@ -23,8 +23,11 @@ mat-form-field{
|
|
|
23
23
|
display: flex;
|
|
24
24
|
justify-content: space-between;
|
|
25
25
|
align-items: center;
|
|
26
|
+
padding-top: 2px;
|
|
27
|
+
padding-bottom: 2px;
|
|
26
28
|
button{
|
|
27
|
-
margin: 6px;
|
|
29
|
+
margin-top: 6px;
|
|
30
|
+
height: 28px;
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
33
|
|
|
@@ -32,8 +35,10 @@ mat-form-field{
|
|
|
32
35
|
display: flex;
|
|
33
36
|
justify-content: center;
|
|
34
37
|
align-items: center;
|
|
38
|
+
padding-top: 2px;
|
|
39
|
+
padding-bottom: 2px;
|
|
35
40
|
button{
|
|
36
|
-
|
|
41
|
+
height: 28px;
|
|
37
42
|
}
|
|
38
43
|
}
|
|
39
44
|
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { Component, AfterViewInit, ViewChild } from '@angular/core';
|
|
2
|
-
import {
|
|
2
|
+
import { TenantAdminService } from './shared/services/tenant-admin.service';
|
|
3
3
|
import { MatMultiSort, MatMultiSortTableDataSource, TableData } from 'ngx-mat-multi-sort';
|
|
4
|
-
import {MatPaginator} from '@angular/material/paginator';
|
|
5
|
-
import {
|
|
4
|
+
import { MatPaginator } from '@angular/material/paginator';
|
|
5
|
+
import { TenantBasic } from './shared/models/tenant.model';
|
|
6
6
|
import { ActivatedRoute, Router, UrlSerializer } from '@angular/router';
|
|
7
7
|
import { Location } from '@angular/common';
|
|
8
8
|
import { TenantStatus, TenantStatusHelper } from './shared/models/tenant.status';
|
|
9
9
|
import { TableQueryResult } from './shared/models/table.query-result';
|
|
10
|
-
import { FormBuilder,
|
|
10
|
+
import { FormBuilder, FormGroup } from '@angular/forms';
|
|
11
11
|
import { MatDialog } from '@angular/material/dialog';
|
|
12
12
|
import { ConfirmDialogComponent, TenantCreateComponent, TenantDetailComponent, TenantUpdateComponent } from '../public-api';
|
|
13
|
+
import { DictBuilderComponent, KeyValue, ModelType } from '@juice-js/dict-builder';
|
|
13
14
|
import { MatSnackBar } from '@angular/material/snack-bar';
|
|
14
15
|
import { TranslateService } from '@ngx-translate/core';
|
|
16
|
+
import { TenantSetting } from './shared/models/tenant.setting.model';
|
|
17
|
+
import { TenantConfiguration } from './shared/tenant-configuration';
|
|
15
18
|
|
|
16
19
|
@Component({
|
|
17
20
|
selector: 'juice-tenants',
|
|
@@ -41,7 +44,7 @@ export class TenantsComponent implements AfterViewInit{
|
|
|
41
44
|
|
|
42
45
|
form: FormGroup = new FormGroup({});
|
|
43
46
|
|
|
44
|
-
constructor(private tenantService:
|
|
47
|
+
constructor(private tenantService: TenantAdminService,
|
|
45
48
|
private router: Router,
|
|
46
49
|
private route: ActivatedRoute,
|
|
47
50
|
private location: Location,
|
|
@@ -49,7 +52,8 @@ export class TenantsComponent implements AfterViewInit{
|
|
|
49
52
|
private fb: FormBuilder,
|
|
50
53
|
public dialog: MatDialog,
|
|
51
54
|
private snackBar: MatSnackBar,
|
|
52
|
-
private localizer: TranslateService
|
|
55
|
+
private localizer: TranslateService,
|
|
56
|
+
private options: TenantConfiguration
|
|
53
57
|
) {
|
|
54
58
|
|
|
55
59
|
this.table = new TableData<TenantBasic>([
|
|
@@ -72,15 +76,22 @@ export class TenantsComponent implements AfterViewInit{
|
|
|
72
76
|
statuses: []
|
|
73
77
|
});
|
|
74
78
|
|
|
75
|
-
let
|
|
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
|
+
}
|
|
76
87
|
var q = params['q'] || "";
|
|
77
88
|
this.filterText?.setValue(q);
|
|
78
89
|
if(params['statuses']=='any'){
|
|
79
90
|
this.statuses?.setValue([]);
|
|
80
91
|
}else{
|
|
81
92
|
this.statuses?.setValue(params['statuses']?
|
|
82
|
-
params['statuses']:
|
|
83
|
-
[TenantStatus.Active, TenantStatus.PendingApproval, TenantStatus.PendingToActive]);
|
|
93
|
+
Array.isArray(params['statuses']) ? params['statuses'] : [params['statuses']]
|
|
94
|
+
:[TenantStatus.Active, TenantStatus.PendingApproval, TenantStatus.PendingToActive]);
|
|
84
95
|
}
|
|
85
96
|
|
|
86
97
|
this.table.pageSize = params['pageSize']? Number.parseInt(params['pageSize']): 10;
|
|
@@ -97,9 +108,6 @@ export class TenantsComponent implements AfterViewInit{
|
|
|
97
108
|
this.table.sortDirs = [sortDirs];
|
|
98
109
|
}
|
|
99
110
|
}
|
|
100
|
-
|
|
101
|
-
this.initFormAndTableEvents();
|
|
102
|
-
sub.unsubscribe();
|
|
103
111
|
});
|
|
104
112
|
}
|
|
105
113
|
|
|
@@ -166,6 +174,8 @@ export class TenantsComponent implements AfterViewInit{
|
|
|
166
174
|
//#region actions
|
|
167
175
|
add(){
|
|
168
176
|
const dialogRef = this.dialog.open(TenantCreateComponent, {
|
|
177
|
+
width: this.options.dialogWidth,
|
|
178
|
+
maxHeight: this.options.dialogMaxHeight,
|
|
169
179
|
data: {}
|
|
170
180
|
});
|
|
171
181
|
|
|
@@ -182,8 +192,10 @@ export class TenantsComponent implements AfterViewInit{
|
|
|
182
192
|
}
|
|
183
193
|
|
|
184
194
|
edit(id: string){
|
|
185
|
-
console.
|
|
195
|
+
console.debug("edit", id);
|
|
186
196
|
const dialogRef = this.dialog.open(TenantUpdateComponent, {
|
|
197
|
+
width: this.options.dialogWidth,
|
|
198
|
+
maxHeight: this.options.dialogMaxHeight,
|
|
187
199
|
data: {id: id}
|
|
188
200
|
});
|
|
189
201
|
|
|
@@ -202,13 +214,15 @@ export class TenantsComponent implements AfterViewInit{
|
|
|
202
214
|
|
|
203
215
|
detail(id: string){
|
|
204
216
|
const dialogRef = this.dialog.open(TenantDetailComponent, {
|
|
217
|
+
width: this.options.dialogWidth,
|
|
218
|
+
maxHeight: this.options.dialogMaxHeight,
|
|
205
219
|
});
|
|
206
220
|
let instance = dialogRef.componentInstance;
|
|
207
221
|
instance.loadTenant(id);
|
|
208
222
|
}
|
|
209
223
|
|
|
210
224
|
delete(id: string){
|
|
211
|
-
console.
|
|
225
|
+
console.debug("delete", id);
|
|
212
226
|
this.confirm(this.doDelete.bind(this, id),
|
|
213
227
|
{
|
|
214
228
|
title: "Dangerous action!",
|
|
@@ -226,12 +240,12 @@ export class TenantsComponent implements AfterViewInit{
|
|
|
226
240
|
this.openSnackBar("Tenant was deleted!");
|
|
227
241
|
}, error: (error: any) => {
|
|
228
242
|
this.openSnackBar("Error deleting tenant!");
|
|
229
|
-
console.
|
|
243
|
+
console.debug(error);
|
|
230
244
|
}});
|
|
231
245
|
}
|
|
232
246
|
|
|
233
247
|
activate(id: string){
|
|
234
|
-
console.
|
|
248
|
+
console.debug("activate", id);
|
|
235
249
|
this.confirm(this.doActivate.bind(this, id),
|
|
236
250
|
{
|
|
237
251
|
message: "Please confirm that you want to activate this tenant.",
|
|
@@ -248,13 +262,13 @@ export class TenantsComponent implements AfterViewInit{
|
|
|
248
262
|
this.openSnackBar("Tenant was activated!");
|
|
249
263
|
}, error: (error: any) => {
|
|
250
264
|
this.openSnackBar("Error activating tenant!");
|
|
251
|
-
console.
|
|
265
|
+
console.debug(error);
|
|
252
266
|
}
|
|
253
267
|
});
|
|
254
268
|
}
|
|
255
269
|
|
|
256
270
|
reactivate(id: string){
|
|
257
|
-
console.
|
|
271
|
+
console.debug("reactivate", id);
|
|
258
272
|
this.confirm(this.doReactivate.bind(this, id),
|
|
259
273
|
{
|
|
260
274
|
message: "Please confirm that you want to reactivate this tenant.",
|
|
@@ -270,13 +284,13 @@ export class TenantsComponent implements AfterViewInit{
|
|
|
270
284
|
this.openSnackBar("Tenant was reactivated!");
|
|
271
285
|
}, error: (error: any) => {
|
|
272
286
|
this.openSnackBar("Error reactivating tenant!");
|
|
273
|
-
console.
|
|
287
|
+
console.debug(error);
|
|
274
288
|
}
|
|
275
289
|
});
|
|
276
290
|
}
|
|
277
291
|
|
|
278
292
|
deactivate(id: string){
|
|
279
|
-
console.
|
|
293
|
+
console.debug("deactivate", id);
|
|
280
294
|
this.confirm(this.doDeactivate.bind(this, id),
|
|
281
295
|
{
|
|
282
296
|
message: "Please confirm that you want to deactivate this tenant. Users will not be able to login!",
|
|
@@ -293,13 +307,13 @@ export class TenantsComponent implements AfterViewInit{
|
|
|
293
307
|
this.openSnackBar("Tenant was activated!");
|
|
294
308
|
}, error: (error: any) => {
|
|
295
309
|
this.openSnackBar("Error activating tenant!");
|
|
296
|
-
console.
|
|
310
|
+
console.debug(error);
|
|
297
311
|
}
|
|
298
312
|
});
|
|
299
313
|
}
|
|
300
314
|
|
|
301
315
|
suspend(id: string){
|
|
302
|
-
console.
|
|
316
|
+
console.debug("suspend", id);
|
|
303
317
|
this.confirm(this.doSuspend.bind(this, id),
|
|
304
318
|
{
|
|
305
319
|
message: "Please confirm that you want to suspend this tenant. Users will not be able to login!",
|
|
@@ -316,13 +330,13 @@ export class TenantsComponent implements AfterViewInit{
|
|
|
316
330
|
this.openSnackBar("Tenant was suspended!");
|
|
317
331
|
}, error: (error: any) => {
|
|
318
332
|
this.openSnackBar("Error suspending tenant!");
|
|
319
|
-
console.
|
|
333
|
+
console.debug(error);
|
|
320
334
|
}
|
|
321
335
|
});
|
|
322
336
|
}
|
|
323
337
|
|
|
324
338
|
abandon(id: string){
|
|
325
|
-
console.
|
|
339
|
+
console.debug("abandon", id);
|
|
326
340
|
this.confirm(this.doAbandon.bind(this, id),
|
|
327
341
|
{
|
|
328
342
|
message: "Please confirm that you want to abandon this tenant. All data will be deleted and this action cannot be undone.",
|
|
@@ -339,13 +353,13 @@ export class TenantsComponent implements AfterViewInit{
|
|
|
339
353
|
this.openSnackBar("Tenant was abandoned!");
|
|
340
354
|
}, error: (error: any) => {
|
|
341
355
|
this.openSnackBar("Error abandoning tenant!");
|
|
342
|
-
console.
|
|
356
|
+
console.debug(error);
|
|
343
357
|
}
|
|
344
358
|
});
|
|
345
359
|
}
|
|
346
360
|
|
|
347
361
|
approve(id: string){
|
|
348
|
-
console.
|
|
362
|
+
console.debug("approve", id);
|
|
349
363
|
this.confirm(this.doApprove.bind(this, id),
|
|
350
364
|
{
|
|
351
365
|
message: "Please confirm that you want to approve this tenant.",
|
|
@@ -362,13 +376,13 @@ export class TenantsComponent implements AfterViewInit{
|
|
|
362
376
|
this.openSnackBar("Tenant was approved!");
|
|
363
377
|
}, error: (error: any) => {
|
|
364
378
|
this.openSnackBar("Error approving tenant!");
|
|
365
|
-
console.
|
|
379
|
+
console.debug(error);
|
|
366
380
|
}
|
|
367
381
|
});
|
|
368
382
|
}
|
|
369
383
|
|
|
370
384
|
reject(id: string){
|
|
371
|
-
console.
|
|
385
|
+
console.debug("reject", id);
|
|
372
386
|
this.confirm(this.doReject.bind(this, id),
|
|
373
387
|
{
|
|
374
388
|
message: "Please confirm that you want to reject this tenant.",
|
|
@@ -385,9 +399,87 @@ export class TenantsComponent implements AfterViewInit{
|
|
|
385
399
|
this.openSnackBar("Tenant was rejected!");
|
|
386
400
|
}, error: (error: any) => {
|
|
387
401
|
this.openSnackBar("Error rejecting tenant!");
|
|
388
|
-
console.
|
|
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);
|
|
389
464
|
}
|
|
390
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
|
+
});
|
|
391
483
|
}
|
|
392
484
|
//#endregion
|
|
393
485
|
|
|
@@ -462,8 +554,8 @@ export class TenantsComponent implements AfterViewInit{
|
|
|
462
554
|
}
|
|
463
555
|
|
|
464
556
|
openSnackBar(message: string) {
|
|
465
|
-
this.localizer.get("Close").subscribe((value:
|
|
466
|
-
|
|
557
|
+
this.localizer.get([message, "Close"]).subscribe((value: any) => {
|
|
558
|
+
this.snackBar.open(value[message], value["Close"], {
|
|
467
559
|
duration: 3000
|
|
468
560
|
});
|
|
469
561
|
});
|
|
@@ -4,12 +4,11 @@ import { CommonModule } from '@angular/common';
|
|
|
4
4
|
import { TranslateModule } from '@ngx-translate/core'
|
|
5
5
|
import { TenantsComponent } from './tenants.component';
|
|
6
6
|
import { TenantDetailComponent } from './tenant-detail/tenant-detail.component';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { TenantAdminService } from './shared/services/tenant-admin.service';
|
|
8
|
+
import { TenantConfiguration, TenantConfigurationParams } from './shared/tenant-configuration';
|
|
9
9
|
import { MaterialModule } from './shared/material.module';
|
|
10
10
|
import { TenantSummaryComponent } from './tenant-summary/tenant-summary.component';
|
|
11
11
|
import { TenantCreateComponent } from './tenant-create/tenant-create.component';
|
|
12
|
-
import { DictBuilderComponent } from './dict-builder/dict-builder.component';
|
|
13
12
|
import { TenantUpdateComponent } from './tenant-update/tenant-update.component';
|
|
14
13
|
import { ClipboardModule } from '@angular/cdk/clipboard';
|
|
15
14
|
import { MatMultiSortModule } from 'ngx-mat-multi-sort';
|
|
@@ -22,7 +21,6 @@ import { ConfirmDialogComponent } from './confirm-dialog/confirm-dialog.componen
|
|
|
22
21
|
TenantDetailComponent,
|
|
23
22
|
TenantSummaryComponent,
|
|
24
23
|
TenantCreateComponent,
|
|
25
|
-
DictBuilderComponent,
|
|
26
24
|
TenantUpdateComponent,
|
|
27
25
|
ConfirmDialogComponent
|
|
28
26
|
],
|
|
@@ -41,20 +39,19 @@ import { ConfirmDialogComponent } from './confirm-dialog/confirm-dialog.componen
|
|
|
41
39
|
TenantSummaryComponent,
|
|
42
40
|
TenantCreateComponent,
|
|
43
41
|
TenantUpdateComponent,
|
|
44
|
-
DictBuilderComponent,
|
|
45
42
|
TranslateModule
|
|
46
43
|
]
|
|
47
44
|
})
|
|
48
45
|
export class TenantsModule {
|
|
49
46
|
|
|
50
|
-
public static forRoot(environment:
|
|
47
|
+
public static forRoot(environment: TenantConfigurationParams): ModuleWithProviders<TenantsModule> {
|
|
51
48
|
|
|
52
49
|
return {
|
|
53
50
|
ngModule: TenantsModule,
|
|
54
51
|
providers: [
|
|
55
|
-
|
|
52
|
+
TenantAdminService,
|
|
56
53
|
{
|
|
57
|
-
provide:
|
|
54
|
+
provide: TenantConfiguration,
|
|
58
55
|
useValue: environment
|
|
59
56
|
}
|
|
60
57
|
]
|
package/src/public-api.ts
CHANGED
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
* Public API Surface of tenants
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
export * from './lib/shared/services/tenant.service';
|
|
5
|
+
export * from './lib/shared/services/tenant-admin.service';
|
|
6
6
|
export * from './lib/tenants.component';
|
|
7
7
|
export * from './lib/tenant-detail/tenant-detail.component';
|
|
8
8
|
export * from './lib/tenant-summary/tenant-summary.component';
|
|
9
9
|
export * from './lib/tenant-create/tenant-create.component';
|
|
10
10
|
export * from './lib/tenant-update/tenant-update.component';
|
|
11
|
-
export * from './lib/dict-builder/dict-builder.component';
|
|
12
11
|
export * from './lib/confirm-dialog/confirm-dialog.component';
|
|
13
12
|
export * from './lib/tenants.module';
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
<mat-card>
|
|
2
|
-
<mat-card-header>
|
|
3
|
-
<mat-card-title>{{ title | translate }}</mat-card-title>
|
|
4
|
-
</mat-card-header>
|
|
5
|
-
<mat-card-content style="padding-top: 10px;">
|
|
6
|
-
<mat-form-field *ngFor="let kvp of models">
|
|
7
|
-
<mat-label>{{ kvp.key }}</mat-label>
|
|
8
|
-
<input matInput *ngIf="isEditing(kvp.key)" [(ngModel)]="editKeyModel" [errorStateMatcher]="matcher">
|
|
9
|
-
<mat-error *ngIf="keyExists(editKeyModel)">
|
|
10
|
-
{{ 'This key is already existed' | translate }}
|
|
11
|
-
</mat-error>
|
|
12
|
-
|
|
13
|
-
<button *ngIf="isEditing(kvp.key) && kvp.key!=editKeyModel" matSuffix mat-icon-button matTooltip="{{ 'Restore key' | translate}}" (click)="cancelEditKey()">
|
|
14
|
-
<mat-icon>restore</mat-icon>
|
|
15
|
-
</button>
|
|
16
|
-
<button *ngIf="isEditing(kvp.key) && !keyExists(editKeyModel)" matSuffix mat-icon-button matTooltip="{{ 'Update key' | translate}}" (click)="updateKey(kvp.key)">
|
|
17
|
-
<mat-icon>save</mat-icon>
|
|
18
|
-
</button>
|
|
19
|
-
|
|
20
|
-
<input matInput *ngIf="!isEditing(kvp.key)" [(ngModel)]="kvp.value">
|
|
21
|
-
|
|
22
|
-
<button *ngIf="!isEditing(kvp.key)" matSuffix mat-icon-button matTooltip="{{ 'Edit key' | translate}}" (click)="editKey(kvp.key)">
|
|
23
|
-
<mat-icon>edit</mat-icon>
|
|
24
|
-
</button>
|
|
25
|
-
<button *ngIf="!isEditing(kvp.key) && kvp.value!=model[kvp.key]" matSuffix mat-icon-button matTooltip="{{ 'Update value' | translate}}" (click)="updateValue(kvp.key)">
|
|
26
|
-
<mat-icon>save</mat-icon>
|
|
27
|
-
</button>
|
|
28
|
-
<button *ngIf="kvp.value && !isEditing(kvp.key)" matSuffix mat-icon-button matTooltip="{{ 'Clear value' | translate}}" (click)="clear(kvp.key)">
|
|
29
|
-
<mat-icon>close</mat-icon>
|
|
30
|
-
</button>
|
|
31
|
-
<button matSuffix mat-icon-button matTooltip="{{ 'Remove key-value' | translate}}" color="warn" (click)="remove(kvp.key)">
|
|
32
|
-
<mat-icon>delete</mat-icon>
|
|
33
|
-
</button>
|
|
34
|
-
</mat-form-field>
|
|
35
|
-
<button mat-icon-button matTooltip="{{ 'Add new key' | translate }}" (click)="add()">
|
|
36
|
-
<mat-icon>add</mat-icon>
|
|
37
|
-
</button>
|
|
38
|
-
</mat-card-content>
|
|
39
|
-
<mat-card-actions align="end">
|
|
40
|
-
<button mat-raised-button color="primary" (click)="save()"><mat-icon>save</mat-icon>{{ 'Save' | translate }}</button>
|
|
41
|
-
<button mat-raised-button (click)="cancel()"><mat-icon>cancel</mat-icon>{{ 'Cancel' | translate }}</button>
|
|
42
|
-
</mat-card-actions>
|
|
43
|
-
</mat-card>
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
|
|
3
|
-
import { DictBuilderComponent } from './dict-builder.component';
|
|
4
|
-
import { MaterialModule } from '../shared/material.module';
|
|
5
|
-
import { TranslateModule } from '@ngx-translate/core';
|
|
6
|
-
|
|
7
|
-
describe('DictBuilderComponent', () => {
|
|
8
|
-
let component: DictBuilderComponent;
|
|
9
|
-
let fixture: ComponentFixture<DictBuilderComponent>;
|
|
10
|
-
|
|
11
|
-
beforeEach(async () => {
|
|
12
|
-
await TestBed.configureTestingModule({
|
|
13
|
-
imports: [
|
|
14
|
-
MaterialModule,
|
|
15
|
-
TranslateModule.forRoot()
|
|
16
|
-
],
|
|
17
|
-
declarations: [ DictBuilderComponent ]
|
|
18
|
-
})
|
|
19
|
-
.compileComponents();
|
|
20
|
-
|
|
21
|
-
fixture = TestBed.createComponent(DictBuilderComponent);
|
|
22
|
-
component = fixture.componentInstance;
|
|
23
|
-
fixture.detectChanges();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('should create', () => {
|
|
27
|
-
expect(component).toBeTruthy();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('configuration key should be standardizing', () => {
|
|
31
|
-
expect(component.standardizeConfigurationKey("abc::0 d ef:")).toBe('abc:def');
|
|
32
|
-
expect(component.standardizeConfigurationKey("abc::0def:xyz")).toBe('abc:def:xyz');
|
|
33
|
-
expect(component.standardizeConfigurationKey("abc:0:xyz")).toBe('abc:xyz');
|
|
34
|
-
expect(component.standardizeConfigurationKey(":abc::0def:")).toBe('abc:def');
|
|
35
|
-
expect(component.standardizeConfigurationKey(":0abc::0def:")).toBe('abc:def');
|
|
36
|
-
expect(component.standardizeConfigurationKey("0abc::0def:")).toBe('abc:def');
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('property key should be standardizing', () => {
|
|
40
|
-
expect(component.standardizePropertyKey("abc::0 d ef:")).toBe('abc0def');
|
|
41
|
-
expect(component.standardizePropertyKey("abc::0def:xyz")).toBe('abc0defxyz');
|
|
42
|
-
expect(component.standardizePropertyKey("abc:0:xyz")).toBe('abc0xyz');
|
|
43
|
-
expect(component.standardizePropertyKey(":abc::0def:")).toBe('abc0def');
|
|
44
|
-
expect(component.standardizePropertyKey(":0abc::0def:")).toBe('abc0def');
|
|
45
|
-
expect(component.standardizePropertyKey("0abc::0def:")).toBe('abc0def');
|
|
46
|
-
});
|
|
47
|
-
});
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { Component, Input, Output, EventEmitter, OnInit , SimpleChange} from '@angular/core';
|
|
2
|
-
|
|
3
|
-
export class KeyValue {
|
|
4
|
-
key: string;
|
|
5
|
-
value: string;
|
|
6
|
-
|
|
7
|
-
constructor(k: string, v: string) {
|
|
8
|
-
this.key = k;
|
|
9
|
-
this.value = v;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export enum ModelType{
|
|
14
|
-
StandardObject = 'standard',
|
|
15
|
-
Configuration = 'configuration'
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
import { FormControl, FormGroupDirective, NgForm } from '@angular/forms';
|
|
19
|
-
import {ErrorStateMatcher} from '@angular/material/core';
|
|
20
|
-
|
|
21
|
-
/** Error when invalid control is dirty, touched, or submitted. */
|
|
22
|
-
export class KeyErrorStateMatcher implements ErrorStateMatcher {
|
|
23
|
-
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
|
|
24
|
-
return control!=null && (control.dirty || control.touched);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
@Component({
|
|
30
|
-
selector: 'juice-dict-builder',
|
|
31
|
-
templateUrl: './dict-builder.component.html',
|
|
32
|
-
styleUrls: ['./dict-builder.component.css']
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
export class DictBuilderComponent implements OnInit{
|
|
36
|
-
@Input() title = "Settings";
|
|
37
|
-
@Input() model : any = {};
|
|
38
|
-
|
|
39
|
-
@Input() type: ModelType = ModelType.StandardObject;
|
|
40
|
-
|
|
41
|
-
@Output() onchange = new EventEmitter<SimpleChange>();
|
|
42
|
-
|
|
43
|
-
@Output() saved = new EventEmitter<any>();
|
|
44
|
-
|
|
45
|
-
@Output() cancelled = new EventEmitter();
|
|
46
|
-
|
|
47
|
-
models: KeyValue[] = new Array<KeyValue>();
|
|
48
|
-
|
|
49
|
-
editingKey: string = "";
|
|
50
|
-
editKeyModel: string = "";
|
|
51
|
-
|
|
52
|
-
matcher = new KeyErrorStateMatcher();
|
|
53
|
-
|
|
54
|
-
ngOnInit(): void {
|
|
55
|
-
this.models = this.objectToKeyValueArray(this.model);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
objectFromKeyValueArray(arr: KeyValue[]) {
|
|
59
|
-
var obj : any = {};
|
|
60
|
-
arr.forEach(kv => obj[kv.key] = kv.value);
|
|
61
|
-
return obj;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
objectToKeyValueArray(obj: any) {
|
|
65
|
-
return Object.keys(obj).map(k => { return { key: k, value: obj[k] } });
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
keyExists(key: string) {
|
|
69
|
-
return key != this.editingKey && this.models.findIndex(m => m.key == key) > -1;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
isEditing(key: string) {
|
|
73
|
-
return key == this.editingKey;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
getNewKey() {
|
|
77
|
-
var i = 1;
|
|
78
|
-
while (this.keyExists("newkey" + i)) {
|
|
79
|
-
i++;
|
|
80
|
-
}
|
|
81
|
-
return "newkey" + i;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
standardizePropertyKey(key: string) {
|
|
85
|
-
return key.trim().replace(/\s+/g, "") // remove spaces
|
|
86
|
-
.replace(/[^a-zA-Z0-9_]/g, "") // remove invalid chars
|
|
87
|
-
.replace(/^[^a-zA-Z]+/g, "") // remove starting non-alpha chars
|
|
88
|
-
.replace(/[^a-zA-Z0-9_]$/g, "") // remove ending non-alphanumeric chars
|
|
89
|
-
;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
standardizeConfigurationKey(key: string) {
|
|
93
|
-
return key.trim().replace(/\s+/g, "") // remove spaces
|
|
94
|
-
.replace(/[^a-zA-Z0-9_:]/g, "") // remove invalid chars
|
|
95
|
-
.replace(/(:[:0-9]+)/g, ":") // remove multiple colons or numbers after colon
|
|
96
|
-
.replace(/^[^a-zA-Z]+/g, "") // remove starting non-alpha chars
|
|
97
|
-
.replace(/[^a-zA-Z0-9]$/g, "") // remove ending non-alphanumeric chars
|
|
98
|
-
;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
add(){
|
|
102
|
-
if(this.editingKey != ""){
|
|
103
|
-
this.updateValue(this.editingKey);
|
|
104
|
-
this.updateKey(this.editingKey);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
var newKey = this.getNewKey();
|
|
108
|
-
this.editingKey = newKey;
|
|
109
|
-
this.editKeyModel = newKey;
|
|
110
|
-
this.models.push(new KeyValue(newKey, ""));
|
|
111
|
-
}
|
|
112
|
-
updateValue(key: string){
|
|
113
|
-
var index = this.models.findIndex(m => m.key == key);
|
|
114
|
-
this.model[key] = this.models[index].value;
|
|
115
|
-
this.onchange.emit(new SimpleChange(new KeyValue(key, this.model[key]), new KeyValue(key, this.models[index].value), false));
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
clear(key: string){
|
|
119
|
-
this.models.find(m => m.key == key)!.value = "";
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
remove(key: string){
|
|
123
|
-
var value = this.model[key];
|
|
124
|
-
var index = this.models.findIndex(m => m.key == key);
|
|
125
|
-
this.models.splice(index, 1);
|
|
126
|
-
delete this.model[key];
|
|
127
|
-
this.onchange.emit(new SimpleChange(new KeyValue(key, value), null, false));
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
editKey(key: string){
|
|
131
|
-
this.editingKey = key;
|
|
132
|
-
this.editKeyModel = key;
|
|
133
|
-
}
|
|
134
|
-
cancelEditKey(){
|
|
135
|
-
this.editingKey = "";
|
|
136
|
-
this.editKeyModel = "";
|
|
137
|
-
}
|
|
138
|
-
updateKey(key: string){
|
|
139
|
-
this.editKeyModel = this.type == ModelType.Configuration
|
|
140
|
-
? this.standardizeConfigurationKey(this.editKeyModel)
|
|
141
|
-
: this.standardizePropertyKey(this.editKeyModel) ;
|
|
142
|
-
|
|
143
|
-
if(this.keyExists(this.editKeyModel)){
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
var index = this.models.findIndex(m => m.key == key);
|
|
147
|
-
this.models[index].key = this.editKeyModel;
|
|
148
|
-
this.model[this.editKeyModel] = this.models[index].value;
|
|
149
|
-
delete this.model[key];
|
|
150
|
-
this.onchange.emit(new SimpleChange(new KeyValue(key, this.models[index].value),
|
|
151
|
-
new KeyValue(this.editKeyModel, this.models[index].value), false));
|
|
152
|
-
this.editingKey = "";
|
|
153
|
-
this.editKeyModel = "";
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
save() {
|
|
157
|
-
this.model = this.objectFromKeyValueArray(this.models);
|
|
158
|
-
this.saved.emit(this.model);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
cancel(){
|
|
162
|
-
this.cancelled.emit();
|
|
163
|
-
}
|
|
164
|
-
}
|