Merge branch 'enhancement/pattern-support-widget-export' of github.com:rusikv/thingsboard into enhancement/pattern-support-widget-export
This commit is contained in:
commit
228c215e77
@ -1350,9 +1350,9 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
exportWidget($event: Event, layoutCtx: DashboardPageLayoutContext, widget: Widget) {
|
exportWidget($event: Event, layoutCtx: DashboardPageLayoutContext, widget: Widget, widgetExportTitle) {
|
||||||
$event.stopPropagation();
|
$event.stopPropagation();
|
||||||
this.importExport.exportWidget(this.dashboard, this.dashboardCtx.state, layoutCtx.id, widget);
|
this.importExport.exportWidget(this.dashboard, this.dashboardCtx.state, layoutCtx.id, widget, widgetExportTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
widgetClicked($event: Event, layoutCtx: DashboardPageLayoutContext, widget: Widget) {
|
widgetClicked($event: Event, layoutCtx: DashboardPageLayoutContext, widget: Widget) {
|
||||||
|
|||||||
@ -49,7 +49,7 @@ export interface IDashboardController {
|
|||||||
openDashboardState(stateId: string, openRightLayout: boolean);
|
openDashboardState(stateId: string, openRightLayout: boolean);
|
||||||
addWidget($event: Event, layoutCtx: DashboardPageLayoutContext);
|
addWidget($event: Event, layoutCtx: DashboardPageLayoutContext);
|
||||||
editWidget($event: Event, layoutCtx: DashboardPageLayoutContext, widget: Widget);
|
editWidget($event: Event, layoutCtx: DashboardPageLayoutContext, widget: Widget);
|
||||||
exportWidget($event: Event, layoutCtx: DashboardPageLayoutContext, widget: Widget);
|
exportWidget($event: Event, layoutCtx: DashboardPageLayoutContext, widget: Widget, widgetExportTitle: string);
|
||||||
removeWidget($event: Event, layoutCtx: DashboardPageLayoutContext, widget: Widget);
|
removeWidget($event: Event, layoutCtx: DashboardPageLayoutContext, widget: Widget);
|
||||||
widgetMouseDown($event: Event, layoutCtx: DashboardPageLayoutContext, widget: Widget);
|
widgetMouseDown($event: Event, layoutCtx: DashboardPageLayoutContext, widget: Widget);
|
||||||
widgetClicked($event: Event, layoutCtx: DashboardPageLayoutContext, widget: Widget);
|
widgetClicked($event: Event, layoutCtx: DashboardPageLayoutContext, widget: Widget);
|
||||||
|
|||||||
@ -226,8 +226,8 @@ export class DashboardLayoutComponent extends PageComponent implements ILayoutCo
|
|||||||
this.layoutCtx.dashboardCtrl.editWidget($event, this.layoutCtx, widget);
|
this.layoutCtx.dashboardCtrl.editWidget($event, this.layoutCtx, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
onExportWidget($event: Event, widget: Widget): void {
|
onExportWidget($event: Event, widget: Widget, widgetExportTitle: string): void {
|
||||||
this.layoutCtx.dashboardCtrl.exportWidget($event, this.layoutCtx, widget);
|
this.layoutCtx.dashboardCtrl.exportWidget($event, this.layoutCtx, widget, widgetExportTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
onRemoveWidget($event: Event, widget: Widget): void {
|
onRemoveWidget($event: Event, widget: Widget): void {
|
||||||
|
|||||||
@ -54,7 +54,7 @@ import { IAliasController, IStateController } from '@app/core/api/widget-api.mod
|
|||||||
import { Widget, WidgetPosition } from '@app/shared/models/widget.models';
|
import { Widget, WidgetPosition } from '@app/shared/models/widget.models';
|
||||||
import { MatMenuTrigger } from '@angular/material/menu';
|
import { MatMenuTrigger } from '@angular/material/menu';
|
||||||
import { SafeStyle } from '@angular/platform-browser';
|
import { SafeStyle } from '@angular/platform-browser';
|
||||||
import { distinct } from 'rxjs/operators';
|
import { distinct, take } from 'rxjs/operators';
|
||||||
import { ResizeObserver } from '@juggle/resize-observer';
|
import { ResizeObserver } from '@juggle/resize-observer';
|
||||||
import { UtilsService } from '@core/services/utils.service';
|
import { UtilsService } from '@core/services/utils.service';
|
||||||
import { WidgetComponentAction, WidgetComponentActionType } from '@home/components/widget/widget-container.component';
|
import { WidgetComponentAction, WidgetComponentActionType } from '@home/components/widget/widget-container.component';
|
||||||
@ -436,7 +436,11 @@ export class DashboardComponent extends PageComponent implements IDashboardCompo
|
|||||||
$event.stopPropagation();
|
$event.stopPropagation();
|
||||||
}
|
}
|
||||||
if (this.isExportActionEnabled && this.callbacks && this.callbacks.onExportWidget) {
|
if (this.isExportActionEnabled && this.callbacks && this.callbacks.onExportWidget) {
|
||||||
this.callbacks.onExportWidget($event, widget.widget);
|
widget.title$.pipe(
|
||||||
|
take(1)
|
||||||
|
).subscribe((widgetExportTitle) => {
|
||||||
|
this.callbacks.onExportWidget($event, widget.widget, widgetExportTitle);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -65,7 +65,7 @@ export interface WidgetContextMenuItem extends ContextMenuItem {
|
|||||||
|
|
||||||
export interface DashboardCallbacks {
|
export interface DashboardCallbacks {
|
||||||
onEditWidget?: ($event: Event, widget: Widget) => void;
|
onEditWidget?: ($event: Event, widget: Widget) => void;
|
||||||
onExportWidget?: ($event: Event, widget: Widget) => void;
|
onExportWidget?: ($event: Event, widget: Widget, widgetExportTitle: string) => void;
|
||||||
onRemoveWidget?: ($event: Event, widget: Widget) => void;
|
onRemoveWidget?: ($event: Event, widget: Widget) => void;
|
||||||
onWidgetMouseDown?: ($event: Event, widget: Widget) => void;
|
onWidgetMouseDown?: ($event: Event, widget: Widget) => void;
|
||||||
onWidgetClicked?: ($event: Event, widget: Widget) => void;
|
onWidgetClicked?: ($event: Event, widget: Widget) => void;
|
||||||
|
|||||||
@ -198,11 +198,12 @@ export class ImportExportService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public exportWidget(dashboard: Dashboard, sourceState: string, sourceLayout: DashboardLayoutId, widget: Widget) {
|
public exportWidget(dashboard: Dashboard, sourceState: string, sourceLayout: DashboardLayoutId, widget: Widget, widgetExportTitle: string) {
|
||||||
const widgetItem = this.itembuffer.prepareWidgetItem(dashboard, sourceState, sourceLayout, widget);
|
const widgetItem = this.itembuffer.prepareWidgetItem(dashboard, sourceState, sourceLayout, widget);
|
||||||
let name = widgetItem.widget.config.title;
|
const widgetDefaultName = this.widgetService.getWidgetInfoFromCache(widget.typeFullFqn).widgetName;
|
||||||
name = name.toLowerCase().replace(/\W/g, '_');
|
let fileName = widgetDefaultName + (isNotEmptyStr(widgetExportTitle) ? '_' + widgetExportTitle : '');
|
||||||
this.exportToPc(this.prepareExport(widgetItem), name);
|
fileName = fileName.toLowerCase().replace(/\W/g, '_');
|
||||||
|
this.exportToPc(this.prepareExport(widgetItem), fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public importWidget(dashboard: Dashboard, targetState: string,
|
public importWidget(dashboard: Dashboard, targetState: string,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user