From 4dd198b9a6584de02cedc18f6d430427e5b4fa70 Mon Sep 17 00:00:00 2001 From: Qiuxia Fan Date: Tue, 26 Jul 2022 18:01:57 +0800 Subject: [PATCH] update --- src/hooks/useDashboardsSession.ts | 32 +++++++- src/views/dashboard/controls/Widget.vue | 2 +- src/views/dashboard/related/trace/Detail.vue | 55 +++----------- .../trace/components/D3Graph/SpanDetail.vue | 73 +++++-------------- 4 files changed, 58 insertions(+), 104 deletions(-) diff --git a/src/hooks/useDashboardsSession.ts b/src/hooks/useDashboardsSession.ts index e7c332b8..71e996a5 100644 --- a/src/hooks/useDashboardsSession.ts +++ b/src/hooks/useDashboardsSession.ts @@ -15,6 +15,8 @@ * limitations under the License. */ import { useDashboardStore } from "@/store/modules/dashboard"; +import { LayoutConfig } from "@/types/dashboard"; + export default function getDashboard(param: { name: string; layer: string; @@ -29,7 +31,7 @@ export default function getDashboard(param: { d.layer === param.layer ); const all = dashboardStore.layout; - const widgets = []; + const widgets: LayoutConfig[] = []; for (const item of all) { if (item.type === "Tab") { if (item.children && item.children.length) { @@ -43,5 +45,31 @@ export default function getDashboard(param: { widgets.push(item); } } - return { dashboard, widgets }; + function associationWidget(sourceId: string, filters: unknown, type: string) { + const widget = widgets.filter((d: { type: string }) => d.type === type)[0]; + if (!widget) { + return; + } + const item = { + ...widget, + filters, + }; + dashboardStore.setWidget(item); + const targetTabIndex = (widget.id || "").split("-"); + const sourceTabindex = (sourceId || "").split("-") || []; + let container: Nullable; + + if (targetTabIndex[1] === undefined) { + container = document.querySelector(".ds-main"); + } else { + container = document.querySelector(".tab-layout"); + } + if (targetTabIndex[1] && targetTabIndex[1] !== sourceTabindex[1]) { + dashboardStore.setActiveTabIndex(Number(targetTabIndex[1])); + } + if (container && widget) { + container.scrollTop = widget.y * 10; + } + } + return { dashboard, widgets, associationWidget }; } diff --git a/src/views/dashboard/controls/Widget.vue b/src/views/dashboard/controls/Widget.vue index 1598e87c..c1653891 100644 --- a/src/views/dashboard/controls/Widget.vue +++ b/src/views/dashboard/controls/Widget.vue @@ -168,7 +168,7 @@ export default defineComponent({ for (const item of associate) { const widget = widgets.find( - (d: { id: string }) => d.id === item.widgetId + (d: LayoutConfig) => d.id === item.widgetId ); if (widget) { widget.filters = { diff --git a/src/views/dashboard/related/trace/Detail.vue b/src/views/dashboard/related/trace/Detail.vue index 7806bec0..c725442d 100644 --- a/src/views/dashboard/related/trace/Detail.vue +++ b/src/views/dashboard/related/trace/Detail.vue @@ -121,7 +121,7 @@ limitations under the License. -->