UI: widget export title refactoring
This commit is contained in:
parent
8dc9b47bb9
commit
0434a0b167
@ -1343,9 +1343,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();
|
||||
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) {
|
||||
|
||||
@ -49,7 +49,7 @@ export interface IDashboardController {
|
||||
openDashboardState(stateId: string, openRightLayout: boolean);
|
||||
addWidget($event: Event, layoutCtx: DashboardPageLayoutContext);
|
||||
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);
|
||||
widgetMouseDown($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);
|
||||
}
|
||||
|
||||
onExportWidget($event: Event, widget: Widget): void {
|
||||
this.layoutCtx.dashboardCtrl.exportWidget($event, this.layoutCtx, widget);
|
||||
onExportWidget($event: Event, widget: Widget, widgetExportTitle: string): void {
|
||||
this.layoutCtx.dashboardCtrl.exportWidget($event, this.layoutCtx, widget, widgetExportTitle);
|
||||
}
|
||||
|
||||
onRemoveWidget($event: Event, widget: Widget): void {
|
||||
|
||||
@ -438,9 +438,8 @@ export class DashboardComponent extends PageComponent implements IDashboardCompo
|
||||
if (this.isExportActionEnabled && this.callbacks && this.callbacks.onExportWidget) {
|
||||
widget.title$.pipe(
|
||||
take(1)
|
||||
).subscribe((title) => {
|
||||
widget.widget.config.exportTitle = title;
|
||||
this.callbacks.onExportWidget($event, widget.widget);
|
||||
).subscribe((widgetExportTitle) => {
|
||||
this.callbacks.onExportWidget($event, widget.widget, widgetExportTitle);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ export interface WidgetContextMenuItem extends ContextMenuItem {
|
||||
|
||||
export interface DashboardCallbacks {
|
||||
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;
|
||||
onWidgetMouseDown?: ($event: Event, widget: Widget) => void;
|
||||
onWidgetClicked?: ($event: Event, widget: Widget) => void;
|
||||
|
||||
@ -198,11 +198,10 @@ 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 widgetDefaultName = this.widgetService.getWidgetInfoFromCache(widget.typeFullFqn)?.widgetName ||
|
||||
widget.typeFullFqn.split('.').pop();
|
||||
let fileName = widgetDefaultName + (isNotEmptyStr(widget.config.exportTitle) ? '_' + widget.config.exportTitle : '');
|
||||
const widgetDefaultName = this.widgetService.getWidgetInfoFromCache(widget.typeFullFqn).widgetName;
|
||||
let fileName = widgetDefaultName + (isNotEmptyStr(widgetExportTitle) ? '_' + widgetExportTitle : '');
|
||||
fileName = fileName.toLowerCase().replace(/\W/g, '_');
|
||||
this.exportToPc(this.prepareExport(widgetItem), fileName);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user