export type Widget = { height: number; ...

5/12/2021  •  49 views
 
export type Widget = {
height: number;
width: number;
type: string;
properties: any;
}

const metaData = {
height: 6,
width: 6,
type: "metric",
period: 300,
view: "timeSeries",
stacked: false,
}

export function createWidgetsFromJson(stageProps: any, json: Array<any>): Widget[] {
var widgetArray: Widget[] = [];

for (var i = 0; i < json.length; i++) {
let widget = {} as Widget;

var widgetJson = json[i];
widget.properties = widgetJson.properties;

widget.properties.region = stageProps.region;

widget.properties.period = metaData.period;
widget.properties.view = metaData.view;
widget.properties.stacked = metaData.stacked;

widget.height = metaData.height;
widget.width = metaData.width;
widget.type = metaData.type;

widgetArray.push(widget);
}
return widgetArray;
}
https://paste.ac/Y3HhTrN