From 8e56cf2686d1c0f6ad66490d9dd6f8f4eddeb06e Mon Sep 17 00:00:00 2001 From: Qiuxia Fan Date: Tue, 24 May 2022 17:35:44 +0800 Subject: [PATCH] update header --- src/locales/lang/en.ts | 1 + src/locales/lang/es.ts | 1 + src/locales/lang/zh.ts | 1 + src/store/modules/demand-log.ts | 55 +++++++----- src/types/app.d.ts | 4 + src/types/demand-log.ts | 33 +++++++ src/views/dashboard/controls/DemandLog.vue | 8 +- src/views/dashboard/controls/Tab.vue | 8 +- src/views/dashboard/data.ts | 1 + .../dashboard/related/demand-log/Content.vue | 17 ++++ .../related/{demand => demand-log}/Header.vue | 86 ++++++++++--------- .../dashboard/related/demand-log/data.ts | 28 ++++++ .../related/ebpf/components/EBPFStack.vue | 1 - 13 files changed, 178 insertions(+), 66 deletions(-) create mode 100644 src/types/demand-log.ts create mode 100644 src/views/dashboard/related/demand-log/Content.vue rename src/views/dashboard/related/{demand => demand-log}/Header.vue (87%) create mode 100644 src/views/dashboard/related/demand-log/data.ts diff --git a/src/locales/lang/en.ts b/src/locales/lang/en.ts index d3acc4d2..efff77c9 100644 --- a/src/locales/lang/en.ts +++ b/src/locales/lang/en.ts @@ -139,6 +139,7 @@ const msg = { container: "Container", limit: "Limit", page: "Page", + interval: "Refresh Interval", hourTip: "Select Hour", minuteTip: "Select Minute", secondTip: "Select Second", diff --git a/src/locales/lang/es.ts b/src/locales/lang/es.ts index 8337ebe5..b83acd75 100644 --- a/src/locales/lang/es.ts +++ b/src/locales/lang/es.ts @@ -139,6 +139,7 @@ const msg = { ebpfTip: "Le falta el proceso para perfilar", processSelect: "Click para seleccionar proceso", page: "Página", + interval: "Intervalo de actualización", hourTip: "Seleccione Hora", minuteTip: "Seleccione Minuto", secondTip: "Seleccione Segundo", diff --git a/src/locales/lang/zh.ts b/src/locales/lang/zh.ts index c7a17782..aa725ae8 100644 --- a/src/locales/lang/zh.ts +++ b/src/locales/lang/zh.ts @@ -137,6 +137,7 @@ const msg = { container: "容器", limit: "范围", page: "页面", + interval: "刷新间隔时间", hourTip: "选择小时", minuteTip: "选择分钟", secondTip: "选择秒数", diff --git a/src/store/modules/demand-log.ts b/src/store/modules/demand-log.ts index b555635a..af8d8c29 100644 --- a/src/store/modules/demand-log.ts +++ b/src/store/modules/demand-log.ts @@ -21,22 +21,26 @@ import graphql from "@/graphql"; import { AxiosResponse } from "axios"; import { useAppStoreWithOut } from "@/store/modules/app"; import { useSelectorStore } from "@/store/modules/selectors"; +import { Conditions, DemandLog } from "@/types/demand-log"; interface DemandLogState { containers: Instance[]; instances: Instance[]; - conditions: any; + conditions: Conditions; selectorStore: any; - logs: any[]; + logs: DemandLog[]; loadLogs: boolean; } export const demandLogStore = defineStore({ id: "demandLog", state: (): DemandLogState => ({ - containers: [{ value: "0", label: "All" }], - instances: [{ value: "0", label: "All" }], + containers: [{ value: "0", label: "" }], + instances: [{ value: "0", label: "" }], conditions: { + container: "", + serviceId: "", + serviceInstanceId: "", queryDuration: useAppStoreWithOut().durationTime, paging: { pageNum: 1, pageSize: 15 }, }, @@ -48,16 +52,6 @@ export const demandLogStore = defineStore({ 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 @@ -70,16 +64,37 @@ export const demandLogStore = defineStore({ if (res.data.errors) { return res.data; } - this.instances = [ - { value: "0", label: "All" }, - ...res.data.data.pods, - ] || [{ value: " 0", label: "All" }]; + this.instances = res.data.data.pods || []; return res.data; }, - async getLogs() { + async getContainers(instanceId?: string) { + const serviceId = + this.selectorStore.currentService && + this.selectorStore.currentService.id; + const serviceInstanceId = + instanceId || + (this.selectorStore.currentInstance && + this.selectorStore.currentInstance.id); + const condition = { + serviceId, + serviceInstanceId, + }; + const res: AxiosResponse = await graphql.query("fetchContainers").params({ + condition, + }); + + if (res.data.errors) { + return res.data; + } + this.containers = res.data.data.containers.containers.map((d: string) => { + return { label: d, value: d }; + }) || [{ label: "Detail", value: "Detail" }]; + return res.data; + }, + async getDemandLogs() { this.loadLogs = true; const res: AxiosResponse = await graphql - .query("queryServiceLogs") + .query("fetchStreamingLogs") .params({ condition: this.conditions }); this.loadLogs = false; if (res.data.errors) { diff --git a/src/types/app.d.ts b/src/types/app.d.ts index 74e69c32..ee35299a 100644 --- a/src/types/app.d.ts +++ b/src/types/app.d.ts @@ -28,3 +28,7 @@ export interface DurationTime { end: string; step: string; } +export type Paging = { + pageNum: number; + pageSize: number; +}; diff --git a/src/types/demand-log.ts b/src/types/demand-log.ts new file mode 100644 index 00000000..a685792a --- /dev/null +++ b/src/types/demand-log.ts @@ -0,0 +1,33 @@ +/** + * 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 { DurationTime, Paging } from "./app"; + +export interface Conditions { + container: string; + serviceId: string; + serviceInstanceId: string; + queryDuration: DurationTime; + paging: Paging; + keywordsOfContent?: string[]; + excludingKeywordsOfContent?: string; +} + +export interface DemandLog { + content: string; + timestamp: number; + contentType: string; +} diff --git a/src/views/dashboard/controls/DemandLog.vue b/src/views/dashboard/controls/DemandLog.vue index aa83519c..b46f057e 100644 --- a/src/views/dashboard/controls/DemandLog.vue +++ b/src/views/dashboard/controls/DemandLog.vue @@ -32,12 +32,16 @@ limitations under the License. -->
+
+ +