fix query

This commit is contained in:
Fine 2022-10-26 15:26:25 +08:00
parent cfe74b0888
commit 3f20f6165e
3 changed files with 13 additions and 6 deletions

View File

@ -154,6 +154,7 @@ export function useQueryProcessor(config: any) {
} }
}); });
const queryStr = `query queryData(${variables}) {${fragment}}`; const queryStr = `query queryData(${variables}) {${fragment}}`;
console.log(queryStr);
return { return {
queryStr, queryStr,
conditions, conditions,
@ -257,10 +258,12 @@ export function useQueryPodsMetrics(
config: { metrics: string[]; metricTypes: string[] }, config: { metrics: string[]; metricTypes: string[] },
scope: string scope: string
) { ) {
if (!(config.metrics && config.metrics[0])) { const metricTypes = (config.metricTypes || []).filter((m: string) => m);
if (!metricTypes.length) {
return; return;
} }
if (!(config.metricTypes && config.metricTypes[0])) { const metrics = (config.metrics || []).filter((m: string) => m);
if (!metrics.length) {
return; return;
} }
const appStore = useAppStoreWithOut(); const appStore = useAppStoreWithOut();
@ -282,8 +285,8 @@ export function useQueryPodsMetrics(
endpointName: scope === "Endpoint" ? d.label : undefined, endpointName: scope === "Endpoint" ? d.label : undefined,
normal: scope === "Service" ? d.normal : currentService.normal, normal: scope === "Service" ? d.normal : currentService.normal,
}; };
const f = config.metrics.map((name: string, idx: number) => { const f = metrics.map((name: string, idx: number) => {
const metricType = config.metricTypes[idx] || ""; const metricType = metricTypes[idx] || "";
conditions[`condition${index}${idx}`] = { conditions[`condition${index}${idx}`] = {
name, name,
entity: param, entity: param,

View File

@ -191,7 +191,10 @@ async function setMetricType(chart?: any) {
states.metricList = (arr || []).filter( states.metricList = (arr || []).filter(
(d: { catalog: string; type: string }) => { (d: { catalog: string; type: string }) => {
if (states.isList) { if (states.isList) {
if (d.type === MetricsType.REGULAR_VALUE) { if (
d.type === MetricsType.REGULAR_VALUE ||
d.type === MetricsType.LABELED_VALUE
) {
return d; return d;
} }
} else if (g.type === "Table") { } else if (g.type === "Table") {

View File

@ -194,6 +194,7 @@ function clickService(scope: any) {
router.push(path); router.push(path);
} }
async function queryServiceMetrics(currentServices: Service[]) { async function queryServiceMetrics(currentServices: Service[]) {
// console.log(services.value);
if (!currentServices.length) { if (!currentServices.length) {
return; return;
} }
@ -219,7 +220,7 @@ async function queryServiceMetrics(currentServices: Service[]) {
}); });
return; return;
} }
console.log(services.value);
services.value = currentServices; services.value = currentServices;
} }
function objectSpanMethod(param: any): any { function objectSpanMethod(param: any): any {