From 87cac31d25273586c683b44410723852948a8268 Mon Sep 17 00:00:00 2001 From: Qiuxia Fan Date: Sat, 26 Feb 2022 22:35:16 +0800 Subject: [PATCH] fix: update filters --- src/store/modules/trace.ts | 21 ++++- src/types/selector.d.ts | 18 ++--- src/views/dashboard/related/trace/Filter.vue | 80 +++++++++++++++----- 3 files changed, 89 insertions(+), 30 deletions(-) diff --git a/src/store/modules/trace.ts b/src/store/modules/trace.ts index 422c583a..8fe7aafe 100644 --- a/src/store/modules/trace.ts +++ b/src/store/modules/trace.ts @@ -16,7 +16,7 @@ */ import { defineStore } from "pinia"; import { Duration } from "@/types/app"; -import { Instance, Endpoint } from "@/types/selector"; +import { Instance, Endpoint, Service } from "@/types/selector"; import { Trace, Span } from "@/types/trace"; import { store } from "@/store"; import graphql from "@/graphql"; @@ -25,6 +25,7 @@ import { useAppStoreWithOut } from "@/store/modules/app"; import { useSelectorStore } from "@/store/modules/selectors"; interface TraceState { + services: Service[]; instances: Instance[]; endpoints: Endpoint[]; traceList: Trace[]; @@ -44,8 +45,9 @@ interface TraceState { export const traceStore = defineStore({ id: "trace", state: (): TraceState => ({ - instances: [], - endpoints: [], + services: [{ value: "0", label: "All" }], + instances: [{ value: "0", label: "All" }], + endpoints: [{ value: "0", label: "All" }], traceList: [], traceSpans: [], traceTotal: 0, @@ -71,6 +73,19 @@ export const traceStore = defineStore({ setTraceSpans(spans: Span) { this.traceSpans = spans; }, + async getServices(layer: string) { + const res: AxiosResponse = await graphql.query("queryServices").params({ + layer, + }); + if (res.data.errors) { + return res.data; + } + this.services = [ + { value: "0", label: "All" }, + ...res.data.data.services, + ] || [{ value: "0", label: "All" }]; + return res.data; + }, async getInstances() { const res: AxiosResponse = await graphql.query("queryInstances").params({ serviceId: this.selectorStore.currentService.id, diff --git a/src/types/selector.d.ts b/src/types/selector.d.ts index 4b9a6f42..4e1439cd 100644 --- a/src/types/selector.d.ts +++ b/src/types/selector.d.ts @@ -15,25 +15,25 @@ * limitations under the License. */ export type Service = { - id: string; + id?: string; label: string; value: string; - layers: string[]; - normal: boolean; - group: string; + layers?: string[]; + normal?: boolean; + group?: string; }; export type Instance = { value: string; label: string; - layer: string; - language: string; - instanceUUID: string; - attributes: { name: string; value: string }[]; + layer?: string; + language?: string; + instanceUUID?: string; + attributes?: { name: string; value: string }[]; }; export type Endpoint = { - id: string; + id?: string; label: string; value: string; }; diff --git a/src/views/dashboard/related/trace/Filter.vue b/src/views/dashboard/related/trace/Filter.vue index 6e88eff1..236697b1 100644 --- a/src/views/dashboard/related/trace/Filter.vue +++ b/src/views/dashboard/related/trace/Filter.vue @@ -14,7 +14,17 @@ See the License for the specific language governing permissions and limitations under the License. -->