diff --git a/src/components/EditorWindow.vue b/src/components/EditorWindow.vue index afffeab..3ccf1a3 100644 --- a/src/components/EditorWindow.vue +++ b/src/components/EditorWindow.vue @@ -4,7 +4,7 @@ import { ref, onMounted } from 'vue' import HeaderBlock from './HeaderBlock.vue'; import { Network, type Data } from 'vis-network' import { getGraph, updateNode } from './client'; -import type { Graph, GraphEdge, GraphNode } from './models'; +import type { Graph, GraphApplication, GraphEdge, GraphNode } from './models'; const network = ref() @@ -123,6 +123,14 @@ onMounted(async () => { selectNode(graph.value.nodes[0]) }) +function addApplicationToSelectedNode() { + selectedNode.value.applications.push({ name: "" }) +} + +function removeApplicationToSelectedNode(name: string) { + selectedNode.value.applications = selectedNode.value.applications.filter(function (it: GraphApplication): boolean { return it.name != name }) +} + function selectNode(node: GraphNode) { console.log("Select node:", node) updatedNodeID.value = node.code @@ -161,6 +169,30 @@ async function updateSelectedNode() { selectNode(nodes[0]) } +async function deleteSelectedNode() { + console.log("Delete node:", selectedNode.value) + selectedNode.value.code = "" + await updateNode(updatedNodeID.value, selectedNode.value) + await loadGraph() +} + +async function addSelectedNode() { + console.log("Add node:", selectedNode.value) + selectedNode.value.code = updatedNodeID.value + await updateNode("", selectedNode.value) + await loadGraph() + + const nodes = graph.value.nodes.filter(function (it: GraphNode) { + return it.code == selectedNode.value.code + }) + selectNode(nodes[0]) +} + +async function clearSelectedNode() { + console.log("Clear node") + selectNode(emptyNode) +} + function nodeHeader(node: GraphNode): string { return "[" + node.code + "] - " + node.name } @@ -188,6 +220,7 @@ function nodeHeader(node: GraphNode): string { +
@@ -207,15 +240,19 @@ function nodeHeader(node: GraphNode): string {

Редактирование точки

- - + -
-

Приложения: {{ selectedNode.applications.length }}

+

Приложения: {{ selectedNode.applications.length }} + +

+
@@ -228,7 +265,19 @@ function nodeHeader(node: GraphNode): string {
- +
+
+ +
+
+
+ + +
+
+
+ +
@@ -280,15 +329,15 @@ function nodeHeader(node: GraphNode): string { width: 100%; } -.node-edit-save-button { +.editor-button { padding: 3px 7px; - margin: 5px; + margin: 5px 5px 5px 0; background-color: #ffffff; border-radius: 7px; border: 1px solid #373737; } -.node-edit-save-button:hover { +.editor-button:hover { background-color: #dddddd; cursor: pointer; } @@ -324,6 +373,20 @@ function nodeHeader(node: GraphNode): string { width: 220px; } +.application-add-button { + display: inline; + margin-left: 5px; + width: 23px; + height: 23px; +} + +.application-remove-button { + position: absolute; + left: -25px; + width: 23px; + height: 23px; +} + .checkbox-green { display: inline-block;