mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 03:12:13 +08:00
Dashboard SchemaV2: Panel repeater (#98654)
* Wip: working layout for repeaters * Update schema * only persist orig panel * Keep only supported mode and rename repeater function * refactor dimension calcs * v1 transformer uses calculateGridItemDimensions
This commit is contained in:
@ -648,6 +648,21 @@ export const defaultTimeSettingsSpec = (): TimeSettingsSpec => ({
|
||||
fiscalYearStartMonth: 0,
|
||||
});
|
||||
|
||||
// other repeat modes will be added in the future: label, frame
|
||||
export const RepeatMode = "variable";
|
||||
|
||||
export interface RepeatOptions {
|
||||
mode: "variable";
|
||||
value: string;
|
||||
direction?: "h" | "v";
|
||||
maxPerRow?: number;
|
||||
}
|
||||
|
||||
export const defaultRepeatOptions = (): RepeatOptions => ({
|
||||
mode: RepeatMode,
|
||||
value: "",
|
||||
});
|
||||
|
||||
export interface GridLayoutItemSpec {
|
||||
x: number;
|
||||
y: number;
|
||||
@ -655,6 +670,7 @@ export interface GridLayoutItemSpec {
|
||||
height: number;
|
||||
// reference to a PanelKind from dashboard.spec.elements Expressed as JSON Schema reference
|
||||
element: ElementReference;
|
||||
repeat?: RepeatOptions;
|
||||
}
|
||||
|
||||
export const defaultGridLayoutItemSpec = (): GridLayoutItemSpec => ({
|
||||
|
@ -455,12 +455,22 @@ TimeSettingsSpec: {
|
||||
nowDelay?: string // v1: timepicker.nowDelay
|
||||
}
|
||||
|
||||
RepeatMode: "variable" // other repeat modes will be added in the future: label, frame
|
||||
|
||||
RepeatOptions: {
|
||||
mode: RepeatMode
|
||||
value: string
|
||||
direction?: "h" | "v"
|
||||
maxPerRow?: int
|
||||
}
|
||||
|
||||
GridLayoutItemSpec: {
|
||||
x: int
|
||||
y: int
|
||||
width: int
|
||||
height: int
|
||||
element: ElementReference // reference to a PanelKind from dashboard.spec.elements Expressed as JSON Schema reference
|
||||
repeat?: RepeatOptions
|
||||
}
|
||||
|
||||
GridLayoutItemKind: {
|
||||
|
@ -198,6 +198,11 @@ export const handyTestingSchema: DashboardV2Spec = {
|
||||
width: 200,
|
||||
x: 0,
|
||||
y: 0,
|
||||
repeat: {
|
||||
mode: 'variable',
|
||||
value: 'customVar',
|
||||
maxPerRow: 3,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
|
Reference in New Issue
Block a user