From 54fe200256f433ee45ae8428554bb9e120c2f20a Mon Sep 17 00:00:00 2001 From: Fine Date: Wed, 16 Aug 2023 18:11:48 +0800 Subject: [PATCH] feat: add legend expressions --- .../related/topology/components/Settings.vue | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/views/dashboard/related/topology/components/Settings.vue b/src/views/dashboard/related/topology/components/Settings.vue index 9a80c436..4c565dac 100644 --- a/src/views/dashboard/related/topology/components/Settings.vue +++ b/src/views/dashboard/related/topology/components/Settings.vue @@ -197,8 +197,18 @@ limitations under the License. -->
{{ t("legendSettings") }}
{{ t("conditions") }}
-
+
+ class="cp" iconName="add_circle_outlinecontrol_point" size="middle" - v-show="index === legend.metric.length - 1 && legend.metric.length < 5" + v-show="index === legend.length - 1 && legend.length < 5" @click="addMetric" /> -
&&
+
&&
Healthy Description
@@ -311,11 +321,9 @@ limitations under the License. --> nodeExpressions: selectedGrid.nodeExpressions || [], }); const l = selectedGrid.legend && selectedGrid.legend.length; - const legend = reactive<{ - metric: { name: string; condition: string; value: string }[]; - }>({ - metric: l ? selectedGrid.legend : [{ name: "", condition: "", value: "" }], - }); + const legend = ref<{ name: string; condition: string; value: string }[]>( + l ? selectedGrid.legend : [{ name: "", condition: "", value: "" }], + ); const configType = ref(""); const description = reactive(selectedGrid.description || {}); @@ -387,7 +395,7 @@ limitations under the License. --> updateSettings(); } function changeLegend(type: string, opt: any, index: number) { - (legend.metric[index] as any)[type] = opt[0].value || opt; + (legend.value[index] as any)[type] = opt[0].value || opt; } function changeScope(index: number, opt: Option[] | any) { items[index].scope = opt[0].value; @@ -419,7 +427,7 @@ limitations under the License. --> updateSettings(); } function updateSettings(metricConfig?: { [key: string]: MetricConfigOpt[] }) { - const metrics = legend.metric.filter((d: any) => d.name && d.value && d.condition); + const metrics = legend.value.filter((d: any) => d.name && d.value && d.condition); const param = { ...dashboardStore.selectedGrid, linkDashboard: states.linkDashboard, @@ -526,14 +534,14 @@ limitations under the License. --> topologyStore.queryNodeMetrics(states.nodeMetrics); } function deleteMetric(index: number) { - if (legend.metric.length === 1) { - legend.metric = [{ name: "", condition: "", value: "" }]; + if (legend.value.length === 1) { + legend.value = [{ name: "", condition: "", value: "" }]; return; } - legend.metric.splice(index, 1); + legend.value.splice(index, 1); } function addMetric() { - legend.metric.push({ name: "", condition: "", value: "" }); + legend.value.push({ name: "", condition: "", value: "" }); } function setConfigType(type: string) { configType.value = type; @@ -551,6 +559,7 @@ limitations under the License. --> topologyStore.queryNodeExpressions(states.nodeExpressions); } function changeMetricMode() { + legend.value = [{ name: "", condition: "", value: "" }]; const config = { linkServerMetricConfig: [], linkClientMetricConfig: [],