PanelTimeCompare: Support saving time compare window (#113150)
* PanelTimeCompare: Support saving time compare window * fix indentation * Fix merge issue * Update * Update * make gen-cue --------- Co-authored-by: oscarkilhed <oscar.kilhed@grafana.com>
This commit is contained in:
co-authored by
oscarkilhed
parent
3cabc12f4c
commit
344fc5606f
@@ -452,6 +452,7 @@ QueryOptionsSpec: {
|
||||
interval?: string
|
||||
cacheTimeout?: string
|
||||
hideTimeOverride?: bool
|
||||
timeCompare?: string
|
||||
}
|
||||
|
||||
DataQueryKind: {
|
||||
|
||||
@@ -670,6 +670,10 @@ lineage: schemas: [{
|
||||
// Controls if the timeFrom or timeShift overrides are shown in the panel header
|
||||
hideTimeOverride?: bool
|
||||
|
||||
// Compare the current time range with a previous period
|
||||
// For example "1d" to compare current period but shifted back 1 day
|
||||
timeCompare?: string
|
||||
|
||||
// Dynamically load the panel
|
||||
libraryPanel?: #LibraryPanelRef
|
||||
|
||||
|
||||
@@ -670,6 +670,10 @@ lineage: schemas: [{
|
||||
// Controls if the timeFrom or timeShift overrides are shown in the panel header
|
||||
hideTimeOverride?: bool
|
||||
|
||||
// Compare the current time range with a previous period
|
||||
// For example "1d" to compare current period but shifted back 1 day
|
||||
timeCompare?: string
|
||||
|
||||
// Dynamically load the panel
|
||||
libraryPanel?: #LibraryPanelRef
|
||||
|
||||
|
||||
@@ -456,6 +456,7 @@ QueryOptionsSpec: {
|
||||
interval?: string
|
||||
cacheTimeout?: string
|
||||
hideTimeOverride?: bool
|
||||
timeCompare?: string
|
||||
}
|
||||
|
||||
DataQueryKind: {
|
||||
|
||||
@@ -278,6 +278,7 @@ type DashboardQueryOptionsSpec struct {
|
||||
Interval *string `json:"interval,omitempty"`
|
||||
CacheTimeout *string `json:"cacheTimeout,omitempty"`
|
||||
HideTimeOverride *bool `json:"hideTimeOverride,omitempty"`
|
||||
TimeCompare *string `json:"timeCompare,omitempty"`
|
||||
}
|
||||
|
||||
// NewDashboardQueryOptionsSpec creates a new DashboardQueryOptionsSpec object.
|
||||
|
||||
@@ -3426,6 +3426,12 @@ func schema_pkg_apis_dashboard_v2beta1_DashboardQueryOptionsSpec(ref common.Refe
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"timeCompare": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -666,6 +666,10 @@ lineage: schemas: [{
|
||||
// Controls if the timeFrom or timeShift overrides are shown in the panel header
|
||||
hideTimeOverride?: bool
|
||||
|
||||
// Compare the current time range with a previous period
|
||||
// For example "1d" to compare current period but shifted back 1 day
|
||||
timeCompare?: string
|
||||
|
||||
// Dynamically load the panel
|
||||
libraryPanel?: #LibraryPanelRef
|
||||
|
||||
|
||||
@@ -885,6 +885,11 @@ export interface Panel {
|
||||
* Depends on the panel plugin. See the plugin documentation for details.
|
||||
*/
|
||||
targets?: Array<Record<string, unknown>>;
|
||||
/**
|
||||
* Compare the current time range with a previous period
|
||||
* For example "1d" to compare current period but shifted back 1 day
|
||||
*/
|
||||
timeCompare?: string;
|
||||
/**
|
||||
* Overrides the relative time range for individual panels,
|
||||
* which causes them to be different than what is selected in
|
||||
|
||||
@@ -409,6 +409,7 @@ QueryOptionsSpec: {
|
||||
interval?: string
|
||||
cacheTimeout?: string
|
||||
hideTimeOverride?: bool
|
||||
timeCompare?: string
|
||||
}
|
||||
|
||||
DataQueryKind: {
|
||||
|
||||
@@ -219,6 +219,7 @@ export interface QueryOptionsSpec {
|
||||
interval?: string;
|
||||
cacheTimeout?: string;
|
||||
hideTimeOverride?: boolean;
|
||||
timeCompare?: string;
|
||||
}
|
||||
|
||||
export const defaultQueryOptionsSpec = (): QueryOptionsSpec => ({
|
||||
|
||||
@@ -191,6 +191,9 @@ type Panel struct {
|
||||
TimeShift *string `json:"timeShift,omitempty"`
|
||||
// Controls if the timeFrom or timeShift overrides are shown in the panel header
|
||||
HideTimeOverride *bool `json:"hideTimeOverride,omitempty"`
|
||||
// Compare the current time range with a previous period
|
||||
// For example "1d" to compare current period but shifted back 1 day
|
||||
TimeCompare *string `json:"timeCompare,omitempty"`
|
||||
// Dynamically load the panel
|
||||
LibraryPanel *LibraryPanelRef `json:"libraryPanel,omitempty"`
|
||||
// Sets panel queries cache timeout.
|
||||
|
||||
@@ -456,11 +456,12 @@ export function buildGridItemForPanel(panel: PanelModel): DashboardGridItem {
|
||||
});
|
||||
}
|
||||
|
||||
if (panel.timeFrom || panel.timeShift) {
|
||||
if (panel.timeFrom || panel.timeShift || panel.timeCompare) {
|
||||
vizPanelState.$timeRange = new PanelTimeRange({
|
||||
timeFrom: panel.timeFrom,
|
||||
timeShift: panel.timeShift,
|
||||
hideTimeOverride: panel.hideTimeOverride,
|
||||
compareWith: panel.timeCompare,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -232,6 +232,7 @@ export function vizPanelToPanel(
|
||||
panel.timeFrom = panelTime.state.timeFrom;
|
||||
panel.timeShift = panelTime.state.timeShift;
|
||||
panel.hideTimeOverride = panelTime.state.hideTimeOverride;
|
||||
panel.timeCompare = panelTime.state.compareWith;
|
||||
}
|
||||
|
||||
if (gridItem instanceof DashboardGridItem) {
|
||||
|
||||
@@ -387,6 +387,7 @@ function getVizPanelQueryOptions(vizPanel: VizPanel): QueryOptionsSpec {
|
||||
queryOptions.timeFrom = panelTime.state.timeFrom;
|
||||
queryOptions.timeShift = panelTime.state.timeShift;
|
||||
queryOptions.hideTimeOverride = panelTime.state.hideTimeOverride;
|
||||
queryOptions.timeCompare = panelTime.state.compareWith;
|
||||
}
|
||||
return queryOptions;
|
||||
}
|
||||
|
||||
@@ -170,6 +170,7 @@ export class PanelModel implements DataConfigSource, IPanelModel {
|
||||
timeFrom?: any;
|
||||
timeShift?: any;
|
||||
hideTimeOverride?: boolean;
|
||||
timeCompare?: string;
|
||||
declare options: {
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user