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[]; expressions?: string[];
metricTypes?: string[]; metricTypes?: string[];
typesOfMQE?: string[]; typesOfMQE?: string[];
children?: { name: string; children: LayoutConfig[]; expression?: string }[]; children?: { name: string; children: LayoutConfig[]; expression?: string; enable: boolean }[];
activedTabIndex?: number; activedTabIndex?: number;
metricConfig?: MetricConfigOpt[]; metricConfig?: MetricConfigOpt[];
id?: string; id?: string;

View File

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