This commit is contained in:
Fine 2025-04-24 11:06:41 +08:00
parent a4cd265d45
commit 9ba3f12f6d

View File

@ -109,7 +109,7 @@ export async function useDashboardQueryProcessor(configList: Indexable[]) {
return { source: {}, tips: [], typesOfMQE: [] }; return { source: {}, tips: [], typesOfMQE: [] };
} }
const tips: string[] = []; const tips: string[] = [];
const source: { [key: string]: unknown } = {}; const source: Indexable<unknown> = {};
const keys = Object.keys(resp.data); const keys = Object.keys(resp.data);
const typesOfMQE: string[] = []; const typesOfMQE: string[] = [];
@ -125,15 +125,16 @@ export async function useDashboardQueryProcessor(configList: Indexable[]) {
if (!obj.error) { if (!obj.error) {
if ([ExpressionResultType.SINGLE_VALUE, ExpressionResultType.TIME_SERIES_VALUES].includes(type)) { if ([ExpressionResultType.SINGLE_VALUE, ExpressionResultType.TIME_SERIES_VALUES].includes(type)) {
for (const item of results) { for (const item of results) {
const label = let label =
item.metric && item.metric &&
item.metric.labels.map((d: { key: string; value: string }) => `${d.key}=${d.value}`).join(","); item.metric.labels.map((d: { key: string; value: string }) => `${d.key}=${d.value}`).join(",");
const values = item.values.map((d: { value: unknown }) => d.value) || []; const values = item.values.map((d: { value: unknown }) => d.value) || [];
if (results.length === 1) { if (label) {
source[label || c.label || name] = values; label = `${c.label || name}, ${label}`;
} else { } else {
source[label] = values; label = c.label || name;
} }
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)) {
@ -148,7 +149,7 @@ export async function useDashboardQueryProcessor(configList: Indexable[]) {
const appStore = useAppStoreWithOut(); const appStore = useAppStoreWithOut();
const variables: string[] = [`$duration: Duration!`]; const variables: string[] = [`$duration: Duration!`];
let fragments = ""; let fragments = "";
let conditions: Recordable = { let conditions: Recordable<unknown> = {
duration: appStore.durationTime, duration: appStore.durationTime,
}; };
for (let i = 0; i < configArr.length; i++) { for (let i = 0; i < configArr.length; i++) {
@ -465,7 +466,7 @@ export function useQueryTopologyExpressionsProcessor(metrics: string[], instance
return { queryStr, conditions }; return { queryStr, conditions };
} }
function handleExpressionValues(partMetrics: string[], resp: { [key: string]: any }) { function handleExpressionValues(partMetrics: string[], resp: { [key: string]: any }) {
const obj: any = {}; const obj: Indexable = {};
for (let idx = 0; idx < instances.length; idx++) { for (let idx = 0; idx < instances.length; idx++) {
for (let index = 0; index < partMetrics.length; index++) { for (let index = 0; index < partMetrics.length; index++) {
const k = "expression" + idx + index; const k = "expression" + idx + index;