fix: address pr

This commit is contained in:
Fine 2023-06-04 14:05:44 +08:00
parent 166b321b82
commit 8eebc0a8c3
3 changed files with 4 additions and 5 deletions

View File

@ -119,11 +119,10 @@ export function useExpressionsSourceProcessor(
source[c.label || name] = results[0].values.map((d: { value: unknown }) => d.value) || []; source[c.label || name] = results[0].values.map((d: { value: unknown }) => d.value) || [];
} else { } else {
const labels = (c.label || "").split(",").map((item: string) => item.replace(/^\s*|\s*$/g, "")); const labels = (c.label || "").split(",").map((item: string) => item.replace(/^\s*|\s*$/g, ""));
const labelsIdx = (c.labelsIndex || "").split(",").map((item: string) => item.replace(/^\s*|\s*$/g, ""));
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 index = item.metric.labels[0].value; const index = item.metric.labels[0].value;
const indexNum = labelsIdx.findIndex((d: string) => d === index); const indexNum = labels.findIndex((_, i: number) => i === Number(index));
if (labels[indexNum] && indexNum > -1) { if (labels[indexNum] && indexNum > -1) {
source[labels[indexNum]] = values; source[labels[indexNum]] = values;
} else { } else {

View File

@ -34,7 +34,7 @@ limitations under the License. -->
size="small" size="small"
@change="changeMetricMode" @change="changeMetricMode"
/> />
<div v-if="isExpression"> <div v-if="isExpression && states.isList">
<span class="title">Summary</span> <span class="title">Summary</span>
<span>Detail</span> <span>Detail</span>
</div> </div>

View File

@ -45,8 +45,8 @@ limitations under the License. -->
<div <div
class="item mb-10" class="item mb-10"
v-if=" v-if="
[ProtocolTypes.ReadLabeledMetricsValues].includes(metricType) || [ProtocolTypes.ReadLabeledMetricsValues].includes(metricType) &&
dashboardStore.selectedGrid.metricMode === MetricModes.Expression dashboardStore.selectedGrid.metricMode === MetricModes.General
" "
> >
<span class="label">{{ t("labelsIndex") }}</span> <span class="label">{{ t("labelsIndex") }}</span>