UI: added default widget name to widget export file name
This commit is contained in:
parent
bb027cb987
commit
8dc9b47bb9
@ -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,12 @@ 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) {
|
||||||
|
widget.title$.pipe(
|
||||||
|
take(1)
|
||||||
|
).subscribe((title) => {
|
||||||
|
widget.widget.config.exportTitle = title;
|
||||||
this.callbacks.onExportWidget($event, widget.widget);
|
this.callbacks.onExportWidget($event, widget.widget);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,7 @@ import {
|
|||||||
import { WidgetLayout, WidgetLayouts } from '@app/shared/models/dashboard.models';
|
import { WidgetLayout, WidgetLayouts } from '@app/shared/models/dashboard.models';
|
||||||
import { IDashboardWidget, WidgetAction, WidgetContext, WidgetHeaderAction } from './widget-component.models';
|
import { IDashboardWidget, WidgetAction, WidgetContext, WidgetHeaderAction } from './widget-component.models';
|
||||||
import { Timewindow } from '@shared/models/time/time.models';
|
import { Timewindow } from '@shared/models/time/time.models';
|
||||||
import { Observable, of, Subject, tap } from 'rxjs';
|
import { Observable, of, Subject } from 'rxjs';
|
||||||
import {
|
import {
|
||||||
convertKeysToCamelCase,
|
convertKeysToCamelCase,
|
||||||
formattedDataFormDatasourceData,
|
formattedDataFormDatasourceData,
|
||||||
@ -440,8 +440,7 @@ export class DashboardWidget implements GridsterItem, IDashboardWidget {
|
|||||||
|
|
||||||
const title = isDefined(this.widgetContext.widgetTitle)
|
const title = isDefined(this.widgetContext.widgetTitle)
|
||||||
&& this.widgetContext.widgetTitle.length ? this.widgetContext.widgetTitle : this.widget.config.title;
|
&& this.widgetContext.widgetTitle.length ? this.widgetContext.widgetTitle : this.widget.config.title;
|
||||||
this.title$ = this.widgetContext.registerLabelPattern(title, this.title$).pipe(
|
this.title$ = this.widgetContext.registerLabelPattern(title, this.title$);
|
||||||
tap(value => this.widget.config.titleByPattern = value));
|
|
||||||
this.titleTooltip = isDefined(this.widgetContext.widgetTitleTooltip)
|
this.titleTooltip = isDefined(this.widgetContext.widgetTitleTooltip)
|
||||||
&& this.widgetContext.widgetTitleTooltip.length ? this.widgetContext.widgetTitleTooltip : this.widget.config.titleTooltip;
|
&& this.widgetContext.widgetTitleTooltip.length ? this.widgetContext.widgetTitleTooltip : this.widget.config.titleTooltip;
|
||||||
this.titleTooltip = this.dashboard.utils.customTranslation(this.titleTooltip, this.titleTooltip);
|
this.titleTooltip = this.dashboard.utils.customTranslation(this.titleTooltip, this.titleTooltip);
|
||||||
|
|||||||
@ -200,9 +200,11 @@ export class ImportExportService {
|
|||||||
|
|
||||||
public exportWidget(dashboard: Dashboard, sourceState: string, sourceLayout: DashboardLayoutId, widget: Widget) {
|
public exportWidget(dashboard: Dashboard, sourceState: string, sourceLayout: DashboardLayoutId, widget: Widget) {
|
||||||
const widgetItem = this.itembuffer.prepareWidgetItem(dashboard, sourceState, sourceLayout, widget);
|
const widgetItem = this.itembuffer.prepareWidgetItem(dashboard, sourceState, sourceLayout, widget);
|
||||||
let name = widgetItem.widget.config.titleByPattern;
|
const widgetDefaultName = this.widgetService.getWidgetInfoFromCache(widget.typeFullFqn)?.widgetName ||
|
||||||
name = name.toLowerCase().replace(/\W/g, '_');
|
widget.typeFullFqn.split('.').pop();
|
||||||
this.exportToPc(this.prepareExport(widgetItem), name);
|
let fileName = widgetDefaultName + (isNotEmptyStr(widget.config.exportTitle) ? '_' + widget.config.exportTitle : '');
|
||||||
|
fileName = fileName.toLowerCase().replace(/\W/g, '_');
|
||||||
|
this.exportToPc(this.prepareExport(widgetItem), fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public importWidget(dashboard: Dashboard, targetState: string,
|
public importWidget(dashboard: Dashboard, targetState: string,
|
||||||
|
|||||||
@ -726,7 +726,6 @@ export enum WidgetConfigMode {
|
|||||||
export interface WidgetConfig {
|
export interface WidgetConfig {
|
||||||
configMode?: WidgetConfigMode;
|
configMode?: WidgetConfigMode;
|
||||||
title?: string;
|
title?: string;
|
||||||
titleByPattern?: string;
|
|
||||||
titleFont?: Font;
|
titleFont?: Font;
|
||||||
titleColor?: string;
|
titleColor?: string;
|
||||||
titleIcon?: string;
|
titleIcon?: string;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user