From 5346ca417a1db2ded7ece405d842f85a97c589c4 Mon Sep 17 00:00:00 2001 From: Fine Date: Sat, 15 Jul 2023 23:25:30 +0800 Subject: [PATCH] fix: label --- src/hooks/useExpressionsProcessor.ts | 6 ++++-- src/views/dashboard/graphs/Table.vue | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/hooks/useExpressionsProcessor.ts b/src/hooks/useExpressionsProcessor.ts index d3ee7ee7..e82fb48d 100644 --- a/src/hooks/useExpressionsProcessor.ts +++ b/src/hooks/useExpressionsProcessor.ts @@ -113,7 +113,8 @@ export async function useExpressionsQueryProcessor(config: Indexable) { if (!obj.error) { if (type === ExpressionResultType.TIME_SERIES_VALUES) { if (results.length === 1) { - source[c.label || name] = results[0].values.map((d: { value: unknown }) => d.value) || []; + const label = results[0].metric && results[0].metric.labels[0].value; + source[c.label || label || name] = results[0].values.map((d: { value: unknown }) => d.value) || []; } else { const labels = (c.label || "").split(",").map((item: string) => item.replace(/^\s*|\s*$/g, "")); for (const item of results) { @@ -129,7 +130,8 @@ export async function useExpressionsQueryProcessor(config: Indexable) { } } if (type === ExpressionResultType.SINGLE_VALUE) { - source[c.label || name] = (results[0].values[0] || {}).value; + const label = results[0].metric && results[0].metric.labels[0].value; + source[c.label || label || name] = (results[0].values[0] || {}).value; } if (([ExpressionResultType.RECORD_LIST, ExpressionResultType.SORTED_LIST] as string[]).includes(type)) { source[name] = results[0].values; diff --git a/src/views/dashboard/graphs/Table.vue b/src/views/dashboard/graphs/Table.vue index a03827a5..1ff585f7 100644 --- a/src/views/dashboard/graphs/Table.vue +++ b/src/views/dashboard/graphs/Table.vue @@ -51,7 +51,7 @@ limitations under the License. --> default: () => ({ showTableValues: true }), }, }); - + console.log(props.data); const { t } = useI18n(); const nameWidth = computed(() => (props.config.showTableValues ? "80%" : "100%")); const dataKeys = computed(() => {