Browse Source

UI: Save status include bundle

pull/9579/head
Artem Dzhereleiko 3 years ago
parent
commit
3307e89d97
  1. 11
      ui-ngx/src/app/modules/home/components/import-export/export-widgets-bundle-dialog.component.ts
  2. 17
      ui-ngx/src/app/modules/home/components/import-export/import-export.service.ts
  3. 1
      ui-ngx/src/app/shared/models/user-settings.models.ts

11
ui-ngx/src/app/modules/home/components/import-export/export-widgets-bundle-dialog.component.ts

@ -22,9 +22,11 @@ import { FormControl } from '@angular/forms';
import { Router } from '@angular/router';
import { DialogComponent } from '@app/shared/components/dialog.component';
import { WidgetsBundle } from '@shared/models/widgets-bundle.model';
import { ActionPreferencesPutUserSettings } from '@core/auth/auth.actions';
export interface ExportWidgetsBundleDialogData {
widgetsBundle: WidgetsBundle;
includeBundleWidgetsInExport: boolean;
}
export interface ExportWidgetsBundleDialogResult {
@ -44,12 +46,18 @@ export class ExportWidgetsBundleDialogComponent extends DialogComponent<ExportWi
exportWidgetsFormControl = new FormControl(false);
includeBundleWidgetsInExport: boolean;
constructor(protected store: Store<AppState>,
protected router: Router,
@Inject(MAT_DIALOG_DATA) public data: ExportWidgetsBundleDialogData,
public dialogRef: MatDialogRef<ExportWidgetsBundleDialogComponent, ExportWidgetsBundleDialogResult>) {
super(store, router, dialogRef);
this.widgetsBundle = data.widgetsBundle;
this.includeBundleWidgetsInExport = data.includeBundleWidgetsInExport;
if (this.includeBundleWidgetsInExport) {
this.exportWidgetsFormControl.patchValue(this.includeBundleWidgetsInExport, {emitEvent: false});
}
}
ngOnInit(): void {
@ -60,6 +68,9 @@ export class ExportWidgetsBundleDialogComponent extends DialogComponent<ExportWi
}
export(): void {
if (this.includeBundleWidgetsInExport !== this.exportWidgetsFormControl.value) {
this.store.dispatch(new ActionPreferencesPutUserSettings({includeBundleWidgetsInExport: this.exportWidgetsFormControl.value}));
}
this.dialogRef.close({
exportWidgets: this.exportWidgetsFormControl.value
});

17
ui-ngx/src/app/modules/home/components/import-export/import-export.service.ts

@ -17,7 +17,7 @@
import { Inject, Injectable } from '@angular/core';
import { DashboardService } from '@core/http/dashboard.service';
import { TranslateService } from '@ngx-translate/core';
import { Store } from '@ngrx/store';
import { select, Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
import { ActionNotificationShow } from '@core/notification/notification.actions';
import { Dashboard, DashboardLayoutId } from '@shared/models/dashboard.models';
@ -35,7 +35,7 @@ import {
import { MatDialog } from '@angular/material/dialog';
import { ImportDialogComponent, ImportDialogData } from '@home/components/import-export/import-dialog.component';
import { forkJoin, Observable, of, Subject } from 'rxjs';
import { catchError, map, mergeMap, switchMap, tap } from 'rxjs/operators';
import { catchError, map, mergeMap, switchMap, take, tap } from 'rxjs/operators';
import { DashboardUtilsService } from '@core/services/dashboard-utils.service';
import { EntityService } from '@core/http/entity.service';
import { Widget, WidgetSize, WidgetType, WidgetTypeDetails } from '@shared/models/widget.models';
@ -79,6 +79,7 @@ import {
ExportWidgetsBundleDialogData,
ExportWidgetsBundleDialogResult
} from '@home/components/import-export/export-widgets-bundle-dialog.component';
import { selectUserSettingsProperty } from '@core/auth/auth.selectors';
// @dynamic
@Injectable()
@ -314,6 +315,15 @@ export class ImportExportService {
}
public exportWidgetsBundle(widgetsBundleId: string) {
let includeBundleWidgetsInExport = false;
this.store.pipe(select(selectUserSettingsProperty( 'includeBundleWidgetsInExport'))).pipe(
take(1)
).subscribe((settings: boolean) => {
if(settings) {
includeBundleWidgetsInExport = settings;
}
});
this.widgetService.getWidgetsBundle(widgetsBundleId).subscribe(
(widgetsBundle) => {
this.dialog.open<ExportWidgetsBundleDialogComponent, ExportWidgetsBundleDialogData,
@ -321,7 +331,8 @@ export class ImportExportService {
disableClose: true,
panelClass: ['tb-dialog', 'tb-fullscreen-dialog'],
data: {
widgetsBundle
widgetsBundle,
includeBundleWidgetsInExport
}
}).afterClosed().subscribe(
(result) => {

1
ui-ngx/src/app/shared/models/user-settings.models.ts

@ -18,6 +18,7 @@ export interface UserSettings {
openedMenuSections?: string[];
notDisplayConnectivityAfterAddDevice?: boolean;
notDisplayInstructionsAfterAddEdge?: boolean;
includeBundleWidgetsInExport?: boolean;
}
export const initialUserSettings: UserSettings = {

Loading…
Cancel
Save