update templates

This commit is contained in:
Qiuxia Fan 2022-05-16 15:36:42 +08:00
parent b4f26b04bf
commit 1b45c719e3

View File

@ -231,13 +231,27 @@ function exportTemplates() {
multipleTableRef.value!.clearSelection(); multipleTableRef.value!.clearSelection();
}, 2000); }, 2000);
} }
function optimizeTemplate(children: (LayoutConfig & { moved?: boolean })[]) { function optimizeTemplate(
children: (LayoutConfig & { moved?: boolean; standard?: unknown })[]
) {
for (const child of children || []) { for (const child of children || []) {
delete child.moved; delete child.moved;
delete child.activedTabIndex; delete child.activedTabIndex;
delete child.standard;
if (isEmptyObject(child.graph)) { if (isEmptyObject(child.graph)) {
delete child.graph; delete child.graph;
} }
if (child.widget) {
if (child.widget.title === "") {
delete child.widget.title;
}
if (child.widget.tips === "") {
delete child.widget.tips;
}
}
if (isEmptyObject(child.widget)) {
delete child.widget;
}
if (!(child.metrics && child.metrics.length && child.metrics[0])) { if (!(child.metrics && child.metrics.length && child.metrics[0])) {
delete child.metrics; delete child.metrics;
} }
@ -270,6 +284,13 @@ function optimizeTemplate(children: (LayoutConfig & { moved?: boolean })[]) {
optimizeTemplate(item.children); optimizeTemplate(item.children);
} }
} }
if (
["Trace", "Topology", "Tab", "Profile", "Ebpf", "Log"].includes(
child.type
)
) {
delete child.widget;
}
} }
} }
function handleEdit(row: DashboardItem) { function handleEdit(row: DashboardItem) {