Merge remote-tracking branch 'origin/improvements/dashboard-export' into improvements/dashboard-export
This commit is contained in:
		
						commit
						85404b5b15
					
				@ -27,8 +27,8 @@
 | 
			
		||||
<mat-progress-bar color="warn" mode="indeterminate" *ngIf="(isLoading$ | async) && !ignoreLoading">
 | 
			
		||||
</mat-progress-bar>
 | 
			
		||||
<div mat-dialog-content>
 | 
			
		||||
  <fieldset [disabled]="(isLoading$ | async) && !ignoreLoading">
 | 
			
		||||
    <mat-checkbox [formControl]="includeResourcesFormControl">{{ prompt | translate }}</mat-checkbox>
 | 
			
		||||
  <fieldset [disabled]="(isLoading$ | async) && !ignoreLoading" class="tb-form-row no-border no-padding">
 | 
			
		||||
    <mat-slide-toggle [formControl]="includeResourcesFormControl" class="mat-slide">{{ prompt | translate }}</mat-slide-toggle>
 | 
			
		||||
  </fieldset>
 | 
			
		||||
</div>
 | 
			
		||||
<div mat-dialog-actions class="flex items-center justify-end">
 | 
			
		||||
 | 
			
		||||
@ -1,46 +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.
 | 
			
		||||
 | 
			
		||||
-->
 | 
			
		||||
<mat-toolbar color="primary">
 | 
			
		||||
  <h2 translate>widgets-bundle.export</h2>
 | 
			
		||||
  <span class="flex-1"></span>
 | 
			
		||||
  <button mat-icon-button
 | 
			
		||||
          (click)="cancel()"
 | 
			
		||||
          type="button">
 | 
			
		||||
    <mat-icon class="material-icons">close</mat-icon>
 | 
			
		||||
  </button>
 | 
			
		||||
</mat-toolbar>
 | 
			
		||||
<mat-progress-bar color="warn" mode="indeterminate" *ngIf="(isLoading$ | async) && !ignoreLoading">
 | 
			
		||||
</mat-progress-bar>
 | 
			
		||||
<div mat-dialog-content>
 | 
			
		||||
  <fieldset [disabled]="(isLoading$ | async) && !ignoreLoading">
 | 
			
		||||
    <mat-checkbox [formControl]="exportWidgetsFormControl">{{ 'widgets-bundle.export-widgets-bundle-widgets-prompt' | translate }}</mat-checkbox>
 | 
			
		||||
  </fieldset>
 | 
			
		||||
</div>
 | 
			
		||||
<div mat-dialog-actions class="flex items-center justify-end">
 | 
			
		||||
  <button mat-button color="primary"
 | 
			
		||||
          type="button"
 | 
			
		||||
          [disabled]="(isLoading$ | async) && !ignoreLoading"
 | 
			
		||||
          (click)="cancel()">
 | 
			
		||||
    {{ 'action.cancel' | translate }}
 | 
			
		||||
  </button>
 | 
			
		||||
  <button mat-raised-button color="primary"
 | 
			
		||||
          (click)="export()"
 | 
			
		||||
          [disabled]="(isLoading$ | async) && !ignoreLoading">
 | 
			
		||||
    {{ 'action.export' | translate }}
 | 
			
		||||
  </button>
 | 
			
		||||
</div>
 | 
			
		||||
@ -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<ExportWidgetsBundleDialogComponent, ExportWidgetsBundleDialogResult>
 | 
			
		||||
  implements OnInit {
 | 
			
		||||
 | 
			
		||||
  widgetsBundle: WidgetsBundle;
 | 
			
		||||
 | 
			
		||||
  ignoreLoading = false;
 | 
			
		||||
 | 
			
		||||
  exportWidgetsFormControl = new FormControl(true);
 | 
			
		||||
 | 
			
		||||
  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.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
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@ -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<Widget>, isSingleWidget: boolean,
 | 
			
		||||
                                          customTitle: string, missingEntityAliases: EntityAliases) => Observable<EntityAliases>;
 | 
			
		||||
 | 
			
		||||
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, ExportWidgetsBundleDialogData,
 | 
			
		||||
      ExportWidgetsBundleDialogResult>(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, ExportResourceDialogData, ExportResourceDialogDialogResult>(
 | 
			
		||||
      ExportResourceDialogComponent, {
 | 
			
		||||
        disableClose: true,
 | 
			
		||||
        panelClass: ['tb-dialog', 'tb-fullscreen-dialog'],
 | 
			
		||||
        data: { title, prompt, include: includeResources }
 | 
			
		||||
        data: { title, prompt, include: includeResources, ignoreLoading }
 | 
			
		||||
      }
 | 
			
		||||
    ).afterClosed();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -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,
 | 
			
		||||
 | 
			
		||||
@ -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",
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user