add setting to enable and disable transport mode

This commit is contained in:
liamcottle 2025-01-02 17:13:37 +13:00
parent d3e8c2de9a
commit 4b6978f7cc
2 changed files with 64 additions and 0 deletions

View file

@ -37,6 +37,25 @@
</div>
</div>
<!-- transport mode -->
<div class="bg-white dark:bg-zinc-800 rounded shadow">
<div class="flex border-b border-gray-300 dark:border-zinc-700 text-gray-700 dark:text-gray-200 p-2 font-semibold">Transport Mode</div>
<div class="divide-y divide-gray-300 dark:divide-zinc-700 text-gray-900 dark:text-gray-100">
<div class="p-2">
<div class="flex items-start">
<div class="flex items-center h-5">
<input v-model="config.is_transport_enabled" @change="onIsTransportEnabledChange" type="checkbox" class="w-4 h-4 border border-gray-300 dark:border-zinc-600 rounded bg-gray-50 dark:bg-zinc-700 focus:ring-3 focus:ring-blue-300 dark:focus:ring-blue-600">
</div>
<label class="ml-2 text-sm font-medium text-gray-900 dark:text-gray-100">Enable Transport Mode</label>
</div>
<div class="text-sm text-gray-700 dark:text-gray-300">When enabled, MeshChat will route traffic for other peers, respond to path requests and pass announces over your interfaces.</div>
<div class="text-sm text-gray-700 dark:text-gray-300">Changing this setting requires you to restart MeshChat.</div>
</div>
</div>
</div>
<!-- messages -->
<div class="bg-white dark:bg-zinc-800 rounded shadow">
<div class="flex border-b border-gray-300 dark:border-zinc-700 text-gray-700 dark:text-gray-200 p-2 font-semibold">Messages</div>
@ -150,6 +169,7 @@
<script>
import Utils from "../../js/Utils";
import WebSocketConnection from "../../js/WebSocketConnection";
import DialogUtils from "../../js/DialogUtils";
export default {
name: 'SettingsPage',
@ -247,6 +267,25 @@ export default {
"lxmf_preferred_propagation_node_auto_sync_interval_seconds": this.config.lxmf_preferred_propagation_node_auto_sync_interval_seconds,
});
},
async onIsTransportEnabledChange() {
if(this.config.is_transport_enabled){
try {
const response = await window.axios.post("/api/v1/reticulum/enable-transport");
DialogUtils.alert(response.data.message);
} catch(e) {
DialogUtils.alert("Failed to enable transport mode!");
console.log(e);
}
} else {
try {
const response = await window.axios.post("/api/v1/reticulum/disable-transport");
DialogUtils.alert(response.data.message);
} catch(e) {
DialogUtils.alert("Failed to disable transport mode!");
console.log(e);
}
}
},
formatSecondsAgo: function(seconds) {
return Utils.formatSecondsAgo(seconds);
},