mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-13 16:27:33 +00:00
refactor
This commit is contained in:
parent
8d994f577d
commit
ad2ee6fd21
@ -73,79 +73,74 @@ export function useQueryProcessor(config: any) {
|
|||||||
topN: c.topN || 10,
|
topN: c.topN || 10,
|
||||||
order: c.sortOrder || "DES",
|
order: c.sortOrder || "DES",
|
||||||
};
|
};
|
||||||
} else if ([MetricQueryTypes.ReadRecords].includes(metricType)) {
|
|
||||||
variables.push(`$condition${index}: RecordCondition!`);
|
|
||||||
conditions[`condition${index}`] = {
|
|
||||||
name,
|
|
||||||
parentEntity: {
|
|
||||||
scope: config.catalog,
|
|
||||||
normal: selectorStore.currentService
|
|
||||||
? selectorStore.currentService.normal
|
|
||||||
: true,
|
|
||||||
serviceName: ["All"].includes(dashboardStore.entity)
|
|
||||||
? null
|
|
||||||
: selectorStore.currentService.value,
|
|
||||||
},
|
|
||||||
topN: c.topN || 10,
|
|
||||||
order: c.sortOrder || "DES",
|
|
||||||
};
|
|
||||||
} else {
|
} else {
|
||||||
if (metricType === MetricQueryTypes.ReadLabeledMetricsValues) {
|
const entity = {
|
||||||
const labels = (c.labelsIndex || "")
|
scope: config.catalog,
|
||||||
.split(",")
|
serviceName:
|
||||||
.map((item: string) => item.replace(/^\s*|\s*$/g, ""));
|
dashboardStore.entity === "All"
|
||||||
variables.push(`$labels${index}: [String!]!`);
|
? undefined
|
||||||
conditions[`labels${index}`] = labels;
|
: selectorStore.currentService.value,
|
||||||
}
|
normal:
|
||||||
variables.push(`$condition${index}: MetricsCondition!`);
|
dashboardStore.entity === "All"
|
||||||
conditions[`condition${index}`] = {
|
? undefined
|
||||||
name,
|
: selectorStore.currentService.normal,
|
||||||
entity: {
|
serviceInstanceName: [
|
||||||
scope: dashboardStore.entity,
|
"ServiceInstance",
|
||||||
serviceName:
|
"ServiceInstanceRelation",
|
||||||
dashboardStore.entity === "All"
|
"ProcessRelation",
|
||||||
? undefined
|
].includes(dashboardStore.entity)
|
||||||
: selectorStore.currentService.value,
|
? selectorStore.currentPod && selectorStore.currentPod.value
|
||||||
normal:
|
: undefined,
|
||||||
dashboardStore.entity === "All"
|
endpointName: dashboardStore.entity.includes("Endpoint")
|
||||||
? undefined
|
? selectorStore.currentPod && selectorStore.currentPod.value
|
||||||
: selectorStore.currentService.normal,
|
: undefined,
|
||||||
serviceInstanceName: [
|
processName: dashboardStore.entity.includes("Process")
|
||||||
"ServiceInstance",
|
? selectorStore.currentProcess && selectorStore.currentProcess.value
|
||||||
"ServiceInstanceRelation",
|
: undefined,
|
||||||
"ProcessRelation",
|
destNormal: isRelation
|
||||||
].includes(dashboardStore.entity)
|
? selectorStore.currentDestService.normal
|
||||||
? selectorStore.currentPod && selectorStore.currentPod.value
|
: undefined,
|
||||||
: undefined,
|
destServiceName: isRelation
|
||||||
endpointName: dashboardStore.entity.includes("Endpoint")
|
? selectorStore.currentDestService.value
|
||||||
? selectorStore.currentPod && selectorStore.currentPod.value
|
: undefined,
|
||||||
: undefined,
|
destServiceInstanceName: [
|
||||||
processName: dashboardStore.entity.includes("Process")
|
"ServiceInstanceRelation",
|
||||||
? selectorStore.currentProcess && selectorStore.currentProcess.value
|
"ProcessRelation",
|
||||||
: undefined,
|
].includes(dashboardStore.entity)
|
||||||
destNormal: isRelation
|
? selectorStore.currentDestPod && selectorStore.currentDestPod.value
|
||||||
? selectorStore.currentDestService.normal
|
: undefined,
|
||||||
: undefined,
|
destEndpointName:
|
||||||
destServiceName: isRelation
|
dashboardStore.entity === "EndpointRelation"
|
||||||
? selectorStore.currentDestService.value
|
|
||||||
: undefined,
|
|
||||||
destServiceInstanceName: [
|
|
||||||
"ServiceInstanceRelation",
|
|
||||||
"ProcessRelation",
|
|
||||||
].includes(dashboardStore.entity)
|
|
||||||
? selectorStore.currentDestPod && selectorStore.currentDestPod.value
|
? selectorStore.currentDestPod && selectorStore.currentDestPod.value
|
||||||
: undefined,
|
: undefined,
|
||||||
destEndpointName:
|
destProcessName: dashboardStore.entity.includes("ProcessRelation")
|
||||||
dashboardStore.entity === "EndpointRelation"
|
? selectorStore.currentDestProcess &&
|
||||||
? selectorStore.currentDestPod &&
|
selectorStore.currentDestProcess.value
|
||||||
selectorStore.currentDestPod.value
|
: undefined,
|
||||||
: undefined,
|
|
||||||
destProcessName: dashboardStore.entity.includes("ProcessRelation")
|
|
||||||
? selectorStore.currentDestProcess &&
|
|
||||||
selectorStore.currentDestProcess.value
|
|
||||||
: undefined,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
if ([MetricQueryTypes.ReadRecords].includes(metricType)) {
|
||||||
|
variables.push(`$condition${index}: RecordCondition!`);
|
||||||
|
conditions[`condition${index}`] = {
|
||||||
|
name,
|
||||||
|
parentEntity: entity,
|
||||||
|
topN: c.topN || 10,
|
||||||
|
order: c.sortOrder || "DES",
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
entity.scope = dashboardStore.entity;
|
||||||
|
if (metricType === MetricQueryTypes.ReadLabeledMetricsValues) {
|
||||||
|
const labels = (c.labelsIndex || "")
|
||||||
|
.split(",")
|
||||||
|
.map((item: string) => item.replace(/^\s*|\s*$/g, ""));
|
||||||
|
variables.push(`$labels${index}: [String!]!`);
|
||||||
|
conditions[`labels${index}`] = labels;
|
||||||
|
}
|
||||||
|
variables.push(`$condition${index}: MetricsCondition!`);
|
||||||
|
conditions[`condition${index}`] = {
|
||||||
|
name,
|
||||||
|
entity,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (metricType === MetricQueryTypes.ReadLabeledMetricsValues) {
|
if (metricType === MetricQueryTypes.ReadLabeledMetricsValues) {
|
||||||
return `${name}${index}: ${metricType}(condition: $condition${index}, labels: $labels${index}, duration: $duration)${RespFields[metricType]}`;
|
return `${name}${index}: ${metricType}(condition: $condition${index}, labels: $labels${index}, duration: $duration)${RespFields[metricType]}`;
|
||||||
|
Loading…
Reference in New Issue
Block a user