diff --git a/ui-ngx/src/app/shared/import-export/export-resource-dialog.component.html b/ui-ngx/src/app/shared/import-export/export-resource-dialog.component.html index e7dccbaea9..33102dd8f5 100644 --- a/ui-ngx/src/app/shared/import-export/export-resource-dialog.component.html +++ b/ui-ngx/src/app/shared/import-export/export-resource-dialog.component.html @@ -27,8 +27,8 @@
-
- {{ prompt | translate }} +
+ {{ prompt | translate }}
diff --git a/ui-ngx/src/app/shared/import-export/export-widgets-bundle-dialog.component.html b/ui-ngx/src/app/shared/import-export/export-widgets-bundle-dialog.component.html deleted file mode 100644 index 7f7a273420..0000000000 --- a/ui-ngx/src/app/shared/import-export/export-widgets-bundle-dialog.component.html +++ /dev/null @@ -1,46 +0,0 @@ - - -

widgets-bundle.export

- - -
- - -
-
- {{ 'widgets-bundle.export-widgets-bundle-widgets-prompt' | translate }} -
-
-
- - -
diff --git a/ui-ngx/src/app/shared/import-export/export-widgets-bundle-dialog.component.ts b/ui-ngx/src/app/shared/import-export/export-widgets-bundle-dialog.component.ts deleted file mode 100644 index f012dc77fe..0000000000 --- a/ui-ngx/src/app/shared/import-export/export-widgets-bundle-dialog.component.ts +++ /dev/null @@ -1,76 +0,0 @@ -/// -/// Copyright © 2016-2024 The Thingsboard Authors -/// -/// Licensed under the Apache License, Version 2.0 (the "License"); -/// you may not use this file except in compliance with the License. -/// You may obtain a copy of the License at -/// -/// http://www.apache.org/licenses/LICENSE-2.0 -/// -/// Unless required by applicable law or agreed to in writing, software -/// distributed under the License is distributed on an "AS IS" BASIS, -/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -/// See the License for the specific language governing permissions and -/// limitations under the License. -/// - -import { Component, Inject, OnInit } from '@angular/core'; -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { Store } from '@ngrx/store'; -import { AppState } from '@core/core.state'; -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 { isDefinedAndNotNull } from '@core/utils'; - -export interface ExportWidgetsBundleDialogData { - widgetsBundle: WidgetsBundle; - includeBundleWidgetsInExport: boolean; - ignoreLoading?: boolean; -} - -export interface ExportWidgetsBundleDialogResult { - exportWidgets: boolean; -} - -@Component({ - selector: 'tb-export-widgets-bundle-dialog', - templateUrl: './export-widgets-bundle-dialog.component.html', - providers: [], - styleUrls: [] -}) -export class ExportWidgetsBundleDialogComponent extends DialogComponent - implements OnInit { - - widgetsBundle: WidgetsBundle; - - ignoreLoading = false; - - exportWidgetsFormControl = new FormControl(true); - - constructor(protected store: Store, - protected router: Router, - @Inject(MAT_DIALOG_DATA) public data: ExportWidgetsBundleDialogData, - public dialogRef: MatDialogRef) { - super(store, router, dialogRef); - this.widgetsBundle = data.widgetsBundle; - this.ignoreLoading = data.ignoreLoading; - if (isDefinedAndNotNull(data.includeBundleWidgetsInExport)) { - this.exportWidgetsFormControl.patchValue(data.includeBundleWidgetsInExport, {emitEvent: false}); - } - } - - ngOnInit(): void { - } - - cancel(): void { - this.dialogRef.close(null); - } - - export(): void { - this.dialogRef.close({ - exportWidgets: this.exportWidgetsFormControl.value - }); - } -} diff --git a/ui-ngx/src/app/shared/import-export/import-export.service.ts b/ui-ngx/src/app/shared/import-export/import-export.service.ts index d61428b438..5ad59fc10f 100644 --- a/ui-ngx/src/app/shared/import-export/import-export.service.ts +++ b/ui-ngx/src/app/shared/import-export/import-export.service.ts @@ -75,11 +75,6 @@ import { EdgeService } from '@core/http/edge.service'; import { RuleNode } from '@shared/models/rule-node.models'; import { AssetProfileService } from '@core/http/asset-profile.service'; import { AssetProfile } from '@shared/models/asset.models'; -import { - ExportWidgetsBundleDialogComponent, - ExportWidgetsBundleDialogData, - ExportWidgetsBundleDialogResult -} from '@shared/import-export/export-widgets-bundle-dialog.component'; import { ImageService } from '@core/http/image.service'; import { ImageExportData, ImageResourceInfo, ImageResourceType } from '@shared/models/resource.models'; import { selectUserSettingsProperty } from '@core/auth/auth.selectors'; @@ -96,7 +91,7 @@ import { export type editMissingAliasesFunction = (widgets: Array, isSingleWidget: boolean, customTitle: string, missingEntityAliases: EntityAliases) => Observable; -type SupportEntityResources = 'includeResourcesInExportWidgetTypes' | 'includeResourcesInExportDashboard'; +type SupportEntityResources = 'includeResourcesInExportWidgetTypes' | 'includeResourcesInExportDashboard' | 'includeBundleWidgetsInExport'; // @dynamic @Injectable() @@ -448,22 +443,11 @@ export class ImportExportService { } private handleExportWidgetsBundle(widgetsBundle: WidgetsBundle, includeBundleWidgetsInExport: boolean, ignoreLoading?: boolean): void { - this.dialog.open(ExportWidgetsBundleDialogComponent, { - disableClose: true, - panelClass: ['tb-dialog', 'tb-fullscreen-dialog'], - data: { - widgetsBundle, - includeBundleWidgetsInExport, - ignoreLoading - } - }).afterClosed().subscribe( - (result) => { + this.openExportDialog('widgets-bundle.export', 'widgets-bundle.export-widgets-bundle-widgets-prompt', + includeBundleWidgetsInExport, ignoreLoading).subscribe((result) => { if (result) { - if (includeBundleWidgetsInExport !== result.exportWidgets) { - this.store.dispatch(new ActionPreferencesPutUserSettings({includeBundleWidgetsInExport: result.exportWidgets})); - } - if (result.exportWidgets) { + this.updateUserSettingsIncludeResourcesIfNeeded(includeBundleWidgetsInExport, result.include, 'includeBundleWidgetsInExport'); + if (result.include) { this.exportWidgetsBundleWithWidgetTypes(widgetsBundle); } else { this.exportWidgetsBundleWithWidgetTypeFqns(widgetsBundle); @@ -1226,12 +1210,12 @@ export class ImportExportService { ); } - private openExportDialog(title: string, prompt: string, includeResources: boolean) { + private openExportDialog(title: string, prompt: string, includeResources: boolean, ignoreLoading?: boolean) { return this.dialog.open( ExportResourceDialogComponent, { disableClose: true, panelClass: ['tb-dialog', 'tb-fullscreen-dialog'], - data: { title, prompt, include: includeResources } + data: { title, prompt, include: includeResources, ignoreLoading } } ).afterClosed(); } diff --git a/ui-ngx/src/app/shared/shared.module.ts b/ui-ngx/src/app/shared/shared.module.ts index 010d449911..02b5817800 100644 --- a/ui-ngx/src/app/shared/shared.module.ts +++ b/ui-ngx/src/app/shared/shared.module.ts @@ -194,7 +194,6 @@ import { ImagePipe } from '@shared/pipe/image.pipe'; import { ImportExportService } from '@shared/import-export/import-export.service'; import { ImportDialogComponent } from '@shared/import-export/import-dialog.component'; import { ImportDialogCsvComponent } from '@shared/import-export/import-dialog-csv.component'; -import { ExportWidgetsBundleDialogComponent } from '@shared/import-export/export-widgets-bundle-dialog.component'; import { ExportResourceDialogComponent } from '@shared/import-export/export-resource-dialog.component'; import { TableColumnsAssignmentComponent } from '@shared/import-export/table-columns-assignment.component'; import { ScrollGridComponent } from '@shared/components/grid/scroll-grid.component'; @@ -407,7 +406,6 @@ export function MarkedOptionsFactory(markedOptionsService: MarkedOptionsService) HintTooltipIconComponent, ImportDialogComponent, ImportDialogCsvComponent, - ExportWidgetsBundleDialogComponent, ExportResourceDialogComponent, TableColumnsAssignmentComponent, ScrollGridComponent, @@ -665,7 +663,6 @@ export function MarkedOptionsFactory(markedOptionsService: MarkedOptionsService) HintTooltipIconComponent, ImportDialogComponent, ImportDialogCsvComponent, - ExportWidgetsBundleDialogComponent, ExportResourceDialogComponent, TableColumnsAssignmentComponent, ScrollGridComponent, diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index 537da3e3a0..0296dafe76 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -1253,7 +1253,7 @@ "import": "Import dashboard", "export": "Export dashboard", "export-failed-error": "Unable to export dashboard: {{error}}", - "export-prompt": "Embed dashboard images and resources in exported data", + "export-prompt": "Embed dashboard images and resources", "create-new-dashboard": "Create new dashboard", "dashboard-file": "Dashboard file", "invalid-dashboard-file-error": "Unable to import dashboard: Invalid dashboard data structure.", @@ -5376,9 +5376,9 @@ "selected-widgets": "{ count, plural, =1 {1 widget} other {# widgets} } selected", "undo": "Undo widget changes", "export": "Export widget", - "export-prompt": "Embed widget images and resources in exported data", + "export-prompt": "Embed widget images and resources", "export-widgets": "Export widgets", - "export-widgets-prompt": "Embed widgets images and resources in exported data", + "export-widgets-prompt": "Embed widgets images and resources", "import": "Import widget", "no-data": "No data to display on widget", "data-overflow": "Widget displays {{count}} out of {{total}} entities",