From 7225ce7f292a7da31869b394b45d53d5288fd949 Mon Sep 17 00:00:00 2001 From: Fedorov Vladimir Date: Sun, 7 Dec 2025 01:34:19 +0700 Subject: [PATCH] update editor --- src/components/EditorWindow.vue | 43 ++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/src/components/EditorWindow.vue b/src/components/EditorWindow.vue index fd35079..7f25b54 100644 --- a/src/components/EditorWindow.vue +++ b/src/components/EditorWindow.vue @@ -7,11 +7,17 @@ import { getGraph } from './client'; const network = ref() +type GraphApplication = { + name: string, +} + type GraphNode = { id: number, label: string, name: string, text: string, + applications: Array, + links: Array, }; type GraphEdge = { @@ -35,6 +41,8 @@ const selectedNode = ref({ label: "", name: "", text: "", + applications: [], + links: [], }) let net = {} @@ -71,8 +79,7 @@ onMounted(async () => { net = new Network(network.value, data, options) net.on("click", function (params) { if (params.nodes.length > 0) { - console.log("Clicked node:", params.nodes[0]); - selectedNode.value = graph.value.nodes[params.nodes[0]] + selectNode(graph.value.nodes[params.nodes[0]]) } else if (params.edges.length > 0) { console.log("Clicked edge:", params.edges[0]); } @@ -82,7 +89,17 @@ onMounted(async () => { }) function selectNode(node: GraphNode) { + console.log("Select node:", node.id) selectedNode.value = node + const links = graph.value.edges.filter(function (it: GraphEdge) { + return it.from == node.id + }).map(function (it: GraphEdge): GraphNode { + const id = it.to + const linkNode = graph.value.nodes.filter(function (it: GraphNode) { return it.id == id }) + return linkNode[0] + }) + + selectedNode.value.links = links net.selectNodes([selectedNode.value.id]) } @@ -105,7 +122,9 @@ function nodeHeader(node: GraphNode): string {
{{ nodeHeader(node) }}
+ v-on:click="selectNode(node)"> + {{ nodeHeader(node) }} +
@@ -117,6 +136,20 @@ function nodeHeader(node: GraphNode): string {
{{ selectedNode.text }}
+
+

Приложения

+
+ {{ application.name }} +
+
+
+

Ссылки

+
+
+ {{ nodeHeader(node) }} +
+
+
@@ -145,6 +178,10 @@ function nodeHeader(node: GraphNode): string { max-width: 300px; } +.node-select-button { + color: #373737; +} + .node-select-button:hover { font-weight: bold; cursor: pointer;