in src/store/modules/dashboard.ts [144:191]
addTabControls(type: WidgetType) {
const activedGridItem = this.activedGridItem.split("-")[0];
const idx = this.layout.findIndex((d: LayoutConfig) => d.i === activedGridItem);
if (idx < 0) {
return;
}
const tabIndex = this.layout[idx].activedTabIndex || 0;
const { children } = (this.layout[idx].children || [])[tabIndex];
const arr = children.map((d: Recordable) => Number(d.i));
let index = String(Math.max(...arr) + 1);
if (!children.length) {
index = "0";
}
const id = `${activedGridItem}-${tabIndex}-${index}`;
const newItem: LayoutConfig = {
...NewControl,
i: index,
id,
type,
};
if (type === WidgetType.Topology) {
newItem.h = 32;
newItem.graph = {
showDepth: true,
};
}
if (ControlsTypes.includes(type)) {
newItem.h = 32;
}
if (type === WidgetType.Text) {
newItem.h = 6;
newItem.graph = TextConfig;
}
if (type === WidgetType.TimeRange) {
newItem.w = 8;
newItem.h = 6;
newItem.graph = TextConfig;
}
if (this.layout[idx].children) {
const items = children.map((d: LayoutConfig) => {
d.y = d.y + newItem.h;
return d;
});
items.push(newItem);
(this.layout[idx].children || [])[tabIndex].children = items;
this.currentTabItems = items;
}
},