@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,77 @@
|
|
|
1
|
+
import { Component, Input, Output, EventEmitter, OnInit } from '@angular/core';
|
|
2
|
+
import { TenantUpdate } from '../shared/models/tenant.update.model';
|
|
3
|
+
import { TenantService } from '../../public-api';
|
|
4
|
+
import {
|
|
5
|
+
FormControl,
|
|
6
|
+
FormGroup,
|
|
7
|
+
Validators
|
|
8
|
+
} from '@angular/forms';
|
|
9
|
+
import { CustomErrorStateMatcher } from '../shared/custom-error-state-matcher';
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@Component({
|
|
13
|
+
selector: 'juice-tenant-update',
|
|
14
|
+
templateUrl: './tenant-update.component.html',
|
|
15
|
+
styleUrls: ['./tenant-update.component.scss']
|
|
16
|
+
})
|
|
17
|
+
export class TenantUpdateComponent{
|
|
18
|
+
|
|
19
|
+
@Input() id!: string;
|
|
20
|
+
|
|
21
|
+
model: TenantUpdate = new TenantUpdate();
|
|
22
|
+
|
|
23
|
+
identifierFormControl = new FormControl(this.model.identifier, [Validators.required]);
|
|
24
|
+
nameFormControl = new FormControl(this.model.name, [Validators.required]);
|
|
25
|
+
coneectionFormControl = new FormControl(this.model.connectionString, []);
|
|
26
|
+
|
|
27
|
+
updateForm = new FormGroup({
|
|
28
|
+
identifier: this.identifierFormControl,
|
|
29
|
+
name: this.nameFormControl,
|
|
30
|
+
connectionString: this.coneectionFormControl
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
matcher = new CustomErrorStateMatcher();
|
|
34
|
+
|
|
35
|
+
@Output() updated = new EventEmitter<string>();
|
|
36
|
+
@Output() cancelled = new EventEmitter<string>();
|
|
37
|
+
|
|
38
|
+
constructor(private tenantService: TenantService) { }
|
|
39
|
+
|
|
40
|
+
ngOnChanges(): void {
|
|
41
|
+
this.tenantService.getTenant(this.id).subscribe((result) => {
|
|
42
|
+
this.updateForm.patchValue(result);
|
|
43
|
+
this.updateModel();
|
|
44
|
+
if(this.id == result.identifier){
|
|
45
|
+
this.id = result.id;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
updateModel(){
|
|
51
|
+
var value = this.updateForm.value;
|
|
52
|
+
this.model.identifier = value.identifier?? '';
|
|
53
|
+
this.model.name = value.name??'';
|
|
54
|
+
this.model.connectionString = value.connectionString??'';
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// for modal control
|
|
58
|
+
setId(value: string){
|
|
59
|
+
this.id = value;
|
|
60
|
+
this.ngOnChanges();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
submit(){
|
|
64
|
+
if(this.updateForm.valid){
|
|
65
|
+
this.updateModel();
|
|
66
|
+
this.tenantService.updateTenant(this.id, this.model).subscribe((_) => {
|
|
67
|
+
this.updateForm.reset();
|
|
68
|
+
this.model = new TenantUpdate();
|
|
69
|
+
this.updated.emit(this.id);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
cancel(){
|
|
75
|
+
this.cancelled.emit(this.id);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
<div class="mat-elevation-z2 minimum-density">
|
|
2
|
+
<form [formGroup]="form" class="table-form">
|
|
3
|
+
<mat-form-field [style.width.px]="300">
|
|
4
|
+
<input matInput type="text" placeholder="{{ 'Search' | translate }}" formControlName="filterText" (keyup.enter)="getData()">
|
|
5
|
+
<button *ngIf="filterText?.value" type="button" matSuffix mat-icon-button aria-label="Clear" (click)="clearFilterText();">
|
|
6
|
+
<mat-icon>close</mat-icon>
|
|
7
|
+
</button>
|
|
8
|
+
</mat-form-field>
|
|
9
|
+
<mat-form-field [style.width.px]="200">
|
|
10
|
+
<mat-label>{{ 'Statuses' | translate }}</mat-label>
|
|
11
|
+
<mat-select formControlName="statuses" multiple [compareWith]="statusCompareFn" placeholder="{{ 'Any status' | translate }}">
|
|
12
|
+
<mat-select-trigger>
|
|
13
|
+
{{statusOptions[statuses?.value?.[0]||-1] || ''}}
|
|
14
|
+
<span *ngIf="(statuses?.value?.length || 0) > 1" class="additional-selection">
|
|
15
|
+
(+{{(statuses?.value?.length || 0) - 1}} {{statuses?.value?.length === 2 ? 'other' : 'others'}})
|
|
16
|
+
</span>
|
|
17
|
+
</mat-select-trigger>
|
|
18
|
+
<option class="clear-statuses" (click)="clearStatuses()">{{'Any status' | translate}}</option>
|
|
19
|
+
<mat-option *ngFor="let s of statusOptions | keyvalue" [value]="s.key">
|
|
20
|
+
{{s.value}}
|
|
21
|
+
</mat-option>
|
|
22
|
+
</mat-select>
|
|
23
|
+
</mat-form-field>
|
|
24
|
+
<mat-card-actions align="end">
|
|
25
|
+
<button type="button" mat-button (click)="add()" color="primary"><mat-icon>add</mat-icon> {{ 'New Organization'}}</button>
|
|
26
|
+
</mat-card-actions>
|
|
27
|
+
</form>
|
|
28
|
+
<table mat-table [dataSource]="table.dataSource" matMultiSort (matSortChange)="table.onSortEvent()">
|
|
29
|
+
|
|
30
|
+
<!--- Note that these columns can be defined in any order.
|
|
31
|
+
The actual rendered columns are set as a property on the row definition" -->
|
|
32
|
+
<ng-container matColumnDef="identifier">
|
|
33
|
+
<th mat-header-cell *matHeaderCellDef mat-multi-sort-header="identifier" disableClear="true"> {{ 'Identifier' | translate }} </th>
|
|
34
|
+
<td class="button-cell" mat-cell *matCellDef="let row"> {{row.identifier}}
|
|
35
|
+
<button mat-icon-button [cdkCopyToClipboard]="row.identifier"
|
|
36
|
+
[attr.aria-label]="'Copy' | translate">
|
|
37
|
+
<mat-icon>content_copy</mat-icon>
|
|
38
|
+
</button>
|
|
39
|
+
</td>
|
|
40
|
+
</ng-container>
|
|
41
|
+
<ng-container matColumnDef="name">
|
|
42
|
+
<th mat-header-cell *matHeaderCellDef > {{'Name'|translate}} </th>
|
|
43
|
+
<td mat-cell *matCellDef="let row">
|
|
44
|
+
{{row.name}}
|
|
45
|
+
</td>
|
|
46
|
+
</ng-container>
|
|
47
|
+
<ng-container matColumnDef="status">
|
|
48
|
+
<th mat-header-cell *matHeaderCellDef > {{'Status'|translate}} </th>
|
|
49
|
+
<td mat-cell *matCellDef="let row" [class]="statusHelper.getColor(row.status)">
|
|
50
|
+
{{row.status}}
|
|
51
|
+
</td>
|
|
52
|
+
</ng-container>
|
|
53
|
+
|
|
54
|
+
<ng-container matColumnDef="actions">
|
|
55
|
+
<th mat-header-cell *matHeaderCellDef style="text-align: center;"> {{'Actions'|translate}} </th>
|
|
56
|
+
<td mat-cell *matCellDef="let row" class="actions-cell">
|
|
57
|
+
<button mat-button (click)="detail(row.id)">
|
|
58
|
+
<mat-icon>info</mat-icon>{{'Detail' | translate}}
|
|
59
|
+
</button>
|
|
60
|
+
<button mat-button (click)="edit(row.id)">
|
|
61
|
+
<mat-icon>edit</mat-icon>{{'Edit' | translate}}
|
|
62
|
+
</button>
|
|
63
|
+
|
|
64
|
+
<button [disabled]="!canAbandon(row.status)" mat-button (click)="abandon(row.id)" color="warn">
|
|
65
|
+
<mat-icon>delete</mat-icon>{{'Abandon' | translate}}
|
|
66
|
+
</button>
|
|
67
|
+
<button mat-icon-button [matMenuTriggerFor]="appMenu" [matMenuTriggerData]="{id: row.id, status: row.status}">
|
|
68
|
+
<mat-icon>more_vert</mat-icon>
|
|
69
|
+
</button>
|
|
70
|
+
</td>
|
|
71
|
+
</ng-container>
|
|
72
|
+
|
|
73
|
+
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr>
|
|
74
|
+
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
|
75
|
+
</table>
|
|
76
|
+
<mat-paginator [pageSize]="table.pageSize" [pageIndex]="table.pageIndex"
|
|
77
|
+
[pageSizeOptions]="table.pageSizeOptions"
|
|
78
|
+
[length]="table.totalElements ? table.totalElements : 0"
|
|
79
|
+
(page)="table.onPaginationEvent($event)"
|
|
80
|
+
aria-label="Items per page"
|
|
81
|
+
showFirstLastButtons>
|
|
82
|
+
</mat-paginator>
|
|
83
|
+
|
|
84
|
+
</div>
|
|
85
|
+
<mat-menu #appMenu="matMenu" class="minimum-density">
|
|
86
|
+
<ng-template matMenuContent let-id="id" let-status="status">
|
|
87
|
+
<button *ngIf="canApproval(status)" class="success-color" mat-menu-item (click)="approve(id)">
|
|
88
|
+
<mat-icon>check_circle_outline</mat-icon>{{'Approve' | translate}}
|
|
89
|
+
</button>
|
|
90
|
+
<button *ngIf="canApproval(status)" class="warn-color" mat-menu-item (click)="reject(id)">
|
|
91
|
+
<mat-icon>highlight_off</mat-icon>{{'Reject' | translate}}
|
|
92
|
+
</button>
|
|
93
|
+
<button *ngIf="canActivate(status)" class="success-color" mat-menu-item (click)="activate(id)">
|
|
94
|
+
<mat-icon>present_to_all</mat-icon>{{'Activate' | translate}}
|
|
95
|
+
</button>
|
|
96
|
+
<button *ngIf="canReactivate(status)" class="success-color" mat-menu-item (click)="reactivate(id)">
|
|
97
|
+
<mat-icon>present_to_all</mat-icon>{{'Activate' | translate}}
|
|
98
|
+
</button>
|
|
99
|
+
<button *ngIf="canDeactivate(status)" class="warn-color" mat-menu-item (click)="deactivate(id)">
|
|
100
|
+
<mat-icon>cancel_presentation</mat-icon>{{'Deactivate' | translate}}
|
|
101
|
+
</button>
|
|
102
|
+
<button *ngIf="canSuspend(status)" class="warn-color" mat-menu-item (click)="suspend(id)">
|
|
103
|
+
<mat-icon>cancel_presentation</mat-icon>{{'Suspend' | translate}}
|
|
104
|
+
</button>
|
|
105
|
+
<button *ngIf="canDelete(status)" class="warn-color" mat-menu-item (click)="delete(id)">
|
|
106
|
+
<mat-icon>delete</mat-icon>{{'Delete' | translate}}
|
|
107
|
+
</button>
|
|
108
|
+
</ng-template>
|
|
109
|
+
</mat-menu>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
:host{
|
|
2
|
+
display: block;
|
|
3
|
+
}
|
|
4
|
+
mat-form-field{
|
|
5
|
+
width: 100%;
|
|
6
|
+
}
|
|
7
|
+
.mat-mdc-button-base {
|
|
8
|
+
margin: 0 8px 8px 0;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.additional-selection{
|
|
12
|
+
opacity: 0.75;
|
|
13
|
+
font-size: 0.75em;
|
|
14
|
+
line-height: 0;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.clear-statuses{
|
|
18
|
+
padding: 10px;
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.button-cell{
|
|
23
|
+
display: flex;
|
|
24
|
+
justify-content: space-between;
|
|
25
|
+
align-items: center;
|
|
26
|
+
button{
|
|
27
|
+
margin: 6px;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.actions-cell{
|
|
32
|
+
display: flex;
|
|
33
|
+
justify-content: center;
|
|
34
|
+
align-items: center;
|
|
35
|
+
button{
|
|
36
|
+
margin: 6px;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.table-form{
|
|
41
|
+
display: flex;
|
|
42
|
+
flex-direction: row;
|
|
43
|
+
align-items: baseline;
|
|
44
|
+
mat-card-actions{
|
|
45
|
+
flex: 1 1 auto;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.mat-mdc-menu-item{
|
|
50
|
+
min-height: 38px;
|
|
51
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
import { RouterTestingModule } from "@angular/router/testing";
|
|
3
|
+
import { TenantsComponent } from './tenants.component';
|
|
4
|
+
import { TenantsTestingModule } from './shared/tenant-testing';
|
|
5
|
+
import { TranslateModule } from '@ngx-translate/core';
|
|
6
|
+
|
|
7
|
+
describe('TenantsComponent', () => {
|
|
8
|
+
let component: TenantsComponent;
|
|
9
|
+
let fixture: ComponentFixture<TenantsComponent>;
|
|
10
|
+
|
|
11
|
+
beforeEach(async () => {
|
|
12
|
+
await TestBed.configureTestingModule({
|
|
13
|
+
imports: [
|
|
14
|
+
RouterTestingModule,
|
|
15
|
+
TranslateModule.forRoot(),
|
|
16
|
+
TenantsTestingModule.forTest({}),
|
|
17
|
+
],
|
|
18
|
+
declarations: [ TenantsComponent ]
|
|
19
|
+
})
|
|
20
|
+
.compileComponents();
|
|
21
|
+
|
|
22
|
+
fixture = TestBed.createComponent(TenantsComponent);
|
|
23
|
+
component = fixture.componentInstance;
|
|
24
|
+
fixture.detectChanges();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should create', () => {
|
|
28
|
+
expect(component).toBeTruthy();
|
|
29
|
+
});
|
|
30
|
+
});
|