From bc5a8f4274d9375ad27961e347aaa5f416c2f74f Mon Sep 17 00:00:00 2001 From: Qiuxia Fan Date: Thu, 19 May 2022 18:26:33 +0800 Subject: [PATCH] add demand log store --- src/store/modules/demand-log.ts | 97 +++++++++++++ src/views/dashboard/related/demand/Header.vue | 131 ++++-------------- 2 files changed, 125 insertions(+), 103 deletions(-) create mode 100644 src/store/modules/demand-log.ts diff --git a/src/store/modules/demand-log.ts b/src/store/modules/demand-log.ts new file mode 100644 index 00000000..ca70cf62 --- /dev/null +++ b/src/store/modules/demand-log.ts @@ -0,0 +1,97 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { defineStore } from "pinia"; +import { Instance, Service } from "@/types/selector"; +import { store } from "@/store"; +import graphql from "@/graphql"; +import { AxiosResponse } from "axios"; +import { useAppStoreWithOut } from "@/store/modules/app"; +import { useSelectorStore } from "@/store/modules/selectors"; + +interface DemandLogState { + services: Service[]; + instances: Instance[]; + conditions: any; + selectorStore: any; + logs: any[]; + loadLogs: boolean; +} + +export const demandLogStore = defineStore({ + id: "demandLog", + state: (): DemandLogState => ({ + services: [{ value: "0", label: "All" }], + instances: [{ value: "0", label: "All" }], + conditions: { + queryDuration: useAppStoreWithOut().durationTime, + paging: { pageNum: 1, pageSize: 15 }, + }, + selectorStore: useSelectorStore(), + logs: [], + loadLogs: false, + }), + actions: { + setLogCondition(data: any) { + this.conditions = { ...this.conditions, ...data }; + }, + async getServices(layer: string) { + const res: AxiosResponse = await graphql.query("queryServices").params({ + layer, + }); + if (res.data.errors) { + return res.data; + } + this.services = res.data.data.services; + return res.data; + }, + async getInstances(id: string) { + const serviceId = this.selectorStore.currentService + ? this.selectorStore.currentService.id + : id; + const res: AxiosResponse = await graphql.query("queryInstances").params({ + serviceId, + duration: useAppStoreWithOut().durationTime, + }); + + if (res.data.errors) { + return res.data; + } + this.instances = [ + { value: "0", label: "All" }, + ...res.data.data.pods, + ] || [{ value: " 0", label: "All" }]; + return res.data; + }, + async getLogs() { + this.loadLogs = true; + const res: AxiosResponse = await graphql + .query("queryServiceLogs") + .params({ condition: this.conditions }); + this.loadLogs = false; + if (res.data.errors) { + return res.data; + } + + this.logs = res.data.data.queryLogs.logs; + return res.data; + }, + }, +}); + +export function useDemandLogStore(): any { + return demandLogStore(store); +} diff --git a/src/views/dashboard/related/demand/Header.vue b/src/views/dashboard/related/demand/Header.vue index 330f729c..068be655 100644 --- a/src/views/dashboard/related/demand/Header.vue +++ b/src/views/dashboard/related/demand/Header.vue @@ -19,18 +19,19 @@ limitations under the License. -->
{{ t("limit") }}: -
@@ -43,18 +44,8 @@ limitations under the License. --> {{ t("search") }} -
-
- {{ t("traceID") }}: - -
- -
-
- {{ t("conditionNotice") }} -
-
-
+
+
{{ t("keywordsOfContent") }}: @change="addLabels('keywordsOfContent')" />
-
+
{{ t("excludingKeywordsOfContent") }}: @change="addLabels('excludingKeywordsOfContent')" /> - + @@ -106,12 +97,10 @@ limitations under the License. -->