@juice-js/tenants 1.0.2 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juice-js/tenants",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Juice tenants admin module",
5
5
  "author": "jack@creatorflow.io",
6
6
  "license": "MIT",
@@ -98,4 +98,12 @@ export class TenantAdminService {
98
98
  public updateTenantSettings(id: string, settings: TenantSetting[]) {
99
99
  return this.http.put(`${this.options.apiEndpoint}/api/v${this.options.apiVersion}/admin/${id}/settings`, settings);
100
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
+ }
101
109
  }
@@ -22,6 +22,9 @@
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>
@@ -411,6 +411,7 @@ export class TenantsComponent implements AfterViewInit{
411
411
  });
412
412
 
413
413
  let instance = dialogRef.componentInstance;
414
+ instance.title = "Tenant settings";
414
415
  instance.loading = true;
415
416
  instance.type = ModelType.Configuration;
416
417
 
@@ -428,7 +429,7 @@ export class TenantsComponent implements AfterViewInit{
428
429
  var settings = instance.models.map(m => new TenantSetting(m.key, m.value, m.inherited));
429
430
  this.tenantService.updateTenantSettings(id, settings).subscribe({
430
431
  next: () => {
431
- this.openSnackBar("Tenant's settings was updated!");
432
+ this.openSnackBar("Tenant settings was updated!");
432
433
  dialogRef.close();
433
434
  }, error: (error: any) => {
434
435
  this.openSnackBar("Error updating tenant settings!");
@@ -441,6 +442,45 @@ export class TenantsComponent implements AfterViewInit{
441
442
  dialogRef.close();
442
443
  });
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);
464
+ }
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
+ });
483
+ }
444
484
  //#endregion
445
485
 
446
486
  //#region status rules