@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
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Tenants
|
|
2
|
+
|
|
3
|
+
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 15.2.0.
|
|
4
|
+
|
|
5
|
+
## Code scaffolding
|
|
6
|
+
|
|
7
|
+
Run `ng generate component component-name --project tenants` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project tenants`.
|
|
8
|
+
> Note: Don't forget to add `--project tenants` or else it will be added to the default project in your `angular.json` file.
|
|
9
|
+
|
|
10
|
+
## Build
|
|
11
|
+
|
|
12
|
+
Run `ng build tenants` to build the project. The build artifacts will be stored in the `dist/` directory.
|
|
13
|
+
|
|
14
|
+
## Publishing
|
|
15
|
+
|
|
16
|
+
After building your library with `ng build tenants`, go to the dist folder `cd dist/tenants` and run `npm publish`.
|
|
17
|
+
|
|
18
|
+
## Running unit tests
|
|
19
|
+
|
|
20
|
+
Run `ng test tenants` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
|
21
|
+
|
|
22
|
+
## Further help
|
|
23
|
+
|
|
24
|
+
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
|
package/ng-package.json
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@juice-js/tenants",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Juice tenants admin module",
|
|
5
|
+
"author": "jack@creatorflow.io",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"bugs": {
|
|
8
|
+
"url": "https://github.com/creatorflow-io/juice-tenants/issues"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/creatorflow-io/juice-tenants#readme",
|
|
11
|
+
"peerDependencies": {
|
|
12
|
+
"@angular/common": "^16.1.1",
|
|
13
|
+
"@angular/core": "^16.1.1",
|
|
14
|
+
"@angular/material": "^16.1.1",
|
|
15
|
+
"@ngx-translate/core": "^14.0.0",
|
|
16
|
+
"ngx-mat-multi-sort": "^0.10.2"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"tslib": "^2.3.0"
|
|
20
|
+
},
|
|
21
|
+
"sideEffects": false
|
|
22
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
@use 'sass:map';
|
|
2
|
+
@use '@angular/material' as mat;
|
|
3
|
+
|
|
4
|
+
@mixin color($theme){
|
|
5
|
+
// Get the color config from the theme.
|
|
6
|
+
$color-config: mat.get-color-config($theme);
|
|
7
|
+
// Get the primary color palette from the color-config.
|
|
8
|
+
$primary-palette: map.get($color-config, 'primary');
|
|
9
|
+
$accent-palette: map.get($color-config, 'accent');
|
|
10
|
+
$warn-palette: map.get($color-config, 'warn');
|
|
11
|
+
$green-palette: mat.define-palette(mat.$green-palette, 500, 300, 700);
|
|
12
|
+
.accent-color {
|
|
13
|
+
color: mat.get-color-from-palette($accent-palette, 'darker') !important;
|
|
14
|
+
.mdc-list-item__primary-text{
|
|
15
|
+
color: mat.get-color-from-palette($accent-palette, 'darker') !important;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.warn-color {
|
|
20
|
+
color: mat.get-color-from-palette($warn-palette, 'darker') !important;
|
|
21
|
+
.mdc-list-item__primary-text{
|
|
22
|
+
color: mat.get-color-from-palette($warn-palette, 'darker') !important;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.success-color, .mat-success.mat-mdc-button:not(:disabled){
|
|
27
|
+
color: mat.get-color-from-palette($green-palette, 'darker') !important;
|
|
28
|
+
.mdc-list-item__primary-text{
|
|
29
|
+
color: mat.get-color-from-palette($green-palette, 'darker') !important;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.accent-bg {
|
|
34
|
+
background-color: mat.get-color-from-palette($accent-palette, 'lighter') !important;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.warn-bg {
|
|
38
|
+
background-color: mat.get-color-from-palette($warn-palette, 'lighter') !important;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.success-bg{
|
|
42
|
+
background-color: mat.get-color-from-palette($green-palette, 'lighter') !important;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<mat-card>
|
|
2
|
+
<mat-card-header>
|
|
3
|
+
<mat-card-title>{{ confirmTitle | translate }}</mat-card-title>
|
|
4
|
+
<mat-card-subtitle [class]="confirmMessageClasses">{{ confirmMessage | translate }}</mat-card-subtitle>
|
|
5
|
+
</mat-card-header>
|
|
6
|
+
<mat-card-actions align="end">
|
|
7
|
+
<button mat-button (click)="confirm()" [color]="confirmButtonColor">{{ confirmButtonText | translate }}</button>
|
|
8
|
+
<button mat-button (click)="cancel()">{{ 'Cancel' | translate }}</button>
|
|
9
|
+
</mat-card-actions>
|
|
10
|
+
</mat-card>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { ConfirmDialogComponent } from './confirm-dialog.component';
|
|
4
|
+
import { TranslateModule } from '@ngx-translate/core';
|
|
5
|
+
import { TenantsTestingModule } from '../shared/tenant-testing';
|
|
6
|
+
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
|
|
7
|
+
|
|
8
|
+
describe('ConfirmDialogComponent', () => {
|
|
9
|
+
let component: ConfirmDialogComponent;
|
|
10
|
+
let fixture: ComponentFixture<ConfirmDialogComponent>;
|
|
11
|
+
|
|
12
|
+
beforeEach(async () => {
|
|
13
|
+
await TestBed.configureTestingModule({
|
|
14
|
+
imports:[
|
|
15
|
+
TranslateModule.forRoot(),
|
|
16
|
+
TenantsTestingModule.forTest({}),
|
|
17
|
+
],
|
|
18
|
+
declarations: [ ConfirmDialogComponent ],
|
|
19
|
+
providers: [
|
|
20
|
+
{ provide: MAT_DIALOG_DATA, useValue: {} }
|
|
21
|
+
]
|
|
22
|
+
})
|
|
23
|
+
.compileComponents();
|
|
24
|
+
|
|
25
|
+
fixture = TestBed.createComponent(ConfirmDialogComponent);
|
|
26
|
+
component = fixture.componentInstance;
|
|
27
|
+
fixture.detectChanges();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('should create', () => {
|
|
31
|
+
expect(component).toBeTruthy();
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Component, Output, EventEmitter, Inject } from '@angular/core';
|
|
2
|
+
import {MAT_DIALOG_DATA} from '@angular/material/dialog';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
selector: 'juice-confirm-dialog',
|
|
6
|
+
templateUrl: './confirm-dialog.component.html',
|
|
7
|
+
styleUrls: ['./confirm-dialog.component.scss']
|
|
8
|
+
})
|
|
9
|
+
export class ConfirmDialogComponent {
|
|
10
|
+
|
|
11
|
+
@Output() confirmed = new EventEmitter();
|
|
12
|
+
@Output() cancelled = new EventEmitter();
|
|
13
|
+
|
|
14
|
+
confirmMessage: string = "Are you sure?";
|
|
15
|
+
confirmMessageClasses: string = "";
|
|
16
|
+
confirmTitle: string = "Action required";
|
|
17
|
+
confirmButtonText: string = "Confirm";
|
|
18
|
+
confirmButtonColor: string = "primary";
|
|
19
|
+
|
|
20
|
+
constructor(@Inject(MAT_DIALOG_DATA) public data: {
|
|
21
|
+
title: string, message: string, buttonText: string, buttonColor: string,
|
|
22
|
+
messageClasses: string
|
|
23
|
+
}) {
|
|
24
|
+
|
|
25
|
+
if(data.title){
|
|
26
|
+
this.confirmTitle = data.title;
|
|
27
|
+
}
|
|
28
|
+
if(data.message){
|
|
29
|
+
this.confirmMessage = data.message;
|
|
30
|
+
}
|
|
31
|
+
if(data.buttonText){
|
|
32
|
+
this.confirmButtonText = data.buttonText;
|
|
33
|
+
}
|
|
34
|
+
if(data.buttonColor){
|
|
35
|
+
this.confirmButtonColor = data.buttonColor;
|
|
36
|
+
}
|
|
37
|
+
if(data.messageClasses){
|
|
38
|
+
this.confirmMessageClasses = data.messageClasses;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
confirm(){
|
|
43
|
+
this.confirmed.emit();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
cancel(){
|
|
47
|
+
this.cancelled.emit();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
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>
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,164 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// import { InjectionToken } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
// export const TENANT_OPTIONS_TOKEN = new InjectionToken<TenantConfiguration>('tenant.options');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export class ApiConfiguration {
|
|
7
|
+
apiEndpoint: string = "";
|
|
8
|
+
apiVersion: string = "2";
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ApiConfigurationParams {
|
|
12
|
+
apiEndpoint?: string;
|
|
13
|
+
apiVersion?: string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FormControl,
|
|
3
|
+
FormGroupDirective,
|
|
4
|
+
NgForm,
|
|
5
|
+
} from '@angular/forms';
|
|
6
|
+
|
|
7
|
+
import {ErrorStateMatcher} from '@angular/material/core';
|
|
8
|
+
|
|
9
|
+
/** Error when invalid control is dirty, touched, or submitted. */
|
|
10
|
+
export class CustomErrorStateMatcher implements ErrorStateMatcher {
|
|
11
|
+
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
|
|
12
|
+
const isSubmitted = form && form.submitted;
|
|
13
|
+
return !!(control && control.invalid && (control.dirty || control.touched || isSubmitted));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
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
|
+
import {MatButtonModule} from '@angular/material/button';
|
|
6
|
+
import {MatButtonToggleModule} from '@angular/material/button-toggle';
|
|
7
|
+
import {MatCardModule} from '@angular/material/card';
|
|
8
|
+
import {MatCheckboxModule} from '@angular/material/checkbox';
|
|
9
|
+
import {MatChipsModule} from '@angular/material/chips';
|
|
10
|
+
import {MatStepperModule} from '@angular/material/stepper';
|
|
11
|
+
import {MatDatepickerModule} from '@angular/material/datepicker';
|
|
12
|
+
import {MatDialogModule} from '@angular/material/dialog';
|
|
13
|
+
import {MatDividerModule} from '@angular/material/divider';
|
|
14
|
+
import {MatExpansionModule} from '@angular/material/expansion';
|
|
15
|
+
import {MatGridListModule} from '@angular/material/grid-list';
|
|
16
|
+
import {MatIconModule} from '@angular/material/icon';
|
|
17
|
+
import {MatInputModule} from '@angular/material/input';
|
|
18
|
+
import {MatListModule} from '@angular/material/list';
|
|
19
|
+
import {MatMenuModule} from '@angular/material/menu';
|
|
20
|
+
import {MatNativeDateModule, MatRippleModule} from '@angular/material/core';
|
|
21
|
+
import {MatPaginatorModule} from '@angular/material/paginator';
|
|
22
|
+
import {MatProgressBarModule} from '@angular/material/progress-bar';
|
|
23
|
+
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';
|
|
24
|
+
import {MatRadioModule} from '@angular/material/radio';
|
|
25
|
+
import {MatSelectModule} from '@angular/material/select';
|
|
26
|
+
import {MatSidenavModule} from '@angular/material/sidenav';
|
|
27
|
+
import {MatSliderModule} from '@angular/material/slider';
|
|
28
|
+
import {MatSlideToggleModule} from '@angular/material/slide-toggle';
|
|
29
|
+
import {MatSnackBarModule} from '@angular/material/snack-bar';
|
|
30
|
+
import {MatSortModule} from '@angular/material/sort';
|
|
31
|
+
import {MatTableModule} from '@angular/material/table';
|
|
32
|
+
import {MatTabsModule} from '@angular/material/tabs';
|
|
33
|
+
import {MatToolbarModule} from '@angular/material/toolbar';
|
|
34
|
+
import {MatTooltipModule} from '@angular/material/tooltip';
|
|
35
|
+
import {MatTreeModule} from '@angular/material/tree';
|
|
36
|
+
|
|
37
|
+
@NgModule({
|
|
38
|
+
exports: [
|
|
39
|
+
MatAutocompleteModule,
|
|
40
|
+
MatBadgeModule,
|
|
41
|
+
MatBottomSheetModule,
|
|
42
|
+
MatButtonModule,
|
|
43
|
+
MatButtonToggleModule,
|
|
44
|
+
MatCardModule,
|
|
45
|
+
MatCheckboxModule,
|
|
46
|
+
MatChipsModule,
|
|
47
|
+
MatStepperModule,
|
|
48
|
+
MatDatepickerModule,
|
|
49
|
+
MatDialogModule,
|
|
50
|
+
MatDividerModule,
|
|
51
|
+
MatExpansionModule,
|
|
52
|
+
MatGridListModule,
|
|
53
|
+
MatIconModule,
|
|
54
|
+
MatInputModule,
|
|
55
|
+
MatListModule,
|
|
56
|
+
MatMenuModule,
|
|
57
|
+
MatNativeDateModule,
|
|
58
|
+
MatPaginatorModule,
|
|
59
|
+
MatProgressBarModule,
|
|
60
|
+
MatProgressSpinnerModule,
|
|
61
|
+
MatRadioModule,
|
|
62
|
+
MatRippleModule,
|
|
63
|
+
MatSelectModule,
|
|
64
|
+
MatSidenavModule,
|
|
65
|
+
MatSliderModule,
|
|
66
|
+
MatSlideToggleModule,
|
|
67
|
+
MatSnackBarModule,
|
|
68
|
+
MatSortModule,
|
|
69
|
+
MatTableModule,
|
|
70
|
+
MatTabsModule,
|
|
71
|
+
MatToolbarModule,
|
|
72
|
+
MatTooltipModule,
|
|
73
|
+
MatTreeModule
|
|
74
|
+
]
|
|
75
|
+
})
|
|
76
|
+
export class MaterialModule {}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export class TenantCreate {
|
|
2
|
+
public name: string = "";
|
|
3
|
+
public identifier: string = "";
|
|
4
|
+
public connectionString: string = "";
|
|
5
|
+
public adminUser: string = "";
|
|
6
|
+
public adminEmail: string = "";
|
|
7
|
+
public properties: any = {};
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class TenantCreated{
|
|
11
|
+
public id: string = "";
|
|
12
|
+
public identifier: string = "";
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TenantStatus } from "./tenant.status";
|
|
2
|
+
|
|
3
|
+
export interface TenantBasic {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
identifier: string;
|
|
7
|
+
status: TenantStatus;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface Tenant extends TenantBasic {
|
|
11
|
+
connectionString: string;
|
|
12
|
+
ownerUser: string;
|
|
13
|
+
ownerName: string;
|
|
14
|
+
serializedProperties: string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
|
|
2
|
+
export enum TenantStatus {
|
|
3
|
+
New, PendingApproval, Approved, Rejected, Initializing, Initialized, PendingToActive, Inactive, Active, Suspended, Abandoned
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export class TenantStatusHelper{
|
|
7
|
+
static getColor(status: TenantStatus){
|
|
8
|
+
var s = (typeof status == "string" ? TenantStatus[status] : status) as TenantStatus;
|
|
9
|
+
switch(s){
|
|
10
|
+
case TenantStatus.New:
|
|
11
|
+
return "accent-color";
|
|
12
|
+
case TenantStatus.Initialized:
|
|
13
|
+
return "success-color";
|
|
14
|
+
case TenantStatus.Approved:
|
|
15
|
+
return "success-color";
|
|
16
|
+
case TenantStatus.PendingApproval:
|
|
17
|
+
return "accent-color";
|
|
18
|
+
case TenantStatus.PendingToActive:
|
|
19
|
+
return "accent-color";
|
|
20
|
+
case TenantStatus.Active:
|
|
21
|
+
return "success-color";
|
|
22
|
+
case TenantStatus.Inactive:
|
|
23
|
+
return "warn-color";
|
|
24
|
+
case TenantStatus.Suspended:
|
|
25
|
+
return "warn-color";
|
|
26
|
+
case TenantStatus.Abandoned:
|
|
27
|
+
return "warn-color";
|
|
28
|
+
default:
|
|
29
|
+
return "";
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|