Merge pull request #9579 from ArtemDzhereleiko/AD/imp/export-bundle/save-status
Save status include bundle widget in export
This commit is contained in:
commit
a2925f27c1
@ -25,6 +25,7 @@ import { WidgetsBundle } from '@shared/models/widgets-bundle.model';
|
|||||||
|
|
||||||
export interface ExportWidgetsBundleDialogData {
|
export interface ExportWidgetsBundleDialogData {
|
||||||
widgetsBundle: WidgetsBundle;
|
widgetsBundle: WidgetsBundle;
|
||||||
|
includeBundleWidgetsInExport: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ExportWidgetsBundleDialogResult {
|
export interface ExportWidgetsBundleDialogResult {
|
||||||
@ -50,6 +51,9 @@ export class ExportWidgetsBundleDialogComponent extends DialogComponent<ExportWi
|
|||||||
public dialogRef: MatDialogRef<ExportWidgetsBundleDialogComponent, ExportWidgetsBundleDialogResult>) {
|
public dialogRef: MatDialogRef<ExportWidgetsBundleDialogComponent, ExportWidgetsBundleDialogResult>) {
|
||||||
super(store, router, dialogRef);
|
super(store, router, dialogRef);
|
||||||
this.widgetsBundle = data.widgetsBundle;
|
this.widgetsBundle = data.widgetsBundle;
|
||||||
|
if (data.includeBundleWidgetsInExport) {
|
||||||
|
this.exportWidgetsFormControl.patchValue(data.includeBundleWidgetsInExport, {emitEvent: false});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
import { Inject, Injectable } from '@angular/core';
|
import { Inject, Injectable } from '@angular/core';
|
||||||
import { DashboardService } from '@core/http/dashboard.service';
|
import { DashboardService } from '@core/http/dashboard.service';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { Store } from '@ngrx/store';
|
import { select, Store } from '@ngrx/store';
|
||||||
import { AppState } from '@core/core.state';
|
import { AppState } from '@core/core.state';
|
||||||
import { ActionNotificationShow } from '@core/notification/notification.actions';
|
import { ActionNotificationShow } from '@core/notification/notification.actions';
|
||||||
import { Dashboard, DashboardLayoutId } from '@shared/models/dashboard.models';
|
import { Dashboard, DashboardLayoutId } from '@shared/models/dashboard.models';
|
||||||
@ -35,10 +35,10 @@ import {
|
|||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { ImportDialogComponent, ImportDialogData } from '@shared/import-export/import-dialog.component';
|
import { ImportDialogComponent, ImportDialogData } from '@shared/import-export/import-dialog.component';
|
||||||
import { forkJoin, Observable, of, Subject } from 'rxjs';
|
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 { DashboardUtilsService } from '@core/services/dashboard-utils.service';
|
||||||
import { EntityService } from '@core/http/entity.service';
|
import { EntityService } from '@core/http/entity.service';
|
||||||
import { Widget, WidgetSize, WidgetType, WidgetTypeDetails } from '@shared/models/widget.models';
|
import { Widget, WidgetSize, WidgetTypeDetails } from '@shared/models/widget.models';
|
||||||
import { ItemBufferService, WidgetItem } from '@core/services/item-buffer.service';
|
import { ItemBufferService, WidgetItem } from '@core/services/item-buffer.service';
|
||||||
import {
|
import {
|
||||||
BulkImportRequest,
|
BulkImportRequest,
|
||||||
@ -77,6 +77,8 @@ import {
|
|||||||
} from '@shared/import-export/export-widgets-bundle-dialog.component';
|
} from '@shared/import-export/export-widgets-bundle-dialog.component';
|
||||||
import { ImageService } from '@core/http/image.service';
|
import { ImageService } from '@core/http/image.service';
|
||||||
import { ImageExportData, ImageResourceInfo, ImageResourceType } from '@shared/models/resource.models';
|
import { ImageExportData, ImageResourceInfo, ImageResourceType } from '@shared/models/resource.models';
|
||||||
|
import { selectUserSettingsProperty } from '@core/auth/auth.selectors';
|
||||||
|
import { ActionPreferencesPutUserSettings } from '@core/auth/auth.actions';
|
||||||
|
|
||||||
export type editMissingAliasesFunction = (widgets: Array<Widget>, isSingleWidget: boolean,
|
export type editMissingAliasesFunction = (widgets: Array<Widget>, isSingleWidget: boolean,
|
||||||
customTitle: string, missingEntityAliases: EntityAliases) => Observable<EntityAliases>;
|
customTitle: string, missingEntityAliases: EntityAliases) => Observable<EntityAliases>;
|
||||||
@ -347,18 +349,27 @@ export class ImportExportService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public exportWidgetsBundle(widgetsBundleId: string) {
|
public exportWidgetsBundle(widgetsBundleId: string) {
|
||||||
this.widgetService.exportWidgetsBundle(widgetsBundleId).subscribe(
|
const tasks = {
|
||||||
(widgetsBundle) => {
|
includeBundleWidgetsInExport: this.store.pipe(select(selectUserSettingsProperty( 'includeBundleWidgetsInExport'))).pipe(take(1)),
|
||||||
|
widgetsBundle: this.widgetService.exportWidgetsBundle(widgetsBundleId)
|
||||||
|
};
|
||||||
|
|
||||||
|
forkJoin(tasks).subscribe({
|
||||||
|
next: ({includeBundleWidgetsInExport, widgetsBundle}) => {
|
||||||
this.dialog.open<ExportWidgetsBundleDialogComponent, ExportWidgetsBundleDialogData,
|
this.dialog.open<ExportWidgetsBundleDialogComponent, ExportWidgetsBundleDialogData,
|
||||||
ExportWidgetsBundleDialogResult>(ExportWidgetsBundleDialogComponent, {
|
ExportWidgetsBundleDialogResult>(ExportWidgetsBundleDialogComponent, {
|
||||||
disableClose: true,
|
disableClose: true,
|
||||||
panelClass: ['tb-dialog', 'tb-fullscreen-dialog'],
|
panelClass: ['tb-dialog', 'tb-fullscreen-dialog'],
|
||||||
data: {
|
data: {
|
||||||
widgetsBundle
|
widgetsBundle,
|
||||||
|
includeBundleWidgetsInExport
|
||||||
}
|
}
|
||||||
}).afterClosed().subscribe(
|
}).afterClosed().subscribe(
|
||||||
(result) => {
|
(result) => {
|
||||||
if (result) {
|
if (result) {
|
||||||
|
if (includeBundleWidgetsInExport !== result.exportWidgets) {
|
||||||
|
this.store.dispatch(new ActionPreferencesPutUserSettings({includeBundleWidgetsInExport: result.exportWidgets}));
|
||||||
|
}
|
||||||
if (result.exportWidgets) {
|
if (result.exportWidgets) {
|
||||||
this.exportWidgetsBundleWithWidgetTypes(widgetsBundle);
|
this.exportWidgetsBundleWithWidgetTypes(widgetsBundle);
|
||||||
} else {
|
} else {
|
||||||
@ -368,10 +379,10 @@ export class ImportExportService {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
(e) => {
|
error: (e) => {
|
||||||
this.handleExportError(e, 'widgets-bundle.export-failed-error');
|
this.handleExportError(e, 'widgets-bundle.export-failed-error');
|
||||||
}
|
}
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private exportWidgetsBundleWithWidgetTypes(widgetsBundle: WidgetsBundle) {
|
private exportWidgetsBundleWithWidgetTypes(widgetsBundle: WidgetsBundle) {
|
||||||
|
|||||||
@ -18,6 +18,7 @@ export interface UserSettings {
|
|||||||
openedMenuSections?: string[];
|
openedMenuSections?: string[];
|
||||||
notDisplayConnectivityAfterAddDevice?: boolean;
|
notDisplayConnectivityAfterAddDevice?: boolean;
|
||||||
notDisplayInstructionsAfterAddEdge?: boolean;
|
notDisplayInstructionsAfterAddEdge?: boolean;
|
||||||
|
includeBundleWidgetsInExport?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const initialUserSettings: UserSettings = {
|
export const initialUserSettings: UserSettings = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user