-
Add Interface
+
+ Edit Interface
+ Add Interface
+
@@ -898,7 +912,8 @@
@@ -936,7 +951,7 @@
audioCalls: [],
lxmfDeliveryAnnounces: [],
- tab: "messages",
+ tab: "interfaces",
peers: {},
peersSearchTerm: "",
selectedPeer: null,
@@ -2109,6 +2124,65 @@
// reload interfaces
await this.loadInterfaces();
+ },
+ 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;
+
+ // rnode interface
+ this.newInterfacePort = null;
+ this.newInterfaceFrequency = null;
+ this.newInterfaceBandwidth = null;
+ this.newInterfaceTxpower = null;
+ this.newInterfaceSpreadingFactor = null;
+ this.newInterfaceCodingRate = null;
+
+ },
+ 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;
+
+ // 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;
+
},
async deleteInterface(interfaceName) {
@@ -2137,6 +2211,7 @@
// 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,
@@ -2152,19 +2227,8 @@
codingrate: this.newInterfaceCodingRate,
});
- // clear add interface form
- this.newInterfaceName = null;
- this.newInterfaceType = null;
- // tcp client interface
- this.newInterfaceTargetHost = null;
- this.newInterfaceTargetPort = null;
- // rnode interface
- this.newInterfacePort = null;
- this.newInterfaceFrequency = null;
- this.newInterfaceBandwidth = null;
- this.newInterfaceTxpower = null;
- this.newInterfaceSpreadingFactor = null;
- this.newInterfaceCodingRate = null;
+ // reset add interface form
+ this.resetAddInterfaceForm();
// go to interfaces tab
this.tab = "interfaces";
diff --git a/web.py b/web.py
index 7086250..1ac1142 100644
--- a/web.py
+++ b/web.py
@@ -239,6 +239,7 @@ class ReticulumWebChat:
data = await request.json()
interface_name = data.get('name')
interface_type = data.get('type')
+ allow_overwriting_interface = data.get('allow_overwriting_interface', False)
# ensure name is provided
if interface_name is None or interface_name == "":
@@ -258,16 +259,18 @@ class ReticulumWebChat:
interfaces = self.reticulum.config["interfaces"]
# ensure name is not for an existing interface, to prevent overwriting
- if interface_name in interfaces:
+ if allow_overwriting_interface is False and interface_name in interfaces:
return web.json_response({
"message": "Name is already in use by another interface",
}, status=422)
- # create interface details
- interface_details = {
- "type": interface_type,
- "interface_enabled": str(data.get('enabled', False)),
- }
+ # get existing interface details if available
+ interface_details = {}
+ if interface_name in interfaces:
+ interface_details = interfaces[interface_name]
+
+ # update interface details
+ interface_details["type"] = interface_type
# handle tcp client interface
if interface_type == "TCPClientInterface":
@@ -350,9 +353,15 @@ class ReticulumWebChat:
# save config
self.reticulum.config.write()
- return web.json_response({
- "message": "Interface has been added",
- })
+ if allow_overwriting_interface:
+ return web.json_response({
+ "message": "Interface has been saved",
+ })
+ else:
+ return web.json_response({
+ "message": "Interface has been added",
+ })
+
# handle websocket clients
@routes.get("/ws")