mirror of
https://github.com/liamcottle/reticulum-meshchat.git
synced 2026-04-28 00:20:48 +00:00
enable and disable interfaces via ui
This commit is contained in:
parent
ef90363423
commit
7446bb49e5
2 changed files with 99 additions and 3 deletions
|
|
@ -710,8 +710,26 @@
|
|||
<div class="text-sm">{{ iface.type ?? 'Unknown Interface Type' }}</div>
|
||||
</div>
|
||||
|
||||
<!-- delete button -->
|
||||
<!-- toggle interface enabled -->
|
||||
<div class="ml-auto my-auto mr-2">
|
||||
<button v-if="isInterfaceEnabled(iface)" @click="disableInterface(interface_name)" type="button" class="cursor-pointer">
|
||||
<span class="flex text-gray-700 bg-gray-100 hover:bg-gray-200 p-2 rounded-full">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-5">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M5.636 5.636a9 9 0 1 0 12.728 0M12 3v9" />
|
||||
</svg>
|
||||
</span>
|
||||
</button>
|
||||
<button v-else @click="enableInterface(interface_name)" type="button" class="cursor-pointer">
|
||||
<span class="flex text-gray-700 bg-gray-100 hover:bg-gray-200 p-2 rounded-full">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-5">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M5.636 5.636a9 9 0 1 0 12.728 0M12 3v9" />
|
||||
</svg>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- delete button -->
|
||||
<div class="my-auto mr-2">
|
||||
<button @click="deleteInterface(interface_name)" type="button" class="cursor-pointer">
|
||||
<span class="flex text-gray-700 bg-gray-100 hover:bg-gray-200 p-2 rounded-full">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5">
|
||||
|
|
@ -1828,6 +1846,38 @@
|
|||
// reload conversation
|
||||
await this.loadLxmfMessages(this.selectedPeer.destination_hash);
|
||||
|
||||
},
|
||||
async enableInterface(interfaceName) {
|
||||
|
||||
// enable interface
|
||||
try {
|
||||
await window.axios.post(`/api/v1/reticulum/interfaces/enable`, {
|
||||
name: interfaceName,
|
||||
});
|
||||
} catch(e) {
|
||||
alert("failed to enable interface");
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
// reload interfaces
|
||||
await this.loadInterfaces();
|
||||
|
||||
},
|
||||
async disableInterface(interfaceName) {
|
||||
|
||||
// disable interface
|
||||
try {
|
||||
await window.axios.post(`/api/v1/reticulum/interfaces/disable`, {
|
||||
name: interfaceName,
|
||||
});
|
||||
} catch(e) {
|
||||
alert("failed to disable interface");
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
// reload interfaces
|
||||
await this.loadInterfaces();
|
||||
|
||||
},
|
||||
async deleteInterface(interfaceName) {
|
||||
|
||||
|
|
@ -1904,7 +1954,7 @@
|
|||
},
|
||||
isInterfaceEnabled: function(iface) {
|
||||
const rawValue = iface.enabled ?? iface.interface_enabled;
|
||||
const value = rawValue.toLowerCase();
|
||||
const value = rawValue?.toLowerCase();
|
||||
return value === "on" || value === "yes" || value === "true";
|
||||
},
|
||||
},
|
||||
|
|
|
|||
48
web.py
48
web.py
|
|
@ -166,6 +166,52 @@ class ReticulumWebChat:
|
|||
"interfaces": interfaces,
|
||||
})
|
||||
|
||||
# enable reticulum interface
|
||||
@routes.post("/api/v1/reticulum/interfaces/enable")
|
||||
async def index(request):
|
||||
|
||||
# get request data
|
||||
data = await request.json()
|
||||
interface_name = data.get('name')
|
||||
|
||||
# enable interface
|
||||
if "interfaces" in self.reticulum.config:
|
||||
interface = self.reticulum.config["interfaces"][interface_name]
|
||||
if "enabled" in interface:
|
||||
interface["enabled"] = "true"
|
||||
if "interface_enabled" in interface:
|
||||
interface["interface_enabled"] = "true"
|
||||
|
||||
# save config
|
||||
self.reticulum.config.write()
|
||||
|
||||
return web.json_response({
|
||||
"message": "Interface Enabled",
|
||||
})
|
||||
|
||||
# disable reticulum interface
|
||||
@routes.post("/api/v1/reticulum/interfaces/disable")
|
||||
async def index(request):
|
||||
|
||||
# get request data
|
||||
data = await request.json()
|
||||
interface_name = data.get('name')
|
||||
|
||||
# disable interface
|
||||
if "interfaces" in self.reticulum.config:
|
||||
interface = self.reticulum.config["interfaces"][interface_name]
|
||||
if "enabled" in interface:
|
||||
interface["enabled"] = "false"
|
||||
if "interface_enabled" in interface:
|
||||
interface["interface_enabled"] = "false"
|
||||
|
||||
# save config
|
||||
self.reticulum.config.write()
|
||||
|
||||
return web.json_response({
|
||||
"message": "Interface Disabled",
|
||||
})
|
||||
|
||||
# delete reticulum interface
|
||||
@routes.post("/api/v1/reticulum/interfaces/delete")
|
||||
async def index(request):
|
||||
|
|
@ -182,7 +228,7 @@ class ReticulumWebChat:
|
|||
self.reticulum.config.write()
|
||||
|
||||
return web.json_response({
|
||||
"message": "Interface deleted",
|
||||
"message": "Interface Deleted",
|
||||
})
|
||||
|
||||
# handle websocket clients
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue