feat: update tabs

This commit is contained in:
Fine 2024-08-21 16:11:27 +08:00
parent bdc9b14f7a
commit 48a37d1093
2 changed files with 26 additions and 1 deletions

View File

@ -128,7 +128,7 @@ limitations under the License. -->
import type { LayoutConfig } from "@/types/dashboard";
import { useDashboardStore } from "@/store/modules/dashboard";
import controls from "./tab";
import { dragIgnoreFrom, WidgetType } from "../data";
import { dragIgnoreFrom, ListChartTypes, WidgetType } from "../data";
import copy from "@/utils/copy";
import { useDashboardQueryProcessor } from "@/hooks/useExpressionsProcessor";

View File

@ -95,6 +95,25 @@ limitations under the License. -->
}
metricsValues.value = (await useDashboardQueryProcessor(configList)) || {};
}
async function queryTabsMetrics() {
const widgets = [];
for (const item of dashboardStore.currentTabItems) {
const isList = ListChartTypes.includes(item.type || "");
if (item.type === WidgetType.Widget && !isList) {
widgets.push(item);
}
}
const configList = widgets.map((d: LayoutConfig) => ({
metrics: d.expressions || [],
metricConfig: d.metricConfig || [],
id: d.i,
}));
if (!widgets.length) {
return {};
}
metricsValues.value = (await useDashboardQueryProcessor(configList)) || {};
}
onBeforeUnmount(() => {
dashboardStore.setLayout([]);
@ -137,6 +156,12 @@ limitations under the License. -->
}
},
);
watch(
() => dashboardStore.currentTabItems,
() => {
queryTabsMetrics();
},
);
return {
dashboardStore,
clickGrid,