mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-12 07:36:14 +00:00
feat: add node layers
This commit is contained in:
parent
860af150f7
commit
3c282d021b
@ -23,6 +23,7 @@ export const ServicesTopology = {
|
|||||||
name
|
name
|
||||||
type
|
type
|
||||||
isReal
|
isReal
|
||||||
|
layers
|
||||||
}
|
}
|
||||||
calls {
|
calls {
|
||||||
id
|
id
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import { store } from "@/store";
|
import { store } from "@/store";
|
||||||
import type { Service } from "@/types/selector";
|
|
||||||
import type { Node, Call, HierarchyNode, ServiceHierarchy, InstanceHierarchy } from "@/types/topology";
|
import type { Node, Call, HierarchyNode, ServiceHierarchy, InstanceHierarchy } from "@/types/topology";
|
||||||
import graphql from "@/graphql";
|
import graphql from "@/graphql";
|
||||||
import { useSelectorStore } from "@/store/modules/selectors";
|
import { useSelectorStore } from "@/store/modules/selectors";
|
||||||
@ -92,7 +91,7 @@ export const topologyStore = defineStore({
|
|||||||
const nodes = (data.nodes || []).reduce((prev: Node[], next: Node) => {
|
const nodes = (data.nodes || []).reduce((prev: Node[], next: Node) => {
|
||||||
if (!obj[next.id]) {
|
if (!obj[next.id]) {
|
||||||
obj[next.id] = true;
|
obj[next.id] = true;
|
||||||
const s = services.filter((d: Service) => d.id === next.id)[0] || {};
|
const s = services.filter((d: any) => d.id === next.id)[0] || {};
|
||||||
next.layer = s.layers ? s.layers[0] : null;
|
next.layer = s.layers ? s.layers[0] : null;
|
||||||
prev.push(next);
|
prev.push(next);
|
||||||
}
|
}
|
||||||
|
1
src/types/topology.d.ts
vendored
1
src/types/topology.d.ts
vendored
@ -44,6 +44,7 @@ export interface Node {
|
|||||||
type: string;
|
type: string;
|
||||||
isReal: boolean;
|
isReal: boolean;
|
||||||
layer?: string;
|
layer?: string;
|
||||||
|
layers: string[];
|
||||||
serviceName?: string;
|
serviceName?: string;
|
||||||
height?: number;
|
height?: number;
|
||||||
width?: number;
|
width?: number;
|
||||||
|
@ -124,7 +124,7 @@ limitations under the License. -->
|
|||||||
left: operationsPos.x + 5 + 'px',
|
left: operationsPos.x + 5 + 'px',
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<span v-for="(item, index) of items" :key="index" @click="item.func(item.dashboard)">
|
<span v-for="(item, index) of items" :key="index" @click="item.func(item)">
|
||||||
{{ item.title }}
|
{{ item.title }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@ -160,6 +160,7 @@ limitations under the License. -->
|
|||||||
import { layout, computeLevels, changeNode } from "../components/utils/layout";
|
import { layout, computeLevels, changeNode } from "../components/utils/layout";
|
||||||
import zoom from "@/views/dashboard/related/components/utils/zoom";
|
import zoom from "@/views/dashboard/related/components/utils/zoom";
|
||||||
import { useQueryTopologyExpressionsProcessor } from "@/hooks/useExpressionsProcessor";
|
import { useQueryTopologyExpressionsProcessor } from "@/hooks/useExpressionsProcessor";
|
||||||
|
import { ConfigFieldTypes } from "@/views/dashboard/data";
|
||||||
/*global Nullable, defineProps */
|
/*global Nullable, defineProps */
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
config: {
|
config: {
|
||||||
@ -414,11 +415,7 @@ limitations under the License. -->
|
|||||||
setNodeTools(settings.value.nodeDashboard);
|
setNodeTools(settings.value.nodeDashboard);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
items.value = [
|
initNodeMenus();
|
||||||
{ id: "hierarchyServices", title: "Hierarchy Services", func: handleHierarchyRelatedServices },
|
|
||||||
{ id: "inspect", title: "Inspect", func: handleInspect },
|
|
||||||
{ id: "alerting", title: "Alerting", func: handleGoAlerting },
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
function handleLinkClick(event: MouseEvent, d: Call) {
|
function handleLinkClick(event: MouseEvent, d: Call) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
@ -462,25 +459,34 @@ limitations under the License. -->
|
|||||||
topologyStore.setNode(null);
|
topologyStore.setNode(null);
|
||||||
topologyStore.setLink(null);
|
topologyStore.setLink(null);
|
||||||
}
|
}
|
||||||
function handleGoEndpoint(name: string) {
|
function handleGoEndpoint(params: { dashboard: string }) {
|
||||||
|
if (!params.dashboard) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const origin = dashboardStore.entity;
|
const origin = dashboardStore.entity;
|
||||||
const path = `/dashboard/${dashboardStore.layerId}/${EntityType[2].value}/${topologyStore.node.id}/${name}`;
|
const path = `/dashboard/${dashboardStore.layerId}/${EntityType[2].value}/${topologyStore.node.id}/${params.dashboard}`;
|
||||||
const routeUrl = router.resolve({ path });
|
const routeUrl = router.resolve({ path });
|
||||||
|
|
||||||
window.open(routeUrl.href, "_blank");
|
window.open(routeUrl.href, "_blank");
|
||||||
dashboardStore.setEntity(origin);
|
dashboardStore.setEntity(origin);
|
||||||
}
|
}
|
||||||
function handleGoInstance(name: string) {
|
function handleGoInstance(params: { dashboard: string }) {
|
||||||
|
if (!params.dashboard) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const origin = dashboardStore.entity;
|
const origin = dashboardStore.entity;
|
||||||
const path = `/dashboard/${dashboardStore.layerId}/${EntityType[3].value}/${topologyStore.node.id}/${name}`;
|
const path = `/dashboard/${dashboardStore.layerId}/${EntityType[3].value}/${topologyStore.node.id}/${params.dashboard}`;
|
||||||
const routeUrl = router.resolve({ path });
|
const routeUrl = router.resolve({ path });
|
||||||
|
|
||||||
window.open(routeUrl.href, "_blank");
|
window.open(routeUrl.href, "_blank");
|
||||||
dashboardStore.setEntity(origin);
|
dashboardStore.setEntity(origin);
|
||||||
}
|
}
|
||||||
function handleGoDashboard(name: string) {
|
function handleGoDashboard(params: { dashboard: string }) {
|
||||||
|
if (!params.dashboard) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const origin = dashboardStore.entity;
|
const origin = dashboardStore.entity;
|
||||||
const path = `/dashboard/${dashboardStore.layerId}/${EntityType[0].value}/${topologyStore.node.id}/${name}`;
|
const path = `/dashboard/${dashboardStore.layerId}/${EntityType[0].value}/${topologyStore.node.id}/${params.dashboard}`;
|
||||||
const routeUrl = router.resolve({ path });
|
const routeUrl = router.resolve({ path });
|
||||||
|
|
||||||
window.open(routeUrl.href, "_blank");
|
window.open(routeUrl.href, "_blank");
|
||||||
@ -492,6 +498,28 @@ limitations under the License. -->
|
|||||||
|
|
||||||
window.open(routeUrl.href, "_blank");
|
window.open(routeUrl.href, "_blank");
|
||||||
}
|
}
|
||||||
|
function handleGoLayerDashboard(param: { id: string }) {
|
||||||
|
if (!(param.id && currentNode.value)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const origin = dashboardStore.entity;
|
||||||
|
const { dashboard } = getDashboard(
|
||||||
|
{
|
||||||
|
layer: param.id,
|
||||||
|
entity: EntityType[0].value,
|
||||||
|
},
|
||||||
|
ConfigFieldTypes.ISDEFAULT,
|
||||||
|
);
|
||||||
|
if (!dashboard) {
|
||||||
|
return ElMessage.info("No Dashboard");
|
||||||
|
}
|
||||||
|
|
||||||
|
const path = `/dashboard/${param.id}/${EntityType[0].value}/${currentNode.value.id}/${dashboard.name}`;
|
||||||
|
const routeUrl = router.resolve({ path });
|
||||||
|
|
||||||
|
window.open(routeUrl.href, "_blank");
|
||||||
|
dashboardStore.setEntity(origin);
|
||||||
|
}
|
||||||
async function backToTopology() {
|
async function backToTopology() {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
await freshNodes();
|
await freshNodes();
|
||||||
@ -520,12 +548,26 @@ limitations under the License. -->
|
|||||||
settings.value = config;
|
settings.value = config;
|
||||||
setNodeTools(config.nodeDashboard);
|
setNodeTools(config.nodeDashboard);
|
||||||
}
|
}
|
||||||
function setNodeTools(nodeDashboard: any) {
|
function initNodeMenus() {
|
||||||
items.value = [
|
items.value = [
|
||||||
{ id: "hierarchyServices", title: "Hierarchy Services", func: handleHierarchyRelatedServices },
|
{ id: "hierarchyServices", title: "Hierarchy Services", func: handleHierarchyRelatedServices },
|
||||||
{ id: "inspect", title: "Inspect", func: handleInspect },
|
{ id: "inspect", title: "Inspect", func: handleInspect },
|
||||||
{ id: "alerting", title: "Alerting", func: handleGoAlerting },
|
{ id: "alerting", title: "Alerting", func: handleGoAlerting },
|
||||||
];
|
];
|
||||||
|
if (!currentNode.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const diffLayers = currentNode.value.layers.filter((l: string) => l !== dashboardStore.layerId);
|
||||||
|
for (const l of diffLayers) {
|
||||||
|
items.value.push({
|
||||||
|
id: l,
|
||||||
|
title: `${l} Dashboard`,
|
||||||
|
func: handleGoLayerDashboard,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function setNodeTools(nodeDashboard: any) {
|
||||||
|
initNodeMenus();
|
||||||
if (!(nodeDashboard && nodeDashboard.length)) {
|
if (!(nodeDashboard && nodeDashboard.length)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user