fix metrics

This commit is contained in:
Qiuxia Fan 2022-03-26 21:12:45 +08:00
parent cdb776866a
commit e95a4d6c41
2 changed files with 12 additions and 15 deletions

View File

@ -117,7 +117,7 @@ function changeMetric(val: string) {
currentMetric.value = val;
const index = metrics.value.findIndex((d: Option) => d.value === val);
currentIndex.value = index || 0;
const config = getMetricConfig.value;
const config = getMetricConfig.value || [];
currentConfig.value = {
unit: "",
@ -125,6 +125,7 @@ function changeMetric(val: string) {
calculation: "",
...config[index],
};
console.log(currentConfig.value);
}
watch(
() => props.type,
@ -134,14 +135,15 @@ watch(
});
metrics.value = m.length ? m : [{ label: "", value: "" }];
currentMetric.value = metrics.value[0].value;
const config = getMetricConfig.value;
const config = getMetricConfig.value || [];
currentIndex.value = 0;
currentConfig.value = config[0] || {
currentConfig.value = {
unit: "",
label: "",
calculation: "",
...config[0],
};
console.log(currentConfig.value);
console.log(config);
}
);
</script>

View File

@ -416,7 +416,6 @@ function updateSettings(config?: { [key: string]: MetricConfigOpt[] }) {
dashboardStore.selectWidget({ ...dashboardStore.selectedGrid, ...param });
dashboardStore.setConfigs({ ...dashboardStore.selectedGrid, ...param });
emit("update", param);
console.log(dashboardStore.selectedGrid);
}
function updateLinkServerMetrics(options: Option[] | any) {
const opt = options.map((d: Option) => d.value);
@ -428,9 +427,8 @@ function updateLinkServerMetrics(options: Option[] | any) {
changeLinkServerMetrics();
return;
}
const config = (
dashboardStore.selectedGrid.linkServerMetricConfig || []
).splice(index, 1);
const origin = dashboardStore.selectedGrid.linkServerMetricConfig || [];
const config = origin.length === 1 ? [] : origin.splice(index, 1);
changeLinkServerMetrics({ linkServerMetricConfig: config });
}
async function changeLinkServerMetrics(config?: {
@ -453,9 +451,8 @@ function updateLinkClientMetrics(options: Option[] | any) {
changeLinkClientMetrics();
return;
}
const config = (
dashboardStore.selectedGrid.linkClientMetricConfig || []
).splice(index, 1);
const origin = dashboardStore.selectedGrid.linkClientMetricConfig || [];
const config = origin.length === 1 ? [] : origin.splice(index, 1);
changeLinkClientMetrics({ linkClientMetricConfig: config });
}
async function changeLinkClientMetrics(config?: {
@ -476,10 +473,8 @@ function updateNodeMetrics(options: Option[] | any) {
changeNodeMetrics();
return;
}
const config = (dashboardStore.selectedGrid.nodeMetricConfig || []).splice(
index,
1
);
const origin = dashboardStore.selectedGrid.nodeMetricConfig || [];
const config = origin.length === 1 ? [] : origin.splice(index, 1);
changeNodeMetrics({ nodeMetricConfig: config });
}
async function changeNodeMetrics(config?: {