mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-14 00:37:33 +00:00
drag and drop
This commit is contained in:
parent
01514533c9
commit
16bfb67f35
2
src/types/ebpf.d.ts
vendored
2
src/types/ebpf.d.ts
vendored
@ -74,4 +74,6 @@ export type ProcessNode = {
|
|||||||
serviceInstanceName: string;
|
serviceInstanceName: string;
|
||||||
name: string;
|
name: string;
|
||||||
isReal: boolean;
|
isReal: boolean;
|
||||||
|
x?: number;
|
||||||
|
y?: number;
|
||||||
};
|
};
|
||||||
|
@ -19,11 +19,11 @@ export default (d3: any, graph: any, diff: number[]) =>
|
|||||||
d3
|
d3
|
||||||
.zoom()
|
.zoom()
|
||||||
.scaleExtent([0.3, 10])
|
.scaleExtent([0.3, 10])
|
||||||
.on("zoom", (event: any) => {
|
.on("zoom", (d: any) => {
|
||||||
graph.attr(
|
graph.attr(
|
||||||
"transform",
|
"transform",
|
||||||
`translate(${event.transform.x + diff[0]},${
|
`translate(${d.transform.x + diff[0]},${
|
||||||
event.transform.y + diff[1]
|
d.transform.y + diff[1]
|
||||||
})scale(${event.transform.k})`
|
})scale(${d.transform.k})`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -39,16 +39,24 @@ limitations under the License. -->
|
|||||||
class="topo-node"
|
class="topo-node"
|
||||||
@mouseover="showNodeTip(node, $event)"
|
@mouseover="showNodeTip(node, $event)"
|
||||||
@mouseout="hideNodeTip"
|
@mouseout="hideNodeTip"
|
||||||
|
@mousemove="moveNode(node, $event)"
|
||||||
|
@mousedown="startMoveNode($event)"
|
||||||
|
@mouseup="stopMoveNode($event)"
|
||||||
>
|
>
|
||||||
<image
|
<image
|
||||||
:href="icons.CUBE"
|
:href="icons.CUBE"
|
||||||
style="cursor: 'move'"
|
style="cursor: 'move'"
|
||||||
width="35"
|
width="35"
|
||||||
height="35"
|
height="35"
|
||||||
:x="node.x - 15"
|
:x="(node.x || 0) - 15"
|
||||||
:y="node.y - 15"
|
:y="(node.y || 0) - 15"
|
||||||
/>
|
/>
|
||||||
<text :x="node.x" :y="node.y + 28" fill="#000" text-anchor="middle">
|
<text
|
||||||
|
:x="node.x"
|
||||||
|
:y="(node.y || 0) + 28"
|
||||||
|
fill="#000"
|
||||||
|
text-anchor="middle"
|
||||||
|
>
|
||||||
{{
|
{{
|
||||||
node.name.length > 10
|
node.name.length > 10
|
||||||
? `${node.name.substring(0, 10)}...`
|
? `${node.name.substring(0, 10)}...`
|
||||||
@ -100,7 +108,7 @@ limitations under the License. -->
|
|||||||
</g>
|
</g>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
<div id="tooltip">test tooltip</div>
|
<div id="tooltip"></div>
|
||||||
</div>
|
</div>
|
||||||
<el-popover placement="bottom" :width="295" trigger="click">
|
<el-popover placement="bottom" :width="295" trigger="click">
|
||||||
<template #reference>
|
<template #reference>
|
||||||
@ -158,7 +166,8 @@ const config = ref<any>(props.config || {});
|
|||||||
const diff = ref<number[]>([220, 200]);
|
const diff = ref<number[]>([220, 200]);
|
||||||
const radius = 210;
|
const radius = 210;
|
||||||
const dates = ref<Nullable<{ start: number; end: number }>>(null);
|
const dates = ref<Nullable<{ start: number; end: number }>>(null);
|
||||||
const nodeList = ref<any>([]);
|
const nodeList = ref<ProcessNode[]>([]);
|
||||||
|
const isMoving = ref<boolean>(false);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
init();
|
init();
|
||||||
@ -424,13 +433,33 @@ function resize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function freshNodes() {
|
async function freshNodes() {
|
||||||
// d3.select(".svg-graph").remove();
|
|
||||||
if (!networkProfilingStore.nodes.length) {
|
if (!networkProfilingStore.nodes.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
drawGraph();
|
drawGraph();
|
||||||
createLayout();
|
createLayout();
|
||||||
}
|
}
|
||||||
|
function startMoveNode(event: MouseEvent) {
|
||||||
|
event.stopPropagation();
|
||||||
|
isMoving.value = true;
|
||||||
|
}
|
||||||
|
function stopMoveNode(event: MouseEvent) {
|
||||||
|
event.stopPropagation();
|
||||||
|
isMoving.value = false;
|
||||||
|
}
|
||||||
|
function moveNode(d: ProcessNode, event: MouseEvent) {
|
||||||
|
event.stopPropagation();
|
||||||
|
if (!isMoving.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
nodeList.value = nodeList.value.map((node: ProcessNode) => {
|
||||||
|
if (node.id === d.id) {
|
||||||
|
node.x = event.offsetX - diff.value[0];
|
||||||
|
node.y = event.offsetY - diff.value[1];
|
||||||
|
}
|
||||||
|
return node;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function showNodeTip(d: ProcessNode, event: MouseEvent) {
|
function showNodeTip(d: ProcessNode, event: MouseEvent) {
|
||||||
const tipHtml = ` <div class="mb-5"><span class="grey">name: </span>${d.name}</div>`;
|
const tipHtml = ` <div class="mb-5"><span class="grey">name: </span>${d.name}</div>`;
|
||||||
@ -549,7 +578,7 @@ watch(
|
|||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
border: 1px solid #000;
|
border: 1px solid #000;
|
||||||
border-radius: 5px;
|
border-radius: 3px;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
Loading…
Reference in New Issue
Block a user