diff --git a/src/components/FlowsPanel.vue b/src/components/FlowsPanel.vue index 476ccf1..48c83c1 100644 --- a/src/components/FlowsPanel.vue +++ b/src/components/FlowsPanel.vue @@ -8,6 +8,7 @@ const editCellRenderer = if (rowData.editing) { return ( -import { ref, toRefs } from 'vue' +import { ref } from 'vue' import { Network, SignalEditTopology, SignalAddNode, SignalUpdateLinks } from '@/hooks/useStates' -import { Check, Plus, Switch, Sort, Share } from '@element-plus/icons-vue' +import { Check, Plus, Switch, Sort, Share, Download } from '@element-plus/icons-vue' import { NODE_TYPE } from '@/core/typedefs' const nodeType = ref(0) @@ -26,22 +26,16 @@ const nodeTypes = [ } ] -const nodeId1 = ref('') -const nodeId2 = ref('') +const v1 = ref(1) +const v2 = ref(1) const addNode = () => { Network.AddNode(nodeType.value) SignalAddNode.value++ } const connect = () => { - const v1 = parseInt(nodeId1.value, 10) - const v2 = parseInt(nodeId2.value, 10) - if (!isNaN(v1) && !isNaN(v2)) { - Network.connect(v1, v2) - SignalUpdateLinks.value++ - } else { - console.error('Invalid node IDs.') - } + Network.connect(v1.value, v2.value) + SignalUpdateLinks.value++ } const autoConnect = () => { Network.EstablishConnection() @@ -66,71 +60,67 @@ const exportTopo = () => { diff --git a/src/core/network.ts b/src/core/network.ts index bdf40b1..f1e56a8 100644 --- a/src/core/network.ts +++ b/src/core/network.ts @@ -300,9 +300,8 @@ export class NetworkHub { } connect(v1: number, v2: number) { - const node1 = this.Nodes.value.find((n) => n.id === v1) - const node2 = this.Nodes.value.find((n) => n.id === v2) - + const node1 = this.Nodes.value.find((n) => n.id == v1) + const node2 = this.Nodes.value.find((n) => n.id == v2) if (!node1 || !node2) { console.error('Connection error: node(s) not found.') return diff --git a/src/core/typedefs/message.ts b/src/core/typedefs/message.ts index 3dc2053..d06dca8 100644 --- a/src/core/typedefs/message.ts +++ b/src/core/typedefs/message.ts @@ -1,4 +1,5 @@ import type { Flow } from './flow' +import type { RoutingTable } from './routing' import type { NodeStats } from './stats' // Message is used for direct communication (debug, cmd, stats) between nodes and controller @@ -28,9 +29,7 @@ export interface ASNMsgPayload { asn: number } -export interface RoutingMsgPayload { - [dst: number]: number -} +export type RoutingMsgPayload = RoutingTable export interface FlowMsgPayload { flows: Flow[] diff --git a/src/hooks/useDrawTopology.ts b/src/hooks/useDrawTopology.ts index 5660cdf..40c3166 100644 --- a/src/hooks/useDrawTopology.ts +++ b/src/hooks/useDrawTopology.ts @@ -583,7 +583,6 @@ export async function useDrawTopology(dom: HTMLElement) { Network.ConstructRoutingGraph() Network.AddFlows(3) // specify number of flows Network.StartWebWorkers() - // ################### watch(SignalAddNode, () => {