From b9b41f8627d5671803b34923effac4b31f834f26 Mon Sep 17 00:00:00 2001 From: Fine Date: Wed, 10 Aug 2022 16:30:22 +0800 Subject: [PATCH] add metrics panel --- src/store/modules/ebpf.ts | 16 ++ src/views/dashboard/controls/Tab.vue | 22 +- src/views/dashboard/controls/tab.ts | 39 ++++ src/views/dashboard/graphs/topology.ts | 32 +++ .../components/metrics-panel/Index.vue | 65 ++++++ .../components/metrics-panel/MetricWidget.vue | 216 ++++++++++++++++++ 6 files changed, 370 insertions(+), 20 deletions(-) create mode 100644 src/views/dashboard/controls/tab.ts create mode 100644 src/views/dashboard/graphs/topology.ts create mode 100644 src/views/dashboard/related/network-profiling/components/metrics-panel/Index.vue create mode 100644 src/views/dashboard/related/network-profiling/components/metrics-panel/MetricWidget.vue diff --git a/src/store/modules/ebpf.ts b/src/store/modules/ebpf.ts index 94778da8..e5f0646a 100644 --- a/src/store/modules/ebpf.ts +++ b/src/store/modules/ebpf.ts @@ -27,6 +27,7 @@ import { store } from "@/store"; import graphql from "@/graphql"; import { AxiosResponse } from "axios"; import { Call } from "@/types/topology"; +import { LayoutConfig } from "@/types/dashboard"; interface EbpfStore { taskList: EBPFTaskList[]; networkTasks: EBPFTaskList[]; @@ -44,6 +45,9 @@ interface EbpfStore { calls: Call[]; node: Nullable; call: Nullable; + metricsLayout: LayoutConfig[]; + selectedMetric: Nullable; + activeMetricIndex: string; } export const ebpfStore = defineStore({ @@ -65,6 +69,9 @@ export const ebpfStore = defineStore({ calls: [], node: null, call: null, + metricsLayout: [], + selectedMetric: null, + activeMetricIndex: "", }), actions: { setSelectedTask(task: EBPFTaskList) { @@ -85,6 +92,15 @@ export const ebpfStore = defineStore({ setLink(link: Call) { this.call = link; }, + setMetricsLayout(layout: LayoutConfig[]) { + this.metricsLayout = layout; + }, + setSelectedMetric(item: LayoutConfig) { + this.selectedMetric = item; + }, + setActiveItem(index: string) { + this.activeMetricIndex = index; + }, setTopology(data: { nodes: ProcessNode[]; calls: Call[] }) { const obj = {} as any; const calls = (data.calls || []).reduce((prev: Call[], next: Call) => { diff --git a/src/views/dashboard/controls/Tab.vue b/src/views/dashboard/controls/Tab.vue index 74a71907..2188862e 100644 --- a/src/views/dashboard/controls/Tab.vue +++ b/src/views/dashboard/controls/Tab.vue @@ -110,17 +110,8 @@ import { useRoute } from "vue-router"; import type { PropType } from "vue"; import { LayoutConfig } from "@/types/dashboard"; import { useDashboardStore } from "@/store/modules/dashboard"; -import Topology from "./Topology.vue"; -import Widget from "./Widget.vue"; -import Trace from "./Trace.vue"; -import Profile from "./Profile.vue"; -import Log from "./Log.vue"; -import Text from "./Text.vue"; -import Ebpf from "./Ebpf.vue"; -import Event from "./Event.vue"; -import NetworkProfiling from "./NetworkProfiling.vue"; +import controls from "./tab"; import { dragIgnoreFrom } from "../data"; -import DemandLog from "./DemandLog.vue"; import copy from "@/utils/copy"; const props = { @@ -133,16 +124,7 @@ const props = { export default defineComponent({ name: "Tab", components: { - Topology, - Widget, - Trace, - Profile, - Log, - Text, - Ebpf, - DemandLog, - Event, - NetworkProfiling, + ...controls, }, props, setup(props) { diff --git a/src/views/dashboard/controls/tab.ts b/src/views/dashboard/controls/tab.ts new file mode 100644 index 00000000..90c33ed7 --- /dev/null +++ b/src/views/dashboard/controls/tab.ts @@ -0,0 +1,39 @@ +/** + * 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 Topology from "./Topology.vue"; +import Widget from "./Widget.vue"; +import Trace from "./Trace.vue"; +import Profile from "./Profile.vue"; +import Log from "./Log.vue"; +import Text from "./Text.vue"; +import Ebpf from "./Ebpf.vue"; +import DemandLog from "./DemandLog.vue"; +import Event from "./Event.vue"; +import NetworkProfiling from "./NetworkProfiling.vue"; + +export default { + Widget, + Trace, + Topology, + Profile, + Log, + Text, + Ebpf, + DemandLog, + Event, + NetworkProfiling, +}; diff --git a/src/views/dashboard/graphs/topology.ts b/src/views/dashboard/graphs/topology.ts new file mode 100644 index 00000000..0b576ce2 --- /dev/null +++ b/src/views/dashboard/graphs/topology.ts @@ -0,0 +1,32 @@ +/** + * 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 Area from "./Area.vue"; +import Line from "./Line.vue"; +import Bar from "./Bar.vue"; +import TopList from "./TopList.vue"; +import Table from "./Table.vue"; +import Card from "./Card.vue"; + +export default { + Line, + Bar, + TopList, + Area, + Table, + Card, +}; diff --git a/src/views/dashboard/related/network-profiling/components/metrics-panel/Index.vue b/src/views/dashboard/related/network-profiling/components/metrics-panel/Index.vue new file mode 100644 index 00000000..40755247 --- /dev/null +++ b/src/views/dashboard/related/network-profiling/components/metrics-panel/Index.vue @@ -0,0 +1,65 @@ + + + diff --git a/src/views/dashboard/related/network-profiling/components/metrics-panel/MetricWidget.vue b/src/views/dashboard/related/network-profiling/components/metrics-panel/MetricWidget.vue new file mode 100644 index 00000000..feaea61d --- /dev/null +++ b/src/views/dashboard/related/network-profiling/components/metrics-panel/MetricWidget.vue @@ -0,0 +1,216 @@ + + + +