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:
Haris Rozajac
2025-01-10 08:09:06 -07:00
committed by GitHub
parent 7499611129
commit f3d2313f09
7 changed files with 140 additions and 15 deletions

View File

@ -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 => ({

View File

@ -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: {

View File

@ -198,6 +198,11 @@ export const handyTestingSchema: DashboardV2Spec = {
width: 200,
x: 0,
y: 0,
repeat: {
mode: 'variable',
value: 'customVar',
maxPerRow: 3,
},
},
},
],