diff --git a/src/views/dashboard/List.vue b/src/views/dashboard/List.vue index 50bb9702..fe56d192 100644 --- a/src/views/dashboard/List.vue +++ b/src/views/dashboard/List.vue @@ -39,14 +39,14 @@ limitations under the License. --> - + {{ t("view") }} - + {{ t("edit") }} diff --git a/src/views/dashboard/configuration/ConfigEdit.vue b/src/views/dashboard/configuration/ConfigEdit.vue index 5c5e5f63..c2bbd49f 100644 --- a/src/views/dashboard/configuration/ConfigEdit.vue +++ b/src/views/dashboard/configuration/ConfigEdit.vue @@ -60,10 +60,10 @@ limitations under the License. --> diff --git a/src/views/dashboard/data.ts b/src/views/dashboard/data.ts index f651d6ee..d0a93443 100644 --- a/src/views/dashboard/data.ts +++ b/src/views/dashboard/data.ts @@ -142,7 +142,7 @@ export enum MetricCatalog { export const EntityType = [ { value: "Service", label: "Service", key: 1 }, { value: "All", label: "All", key: 10 }, - { value: "Endpoint", label: "Service Endpoint", key: 3 }, + { value: "Endpoint", label: "Endpoint", key: 3 }, { value: "ServiceInstance", label: "Service Instance", key: 3 }, { value: "ServiceRelation", label: "Service Relation", key: 2 }, { @@ -172,3 +172,8 @@ export const ToolIcons = [ { name: "device_hub", content: "Topology", id: "topology" }, // { name: "save", content: "Apply", id: "apply" }, ]; +export const ScopeType = [ + { value: "Service", label: "Service", key: 1 }, + { value: "Endpoint", label: "Endpoint", key: 3 }, + { value: "ServiceInstance", label: "Service Instance", key: 3 }, +]; diff --git a/src/views/dashboard/related/topology/components/Graph.vue b/src/views/dashboard/related/topology/components/Graph.vue index 395b99a0..53066e16 100644 --- a/src/views/dashboard/related/topology/components/Graph.vue +++ b/src/views/dashboard/related/topology/components/Graph.vue @@ -42,7 +42,11 @@ limitations under the License. --> left: operationsPos.x + 'px', }" > - + {{ item.title }} @@ -88,7 +92,9 @@ const legend = ref(null); const showSetting = ref(false); const settings = ref({}); const operationsPos = reactive<{ x: number; y: number }>({ x: NaN, y: NaN }); -const items = ref([ +const items = ref< + { id: string; title: string; func: any; dashboard?: string }[] +>([ { id: "inspect", title: "Inspect", func: handleInspect }, { id: "alarm", title: "Alarm", func: handleGoAlarm }, ]); @@ -334,20 +340,20 @@ async function handleInspect() { await init(); update(); } -function handleGoEndpoint() { - const path = `/dashboard/${dashboardStore.layerId}/Endpoint/${topologyStore.node.id}/${settings.value.endpointDashboard}`; +function handleGoEndpoint(name: string) { + const path = `/dashboard/${dashboardStore.layerId}/Endpoint/${topologyStore.node.id}/${name}`; const routeUrl = router.resolve({ path }); window.open(routeUrl.href, "_blank"); } -function handleGoInstance() { - const path = `/dashboard/${dashboardStore.layerId}/ServiceInstance/${topologyStore.node.id}/${settings.value.instanceDashboard}`; +function handleGoInstance(name: string) { + const path = `/dashboard/${dashboardStore.layerId}/ServiceInstance/${topologyStore.node.id}/${name}`; const routeUrl = router.resolve({ path }); window.open(routeUrl.href, "_blank"); } -function handleGoDashboard() { - const path = `/dashboard/${dashboardStore.layerId}/Service/${topologyStore.node.id}/${settings.value.nodeDashboard}`; +function handleGoDashboard(name: string) { + const path = `/dashboard/${dashboardStore.layerId}/Service/${topologyStore.node.id}/${name}`; const routeUrl = router.resolve({ path }); window.open(routeUrl.href, "_blank"); @@ -400,26 +406,31 @@ function updateSettings(config: any) { { id: "alarm", title: "Alarm", func: handleGoAlarm }, ]; settings.value = config; - if (config.nodeDashboard) { - items.value.push({ - id: "dashboard", - title: "View Dashboard", - func: handleGoDashboard, - }); - } - if (config.instanceDashboard) { - items.value.push({ - id: "instance", - title: "Instance", - func: handleGoInstance, - }); - } - if (config.endpointDashboard) { - items.value.push({ - id: "endpoint", - title: "Endpoint", - func: handleGoEndpoint, - }); + for (const item of config.nodeDashboard) { + if (item.scope === EntityType[0].value) { + items.value.push({ + id: "dashboard", + title: "Dashboard", + func: handleGoDashboard, + ...item, + }); + } + if (item.scope === EntityType[2].value) { + items.value.push({ + id: "endpoint", + title: "Endpoint", + func: handleGoEndpoint, + ...item, + }); + } + if (item.scope === EntityType[3].value) { + items.value.push({ + id: "instance", + title: "Service Instance", + func: handleGoInstance, + ...item, + }); + } } } onBeforeUnmount(() => { diff --git a/src/views/dashboard/related/topology/components/Settings.vue b/src/views/dashboard/related/topology/components/Settings.vue index 544a1a9d..b315624f 100644 --- a/src/views/dashboard/related/topology/components/Settings.vue +++ b/src/views/dashboard/related/topology/components/Settings.vue @@ -51,31 +51,39 @@ limitations under the License. --> {{ t("nodeSettings") }} {{ t("nodeDashboard") }} - - - {{ t("instanceDashboard") }} - + - {{ t("endpointDashboard") }} - + + + + + {{ t("nodeMetrics") }} ([{ scope: "", dashboard: "" }]); const states = reactive<{ linkDashboard: string; nodeDashboard: string; - instanceDashboard: string; - endpointDashboard: string; linkServerMetrics: string[]; linkClientMetrics: string[]; nodeMetrics: string[]; @@ -118,17 +130,12 @@ const states = reactive<{ }>({ linkDashboard: "", nodeDashboard: "", - instanceDashboard: "", - endpointDashboard: "", linkServerMetrics: [], linkClientMetrics: [], nodeMetrics: [], nodeMetricList: [], linkMetricList: [], }); -const isService = ref( - [EntityType[1].value, EntityType[0].value].includes(dashboardStore.entity) -); getMetricList(); async function getMetricList() { @@ -152,12 +159,27 @@ async function getMetricList() { e + "Relation" === (MetricCatalog as any)[d.catalog] ); } +function changeScope(index: number, opt: Option[]) { + items[index].scope = opt[0].value; + items[index].dashboard = ""; +} +function updateNodeDashboards(index: number, content: string) { + items[index].dashboard = content; + updateSettings(); +} +function addItem() { + items.push({ scope: "", dashboard: "" }); +} +function deleteItem(index: number) { + items.splice(index, 1); + updateSettings(); +} function updateSettings() { emit("update", { linkDashboard: states.linkDashboard, - nodeDashboard: states.nodeDashboard, - endpointDashboard: states.endpointDashboard, - instanceDashboard: states.instanceDashboard, + nodeDashboard: items.filter( + (d: { scope: string; dashboard: string }) => d.dashboard + ), linkServerMetrics: states.linkServerMetrics, linkClientMetrics: states.linkClientMetrics, nodeMetrics: states.nodeMetrics, @@ -223,6 +245,11 @@ async function changeNodeMetrics(options: Option[]) { width: 330px; } +.item { + width: 137px; + margin: 5px 5px 0 0; +} + .title { margin-bottom: 0; }