mirror of
https://github.com/liamcottle/reticulum-meshchat.git
synced 2026-12-01 20:36:28 -05:00
refactor updating of interface settings to allow removing values when saving an existing interface
This commit is contained in:
parent
33e4888737
commit
734eaeed1b
3 changed files with 137 additions and 142 deletions
14
src/backend/interface_editor.py
Normal file
14
src/backend/interface_editor.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
class InterfaceEditor:
|
||||
|
||||
@staticmethod
|
||||
def update_value(interface_details: dict, data: dict, key: str):
|
||||
|
||||
# update value if provided and not empty
|
||||
value = data.get(key)
|
||||
if value is not None and value != "":
|
||||
interface_details[key] = value
|
||||
return
|
||||
|
||||
# otherwise remove existing value
|
||||
if key in interface_details:
|
||||
del interface_details[key]
|
||||
|
|
@ -334,7 +334,7 @@
|
|||
|
||||
<div class="mb-2">
|
||||
<FormLabel class="mb-1">Serial connection baud rate (bps)</FormLabel>
|
||||
<input v-model="newInterfaceSpeed" placeholder="115200" type="number" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-zinc-900 dark:border-zinc-600 dark:text-white">
|
||||
<input v-model="newInterfaceSpeed" placeholder="9600" type="number" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-zinc-900 dark:border-zinc-600 dark:text-white">
|
||||
</div>
|
||||
|
||||
<div class="mb-2">
|
||||
|
|
@ -344,7 +344,11 @@
|
|||
|
||||
<div class="mb-2">
|
||||
<FormLabel class="mb-1">Parity</FormLabel>
|
||||
<input v-model="newInterfaceParity" type="number" placeholder="" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-zinc-900 dark:border-zinc-600 dark:text-white">
|
||||
<select v-model="newInterfaceParity" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-zinc-900 dark:border-zinc-600 dark:text-white dark:focus:ring-blue-600 dark:focus:border-blue-600">
|
||||
<option :value="undefined">None</option>
|
||||
<option value="even">Even</option>
|
||||
<option value="odd">Odd</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
|
|
@ -605,9 +609,9 @@
|
|||
</template>
|
||||
</ExpandingSection>
|
||||
|
||||
<!-- optional TCPClientInterface and UDPInterface settings -->
|
||||
<ExpandingSection v-if="newInterfaceType === 'TCPServerInterface' || newInterfaceType === 'UDPInterface'">
|
||||
<template v-slot:title>Optional {{ newInterfaceType }} settings</template>
|
||||
<!-- optional TCPClientInterface settings -->
|
||||
<ExpandingSection v-if="newInterfaceType === 'TCPServerInterface'">
|
||||
<template v-slot:title>Optional TCPServerInterface settings</template>
|
||||
<template v-slot:content>
|
||||
<div class="p-2 space-y-3">
|
||||
|
||||
|
|
@ -635,6 +639,22 @@
|
|||
</template>
|
||||
</ExpandingSection>
|
||||
|
||||
<!-- optional UDPInterface settings -->
|
||||
<ExpandingSection v-if="newInterfaceType === 'UDPInterface'">
|
||||
<template v-slot:title>Optional UDPInterface settings</template>
|
||||
<template v-slot:content>
|
||||
<div class="p-2 space-y-3">
|
||||
|
||||
<div>
|
||||
<FormLabel>Network device</FormLabel>
|
||||
<span class="text-sm text-gray-500 dark:text-zinc-300">Binds the interface to a specific network interface</span>
|
||||
<input type="text" placeholder="e.g: eth0" v-model="newInterfaceNetworkDevice" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-zinc-900 dark:border-zinc-600 dark:text-white dark:focus:ring-blue-600 dark:focus:border-blue-600">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
</ExpandingSection>
|
||||
|
||||
<!-- optional RNodeInterface settings -->
|
||||
<ExpandingSection v-if="newInterfaceType === 'RNodeInterface'">
|
||||
<template v-slot:title>Optional RNodeInterface Settings</template>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue