diff --git a/public/index.html b/public/index.html index 12e8efa..8360dff 100644 --- a/public/index.html +++ b/public/index.html @@ -104,6 +104,18 @@ + +
  • + +
  • + @@ -202,11 +214,9 @@ - -
    - - -
    + +
    +
    @@ -259,9 +269,11 @@
    +
    - -
    + +
    +
    @@ -314,7 +326,6 @@
    -
    @@ -663,6 +674,81 @@ + +
    +
    + +
    + + +
    + + + + + + + + + + + + + + + + + + + + + +
    + +
    +
    {{ interface_name }}
    +
    {{ iface.type ?? 'Unknown Interface Type' }}
    +
    + + +
    + +
    + +
    + + +
    + + +
    +
    Target: {{ iface.target_host }}:{{ iface.target_port }}
    +
    + + +
    +
    Port: {{ iface.port }}
    +
    Frequency: {{ iface.frequency }}
    +
    Bandwidth: {{ iface.bandwidth }}
    +
    TX Power: {{ iface.txpower }}
    +
    Spreading Factor: {{ iface.spreadingfactor }}
    +
    Coding Rate: {{ iface.codingrate }}
    +
    + + +
    {{ isInterfaceEnabled(iface) ? 'Enabled' : 'Disabled' }}
    + +
    + +
    +
    +
    @@ -693,7 +779,7 @@ audioCalls: [], lxmfDeliveryAnnounces: [], - tab: "messages", + tab: "interfaces", peers: {}, peersSearchTerm: "", selectedPeer: null, @@ -723,6 +809,8 @@ nomadnetPageDownloadCallbacks: {}, nomadnetFileDownloadCallbacks: {}, + interfaces: {}, + }; }, mounted: function() { @@ -730,6 +818,8 @@ this.connectWebsocket(); this.getLxmfDeliveryAnnounces(); this.getNomadnetworkNodeAnnounces(); + this.loadInterfaces(); + window.onNodePageUrlClick = (url) => { this.onNodePageUrlClick(url); }; @@ -1272,6 +1362,19 @@ // do nothing if failed to load messages } }, + async loadInterfaces() { + try { + + // fetch interfaces + const response = await window.axios.get(`/api/v1/reticulum/interfaces`); + + // update ui + this.interfaces = response.data.interfaces; + + } catch(e) { + // do nothing if failed to load interfaces + } + }, async loadNodePage(destinationHash, pagePath, addToHistory = true, loadFromCache = true) { // get new sequence for this page load @@ -1725,6 +1828,27 @@ // reload conversation await this.loadLxmfMessages(this.selectedPeer.destination_hash); + }, + async deleteInterface(interfaceName) { + + // ask user to confirm deleting conversation history + if(!confirm("Are you sure you want to delete this interface? This can not be undone!")){ + return; + } + + // delete interface + try { + await window.axios.post(`/api/v1/reticulum/interfaces/delete`, { + name: interfaceName, + }); + } catch(e) { + alert("failed to delete interface"); + console.log(e); + } + + // reload interfaces + await this.loadInterfaces(); + }, onChatItemClick: function(chatItem) { if(!chatItem.is_actions_expanded){ @@ -1778,6 +1902,11 @@ return window.prompt(message); } }, + isInterfaceEnabled: function(iface) { + const rawValue = iface.enabled ?? iface.interface_enabled; + const value = rawValue.toLowerCase(); + return value === "on" || value === "yes" || value === "true"; + }, }, computed: { isMobile() { diff --git a/web.py b/web.py index cf9d03b..80942b1 100644 --- a/web.py +++ b/web.py @@ -166,6 +166,25 @@ class ReticulumWebChat: "interfaces": interfaces, }) + # delete reticulum interface + @routes.post("/api/v1/reticulum/interfaces/delete") + async def index(request): + + # get request data + data = await request.json() + interface_name = data.get('name') + + # delete interface + if "interfaces" in self.reticulum.config: + del self.reticulum.config["interfaces"][interface_name] + + # save config + self.reticulum.config.write() + + return web.json_response({ + "message": "Interface deleted", + }) + # handle websocket clients @routes.get("/ws") async def ws(request):