mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-02 18:04:54 +00:00
feat: support the SINGLE_VALUE
for table widgets (#383)
This commit is contained in:
parent
fd2c7ca716
commit
460b24f42c
@ -119,14 +119,26 @@ export async function useExpressionsQueryProcessor(config: Indexable) {
|
|||||||
} else {
|
} else {
|
||||||
for (const item of results) {
|
for (const item of results) {
|
||||||
const values = item.values.map((d: { value: unknown }) => d.value) || [];
|
const values = item.values.map((d: { value: unknown }) => d.value) || [];
|
||||||
const label = item.metric.labels.map((d: any) => `${d.key}=${d.value}`).join(",");
|
const label = item.metric.labels
|
||||||
|
.map((d: { key: string; value: string }) => `${d.key}=${d.value}`)
|
||||||
|
.join(",");
|
||||||
|
|
||||||
source[label] = values;
|
source[label] = values;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type === ExpressionResultType.SINGLE_VALUE) {
|
if (type === ExpressionResultType.SINGLE_VALUE) {
|
||||||
source[c.label || name] = (results[0].values[0] || {}).value;
|
for (const item of results) {
|
||||||
|
const label = item.metric.labels
|
||||||
|
.map((d: { key: string; value: string }) => `${d.key}=${d.value}`)
|
||||||
|
.join(",");
|
||||||
|
const values = item.values.map((d: { value: unknown }) => d.value) || [];
|
||||||
|
if (results.length === 1) {
|
||||||
|
source[label || c.label || name] = values;
|
||||||
|
} else {
|
||||||
|
source[label] = values;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (([ExpressionResultType.RECORD_LIST, ExpressionResultType.SORTED_LIST] as string[]).includes(type)) {
|
if (([ExpressionResultType.RECORD_LIST, ExpressionResultType.SORTED_LIST] as string[]).includes(type)) {
|
||||||
source[name] = results[0].values;
|
source[name] = results[0].values;
|
||||||
|
@ -37,12 +37,7 @@ limitations under the License. -->
|
|||||||
>{{ k.split("=")[1] }}</div
|
>{{ k.split("=")[1] }}</div
|
||||||
>
|
>
|
||||||
<div class="value-col" v-if="config.showTableValues">
|
<div class="value-col" v-if="config.showTableValues">
|
||||||
{{
|
{{ data[(keys as string[]).join(",")][data[(keys as string[]).join(",")].length - 1 || 0] }}
|
||||||
(config.metricTypes && config.metricTypes[0] === "readMetricsValue") ||
|
|
||||||
(props.config.typesOfMQE && props.config.typesOfMQE[0] === ExpressionResultType.SINGLE_VALUE)
|
|
||||||
? data[keys[0]]
|
|
||||||
: data[(keys as string[]).join(",")][data[(keys as string[]).join(",")].length - 1 || 0]
|
|
||||||
}}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -51,7 +46,6 @@ limitations under the License. -->
|
|||||||
import { computed } from "vue";
|
import { computed } from "vue";
|
||||||
import type { PropType } from "vue";
|
import type { PropType } from "vue";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { ExpressionResultType } from "@/views/dashboard/data";
|
|
||||||
/*global defineProps */
|
/*global defineProps */
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
data: {
|
data: {
|
||||||
@ -76,10 +70,6 @@ limitations under the License. -->
|
|||||||
const keys = Object.keys(props.data || {});
|
const keys = Object.keys(props.data || {});
|
||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
if (props.config.typesOfMQE && props.config.typesOfMQE[0] === ExpressionResultType.SINGLE_VALUE) {
|
|
||||||
const keys = Object.keys(props.data || {});
|
|
||||||
return keys;
|
|
||||||
}
|
|
||||||
const keys = Object.keys(props.data || {}).filter(
|
const keys = Object.keys(props.data || {}).filter(
|
||||||
(i: string) => Array.isArray(props.data[i]) && props.data[i].length,
|
(i: string) => Array.isArray(props.data[i]) && props.data[i].length,
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user