mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 10:04:33 +02:00
save settings to file on change
This commit is contained in:
parent
c5262bb165
commit
6c661d9863
|
@ -20,7 +20,7 @@ const settings = useSettingsStore(pinia);
|
|||
class="form-check-input"
|
||||
type="checkbox"
|
||||
id="enable_is_writing"
|
||||
v-model="settings.enable_is_writing" true-value="True" false-value="False"
|
||||
@change="saveSettings" v-model="settings.enable_is_writing" true-value="True" false-value="False"
|
||||
/>
|
||||
<label class="form-check-label" for="GraphicsSwitch"
|
||||
>Additional broadcast burst</label
|
||||
|
@ -39,7 +39,7 @@ const settings = useSettingsStore(pinia);
|
|||
class="form-check-input"
|
||||
type="checkbox"
|
||||
id="enable_request_profile"
|
||||
v-model="settings.enable_request_profile" true-value="True" false-value="False"
|
||||
@change="saveSettings" v-model="settings.enable_request_profile" true-value="True" false-value="False"
|
||||
/>
|
||||
</div>
|
||||
</label>
|
||||
|
@ -55,7 +55,7 @@ const settings = useSettingsStore(pinia);
|
|||
class="form-check-input"
|
||||
type="checkbox"
|
||||
id="enable_request_shared_folder"
|
||||
v-model="settings.enable_request_shared_folder" true-value="True" false-value="False"
|
||||
@change="saveSettings" v-model="settings.enable_request_shared_folder" true-value="True" false-value="False"
|
||||
/>
|
||||
</div>
|
||||
</label>
|
||||
|
@ -77,7 +77,7 @@ const settings = useSettingsStore(pinia);
|
|||
class="form-check-input"
|
||||
type="checkbox"
|
||||
id="enable_auto_retry"
|
||||
v-model="settings.enable_auto_retry" true-value="True" false-value="False"
|
||||
@change="saveSettings" v-model="settings.enable_auto_retry" true-value="True" false-value="False"
|
||||
/>
|
||||
</div>
|
||||
</label>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<script setup lang="ts">
|
||||
|
||||
import {saveSettingsToFile} from '../js/settingsHandler'
|
||||
|
||||
import { setActivePinia } from 'pinia';
|
||||
import pinia from '../store/index';
|
||||
|
@ -8,6 +9,10 @@ setActivePinia(pinia);
|
|||
import { useSettingsStore } from '../store/settingsStore.js';
|
||||
const settings = useSettingsStore(pinia);
|
||||
|
||||
function saveSettings(){
|
||||
saveSettingsToFile()
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -16,7 +21,7 @@ const settings = useSettingsStore(pinia);
|
|||
<label class="input-group-text w-50">Enable autotune</label>
|
||||
<label class="input-group-text w-50">
|
||||
<div class="form-check form-switch form-check-inline ms-2">
|
||||
<input class="form-check-input" type="checkbox" id="autoTuneSwitch" v-model="settings.auto_tune" true-value="True" false-value="False" />
|
||||
<input class="form-check-input" type="checkbox" id="autoTuneSwitch" @change="saveSettings" v-model="settings.auto_tune" true-value="True" false-value="False" />
|
||||
<label class="form-check-label" for="autoTuneSwitch"
|
||||
>adjust ALC on TX</label
|
||||
>
|
||||
|
@ -27,7 +32,7 @@ const settings = useSettingsStore(pinia);
|
|||
<label class="input-group-text w-50">Enable FSK mode</label>
|
||||
<label class="input-group-text w-50">
|
||||
<div class="form-check form-switch form-check-inline ms-2">
|
||||
<input class="form-check-input" type="checkbox" id="fskModeSwitch" v-model="settings.enable_fsk" true-value="True" false-value="False"/>
|
||||
<input class="form-check-input" type="checkbox" id="fskModeSwitch" @change="saveSettings" v-model="settings.enable_fsk" true-value="True" false-value="False"/>
|
||||
<label class="form-check-label" for="fskModeSwitch"
|
||||
>not available, yet</label
|
||||
>
|
||||
|
@ -42,6 +47,7 @@ const settings = useSettingsStore(pinia);
|
|||
class="form-check-input"
|
||||
type="checkbox"
|
||||
id="enableMeshSwitch"
|
||||
@change="saveSettings"
|
||||
v-model="settings.enable_mesh_features" true-value="True" false-value="False"
|
||||
/>
|
||||
<label class="form-check-label" for="enableMeshSwitch"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<script setup lang="ts">
|
||||
|
||||
import {saveSettingsToFile} from '../js/settingsHandler'
|
||||
|
||||
import { setActivePinia } from 'pinia';
|
||||
import pinia from '../store/index';
|
||||
|
@ -8,6 +9,12 @@ setActivePinia(pinia);
|
|||
import { useSettingsStore } from '../store/settingsStore.js';
|
||||
const settings = useSettingsStore(pinia);
|
||||
|
||||
|
||||
function saveSettings(){
|
||||
saveSettingsToFile()
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
<template>
|
||||
|
||||
|
@ -65,7 +72,7 @@ const settings = useSettingsStore(pinia);
|
|||
<label class="input-group-text w-50">Enable fancy GUI</label>
|
||||
<label class="input-group-text w-50">
|
||||
<div class="form-check form-switch form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" id="GraphicsSwitch" v-model="settings.high_graphics" true-value="True" false-value="False"/>
|
||||
<input class="form-check-input" type="checkbox" id="GraphicsSwitch" @change="saveSettings" v-model="settings.high_graphics" true-value="True" false-value="False"/>
|
||||
<label class="form-check-label" for="GraphicsSwitch"
|
||||
>Higher CPU Usage</label
|
||||
>
|
||||
|
@ -97,7 +104,7 @@ const settings = useSettingsStore(pinia);
|
|||
class="form-check-input"
|
||||
type="checkbox"
|
||||
id="NotificationSwitch"
|
||||
v-model="settings.enable_sys_notification" true-value="True" false-value="False"
|
||||
@change="saveSettings" v-model="settings.enable_sys_notification" true-value="True" false-value="False"
|
||||
/>
|
||||
<label class="form-check-label" for="NotificationSwitch"
|
||||
>Show system pop-ups</label
|
||||
|
@ -113,7 +120,7 @@ const settings = useSettingsStore(pinia);
|
|||
class="form-check-input"
|
||||
type="checkbox"
|
||||
id="AutoStartSwitch"
|
||||
v-model="settings.auto_start" true-value="True" false-value="False"
|
||||
@change="saveSettings" v-model="settings.auto_start" true-value="True" false-value="False"
|
||||
/>
|
||||
<label class="form-check-label" for="AutoStartSwitch"
|
||||
>Start on app launch</label
|
||||
|
|
|
@ -16,7 +16,7 @@ const settings = useSettingsStore(pinia);
|
|||
<label class="input-group-text w-50">Explorer publishing</label>
|
||||
<label class="input-group-text w-50">
|
||||
<div class="form-check form-switch form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" id="ExplorerSwitch" v-model="settings.enable_explorer" true-value="True" false-value="False"/>
|
||||
<input class="form-check-input" type="checkbox" id="ExplorerSwitch" @change="saveSettings" v-model="settings.enable_explorer" true-value="True" false-value="False"/>
|
||||
<label class="form-check-label" for="ExplorerSwitch">Publish</label>
|
||||
</div>
|
||||
</label>
|
||||
|
@ -29,7 +29,7 @@ const settings = useSettingsStore(pinia);
|
|||
class="form-check-input"
|
||||
type="checkbox"
|
||||
id="ExplorerStatsSwitch"
|
||||
v-model="settings.enable_stats" true-value="True" false-value="False"
|
||||
@change="saveSettings" v-model="settings.enable_stats" true-value="True" false-value="False"
|
||||
/>
|
||||
<label class="form-check-label" for="ExplorerStatsSwitch"
|
||||
>Publish stats</label
|
||||
|
|
|
@ -90,6 +90,8 @@ if (!fs.existsSync(configPath)) {
|
|||
fs.writeFileSync(configPath, configDefaultSettings);
|
||||
}
|
||||
|
||||
|
||||
export function loadSettings(){
|
||||
// load settings
|
||||
var config = require(configPath);
|
||||
|
||||
|
@ -115,4 +117,13 @@ for (var key in parsedConfig) {
|
|||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function saveSettingsToFile(){
|
||||
console.log("save settings to file...")
|
||||
let config = settings.getJSON()
|
||||
console.log(config)
|
||||
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
import { createApp, Vue } from 'vue'
|
||||
import { createPinia } from 'pinia'
|
||||
|
||||
import {loadSettings} from './js/settingsHandler'
|
||||
|
||||
import './styles.css'
|
||||
|
||||
|
@ -25,11 +25,11 @@ const app = createApp(App)//.mount('#app').$nextTick(() => postMessage({ payload
|
|||
|
||||
const pinia = createPinia()
|
||||
app.mount('#app')
|
||||
|
||||
console.log("init...")
|
||||
app.use(pinia)
|
||||
loadSettings()
|
||||
|
||||
|
||||
|
||||
import './js/settingsHandler.js'
|
||||
//import './js/settingsHandler.js'
|
||||
import './js/daemon.js'
|
||||
import './js/sock.js'
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import { defineStore } from 'pinia'
|
||||
import { defineStore } from 'pinia';
|
||||
import { ref, computed } from 'vue';
|
||||
|
||||
export const useSettingsStore = defineStore('settingsStore', () => {
|
||||
|
||||
|
||||
// network
|
||||
var tnc_host = ref("127.0.0.1");
|
||||
var tnc_port = ref(3000);
|
||||
|
@ -75,6 +76,71 @@ export const useSettingsStore = defineStore('settingsStore', () => {
|
|||
var tx_delay = ref(0);
|
||||
var enable_mesh_features = ref("False");
|
||||
|
||||
function getJSON(){
|
||||
var config_export = {
|
||||
"tnc_host": tnc_host.value,
|
||||
"tnc_port": tnc_port.value,
|
||||
"daemon_host": daemon_host.value,
|
||||
"daemon_port": daemon_port.value,
|
||||
"mycall": mycall.value,
|
||||
"mygrid": mygrid.value,
|
||||
"radiocontrol" : radiocontrol.value,
|
||||
"hamlib_deviceid": hamlib_deviceid.value,
|
||||
"hamlib_deviceport": hamlib_deviceport.value,
|
||||
"hamlib_stop_bits": hamlib_stop_bits.value,
|
||||
"hamlib_data_bits": hamlib_data_bits.value,
|
||||
"hamlib_handshake": hamlib_handshake.value,
|
||||
"hamlib_serialspeed": hamlib_serialspeed.value,
|
||||
"hamlib_dtrstate": hamlib_dtrstate.value,
|
||||
"hamlib_pttprotocol": hamlib_pttprotocol.value,
|
||||
"hamlib_ptt_port": hamlib_ptt_port.value,
|
||||
"hamlib_dcd": hamlib_dcd.value,
|
||||
"hamlbib_serialspeed_ptt": hamlib_serialspeed.value,
|
||||
"hamlib_rigctld_port" : hamlib_rigctld_port.value,
|
||||
"hamlib_rigctld_ip" : hamlib_rigctld_ip.value,
|
||||
"hamlib_rigctld_path" : hamlib_rigctld_path.value,
|
||||
"hamlib_rigctld_server_port" : hamlib_rigctld_server_port.value,
|
||||
"hamlib_rigctld_custom_args": hamlib_rigctld_custom_args.value,
|
||||
"tci_port" : tci_port.value,
|
||||
"tci_ip" : tci_ip.value,
|
||||
"spectrum": spectrum.value,
|
||||
"tnclocation": tnclocation.value,
|
||||
"enable_scatter" : enable_scatter.value,
|
||||
"enable_fft" : enable_fft.value,
|
||||
"enable_fsk" : enable_fsk.value,
|
||||
"low_bandwidth_mode" : low_bandwidth_mode.value,
|
||||
"theme" : theme.value,
|
||||
"screen_height" : screen_height.value,
|
||||
"screen_width" : screen_width.value,
|
||||
"update_channel" : update_channel.value,
|
||||
"beacon_interval" : beacon_interval.value,
|
||||
"received_files_folder" : received_files_folder.value,
|
||||
"tuning_range_fmin" : tuning_range_fmin.value,
|
||||
"tuning_range_fmax" : tuning_range_fmax.value,
|
||||
"respond_to_cq" : respond_to_cq.value,
|
||||
"rx_buffer_size" : rx_buffer_size.value,
|
||||
"enable_explorer" : enable_explorer.value,
|
||||
"wftheme": wftheme.value,
|
||||
"high_graphics" : high_graphics.value,
|
||||
"explorer_stats" : explorer_stats.value,
|
||||
"auto_tune" : auto_tune.value,
|
||||
"enable_is_writing" : enable_is_writing.value,
|
||||
"shared_folder_path" : shared_folder_path.value,
|
||||
"enable_request_profile" : enable_request_profile.value,
|
||||
"enable_request_shared_folder" : enable_request_shared_folder.value,
|
||||
"max_retry_attempts" : max_retry_attempts.value,
|
||||
"enable_auto_retry" : enable_auto_retry.value,
|
||||
"tx_delay" : tx_delay.value,
|
||||
"auto_start": auto_start.value,
|
||||
"enable_sys_notification": enable_sys_notification.value,
|
||||
"enable_mesh_features": enable_mesh_features.value
|
||||
};
|
||||
|
||||
return config_export
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return {
|
||||
tnc_host,
|
||||
|
@ -134,7 +200,8 @@ export const useSettingsStore = defineStore('settingsStore', () => {
|
|||
auto_tune,
|
||||
enable_is_writing,
|
||||
tx_delay,
|
||||
enable_mesh_features
|
||||
enable_mesh_features,
|
||||
getJSON
|
||||
};
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue