feat: Add menus in side bar (#30)

This commit is contained in:
Fine0830 2022-03-21 15:36:56 +08:00 committed by GitHub
parent 42d8e909f6
commit 61f82c54df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 386 additions and 95 deletions

View File

@ -0,0 +1,17 @@
<!-- 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. -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<path d="M18.984 18q1.219 0 2.109-0.891t0.891-2.109-0.891-2.109-2.109-0.891h-1.5v-0.516q0-2.297-1.594-3.891t-3.891-1.594q-1.875 0-3.328 1.125t-1.969 2.859h-0.703q-1.641 0-2.813 1.195t-1.172 2.836 1.172 2.813 2.813 1.172h12.984zM19.359 10.031q1.922 0.141 3.281 1.57t1.359 3.398q0 2.063-1.477 3.539t-3.539 1.477h-12.984q-2.484 0-4.242-1.758t-1.758-4.242q0-2.203 1.57-3.961t3.773-1.992q0.984-1.828 2.766-2.953t3.891-1.125q2.531 0 4.711 1.781t2.648 4.266z"></path>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -0,0 +1,17 @@
<!-- 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. -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<path d="M16.359 14.016h3.375q0.281-1.313 0.281-2.016t-0.281-2.016h-3.375q0.141 0.984 0.141 2.016t-0.141 2.016zM14.578 19.547q1.172-0.375 2.438-1.43t1.922-2.133h-2.953q-0.469 1.875-1.406 3.563zM14.344 14.016q0.141-0.984 0.141-2.016t-0.141-2.016h-4.688q-0.141 0.984-0.141 2.016t0.141 2.016h4.688zM12 19.969q1.313-1.922 1.922-3.984h-3.844q0.609 2.063 1.922 3.984zM8.016 8.016q0.563-2.016 1.406-3.563-1.172 0.375-2.461 1.43t-1.898 2.133h2.953zM5.063 15.984q0.609 1.078 1.898 2.133t2.461 1.43q-0.938-1.688-1.406-3.563h-2.953zM4.266 14.016h3.375q-0.141-0.984-0.141-2.016t0.141-2.016h-3.375q-0.281 1.313-0.281 2.016t0.281 2.016zM12 4.031q-1.313 1.922-1.922 3.984h3.844q-0.609-2.063-1.922-3.984zM18.938 8.016q-0.656-1.078-1.922-2.133t-2.438-1.43q0.844 1.547 1.406 3.563h2.953zM12 2.016q4.125 0 7.055 2.93t2.93 7.055-2.93 7.055-7.055 2.93-7.055-2.93-2.93-7.055 2.93-7.055 7.055-2.93z"></path>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -0,0 +1,17 @@
<!-- 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. -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<path d="M19.5 9.516q1.031 0 1.758 0.727t0.727 1.758-0.727 1.758-1.758 0.727q-1.688 0-2.297-1.5h-2.906q-0.609 1.5-2.297 1.5t-2.297-1.5h-2.906q-0.609 1.5-2.297 1.5-1.031 0-1.758-0.727t-0.727-1.758 0.727-1.758 1.758-0.727q1.688 0 2.297 1.5h2.906q0.609-1.5 2.297-1.5t2.297 1.5h2.906q0.609-1.5 2.297-1.5z"></path>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -37,8 +37,8 @@ import { ref, watch } from "vue";
import type { PropType } from "vue"; import type { PropType } from "vue";
interface Option { interface Option {
label: string; label: string | number;
value: string; value: string | number;
} }
/*global defineProps, defineEmits*/ /*global defineProps, defineEmits*/
@ -49,11 +49,14 @@ const props = defineProps({
default: () => [], default: () => [],
}, },
value: { value: {
type: [Array, String, Number] as PropType<any>, type: [Array, String, Number, undefined] as PropType<any>,
default: () => [], default: () => [],
}, },
size: { type: null, default: "default" }, size: { type: null, default: "default" },
placeholder: { type: String, default: "Select a option" }, placeholder: {
type: [String, Number] as PropType<string | number>,
default: "Select a option",
},
borderRadius: { type: Number, default: 3 }, borderRadius: { type: Number, default: 3 },
multiple: { type: Boolean, default: false }, multiple: { type: Boolean, default: false },
disabled: { type: Boolean, default: false }, disabled: { type: Boolean, default: false },
@ -61,7 +64,7 @@ const props = defineProps({
const selected = ref<string[] | string>(props.value); const selected = ref<string[] | string>(props.value);
function changeSelected() { function changeSelected() {
const options = props.options.filter((d: Option) => const options = props.options.filter((d: any) =>
props.multiple props.multiple
? selected.value.includes(d.value) ? selected.value.includes(d.value)
: selected.value === d.value : selected.value === d.value

View File

@ -57,7 +57,7 @@ export function useQueryProcessor(config: any) {
variables.push(`$condition${index}: TopNCondition!`); variables.push(`$condition${index}: TopNCondition!`);
conditions[`condition${index}`] = { conditions[`condition${index}`] = {
name, name,
parentService: ["Service", "All"].includes(dashboardStore.entity) parentService: ["All"].includes(dashboardStore.entity)
? null ? null
: selectorStore.currentService.value, : selectorStore.currentService.value,
normal: selectorStore.currentService.normal, normal: selectorStore.currentService.normal,

View File

@ -33,13 +33,17 @@ limitations under the License. -->
<template v-for="(menu, index) in routes" :key="index"> <template v-for="(menu, index) in routes" :key="index">
<el-sub-menu :index="String(menu.name)" v-if="menu.meta.hasGroup"> <el-sub-menu :index="String(menu.name)" v-if="menu.meta.hasGroup">
<template #title> <template #title>
<router-link :to="menu.path" :exact="menu.meta.exact || false"> <router-link
class="items"
:to="menu.path"
:exact="menu.meta.exact || false"
>
<el-icon class="menu-icons" :style="{ marginRight: '12px' }"> <el-icon class="menu-icons" :style="{ marginRight: '12px' }">
<Icon size="lg" :iconName="menu.meta.icon" /> <Icon size="lg" :iconName="menu.meta.icon" />
</el-icon> </el-icon>
<span :class="isCollapse ? 'collapse' : ''">{{ <span :class="isCollapse ? 'collapse' : ''">
t(menu.meta.title) {{ t(menu.meta.title) }}
}}</span> </span>
</router-link> </router-link>
</template> </template>
<el-menu-item-group> <el-menu-item-group>
@ -48,7 +52,11 @@ limitations under the License. -->
:index="m.name" :index="m.name"
:key="idx" :key="idx"
> >
<router-link :to="m.path" :exact="m.meta.exact || false"> <router-link
class="items"
:to="m.path"
:exact="m.meta.exact || false"
>
<span>{{ t(m.meta.title) }}</span> <span>{{ t(m.meta.title) }}</span>
</router-link> </router-link>
</el-menu-item> </el-menu-item>
@ -59,13 +67,21 @@ limitations under the License. -->
@click="changePage(menu)" @click="changePage(menu)"
v-else v-else
> >
<el-icon class="menu-icons" :style="{ margin: '-10px 12px 0 0' }"> <el-icon class="menu-icons" :style="{ marginRight: '12px' }">
<router-link :to="menu.children[0].path" :exact="menu.meta.exact"> <router-link
class="items"
:to="menu.children[0].path"
:exact="menu.meta.exact"
>
<Icon size="lg" :iconName="menu.meta.icon" /> <Icon size="lg" :iconName="menu.meta.icon" />
</router-link> </router-link>
</el-icon> </el-icon>
<template #title> <template #title>
<router-link :to="menu.children[0].path" :exact="menu.meta.exact"> <router-link
class="items"
:to="menu.children[0].path"
:exact="menu.meta.exact"
>
<span>{{ t(menu.meta.title) }}</span> <span>{{ t(menu.meta.title) }}</span>
</router-link> </router-link>
</template> </template>
@ -99,7 +115,7 @@ const theme = ["VirtualMachine", "Kubernetes"].includes(name.value || "")
? ref("light") ? ref("light")
: ref("black"); : ref("black");
const routes = ref<any>(useRouter().options.routes); const routes = ref<any>(useRouter().options.routes);
const isCollapse = ref(true); const isCollapse = ref(false);
const controlMenu = () => { const controlMenu = () => {
isCollapse.value = !isCollapse.value; isCollapse.value = !isCollapse.value;
}; };
@ -172,4 +188,9 @@ span.collapse {
.el-icon.el-sub-menu__icon-arrow { .el-icon.el-sub-menu__icon-arrow {
height: 12px; height: 12px;
} }
.items {
display: inline-block;
width: 100%;
}
</style> </style>

View File

@ -113,6 +113,12 @@ const msg = {
noRoot: "Please set a root dashboard for", noRoot: "Please set a root dashboard for",
noWidget: "Please add widgets.", noWidget: "Please add widgets.",
rename: "Rename", rename: "Rename",
selfObservability: "Self Observability",
satellite: "Satellite",
skyWalkingServer: "Sky Walking Server",
functions: "Functions",
browser: "Browser",
linux: "Linux",
hourTip: "Select Hour", hourTip: "Select Hour",
minuteTip: "Select Minute", minuteTip: "Select Minute",
secondTip: "Select Second", secondTip: "Select Second",

View File

@ -113,6 +113,12 @@ const msg = {
showGroup: "显示分组", showGroup: "显示分组",
noWidget: "请添加组件", noWidget: "请添加组件",
rename: "重命名", rename: "重命名",
selfObservability: "自观性",
satellite: "Satellite",
skyWalkingServer: "Sky Walking服务",
functions: "Functions",
linux: "Linux",
browser: "浏览器",
hourTip: "选择小时", hourTip: "选择小时",
minuteTip: "选择分钟", minuteTip: "选择分钟",
secondTip: "选择秒数", secondTip: "选择秒数",

43
src/router/browser.ts Normal file
View File

@ -0,0 +1,43 @@
/**
* 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 { RouteRecordRaw } from "vue-router";
import Layout from "@/layout/Index.vue";
export const routesBrowser: Array<RouteRecordRaw> = [
{
path: "",
name: "Browser",
meta: {
title: "browser",
icon: "language",
},
redirect: "/browser",
component: Layout,
children: [
{
path: "/browser",
name: "Browser",
meta: {
title: "browser",
headPath: "/browser",
exact: true,
},
component: () => import("@/views/Layer.vue"),
},
],
},
];

View File

@ -23,7 +23,7 @@ export const routesDatabase: Array<RouteRecordRaw> = [
name: "Database", name: "Database",
meta: { meta: {
title: "database", title: "database",
icon: "epic", icon: "bar_chart",
}, },
redirect: "/database", redirect: "/database",
component: Layout, component: Layout,

43
src/router/functions.ts Normal file
View File

@ -0,0 +1,43 @@
/**
* 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 { RouteRecordRaw } from "vue-router";
import Layout from "@/layout/Index.vue";
export const routesFunctions: Array<RouteRecordRaw> = [
{
path: "",
name: "Functions",
meta: {
title: "functions",
icon: "cloud_queue",
},
redirect: "/functions",
component: Layout,
children: [
{
path: "/functions",
name: "Functions",
meta: {
title: "functions",
headPath: "/functions",
exact: true,
},
component: () => import("@/views/Layer.vue"),
},
],
},
];

View File

@ -23,12 +23,18 @@ import { routesDashboard } from "./dashboard";
import { routesEvent } from "./event"; import { routesEvent } from "./event";
import { routesSetting } from "./setting"; import { routesSetting } from "./setting";
import { routesAlarm } from "./alarm"; import { routesAlarm } from "./alarm";
import { routesSelf } from "./selfObservability";
import { routesFunctions } from "./functions";
import { routesBrowser } from "./browser";
const routes: Array<RouteRecordRaw> = [ const routes: Array<RouteRecordRaw> = [
...routesGen, ...routesGen,
...routesMesh, ...routesMesh,
...routesDatabase, ...routesFunctions,
...routesInfra, ...routesInfra,
...routesBrowser,
...routesDatabase,
...routesSelf,
...routesDashboard, ...routesDashboard,
...routesAlarm, ...routesAlarm,
...routesEvent, ...routesEvent,

View File

@ -27,24 +27,34 @@ export const routesInfra: Array<RouteRecordRaw> = [
exact: true, exact: true,
hasGroup: true, hasGroup: true,
}, },
redirect: "/infrastructure",
component: Layout, component: Layout,
children: [ children: [
{ {
path: "/infrastructure/vm", path: "/infrastructure",
name: "VirtualMachine", name: "Linux",
meta: { meta: {
title: "virtualMachine", title: "linux",
}, },
component: () => import("@/views/infrastructure/Infrastructure.vue"), component: () => import("@/views/Layer.vue"),
}, // component: () => import("@/views/infrastructure/Infrastructure.vue"),
{
path: "/infrastructure/k8s",
name: "Kubernetes",
meta: {
title: "kubernetes",
},
component: () => import("@/views/infrastructure/Infrastructure.vue"),
}, },
// {
// path: "/infrastructure/vm",
// name: "VirtualMachine",
// meta: {
// title: "virtualMachine",
// },
// component: () => import("@/views/infrastructure/Infrastructure.vue"),
// },
// {
// path: "/infrastructure/k8s",
// name: "Kubernetes",
// meta: {
// title: "kubernetes",
// },
// component: () => import("@/views/infrastructure/Infrastructure.vue"),
// },
], ],
}, },
]; ];

View File

@ -0,0 +1,52 @@
/**
* 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 { RouteRecordRaw } from "vue-router";
import Layout from "@/layout/Index.vue";
export const routesSelf: Array<RouteRecordRaw> = [
{
path: "",
name: "SelfObservability",
redirect: "/self/skyWalkingServer",
meta: {
title: "selfObservability",
icon: "logo",
hasGroup: true,
},
component: Layout,
children: [
{
path: "/self/skyWalkingServer",
name: "SkyWalkingServer",
meta: {
title: "skyWalkingServer",
headPath: "/mesh/services",
},
component: () => import("@/views/Layer.vue"),
},
{
path: "/self/satellite",
name: "Satellite",
meta: {
title: "satellite",
headPath: "/mesh/controlPanel",
},
component: () => import("@/views/Layer.vue"),
},
],
},
];

View File

@ -24,7 +24,7 @@ export const routesMesh: Array<RouteRecordRaw> = [
redirect: "/mesh/services", redirect: "/mesh/services",
meta: { meta: {
title: "serviceMesh", title: "serviceMesh",
icon: "bar_chart", icon: "epic",
hasGroup: true, hasGroup: true,
}, },
component: Layout, component: Layout,

View File

@ -34,6 +34,11 @@ const routeNames = [
"MeshServices", "MeshServices",
"ControlPanel", "ControlPanel",
"DataPanel", "DataPanel",
"Linux",
"SkyWalkingServer",
"Satellite",
"Functions",
"Browser",
]; ];
const layer = ref<string>("GENERAL"); const layer = ref<string>("GENERAL");
getDashboard(); getDashboard();
@ -69,6 +74,21 @@ function setLayer(n: string) {
case routeNames[4]: case routeNames[4]:
layer.value = "MESH_DP"; layer.value = "MESH_DP";
break; break;
case routeNames[5]:
layer.value = "OS_LINUX";
break;
case routeNames[6]:
layer.value = "SO11Y_OAP";
break;
case routeNames[7]:
layer.value = "SO11Y_SATELLITE";
break;
case routeNames[8]:
layer.value = "FAAS";
break;
case routeNames[9]:
layer.value = "BROWSER";
break;
default: default:
layer.value = "GENERAL"; layer.value = "GENERAL";
break; break;

View File

@ -57,7 +57,7 @@ limitations under the License. -->
<el-table-column label="Operations"> <el-table-column label="Operations">
<template #default="scope"> <template #default="scope">
<el-button size="small" @click="handleView(scope.row)"> <el-button size="small" @click="handleView(scope.row)">
{{ t("view") }} {{ t("edit") }}
</el-button> </el-button>
<el-button size="small" @click="handleEdit(scope.row)"> <el-button size="small" @click="handleEdit(scope.row)">
{{ t("rename") }} {{ t("rename") }}

View File

@ -90,12 +90,11 @@ import { useDashboardStore } from "@/store/modules/dashboard";
import { import {
MetricTypes, MetricTypes,
ListChartTypes, ListChartTypes,
MetricCatalog,
DefaultGraphConfig, DefaultGraphConfig,
EntityType, EntityType,
ChartTypes, ChartTypes,
PodsChartTypes, PodsChartTypes,
ListEntity, MetricsType,
} from "../../data"; } from "../../data";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
import Icon from "@/components/Icon.vue"; import Icon from "@/components/Icon.vue";
@ -134,13 +133,8 @@ states.visTypes = setVisTypes();
setDashboards(); setDashboards();
setMetricType(); setMetricType();
async function setMetricType(catalog?: string) { async function setMetricType() {
const { graph } = dashboardStore.selectedGrid; const { graph } = dashboardStore.selectedGrid;
if (states.isList) {
catalog = catalog || ListEntity[graph.type];
} else {
catalog = catalog || dashboardStore.entity;
}
const json = await dashboardStore.fetchMetricList(); const json = await dashboardStore.fetchMetricList();
if (json.errors) { if (json.errors) {
ElMessage.error(json.errors); ElMessage.error(json.errors);
@ -149,16 +143,11 @@ async function setMetricType(catalog?: string) {
states.metricList = (json.data.metrics || []).filter( states.metricList = (json.data.metrics || []).filter(
(d: { catalog: string; type: string }) => { (d: { catalog: string; type: string }) => {
if (states.isList || graph.type === "Table") { if (states.isList || graph.type === "Table") {
if ( if (d.type === MetricsType.REGULAR_VALUE) {
d.type === "REGULAR_VALUE" &&
catalog === (MetricCatalog as any)[d.catalog]
) {
return d; return d;
} }
} else { } else {
if (catalog === (MetricCatalog as any)[d.catalog]) { return d;
return d;
}
} }
} }
); );
@ -253,12 +242,7 @@ function changeChartType(item: Option) {
states.metrics = [""]; states.metrics = [""];
states.metricTypes = [""]; states.metricTypes = [""];
} }
const catalog: { [key: string]: string } = { setMetricType();
InstanceList: EntityType[3].value,
EndpointList: EntityType[2].value,
ServiceList: EntityType[0].value,
};
setMetricType(catalog[graph.type]);
setDashboards(); setDashboards();
states.dashboardName = ""; states.dashboardName = "";
} }
@ -367,7 +351,7 @@ function deleteMetric(index: number) {
states.metricTypes.splice(index, 1); states.metricTypes.splice(index, 1);
} }
function setMetricTypeList(type: string) { function setMetricTypeList(type: string) {
if (type !== "REGULAR_VALUE") { if (type !== MetricsType.REGULAR_VALUE) {
return MetricTypes[type]; return MetricTypes[type];
} }
if (states.isList || dashboardStore.selectedGrid.graph.type === "Table") { if (states.isList || dashboardStore.selectedGrid.graph.type === "Table") {

View File

@ -213,7 +213,7 @@ function handleNodeClick(d: Node & { x: number; y: number }) {
topologyStore.setNode(d); topologyStore.setNode(d);
topologyStore.setLink(null); topologyStore.setLink(null);
operationsPos.x = d.x; operationsPos.x = d.x;
operationsPos.y = d.y + 30; operationsPos.y = d.y - 70;
if (d.layer === String(dashboardStore.layerId)) { if (d.layer === String(dashboardStore.layerId)) {
return; return;
} }
@ -239,7 +239,9 @@ function handleLinkClick(event: any, d: Call) {
dashboardStore.entity === EntityType[1].value dashboardStore.entity === EntityType[1].value
? EntityType[0].value ? EntityType[0].value
: dashboardStore.entity; : dashboardStore.entity;
const path = `/dashboard/${dashboardStore.layerId}/${e}Relation/${d.source.id}/${d.target.id}/${settings.value.linkDashboard}`; const path = `/dashboard/${dashboardStore.layerId}/${e}Relation/${
d.source.id
}/${d.target.id}/${settings.value.linkDashboard.split(" ").join("-")}`;
const routeUrl = router.resolve({ path }); const routeUrl = router.resolve({ path });
window.open(routeUrl.href, "_blank"); window.open(routeUrl.href, "_blank");
} }
@ -371,19 +373,25 @@ async function handleInspect() {
update(); update();
} }
function handleGoEndpoint(name: string) { function handleGoEndpoint(name: string) {
const path = `/dashboard/${dashboardStore.layerId}/Endpoint/${topologyStore.node.id}/${name}`; const path = `/dashboard/${dashboardStore.layerId}/Endpoint/${
topologyStore.node.id
}/${name.split(" ").join("-")}`;
const routeUrl = router.resolve({ path }); const routeUrl = router.resolve({ path });
window.open(routeUrl.href, "_blank"); window.open(routeUrl.href, "_blank");
} }
function handleGoInstance(name: string) { function handleGoInstance(name: string) {
const path = `/dashboard/${dashboardStore.layerId}/ServiceInstance/${topologyStore.node.id}/${name}`; const path = `/dashboard/${dashboardStore.layerId}/ServiceInstance/${
topologyStore.node.id
}/${name.split(" ").join("-")}`;
const routeUrl = router.resolve({ path }); const routeUrl = router.resolve({ path });
window.open(routeUrl.href, "_blank"); window.open(routeUrl.href, "_blank");
} }
function handleGoDashboard(name: string) { function handleGoDashboard(name: string) {
const path = `/dashboard/${dashboardStore.layerId}/Service/${topologyStore.node.id}/${name}`; const path = `/dashboard/${dashboardStore.layerId}/Service/${
topologyStore.node.id
}/${name.split(" ").join("-")}`;
const routeUrl = router.resolve({ path }); const routeUrl = router.resolve({ path });
window.open(routeUrl.href, "_blank"); window.open(routeUrl.href, "_blank");

View File

@ -189,8 +189,8 @@ function selectNodeLink(d: any) {
} }
topologyStore.setNode(d.data); topologyStore.setNode(d.data);
topologyStore.setLink(null); topologyStore.setLink(null);
operationsPos.x = d.event.event.clientX; operationsPos.x = d.event.event.clientX - 200;
operationsPos.y = d.event.event.clientY; operationsPos.y = d.event.event.clientY - 150;
} }
async function changeDepth(opt: Option[] | any) { async function changeDepth(opt: Option[] | any) {

View File

@ -16,11 +16,12 @@ limitations under the License. -->
<div class="link-settings"> <div class="link-settings">
<h5 class="title">{{ t("callSettings") }}</h5> <h5 class="title">{{ t("callSettings") }}</h5>
<div class="label">{{ t("linkDashboard") }}</div> <div class="label">{{ t("linkDashboard") }}</div>
<el-input <Selector
v-model="states.linkDashboard" :value="states.linkDashboard"
placeholder="Please input a dashboard name for calls" :options="states.linkDashboards"
@change="updateSettings"
size="small" size="small"
placeholder="Please input a dashboard name for calls"
@change="changeLinkDashboard"
class="inputs" class="inputs"
/> />
<div class="label">{{ t("linkServerMetrics") }}</div> <div class="label">{{ t("linkServerMetrics") }}</div>
@ -51,16 +52,17 @@ limitations under the License. -->
<div class="node-settings"> <div class="node-settings">
<h5 class="title">{{ t("nodeSettings") }}</h5> <h5 class="title">{{ t("nodeSettings") }}</h5>
<div class="label">{{ t("nodeDashboard") }}</div> <div class="label">{{ t("nodeDashboard") }}</div>
<el-input <Selector
v-show="!isServer" v-show="!isService"
v-model="states.nodeDashboard" :value="states.nodeDashboard"
placeholder="Please input a dashboard name for nodes" :options="states.nodeDashboards"
@change="updateSettings"
size="small" size="small"
placeholder="Please input a dashboard name for nodes"
@change="changeNodeDashboard"
class="inputs" class="inputs"
/> />
<div <div
v-show="isServer" v-show="isService"
v-for="(item, index) in items" v-for="(item, index) in items"
:key="index" :key="index"
class="metric-item" class="metric-item"
@ -73,11 +75,12 @@ limitations under the License. -->
@change="changeScope(index, $event)" @change="changeScope(index, $event)"
class="item mr-5" class="item mr-5"
/> />
<el-input <Selector
v-model="item.dashboard" :value="item.dashboard"
:options="states.nodeDashboards"
size="small"
placeholder="Please input a dashboard name for nodes" placeholder="Please input a dashboard name for nodes"
@change="updateNodeDashboards(index, $event)" @change="updateNodeDashboards(index, $event)"
size="small"
class="item mr-5" class="item mr-5"
/> />
<span> <span>
@ -108,7 +111,7 @@ limitations under the License. -->
@change="changeNodeMetrics" @change="changeNodeMetrics"
/> />
</div> </div>
<div class="legend-settings" v-show="isServer"> <div class="legend-settings" v-show="isService">
<h5 class="title">{{ t("legendSettings") }}</h5> <h5 class="title">{{ t("legendSettings") }}</h5>
<div class="label">{{ t("conditions") }}</div> <div class="label">{{ t("conditions") }}</div>
<div v-for="(metric, index) of legend.metric" :key="metric.name + index"> <div v-for="(metric, index) of legend.metric" :key="metric.name + index">
@ -184,7 +187,8 @@ import { MetricCatalog, ScopeType, MetricConditions } from "../../../data";
import { Option } from "@/types/app"; import { Option } from "@/types/app";
import { useQueryTopologyMetrics } from "@/hooks/useProcessor"; import { useQueryTopologyMetrics } from "@/hooks/useProcessor";
import { Node, Call } from "@/types/topology"; import { Node, Call } from "@/types/topology";
import { EntityType, LegendOpt } from "../../../data"; import { DashboardItem } from "@/types/dashboard";
import { EntityType, LegendOpt, MetricsType } from "../../../data";
/*global defineEmits */ /*global defineEmits */
const emit = defineEmits(["update", "updateNodes"]); const emit = defineEmits(["update", "updateNodes"]);
@ -208,6 +212,8 @@ const states = reactive<{
nodeMetrics: string[]; nodeMetrics: string[];
nodeMetricList: Option[]; nodeMetricList: Option[];
linkMetricList: Option[]; linkMetricList: Option[];
linkDashboards: (DashboardItem & { label: string; value: string })[];
nodeDashboards: (DashboardItem & { label: string; value: string })[];
}>({ }>({
linkDashboard: "", linkDashboard: "",
nodeDashboard: [], nodeDashboard: [],
@ -216,8 +222,10 @@ const states = reactive<{
nodeMetrics: [], nodeMetrics: [],
nodeMetricList: [], nodeMetricList: [],
linkMetricList: [], linkMetricList: [],
linkDashboards: [],
nodeDashboards: [],
}); });
const isServer = [EntityType[0].value, EntityType[1].value].includes( const isService = [EntityType[0].value, EntityType[1].value].includes(
dashboardStore.entity dashboardStore.entity
); );
const legend = reactive<{ const legend = reactive<{
@ -226,6 +234,7 @@ const legend = reactive<{
getMetricList(); getMetricList();
async function getMetricList() { async function getMetricList() {
const list = JSON.parse(sessionStorage.getItem("dashboards") || "[]");
const json = await dashboardStore.fetchMetricList(); const json = await dashboardStore.fetchMetricList();
if (json.errors) { if (json.errors) {
ElMessage.error(json.errors); ElMessage.error(json.errors);
@ -237,18 +246,28 @@ async function getMetricList() {
: dashboardStore.entity === EntityType[4].value : dashboardStore.entity === EntityType[4].value
? EntityType[3].value ? EntityType[3].value
: dashboardStore.entity; : dashboardStore.entity;
states.nodeMetricList = (json.data.metrics || []).filter( states.linkDashboards = list.reduce(
(d: { catalog: string }) => entity === (MetricCatalog as any)[d.catalog] (
prev: (DashboardItem & { label: string; value: string })[],
d: DashboardItem
) => {
if (
d.layer === dashboardStore.layerId &&
d.entity === entity + "Relation"
) {
prev.push({ ...d, label: d.name, value: d.name });
}
return prev;
},
[]
);
states.nodeMetricList = (json.data.metrics || []).filter(
(d: { type: string }) => d.type === MetricsType.REGULAR_VALUE
); );
const e =
dashboardStore.entity === EntityType[1].value
? EntityType[0].value
: dashboardStore.entity === EntityType[4].value
? EntityType[3].value
: dashboardStore.entity;
states.linkMetricList = (json.data.metrics || []).filter( states.linkMetricList = (json.data.metrics || []).filter(
(d: { catalog: string }) => (d: { catalog: string; type: string }) =>
e + "Relation" === (MetricCatalog as any)[d.catalog] entity + "Relation" === (MetricCatalog as any)[d.catalog] &&
d.type === MetricsType.REGULAR_VALUE
); );
} }
async function setLegend() { async function setLegend() {
@ -259,7 +278,7 @@ async function setLegend() {
emit("update", { emit("update", {
linkDashboard: states.linkDashboard, linkDashboard: states.linkDashboard,
nodeDashboard: isServer nodeDashboard: isService
? items.filter((d: { scope: string; dashboard: string }) => d.dashboard) ? items.filter((d: { scope: string; dashboard: string }) => d.dashboard)
: states.nodeDashboard, : states.nodeDashboard,
linkServerMetrics: states.linkServerMetrics, linkServerMetrics: states.linkServerMetrics,
@ -276,15 +295,34 @@ async function setLegend() {
} }
emit("updateNodes"); emit("updateNodes");
} }
function changeNodeDashboard(opt: any) {
states.nodeDashboard = opt[0].value;
}
function changeLinkDashboard(opt: any) {
states.linkDashboard = opt[0].value;
}
function changeLegend(type: string, opt: any, index: number) { function changeLegend(type: string, opt: any, index: number) {
(legend.metric[index] as any)[type] = opt[0].value || opt; (legend.metric[index] as any)[type] = opt[0].value || opt;
} }
function changeScope(index: number, opt: Option[]) { function changeScope(index: number, opt: Option[] | any) {
items[index].scope = opt[0].value; items[index].scope = opt[0].value;
items[index].dashboard = ""; const list = JSON.parse(sessionStorage.getItem("dashboards") || "[]");
states.nodeDashboards = list.reduce(
(
prev: (DashboardItem & { label: string; value: string })[],
d: DashboardItem
) => {
if (d.layer === dashboardStore.layerId && d.entity === opt[0].value) {
prev.push({ ...d, label: d.name, value: d.name });
}
return prev;
},
[]
);
items[index].dashboard = states.nodeDashboards[0].value;
} }
function updateNodeDashboards(index: number, content: string) { function updateNodeDashboards(index: number, content: Option[] | any) {
items[index].dashboard = content; items[index].dashboard = content[0].value;
updateSettings(); updateSettings();
} }
function addItem() { function addItem() {
@ -297,7 +335,7 @@ function deleteItem(index: number) {
function updateSettings() { function updateSettings() {
emit("update", { emit("update", {
linkDashboard: states.linkDashboard, linkDashboard: states.linkDashboard,
nodeDashboard: isServer nodeDashboard: isService
? items.filter((d: { scope: string; dashboard: string }) => d.dashboard) ? items.filter((d: { scope: string; dashboard: string }) => d.dashboard)
: states.nodeDashboard, : states.nodeDashboard,
linkServerMetrics: states.linkServerMetrics, linkServerMetrics: states.linkServerMetrics,
@ -306,7 +344,7 @@ function updateSettings() {
legend: legend.metric, legend: legend.metric,
}); });
} }
async function changeLinkServerMetrics(options: Option[]) { async function changeLinkServerMetrics(options: Option[] | any) {
states.linkServerMetrics = options.map((d: Option) => d.value); states.linkServerMetrics = options.map((d: Option) => d.value);
updateSettings(); updateSettings();
if (!states.linkServerMetrics.length) { if (!states.linkServerMetrics.length) {
@ -323,7 +361,7 @@ async function changeLinkServerMetrics(options: Option[]) {
ElMessage.error(res.errors); ElMessage.error(res.errors);
} }
} }
async function changeLinkClientMetrics(options: Option[]) { async function changeLinkClientMetrics(options: Option[] | any) {
states.linkClientMetrics = options.map((d: Option) => d.value); states.linkClientMetrics = options.map((d: Option) => d.value);
updateSettings(); updateSettings();
if (!states.linkClientMetrics.length) { if (!states.linkClientMetrics.length) {
@ -340,7 +378,7 @@ async function changeLinkClientMetrics(options: Option[]) {
ElMessage.error(res.errors); ElMessage.error(res.errors);
} }
} }
async function changeNodeMetrics(options: Option[]) { async function changeNodeMetrics(options: Option[] | any) {
states.nodeMetrics = options.map((d: Option) => d.value); states.nodeMetrics = options.map((d: Option) => d.value);
updateSettings(); updateSettings();
if (!states.nodeMetrics.length) { if (!states.nodeMetrics.length) {