|
|
@ -36,6 +36,7 @@ import { |
|
|
|
isStandardFieldProp, |
|
|
|
isStandardFieldProp, |
|
|
|
restoreCustomOverrideRules, |
|
|
|
restoreCustomOverrideRules, |
|
|
|
} from './getPanelOptionsWithDefaults'; |
|
|
|
} from './getPanelOptionsWithDefaults'; |
|
|
|
|
|
|
|
import { QueryGroupOptions } from 'app/types'; |
|
|
|
import { PanelModelLibraryPanel } from '../../library-panels/types'; |
|
|
|
import { PanelModelLibraryPanel } from '../../library-panels/types'; |
|
|
|
|
|
|
|
|
|
|
|
export interface GridPos { |
|
|
|
export interface GridPos { |
|
|
@ -57,6 +58,7 @@ const notPersistedProperties: { [str: string]: boolean } = { |
|
|
|
queryRunner: true, |
|
|
|
queryRunner: true, |
|
|
|
replaceVariables: true, |
|
|
|
replaceVariables: true, |
|
|
|
editSourceId: true, |
|
|
|
editSourceId: true, |
|
|
|
|
|
|
|
hasChanged: true, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// For angular panels we need to clean up properties when changing type
|
|
|
|
// For angular panels we need to clean up properties when changing type
|
|
|
@ -157,6 +159,7 @@ export class PanelModel implements DataConfigSource { |
|
|
|
isViewing: boolean; |
|
|
|
isViewing: boolean; |
|
|
|
isEditing: boolean; |
|
|
|
isEditing: boolean; |
|
|
|
isInView: boolean; |
|
|
|
isInView: boolean; |
|
|
|
|
|
|
|
hasChanged: boolean; |
|
|
|
|
|
|
|
|
|
|
|
hasRefreshed: boolean; |
|
|
|
hasRefreshed: boolean; |
|
|
|
events: EventBus; |
|
|
|
events: EventBus; |
|
|
@ -228,12 +231,14 @@ export class PanelModel implements DataConfigSource { |
|
|
|
|
|
|
|
|
|
|
|
updateOptions(options: object) { |
|
|
|
updateOptions(options: object) { |
|
|
|
this.options = options; |
|
|
|
this.options = options; |
|
|
|
|
|
|
|
this.hasChanged = true; |
|
|
|
this.events.publish(new PanelOptionsChangedEvent()); |
|
|
|
this.events.publish(new PanelOptionsChangedEvent()); |
|
|
|
this.render(); |
|
|
|
this.render(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
updateFieldConfig(config: FieldConfigSource) { |
|
|
|
updateFieldConfig(config: FieldConfigSource) { |
|
|
|
this.fieldConfig = config; |
|
|
|
this.fieldConfig = config; |
|
|
|
|
|
|
|
this.hasChanged = true; |
|
|
|
this.events.publish(new PanelOptionsChangedEvent()); |
|
|
|
this.events.publish(new PanelOptionsChangedEvent()); |
|
|
|
|
|
|
|
|
|
|
|
this.resendLastResult(); |
|
|
|
this.resendLastResult(); |
|
|
@ -392,6 +397,7 @@ export class PanelModel implements DataConfigSource { |
|
|
|
// switch
|
|
|
|
// switch
|
|
|
|
this.type = pluginId; |
|
|
|
this.type = pluginId; |
|
|
|
this.plugin = newPlugin; |
|
|
|
this.plugin = newPlugin; |
|
|
|
|
|
|
|
this.hasChanged = true; |
|
|
|
|
|
|
|
|
|
|
|
// For some reason I need to rebind replace variables here, otherwise the viz repeater does not work
|
|
|
|
// For some reason I need to rebind replace variables here, otherwise the viz repeater does not work
|
|
|
|
this.replaceVariables = this.replaceVariables.bind(this); |
|
|
|
this.replaceVariables = this.replaceVariables.bind(this); |
|
|
@ -402,20 +408,30 @@ export class PanelModel implements DataConfigSource { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
updateQueries(queries: DataQuery[]) { |
|
|
|
updateQueries(options: QueryGroupOptions) { |
|
|
|
|
|
|
|
this.datasource = options.dataSource.default ? null : options.dataSource.name!; |
|
|
|
|
|
|
|
this.timeFrom = options.timeRange?.from; |
|
|
|
|
|
|
|
this.timeShift = options.timeRange?.shift; |
|
|
|
|
|
|
|
this.hideTimeOverride = options.timeRange?.hide; |
|
|
|
|
|
|
|
this.interval = options.minInterval; |
|
|
|
|
|
|
|
this.maxDataPoints = options.maxDataPoints; |
|
|
|
|
|
|
|
this.targets = options.queries; |
|
|
|
|
|
|
|
this.hasChanged = true; |
|
|
|
|
|
|
|
|
|
|
|
this.events.publish(new PanelQueriesChangedEvent()); |
|
|
|
this.events.publish(new PanelQueriesChangedEvent()); |
|
|
|
this.targets = queries; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
addQuery(query?: Partial<DataQuery>) { |
|
|
|
addQuery(query?: Partial<DataQuery>) { |
|
|
|
query = query || { refId: 'A' }; |
|
|
|
query = query || { refId: 'A' }; |
|
|
|
query.refId = getNextRefIdChar(this.targets); |
|
|
|
query.refId = getNextRefIdChar(this.targets); |
|
|
|
this.targets.push(query as DataQuery); |
|
|
|
this.targets.push(query as DataQuery); |
|
|
|
|
|
|
|
this.hasChanged = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
changeQuery(query: DataQuery, index: number) { |
|
|
|
changeQuery(query: DataQuery, index: number) { |
|
|
|
// ensure refId is maintained
|
|
|
|
// ensure refId is maintained
|
|
|
|
query.refId = this.targets[index].refId; |
|
|
|
query.refId = this.targets[index].refId; |
|
|
|
|
|
|
|
this.hasChanged = true; |
|
|
|
|
|
|
|
|
|
|
|
// update query in array
|
|
|
|
// update query in array
|
|
|
|
this.targets = this.targets.map((item, itemIndex) => { |
|
|
|
this.targets = this.targets.map((item, itemIndex) => { |
|
|
@ -486,9 +502,15 @@ export class PanelModel implements DataConfigSource { |
|
|
|
setTransformations(transformations: DataTransformerConfig[]) { |
|
|
|
setTransformations(transformations: DataTransformerConfig[]) { |
|
|
|
this.transformations = transformations; |
|
|
|
this.transformations = transformations; |
|
|
|
this.resendLastResult(); |
|
|
|
this.resendLastResult(); |
|
|
|
|
|
|
|
this.hasChanged = true; |
|
|
|
this.events.publish(new PanelTransformationsChangedEvent()); |
|
|
|
this.events.publish(new PanelTransformationsChangedEvent()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setProperty(key: keyof this, value: any) { |
|
|
|
|
|
|
|
this[key] = value; |
|
|
|
|
|
|
|
this.hasChanged = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
replaceVariables(value: string, extraVars: ScopedVars | undefined, format?: string | Function) { |
|
|
|
replaceVariables(value: string, extraVars: ScopedVars | undefined, format?: string | Function) { |
|
|
|
let vars = this.scopedVars; |
|
|
|
let vars = this.scopedVars; |
|
|
|
|
|
|
|
|
|
|
|