Skip to content

Commit

Permalink
Fix the Table widget (#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fine0830 committed Apr 16, 2024
1 parent 12cd279 commit 7f6e4d0
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions src/hooks/useExpressionsProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,22 +112,7 @@ export async function useExpressionsQueryProcessor(config: Indexable) {
tips.push(obj.error);
typesOfMQE.push(type);
if (!obj.error) {
if (type === ExpressionResultType.TIME_SERIES_VALUES) {
if (results.length === 1) {
const label = results[0].metric && results[0].metric.labels[0] && results[0].metric.labels[0].value;
source[c.label || label || name] = results[0].values.map((d: { value: unknown }) => d.value) || [];
} else {
for (const item of results) {
const values = item.values.map((d: { value: unknown }) => d.value) || [];
const label = item.metric.labels
.map((d: { key: string; value: string }) => `${d.key}=${d.value}`)
.join(",");

source[label] = values;
}
}
}
if (type === ExpressionResultType.SINGLE_VALUE) {
if ([ExpressionResultType.SINGLE_VALUE, ExpressionResultType.TIME_SERIES_VALUES].includes(type)) {
for (const item of results) {
const label =
item.metric &&
Expand Down

0 comments on commit 7f6e4d0

Please sign in to comment.