diff --git a/src/store/modules/log.ts b/src/store/modules/log.ts index 27c74534..a4d93ca3 100644 --- a/src/store/modules/log.ts +++ b/src/store/modules/log.ts @@ -68,9 +68,12 @@ export const logStore = defineStore({ this.services = res.data.data.services; return res.data; }, - async getInstances() { + async getInstances(id: string) { + const serviceId = this.selectorStore.currentService + ? this.selectorStore.currentService.id + : id; const res: AxiosResponse = await graphql.query("queryInstances").params({ - serviceId: this.selectorStore.currentService.id, + serviceId, duration: this.durationTime, }); @@ -83,9 +86,12 @@ export const logStore = defineStore({ ] || [{ value: " 0", label: "All" }]; return res.data; }, - async getEndpoints() { + async getEndpoints(id: string) { + const serviceId = this.selectorStore.currentService + ? this.selectorStore.currentService.id + : id; const res: AxiosResponse = await graphql.query("queryEndpoints").params({ - serviceId: this.selectorStore.currentService.id, + serviceId, duration: this.durationTime, keyword: "", }); diff --git a/src/store/modules/trace.ts b/src/store/modules/trace.ts index 79d8a8f2..695865f7 100644 --- a/src/store/modules/trace.ts +++ b/src/store/modules/trace.ts @@ -83,9 +83,12 @@ export const traceStore = defineStore({ this.services = res.data.data.services; return res.data; }, - async getInstances() { + async getInstances(id: string) { + const serviceId = this.selectorStore.currentService + ? this.selectorStore.currentService.id + : id; const res: AxiosResponse = await graphql.query("queryInstances").params({ - serviceId: this.selectorStore.currentService.id, + serviceId: serviceId, duration: this.durationTime, }); @@ -98,9 +101,12 @@ export const traceStore = defineStore({ ] || [{ value: " 0", label: "All" }]; return res.data; }, - async getEndpoints() { + async getEndpoints(id: string) { + const serviceId = this.selectorStore.currentService + ? this.selectorStore.currentService.id + : id; const res: AxiosResponse = await graphql.query("queryEndpoints").params({ - serviceId: this.selectorStore.currentService.id, + serviceId, duration: this.durationTime, keyword: "", }); diff --git a/src/views/dashboard/related/log/Header.vue b/src/views/dashboard/related/log/Header.vue index f20f7773..be71bc07 100644 --- a/src/views/dashboard/related/log/Header.vue +++ b/src/views/dashboard/related/log/Header.vue @@ -186,18 +186,20 @@ async function getServices() { return; } state.service = logStore.services[0]; + getInstances(state.service.id); + getEndpoints(state.service.id); } -async function getEndpoints() { - const resp = await logStore.getEndpoints(); +async function getEndpoints(id?: string) { + const resp = await logStore.getEndpoints(id); if (resp.errors) { ElMessage.error(resp.errors); return; } state.endpoint = logStore.endpoints[0]; } -async function getInstances() { - const resp = await logStore.getInstances(); +async function getInstances(id?: string) { + const resp = await logStore.getInstances(id); if (resp.errors) { ElMessage.error(resp.errors); return; @@ -237,8 +239,8 @@ async function queryLogs() { function changeField(type: string, opt: any) { state[type] = opt[0]; if (type === "service") { - getEndpoints(); - getInstances(); + getEndpoints(state.service.id); + getInstances(state.service.id); } } function updateTags(data: { tagsMap: Array