diff --git a/src/frontend/components/App.vue b/src/frontend/components/App.vue index 695a1ed..a2cd66d 100644 --- a/src/frontend/components/App.vue +++ b/src/frontend/components/App.vue @@ -292,6 +292,7 @@ export default { // update calls list this.updateCallsList(); + // fixme: clear interval on unmount // update info every few seconds setInterval(() => { this.updateCallsList(); diff --git a/src/frontend/components/interfaces/AddInterfacePage.vue b/src/frontend/components/interfaces/AddInterfacePage.vue new file mode 100644 index 0000000..5ded57a --- /dev/null +++ b/src/frontend/components/interfaces/AddInterfacePage.vue @@ -0,0 +1,374 @@ + + + diff --git a/src/frontend/components/interfaces/InterfacesPage.vue b/src/frontend/components/interfaces/InterfacesPage.vue index c36a245..179f406 100644 --- a/src/frontend/components/interfaces/InterfacesPage.vue +++ b/src/frontend/components/interfaces/InterfacesPage.vue @@ -1,8 +1,6 @@ @@ -351,74 +183,16 @@ export default { name: 'InterfacesPage', data() { return { - - tab: "interfaces", - isEditingInterface: false, - - config: null, interfaces: {}, interfaceStats: {}, - - newInterfaceName: null, - newInterfaceType: null, - - newInterfaceTargetHost: null, - newInterfaceTargetPort: null, - - newInterfaceListenIp: null, - newInterfaceListenPort: null, - - newInterfaceForwardIp: null, - newInterfaceForwardPort: null, - - newInterfacePort: null, - newInterfaceFrequency: null, - newInterfaceBandwidth: null, - newInterfaceTxpower: null, - newInterfaceSpreadingFactor: null, - newInterfaceCodingRate: null, - - RNodeInterfaceDefaults: { - // bandwidth in hz - bandwidths: [ - 7800, // 7.8 kHz - 10400, // 10.4 kHz - 15600, // 15.6 kHz - 20800, // 20.8 kHz - 31250, // 31.25 kHz - 41700, // 41.7 kHz - 62500, // 62.5 kHz - 125000, // 125 kHz - 250000, // 250 kHz - 500000, // 500 kHz - ], - codingrates: [ - 5, // 4:5 - 6, // 4:6 - 7, // 4:7 - 8, // 4:8 - ], - spreadingfactors: [ - 7, - 8, - 9, - 10, - 11, - 12, - ], - }, - - comports: [], - }; }, mounted() { - this.getConfig(); this.loadInterfaces(); this.updateInterfaceStats(); - this.loadComports(); + // fixme: clear interval on unmount // update info every few seconds setInterval(() => { this.updateInterfaceStats(); @@ -434,15 +208,6 @@ export default { onIFACSignatureClick: function(ifacSignature) { DialogUtils.alert(ifacSignature); }, - async getConfig() { - try { - const response = await window.axios.get(`/api/v1/config`); - this.config = response.data.config; - } catch(e) { - // do nothing if failed to load config - console.log(e); - } - }, async loadInterfaces() { try { @@ -472,45 +237,6 @@ export default { // do nothing if failed to load interfaces } }, - showAddInterfaceForm() { - this.resetAddInterfaceForm(); - this.loadComports(); - this.isEditingInterface = false; - this.tab = "interfaces.add"; - }, - showEditInterfaceForm() { - this.resetAddInterfaceForm(); - this.loadComports(); - this.isEditingInterface = true; - this.tab = "interfaces.add"; - }, - resetAddInterfaceForm() { - - // clear add interface form - this.newInterfaceName = null; - this.newInterfaceType = null; - - // tcp client interface - this.newInterfaceTargetHost = null; - this.newInterfaceTargetPort = null; - - // tcp server interface & udp interface - this.newInterfaceListenIp = null; - this.newInterfaceListenPort = null; - - // udp interface - this.newInterfaceForwardIp = null; - this.newInterfaceForwardPort = null; - - // rnode interface - this.newInterfacePort = null; - this.newInterfaceFrequency = null; - this.newInterfaceBandwidth = null; - this.newInterfaceTxpower = null; - this.newInterfaceSpreadingFactor = null; - this.newInterfaceCodingRate = null; - - }, findInterfaceStats(interfaceName) { const interfaceDescription = this.getInterfaceDescription(interfaceName); return this.interfaceStats[interfaceDescription]; @@ -593,40 +319,12 @@ export default { }, async editInterface(interfaceName) { - - // find interface - const iface = this.interfaces[interfaceName]; - if(!iface){ - return; - } - - // go to edit interface tab - this.showEditInterfaceForm(); - - // set form values - this.newInterfaceName = interfaceName; - this.newInterfaceType = iface.type; - - // tcp client interface - this.newInterfaceTargetHost = iface.target_host; - this.newInterfaceTargetPort = iface.target_port; - - // tcp server interface & udp interface - this.newInterfaceListenIp = iface.listen_ip; - this.newInterfaceListenPort = iface.listen_port; - - // udp interface - this.newInterfaceForwardIp = iface.forward_ip; - this.newInterfaceForwardPort = iface.forward_port; - - // rnode interface - this.newInterfacePort = iface.port; - this.newInterfaceFrequency = iface.frequency; - this.newInterfaceBandwidth = iface.bandwidth; - this.newInterfaceTxpower = iface.txpower; - this.newInterfaceSpreadingFactor = iface.spreadingfactor; - this.newInterfaceCodingRate = iface.codingrate; - + this.$router.push({ + name: "interfaces.edit", + query: { + interface_name: interfaceName, + }, + }); }, async deleteInterface(interfaceName) { @@ -655,75 +353,6 @@ export default { formatBytes: function(bytes) { return Utils.formatBytes(bytes); }, - async updateConfig(config) { - try { - const response = await window.axios.patch("/api/v1/config", config); - this.config = response.data.config; - } catch(e) { - alert("Failed to save config!"); - console.log(e); - } - }, - formatFrequency: function(hz) { - return Utils.formatFrequency(hz); - }, - async addInterface() { - - try { - - // add interface - const response = await window.axios.post(`/api/v1/reticulum/interfaces/add`, { - allow_overwriting_interface: this.isEditingInterface, - // required values - name: this.newInterfaceName, - type: this.newInterfaceType, - // tcp client interface - target_host: this.newInterfaceTargetHost, - target_port: this.newInterfaceTargetPort, - // tcp server interface & udp interface - listen_ip: this.newInterfaceListenIp, - listen_port: this.newInterfaceListenPort, - // udp interface - forward_ip: this.newInterfaceForwardIp, - forward_port: this.newInterfaceForwardPort, - // rnode interface - port: this.newInterfacePort, - frequency: this.newInterfaceFrequency, - bandwidth: this.newInterfaceBandwidth, - txpower: this.newInterfaceTxpower, - spreadingfactor: this.newInterfaceSpreadingFactor, - codingrate: this.newInterfaceCodingRate, - }); - - // reset add interface form - this.resetAddInterfaceForm(); - - // go to interfaces tab - this.tab = "interfaces"; - - // show success message - if(response.data.message){ - DialogUtils.alert(response.data.message); - } - - } catch(e) { - const message = e.response?.data?.message ?? "failed to add interface"; - DialogUtils.alert(message); - console.log(e); - } - - // reload interfaces - await this.loadInterfaces(); - - }, - async loadComports() { - try { - const response = await window.axios.get(`/api/v1/comports`); - this.comports = response.data.comports; - } catch(e) { - // do nothing if failed to load interfaces - } - }, }, computed: { isElectron() { diff --git a/src/frontend/components/messages/MessagesPage.vue b/src/frontend/components/messages/MessagesPage.vue index d3f8f94..64bb64e 100644 --- a/src/frontend/components/messages/MessagesPage.vue +++ b/src/frontend/components/messages/MessagesPage.vue @@ -65,6 +65,7 @@ export default { this.getConversations(); this.getLxmfDeliveryAnnounces(); + // fixme: clear interval on unmount // update info every few seconds setInterval(() => { this.getConversations(); diff --git a/src/frontend/components/messages/MessagesSidebar.vue b/src/frontend/components/messages/MessagesSidebar.vue index 40db3f2..c0575c8 100644 --- a/src/frontend/components/messages/MessagesSidebar.vue +++ b/src/frontend/components/messages/MessagesSidebar.vue @@ -144,9 +144,6 @@ export default { conversationsSearchTerm: "", peersSearchTerm: "", }; - }, - mounted() { - }, methods: { onConversationClick(conversation) { diff --git a/src/frontend/components/nomadnetwork/NomadNetworkSidebar.vue b/src/frontend/components/nomadnetwork/NomadNetworkSidebar.vue index fdaa1f7..5a4d733 100644 --- a/src/frontend/components/nomadnetwork/NomadNetworkSidebar.vue +++ b/src/frontend/components/nomadnetwork/NomadNetworkSidebar.vue @@ -70,9 +70,6 @@ export default { return { nodesSearchTerm: "", }; - }, - mounted() { - }, methods: { onNodeClick(node) { diff --git a/src/frontend/main.js b/src/frontend/main.js index b91d185..3344dca 100644 --- a/src/frontend/main.js +++ b/src/frontend/main.js @@ -8,6 +8,7 @@ import NetworkVisualiserPage from "./components/network/NetworkVisualiserPage.vu import InterfacesPage from "./components/interfaces/InterfacesPage.vue"; import NomadNetworkPage from "./components/nomadnetwork/NomadNetworkPage.vue"; import MessagesPage from "./components/messages/MessagesPage.vue"; +import AddInterfacePage from "./components/interfaces/AddInterfacePage.vue"; const router = createRouter({ history: createWebHashHistory(), @@ -18,6 +19,8 @@ const router = createRouter({ { path: '/nomadnetwork', name: "nomadnetwork", component: NomadNetworkPage }, { path: '/settings', name: "settings", component: SettingsPage }, { path: '/interfaces', name: "interfaces", component: InterfacesPage }, + { path: '/interfaces/add', name: "interfaces.add", component: AddInterfacePage }, + { path: '/interfaces/edit', name: "interfaces.edit", component: AddInterfacePage, props: { interface_name: String } }, { path: '/network-visualiser', name: "network-visualiser", component: NetworkVisualiserPage }, ], })