@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,28 @@
|
|
|
1
|
+
import { TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { TenantService } from './tenant.service';
|
|
4
|
+
import { HttpClientModule } from '@angular/common/http';
|
|
5
|
+
import { ApiConfiguration } from '../api-configuration';
|
|
6
|
+
|
|
7
|
+
describe('TenantsService', () => {
|
|
8
|
+
let service: TenantService;
|
|
9
|
+
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
TestBed.configureTestingModule({
|
|
12
|
+
imports: [
|
|
13
|
+
HttpClientModule
|
|
14
|
+
],
|
|
15
|
+
providers: [
|
|
16
|
+
{
|
|
17
|
+
provide: ApiConfiguration,
|
|
18
|
+
useValue: {}
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
});
|
|
22
|
+
service = TestBed.inject(TenantService);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('should be created', () => {
|
|
26
|
+
expect(service).toBeTruthy();
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Injectable, Inject } from '@angular/core';
|
|
2
|
+
import { HttpClient, HttpParams } from '@angular/common/http';
|
|
3
|
+
import { ApiConfiguration } from '../api-configuration';
|
|
4
|
+
import { Tenant, TenantBasic } from '../models/tenant.model';
|
|
5
|
+
import { TenantCreate, TenantCreated } from '../models/tenant.create.model';
|
|
6
|
+
import { TenantUpdate } from '../models/tenant.update.model';
|
|
7
|
+
import { TenantStatus } from '../models/tenant.status';
|
|
8
|
+
import { TableQueryResult } from '../models/table.query-result';
|
|
9
|
+
import { Observable } from 'rxjs';
|
|
10
|
+
|
|
11
|
+
@Injectable({
|
|
12
|
+
providedIn: 'root'
|
|
13
|
+
})
|
|
14
|
+
export class TenantService {
|
|
15
|
+
|
|
16
|
+
constructor(private http: HttpClient, private options: ApiConfiguration) {
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public getTenants(filterText: string = "", statuses: TenantStatus[] = [],
|
|
21
|
+
sortColumns: string[] = [], sortDirections: string[]=[],
|
|
22
|
+
pageIndex: number =0, pageSize: number = 20): Observable<TableQueryResult<TenantBasic>> {
|
|
23
|
+
|
|
24
|
+
var params = new HttpParams()
|
|
25
|
+
.set('q', filterText)
|
|
26
|
+
.set('page', pageIndex+1)
|
|
27
|
+
.set('pageSize', pageSize);
|
|
28
|
+
|
|
29
|
+
if (statuses.length > 0) {
|
|
30
|
+
for (var i = 0; i < statuses.length; i++) {
|
|
31
|
+
params = params.append('statuses', statuses[i]);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if(sortColumns.length > 0) {
|
|
35
|
+
if(sortDirections.length != sortColumns.length) throw new Error("sortColumns and sortDirections must be the same length");
|
|
36
|
+
for (var i = 0; i < sortColumns.length; i++) {
|
|
37
|
+
params = params.set("sorts["+i+"].property", sortColumns[i])
|
|
38
|
+
.set("sorts["+i+"].sortDir", sortDirections[i]);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return this.http.get<TableQueryResult<TenantBasic>>(`${this.options.apiEndpoint}/api/v${this.options.apiVersion}/tenants`,
|
|
42
|
+
{params: params});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
public getTenant(identifier: string) {
|
|
47
|
+
return this.http.get<Tenant>(`${this.options.apiEndpoint}/api/v${this.options.apiVersion}/admin/${identifier}`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public getSummary(identifier: string) {
|
|
51
|
+
return this.http.get<TenantBasic>(`${this.options.apiEndpoint}/${identifier}/api/v${this.options.apiVersion}/operation`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public createTenant(tenant: TenantCreate) {
|
|
55
|
+
return this.http.post<TenantCreated>(`${this.options.apiEndpoint}/api/v${this.options.apiVersion}/admin`, tenant);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public updateTenant(id: string, tenant: TenantUpdate) {
|
|
59
|
+
return this.http.put(`${this.options.apiEndpoint}/api/v${this.options.apiVersion}/admin/${id}`, tenant);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public deleteTenant(id: string) {
|
|
63
|
+
return this.http.delete(`${this.options.apiEndpoint}/api/v${this.options.apiVersion}/admin/${id}`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public activateTenant(id: string) {
|
|
67
|
+
return this.http.post(`${this.options.apiEndpoint}/api/v${this.options.apiVersion}/admin/${id}/activate`, null);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public deactivateTenant(id: string) {
|
|
71
|
+
return this.http.post(`${this.options.apiEndpoint}/api/v${this.options.apiVersion}/admin/${id}/deactivate`, null);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public reactivateTenant(id: string) {
|
|
75
|
+
return this.http.post(`${this.options.apiEndpoint}/api/v${this.options.apiVersion}/admin/${id}/reactivate`, null);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
public suspendTenant(id: string) {
|
|
79
|
+
return this.http.post(`${this.options.apiEndpoint}/api/v${this.options.apiVersion}/admin/${id}/suspend`, null);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public approveTenant(id: string) {
|
|
83
|
+
return this.http.post(`${this.options.apiEndpoint}/api/v${this.options.apiVersion}/admin/${id}/approve`, null);
|
|
84
|
+
}
|
|
85
|
+
public rejectTenant(id: string) {
|
|
86
|
+
return this.http.post(`${this.options.apiEndpoint}/api/v${this.options.apiVersion}/admin/${id}/reject`, null);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
public abandonTenant(id: string) {
|
|
90
|
+
return this.http.put(`${this.options.apiEndpoint}/api/v${this.options.apiVersion}/admin/${id}/abandon`, null);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { NgModule, ModuleWithProviders } from '@angular/core';
|
|
2
|
+
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
3
|
+
import { CommonModule } from '@angular/common';
|
|
4
|
+
import { TenantService } from './services/tenant.service';
|
|
5
|
+
import { ApiConfiguration, ApiConfigurationParams } from './api-configuration';
|
|
6
|
+
import { MaterialModule } from './material.module';
|
|
7
|
+
import { HttpClientModule } from '@angular/common/http';
|
|
8
|
+
import { BrowserModule } from '@angular/platform-browser';
|
|
9
|
+
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@NgModule({
|
|
13
|
+
imports: [
|
|
14
|
+
FormsModule,
|
|
15
|
+
ReactiveFormsModule,
|
|
16
|
+
CommonModule,
|
|
17
|
+
MaterialModule,
|
|
18
|
+
HttpClientModule,
|
|
19
|
+
BrowserModule,
|
|
20
|
+
BrowserAnimationsModule
|
|
21
|
+
],
|
|
22
|
+
exports: [
|
|
23
|
+
MaterialModule,
|
|
24
|
+
FormsModule,
|
|
25
|
+
ReactiveFormsModule,
|
|
26
|
+
CommonModule
|
|
27
|
+
]
|
|
28
|
+
})
|
|
29
|
+
export class TenantsTestingModule {
|
|
30
|
+
|
|
31
|
+
public static forTest(environment: ApiConfigurationParams): ModuleWithProviders<TenantsTestingModule> {
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
ngModule: TenantsTestingModule,
|
|
35
|
+
providers: [
|
|
36
|
+
TenantService,
|
|
37
|
+
{
|
|
38
|
+
provide: ApiConfiguration,
|
|
39
|
+
useValue: environment
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
<mat-card>
|
|
3
|
+
<mat-card-header>
|
|
4
|
+
<mat-card-title>{{ 'Create new organization' | translate }}</mat-card-title>
|
|
5
|
+
</mat-card-header>
|
|
6
|
+
<mat-card-content style="padding-top: 10px;">
|
|
7
|
+
<mat-form-field>
|
|
8
|
+
<mat-label>{{ 'Identifier' | translate }}</mat-label>
|
|
9
|
+
<input matInput [formControl]="identifierFormControl" [errorStateMatcher]="matcher">
|
|
10
|
+
<mat-error *ngIf="identifierFormControl.hasError('required')">
|
|
11
|
+
{{ 'Please enter an identifier' | translate }}
|
|
12
|
+
</mat-error>
|
|
13
|
+
</mat-form-field>
|
|
14
|
+
|
|
15
|
+
<mat-form-field>
|
|
16
|
+
<mat-label>{{ 'Organization name' | translate }}</mat-label>
|
|
17
|
+
<input matInput [formControl]="nameFormControl" [errorStateMatcher]="matcher">
|
|
18
|
+
<mat-error *ngIf="nameFormControl.hasError('required')">
|
|
19
|
+
{{ 'Please enter a name' | translate }}
|
|
20
|
+
</mat-error>
|
|
21
|
+
</mat-form-field>
|
|
22
|
+
|
|
23
|
+
<mat-form-field>
|
|
24
|
+
<mat-label>{{ 'Admin user' | translate }}</mat-label>
|
|
25
|
+
<input matInput [(ngModel)]="model.adminUser">
|
|
26
|
+
</mat-form-field>
|
|
27
|
+
|
|
28
|
+
<mat-form-field>
|
|
29
|
+
<mat-label>{{ 'Admin email' | translate }}</mat-label>
|
|
30
|
+
<input matInput [formControl]="emailFormControl" [errorStateMatcher]="matcher">
|
|
31
|
+
<mat-error *ngIf="emailFormControl.hasError('email') && !emailFormControl.hasError('required')">
|
|
32
|
+
{{ 'Please enter a valid email address' | translate }}
|
|
33
|
+
</mat-error>
|
|
34
|
+
</mat-form-field>
|
|
35
|
+
|
|
36
|
+
<mat-form-field>
|
|
37
|
+
<mat-label>{{ 'DB connection' | translate }}</mat-label>
|
|
38
|
+
<input matInput [(ngModel)]="model.connectionString">
|
|
39
|
+
</mat-form-field>
|
|
40
|
+
</mat-card-content>
|
|
41
|
+
<mat-card-actions align="end">
|
|
42
|
+
<button mat-raised-button color="primary" (click)="submit()" [disabled]="createForm.invalid"><mat-icon>save</mat-icon>{{ 'Submit' | translate }}</button>
|
|
43
|
+
<button mat-raised-button (click)="cancel()"><mat-icon>cancel</mat-icon>{{ 'Cancel' | translate }}</button>
|
|
44
|
+
</mat-card-actions>
|
|
45
|
+
</mat-card>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { TenantCreateComponent } from './tenant-create.component';
|
|
4
|
+
import { HttpClientModule } from '@angular/common/http';
|
|
5
|
+
import { ApiConfiguration } from '../shared/api-configuration';
|
|
6
|
+
import { MaterialModule } from '../shared/material.module';
|
|
7
|
+
import { TranslateModule } from '@ngx-translate/core';
|
|
8
|
+
import { TenantsTestingModule } from '../shared/tenant-testing';
|
|
9
|
+
|
|
10
|
+
describe('TenantCreateComponent', () => {
|
|
11
|
+
let component: TenantCreateComponent;
|
|
12
|
+
let fixture: ComponentFixture<TenantCreateComponent>;
|
|
13
|
+
|
|
14
|
+
beforeEach(async () => {
|
|
15
|
+
await TestBed.configureTestingModule({
|
|
16
|
+
imports: [
|
|
17
|
+
TranslateModule.forRoot(),
|
|
18
|
+
TenantsTestingModule.forTest({}),
|
|
19
|
+
],
|
|
20
|
+
declarations: [ TenantCreateComponent ]
|
|
21
|
+
})
|
|
22
|
+
.compileComponents();
|
|
23
|
+
|
|
24
|
+
fixture = TestBed.createComponent(TenantCreateComponent);
|
|
25
|
+
component = fixture.componentInstance;
|
|
26
|
+
fixture.detectChanges();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should create', () => {
|
|
30
|
+
expect(component).toBeTruthy();
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Component, OnInit, Output, EventEmitter, Input } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
import { TenantCreate, TenantCreated } from '../shared/models/tenant.create.model';
|
|
4
|
+
import { TenantService } from '../../public-api';
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
FormControl,
|
|
8
|
+
FormGroup,
|
|
9
|
+
Validators
|
|
10
|
+
} from '@angular/forms';
|
|
11
|
+
import { CustomErrorStateMatcher } from '../shared/custom-error-state-matcher';
|
|
12
|
+
|
|
13
|
+
@Component({
|
|
14
|
+
selector: 'juice-tenant-create',
|
|
15
|
+
templateUrl: './tenant-create.component.html',
|
|
16
|
+
styleUrls: ['./tenant-create.component.css']
|
|
17
|
+
})
|
|
18
|
+
export class TenantCreateComponent implements OnInit{
|
|
19
|
+
model: TenantCreate = new TenantCreate();
|
|
20
|
+
|
|
21
|
+
emailFormControl = new FormControl('', [Validators.email]);
|
|
22
|
+
identifierFormControl = new FormControl('', [Validators.required]);
|
|
23
|
+
nameFormControl = new FormControl('', [Validators.required]);
|
|
24
|
+
|
|
25
|
+
createForm = new FormGroup({
|
|
26
|
+
identifier: this.identifierFormControl,
|
|
27
|
+
name: this.nameFormControl,
|
|
28
|
+
email: this.emailFormControl
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
matcher = new CustomErrorStateMatcher();
|
|
32
|
+
|
|
33
|
+
@Output() created = new EventEmitter<TenantCreated>();
|
|
34
|
+
@Output() cancelled = new EventEmitter();
|
|
35
|
+
|
|
36
|
+
constructor(private tenantService: TenantService) { }
|
|
37
|
+
|
|
38
|
+
ngOnInit(): void {
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
updateModel(){
|
|
42
|
+
var value = this.createForm.value;
|
|
43
|
+
this.model.identifier = value.identifier?? '';
|
|
44
|
+
this.model.name = value.name??'';
|
|
45
|
+
this.model.adminEmail = value.email??'';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
submit(){
|
|
49
|
+
if(this.createForm.valid){
|
|
50
|
+
this.updateModel();
|
|
51
|
+
this.tenantService.createTenant(this.model).subscribe({
|
|
52
|
+
next:(result) => {
|
|
53
|
+
if(this.created!=null){
|
|
54
|
+
this.created.emit(result);
|
|
55
|
+
}
|
|
56
|
+
this.createForm.reset();
|
|
57
|
+
this.model = new TenantCreate();
|
|
58
|
+
},
|
|
59
|
+
error:(err) => {
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
cancel(){
|
|
66
|
+
this.cancelled.emit();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<mat-card>
|
|
2
|
+
<mat-card-header>
|
|
3
|
+
<mat-card-title>{{ 'Organization information' | translate }}</mat-card-title>
|
|
4
|
+
</mat-card-header>
|
|
5
|
+
|
|
6
|
+
<mat-card-content>
|
|
7
|
+
<div *ngIf="tenant">
|
|
8
|
+
<h3>{{ tenant.name }}</h3>
|
|
9
|
+
|
|
10
|
+
<mat-list>
|
|
11
|
+
<mat-list-item>
|
|
12
|
+
<span matListItemTitle>{{ 'Unique Id' | translate }}</span>
|
|
13
|
+
<span matListItemLine>{{ tenant.id }}
|
|
14
|
+
<button style="margin-left: 6px;" mat-icon-button [cdkCopyToClipboard]="tenant.id"
|
|
15
|
+
[attr.aria-label]="'Copy' | translate">
|
|
16
|
+
<mat-icon>content_copy</mat-icon>
|
|
17
|
+
</button>
|
|
18
|
+
</span>
|
|
19
|
+
</mat-list-item>
|
|
20
|
+
|
|
21
|
+
<mat-list-item>
|
|
22
|
+
<span matListItemTitle>{{ 'Identifier' | translate }}</span>
|
|
23
|
+
<span matListItemLine>{{ tenant.identifier }}</span>
|
|
24
|
+
</mat-list-item>
|
|
25
|
+
|
|
26
|
+
<mat-list-item>
|
|
27
|
+
<span matListItemTitle>{{ 'Status' | translate }}</span>
|
|
28
|
+
<span matListItemLine [class]="statusHelper.getColor(tenant.status)">{{ tenant.status }}</span>
|
|
29
|
+
</mat-list-item>
|
|
30
|
+
|
|
31
|
+
<mat-list-item>
|
|
32
|
+
<span matListItemTitle>{{ 'ConnectionString' | translate }}</span>
|
|
33
|
+
<span matListItemLine>{{ tenant.connectionString }}</span>
|
|
34
|
+
</mat-list-item>
|
|
35
|
+
|
|
36
|
+
<mat-list-item>
|
|
37
|
+
<span matListItemTitle>{{ 'Owner' | translate }}</span>
|
|
38
|
+
<span matListItemLine>{{ tenant.ownerName }}</span>
|
|
39
|
+
</mat-list-item>
|
|
40
|
+
|
|
41
|
+
<mat-list-item>
|
|
42
|
+
<span matListItemTitle>{{ 'Properties' | translate }}</span>
|
|
43
|
+
<span matListItemLine *ngFor="let property of properties | keyvalue">
|
|
44
|
+
{{ property.key }}: {{ property.value }}
|
|
45
|
+
</span>
|
|
46
|
+
</mat-list-item>
|
|
47
|
+
</mat-list>
|
|
48
|
+
</div>
|
|
49
|
+
</mat-card-content>
|
|
50
|
+
</mat-card>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { TenantDetailComponent } from './tenant-detail.component';
|
|
4
|
+
import { TranslateModule } from '@ngx-translate/core';
|
|
5
|
+
import { TenantsTestingModule } from '../shared/tenant-testing';
|
|
6
|
+
|
|
7
|
+
describe('TenantDetailComponent', () => {
|
|
8
|
+
let component: TenantDetailComponent;
|
|
9
|
+
let fixture: ComponentFixture<TenantDetailComponent>;
|
|
10
|
+
|
|
11
|
+
beforeEach(async () => {
|
|
12
|
+
await TestBed.configureTestingModule({
|
|
13
|
+
imports: [
|
|
14
|
+
TranslateModule.forRoot(),
|
|
15
|
+
TenantsTestingModule.forTest({}),
|
|
16
|
+
],
|
|
17
|
+
declarations: [ TenantDetailComponent ]
|
|
18
|
+
})
|
|
19
|
+
.compileComponents();
|
|
20
|
+
|
|
21
|
+
fixture = TestBed.createComponent(TenantDetailComponent);
|
|
22
|
+
component = fixture.componentInstance;
|
|
23
|
+
fixture.detectChanges();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should create', () => {
|
|
27
|
+
expect(component).toBeTruthy();
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Component, OnInit, Input, OnChanges } from '@angular/core';
|
|
2
|
+
import { TenantService } from '../shared/services/tenant.service';
|
|
3
|
+
import { Tenant } from '../shared/models/tenant.model';
|
|
4
|
+
import { TenantStatusHelper } from '../shared/models/tenant.status';
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
selector: 'juice-tenant-detail',
|
|
8
|
+
templateUrl: './tenant-detail.component.html',
|
|
9
|
+
styleUrls: ['./tenant-detail.component.scss']
|
|
10
|
+
})
|
|
11
|
+
export class TenantDetailComponent implements OnChanges {
|
|
12
|
+
|
|
13
|
+
@Input() tenantIdentifier: string = "";
|
|
14
|
+
|
|
15
|
+
tenant!: Tenant;
|
|
16
|
+
properties: any;
|
|
17
|
+
statusHelper = TenantStatusHelper;
|
|
18
|
+
|
|
19
|
+
constructor(private tenantService: TenantService) { }
|
|
20
|
+
|
|
21
|
+
public loadTenant(identifier: string){
|
|
22
|
+
this.tenantService.getTenant(identifier).subscribe(tenant => {
|
|
23
|
+
this.tenant = tenant;
|
|
24
|
+
this.properties = JSON.parse(tenant.serializedProperties);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
ngOnChanges(): void {
|
|
29
|
+
this.loadTenant(this.tenantIdentifier);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<mat-card>
|
|
2
|
+
<mat-card-header>
|
|
3
|
+
<mat-card-title>{{ 'Organization summary' | translate }}</mat-card-title>
|
|
4
|
+
</mat-card-header>
|
|
5
|
+
<mat-card-content>
|
|
6
|
+
<div *ngIf="tenant">
|
|
7
|
+
<h3>{{ tenant.name }}</h3>
|
|
8
|
+
|
|
9
|
+
<mat-list>
|
|
10
|
+
<mat-list-item>
|
|
11
|
+
<span matListItemTitle>{{ 'Unique Id' | translate }}</span>
|
|
12
|
+
<span matListItemLine>{{ tenant.id }}</span>
|
|
13
|
+
</mat-list-item>
|
|
14
|
+
|
|
15
|
+
<mat-list-item>
|
|
16
|
+
<span matListItemTitle>{{ 'Identifier' | translate }}</span>
|
|
17
|
+
<span matListItemLine>{{ tenant.identifier }}</span>
|
|
18
|
+
</mat-list-item>
|
|
19
|
+
|
|
20
|
+
<mat-list-item>
|
|
21
|
+
<span matListItemTitle>{{ 'Status' | translate }}</span>
|
|
22
|
+
<span matListItemLine>{{ tenant.status }}</span>
|
|
23
|
+
</mat-list-item>
|
|
24
|
+
|
|
25
|
+
</mat-list>
|
|
26
|
+
</div>
|
|
27
|
+
</mat-card-content>
|
|
28
|
+
</mat-card>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { TenantSummaryComponent } from './tenant-summary.component';
|
|
4
|
+
import { TenantsTestingModule } from '../shared/tenant-testing';
|
|
5
|
+
import { TranslateModule } from '@ngx-translate/core';
|
|
6
|
+
|
|
7
|
+
describe('TenantSummaryComponent', () => {
|
|
8
|
+
let component: TenantSummaryComponent;
|
|
9
|
+
let fixture: ComponentFixture<TenantSummaryComponent>;
|
|
10
|
+
|
|
11
|
+
beforeEach(async () => {
|
|
12
|
+
await TestBed.configureTestingModule({
|
|
13
|
+
imports:[
|
|
14
|
+
TranslateModule.forRoot(),
|
|
15
|
+
TenantsTestingModule.forTest({}),
|
|
16
|
+
],
|
|
17
|
+
declarations: [ TenantSummaryComponent ]
|
|
18
|
+
})
|
|
19
|
+
.compileComponents();
|
|
20
|
+
|
|
21
|
+
fixture = TestBed.createComponent(TenantSummaryComponent);
|
|
22
|
+
component = fixture.componentInstance;
|
|
23
|
+
fixture.detectChanges();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should create', () => {
|
|
27
|
+
expect(component).toBeTruthy();
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Component, Input, OnChanges } from '@angular/core';
|
|
2
|
+
import { TenantBasic } from '../shared/models/tenant.model';
|
|
3
|
+
import { TenantService } from '../shared/services/tenant.service';
|
|
4
|
+
|
|
5
|
+
@Component({
|
|
6
|
+
selector: 'juice-tenant-summary',
|
|
7
|
+
templateUrl: './tenant-summary.component.html',
|
|
8
|
+
styleUrls: ['./tenant-summary.component.css']
|
|
9
|
+
})
|
|
10
|
+
export class TenantSummaryComponent implements OnChanges{
|
|
11
|
+
|
|
12
|
+
@Input()
|
|
13
|
+
tenantIdentifier: string = "";
|
|
14
|
+
|
|
15
|
+
tenant!: TenantBasic;
|
|
16
|
+
|
|
17
|
+
constructor(private tenantService: TenantService) { }
|
|
18
|
+
|
|
19
|
+
public loadTenant(identifier: string){
|
|
20
|
+
this.tenantService.getSummary(identifier).subscribe(tenant => {
|
|
21
|
+
this.tenant = tenant;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
ngOnChanges(): void {
|
|
26
|
+
this.loadTenant(this.tenantIdentifier);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
|
|
2
|
+
<mat-card>
|
|
3
|
+
<mat-card-header>
|
|
4
|
+
<mat-card-title>{{ 'Update organization information' | translate }}</mat-card-title>
|
|
5
|
+
</mat-card-header>
|
|
6
|
+
<mat-card-content style="padding-top: 10px;">
|
|
7
|
+
<mat-form-field>
|
|
8
|
+
<mat-label>{{ 'Identifier' | translate }}</mat-label>
|
|
9
|
+
<input matInput [formControl]="identifierFormControl" [errorStateMatcher]="matcher">
|
|
10
|
+
<mat-error *ngIf="identifierFormControl.hasError('required')">
|
|
11
|
+
{{ 'Please enter an identifier' | translate }}
|
|
12
|
+
</mat-error>
|
|
13
|
+
</mat-form-field>
|
|
14
|
+
|
|
15
|
+
<mat-form-field>
|
|
16
|
+
<mat-label>{{ 'Organization name' | translate }}</mat-label>
|
|
17
|
+
<input matInput [formControl]="nameFormControl" [errorStateMatcher]="matcher">
|
|
18
|
+
<mat-error *ngIf="nameFormControl.hasError('required')">
|
|
19
|
+
{{ 'Please enter a name' | translate }}
|
|
20
|
+
</mat-error>
|
|
21
|
+
</mat-form-field>
|
|
22
|
+
|
|
23
|
+
<mat-form-field>
|
|
24
|
+
<mat-label>{{ 'DB connection' | translate }}</mat-label>
|
|
25
|
+
<input matInput [formControl]="coneectionFormControl">
|
|
26
|
+
</mat-form-field>
|
|
27
|
+
</mat-card-content>
|
|
28
|
+
<mat-card-actions align="end">
|
|
29
|
+
<button mat-raised-button color="primary" (click)="submit()" [disabled]="updateForm.invalid"><mat-icon>save</mat-icon>{{ 'Submit' | translate }}</button>
|
|
30
|
+
<button mat-raised-button (click)="cancel()"><mat-icon>cancel</mat-icon>{{ 'Cancel' | translate }}</button>
|
|
31
|
+
</mat-card-actions>
|
|
32
|
+
</mat-card>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { TenantUpdateComponent } from './tenant-update.component';
|
|
4
|
+
import { TranslateModule } from '@ngx-translate/core';
|
|
5
|
+
import { TenantsTestingModule } from '../shared/tenant-testing';
|
|
6
|
+
|
|
7
|
+
describe('TenantUpdateComponent', () => {
|
|
8
|
+
let component: TenantUpdateComponent;
|
|
9
|
+
let fixture: ComponentFixture<TenantUpdateComponent>;
|
|
10
|
+
|
|
11
|
+
beforeEach(async () => {
|
|
12
|
+
await TestBed.configureTestingModule({
|
|
13
|
+
imports: [
|
|
14
|
+
TranslateModule.forRoot(),
|
|
15
|
+
TenantsTestingModule.forTest({}),
|
|
16
|
+
],
|
|
17
|
+
declarations: [ TenantUpdateComponent ]
|
|
18
|
+
})
|
|
19
|
+
.compileComponents();
|
|
20
|
+
|
|
21
|
+
fixture = TestBed.createComponent(TenantUpdateComponent);
|
|
22
|
+
component = fixture.componentInstance;
|
|
23
|
+
fixture.detectChanges();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should create', () => {
|
|
27
|
+
expect(component).toBeTruthy();
|
|
28
|
+
});
|
|
29
|
+
});
|