fix: metric config

This commit is contained in:
Fine 2023-06-03 12:58:46 +08:00
parent 94dc2f3642
commit 6867f2ec32
2 changed files with 11 additions and 6 deletions

View File

@ -198,7 +198,7 @@ export async function useExpressionsQueryPodsMetrics(
const names: string[] = []; const names: string[] = [];
const metricConfigArr: MetricConfigOpt[] = []; const metricConfigArr: MetricConfigOpt[] = [];
const metricTypesArr: string[] = []; const metricTypesArr: string[] = [];
const data = pods.map((d: Instance & Indexable, idx: number) => { const data = pods.map((d: any, idx: number) => {
config.expressions.map((exp: string, index: number) => { config.expressions.map((exp: string, index: number) => {
const c: any = (config.metricConfig && config.metricConfig[index]) || {}; const c: any = (config.metricConfig && config.metricConfig[index]) || {};
const k = "expression" + idx + index; const k = "expression" + idx + index;

View File

@ -166,6 +166,8 @@ limitations under the License. -->
states.isList = ListChartTypes.includes(graph.value.type); states.isList = ListChartTypes.includes(graph.value.type);
const defaultLen = ref<number>(states.isList ? 5 : 20); const defaultLen = ref<number>(states.isList ? 5 : 20);
const backupMetricConfig = ref<MetricConfigOpt[]>([]);
setDashboards(); setDashboards();
setMetricType(); setMetricType();
@ -461,11 +463,14 @@ limitations under the License. -->
} }
function changeMetricMode() { function changeMetricMode() {
states.metrics = metrics.value.length ? metrics.value : [""]; states.metrics = metrics.value.length ? metrics.value : [""];
(states.metricTypes = metricTypes.value.length ? metricTypes.value : [""]), states.metricTypes = metricTypes.value.length ? metricTypes.value : [""];
dashboardStore.selectWidget({ const config = dashboardStore.selectedGrid.metricTypes;
...dashboardStore.selectedGrid, dashboardStore.selectWidget({
metricMode: isExpression.value ? "Expression" : "General", ...dashboardStore.selectedGrid,
}); metricMode: isExpression.value ? "Expression" : "General",
metricTypes: backupMetricConfig.value,
});
backupMetricConfig.value = config;
} }
async function changeExpression(event: any, index: number) { async function changeExpression(event: any, index: number) {
const params = event.target.textContent; const params = event.target.textContent;