feat: query expressions

This commit is contained in:
Fine 2023-12-12 12:08:42 +08:00
parent 57f13f2ac5
commit 16decafa1c
2 changed files with 13 additions and 5 deletions

View File

@ -36,7 +36,7 @@ export interface LayoutConfig {
expressions?: string[];
metricTypes?: string[];
typesOfMQE?: string[];
children?: { name: string; children: LayoutConfig[]; expression?: string }[];
children?: { name: string; children: LayoutConfig[]; expression?: string; enable: boolean }[];
activedTabIndex?: number;
metricConfig?: MetricConfigOpt[];
id?: string;

View File

@ -149,7 +149,6 @@ limitations under the License. -->
dashboardStore.setCurrentTabItems(dashboardStore.layout[l].children[activeTabIndex.value].children);
dashboardStore.setActiveTabIndex(activeTabIndex.value, props.data.i);
}
console.log(props.data);
// if (props.needQuery || !dashboardStore.currentDashboard.id) {
// queryExpressions();
@ -241,12 +240,21 @@ limitations under the License. -->
}
async function queryExpressions() {
const tabsProps = props.data;
const metrics = [];
for (const child of props.data.children || []) {
for (const child of tabsProps.children || []) {
child.expression && metrics.push(child.expression);
}
const params = (await useExpressionsQueryProcessor({ metrics })) || {};
console.log(params);
const params: { [key: string]: any } = (await useExpressionsQueryProcessor({ metrics })) || {};
for (const child of tabsProps.children || []) {
if (params.source[child.expression || ""]) {
child.enable = !!Number(params.source[child.expression || ""]) || true;
} else {
child.enable = true;
}
}
console.log(tabsProps);
}
watch(