|
|
|
@ -16,7 +16,7 @@ import { |
|
|
|
|
TimeZone, |
|
|
|
|
UrlQueryValue, |
|
|
|
|
} from '@grafana/data'; |
|
|
|
|
import { RefreshEvent, TimeRangeUpdatedEvent } from '@grafana/runtime'; |
|
|
|
|
import { RefreshEvent, TimeRangeUpdatedEvent, config } from '@grafana/runtime'; |
|
|
|
|
import { Dashboard } from '@grafana/schema'; |
|
|
|
|
import { DEFAULT_ANNOTATION_COLOR } from '@grafana/ui'; |
|
|
|
|
import { GRID_CELL_HEIGHT, GRID_CELL_VMARGIN, GRID_COLUMN_COUNT, REPEAT_DIR_VERTICAL } from 'app/core/constants'; |
|
|
|
@ -41,7 +41,7 @@ import { getTimeSrv } from '../services/TimeSrv'; |
|
|
|
|
import { mergePanels, PanelMergeInfo } from '../utils/panelMerge'; |
|
|
|
|
|
|
|
|
|
import { DashboardMigrator } from './DashboardMigrator'; |
|
|
|
|
import { GridPos, PanelModel } from './PanelModel'; |
|
|
|
|
import { GridPos, PanelModel, autoMigrateAngular } from './PanelModel'; |
|
|
|
|
import { TimeModel } from './TimeModel'; |
|
|
|
|
import { deleteScopeVars, isOnTheSameGridRow } from './utils'; |
|
|
|
|
|
|
|
|
@ -108,6 +108,7 @@ export class DashboardModel implements TimeModel { |
|
|
|
|
// repeat process cycles
|
|
|
|
|
declare meta: DashboardMeta; |
|
|
|
|
events: EventBusExtended; |
|
|
|
|
private getVariablesFromState: GetVariables; |
|
|
|
|
|
|
|
|
|
static nonPersistedProperties: { [str: string]: boolean } = { |
|
|
|
|
events: true, |
|
|
|
@ -126,7 +127,18 @@ export class DashboardModel implements TimeModel { |
|
|
|
|
lastRefresh: true, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
constructor(data: Dashboard, meta?: DashboardMeta, private getVariablesFromState: GetVariables = getVariablesByKey) { |
|
|
|
|
constructor( |
|
|
|
|
data: Dashboard, |
|
|
|
|
meta?: DashboardMeta, |
|
|
|
|
options?: { |
|
|
|
|
// By default this uses variables from redux state
|
|
|
|
|
getVariablesFromState?: GetVariables; |
|
|
|
|
|
|
|
|
|
// Force the loader to migrate panels
|
|
|
|
|
autoMigrateOldPanels?: boolean; |
|
|
|
|
} |
|
|
|
|
) { |
|
|
|
|
this.getVariablesFromState = options?.getVariablesFromState ?? getVariablesByKey; |
|
|
|
|
this.events = new EventBusSrv(); |
|
|
|
|
this.id = data.id || null; |
|
|
|
|
// UID is not there for newly created dashboards
|
|
|
|
@ -162,6 +174,17 @@ export class DashboardModel implements TimeModel { |
|
|
|
|
this.initMeta(meta); |
|
|
|
|
this.updateSchema(data); |
|
|
|
|
|
|
|
|
|
// Auto-migrate old angular panels
|
|
|
|
|
if (options?.autoMigrateOldPanels || !config.angularSupportEnabled || config.featureToggles.autoMigrateOldPanels) { |
|
|
|
|
this.panels.forEach((p) => { |
|
|
|
|
const newType = autoMigrateAngular[p.type]; |
|
|
|
|
if (!p.autoMigrateFrom && newType) { |
|
|
|
|
p.autoMigrateFrom = p.type; |
|
|
|
|
p.type = newType; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.addBuiltInAnnotationQuery(); |
|
|
|
|
this.sortPanelsByGridPos(); |
|
|
|
|
this.panelsAffectedByVariableChange = null; |
|
|
|
|