mirror of https://github.com/DJ2LS/FreeDATA.git
Save GUI local settings to config/config.json
parent
4ea01f39b4
commit
0ca35be688
|
@ -29,4 +29,7 @@ coverage.xml
|
|||
#Ignore gui build items
|
||||
/gui/dist
|
||||
/gui/release
|
||||
/gui/dist-electron
|
||||
/gui/dist-electron
|
||||
|
||||
#Ignore GUI config
|
||||
/gui/config/config.json
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"local": {
|
||||
"host": "127.0.0.1",
|
||||
"port": "5000",
|
||||
"enable_fft": true,
|
||||
"spectrum": "waterfall",
|
||||
"wf_theme": 2,
|
||||
"theme": "default_light",
|
||||
"high_graphics": true,
|
||||
"update_channel": "alpha",
|
||||
"enable_sys_notification": false
|
||||
}
|
||||
}
|
|
@ -51,6 +51,7 @@
|
|||
"file-saver": "2.0.5",
|
||||
"gridstack": "10.0.0",
|
||||
"mime": "4.0.0",
|
||||
"nconf": "^0.12.1",
|
||||
"pinia": "2.1.6",
|
||||
"pouchdb": "8.0.1",
|
||||
"pouchdb-browser": "8.0.1",
|
||||
|
@ -65,6 +66,7 @@
|
|||
"vuemoji-picker": "0.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/nconf": "^0.10.6",
|
||||
"@typescript-eslint/eslint-plugin": "6.7.4",
|
||||
"@vitejs/plugin-vue": "4.5.2",
|
||||
"electron": "28.0.0",
|
||||
|
|
|
@ -2,17 +2,43 @@ import { reactive, ref, watch } from "vue";
|
|||
|
||||
import { getConfig, setConfig } from "../js/api";
|
||||
|
||||
var nconf = require( "nconf");
|
||||
nconf.file({file: 'config/config.json'});
|
||||
|
||||
|
||||
// +++
|
||||
//GUI DEFAULT SETTINGS........
|
||||
//Set GUI defaults here, they will be used if not found in config/config.json
|
||||
//They should be an exact mirror (variable wise) of settingsStore.local
|
||||
//Nothing else should be needed aslong as components are using v-bind
|
||||
// +++
|
||||
nconf.defaults({
|
||||
local: {
|
||||
host: "127.0.0.1",
|
||||
port: "5000",
|
||||
enable_fft: true,
|
||||
spectrum: "waterfall",
|
||||
wf_theme: 2,
|
||||
theme: "default_light",
|
||||
high_graphics: true,
|
||||
update_channel: "alpha",
|
||||
enable_sys_notification: false,
|
||||
}
|
||||
});
|
||||
|
||||
nconf.required(['local:host','local:port']);
|
||||
|
||||
export const settingsStore = reactive({
|
||||
local: {
|
||||
host: "127.0.0.1",
|
||||
port: "5000",
|
||||
enable_fft: false,
|
||||
enable_fft: true,
|
||||
spectrum: "waterfall",
|
||||
wf_theme: 0,
|
||||
wf_theme: 2,
|
||||
theme: "default_light",
|
||||
high_graphics: true,
|
||||
update_channel: "alpha",
|
||||
enable_sys_notification: true,
|
||||
enable_sys_notification: false,
|
||||
},
|
||||
remote: {
|
||||
AUDIO: {
|
||||
|
@ -73,6 +99,10 @@ export const settingsStore = reactive({
|
|||
},
|
||||
});
|
||||
|
||||
//Save settings for GUI to config file
|
||||
settingsStore.local = nconf.get('local');
|
||||
saveSettingsToConfig();
|
||||
|
||||
export function onChange() {
|
||||
setConfig(settingsStore.remote).then((conf) => {
|
||||
settingsStore.remote = conf;
|
||||
|
@ -86,6 +116,13 @@ export function getRemote() {
|
|||
}
|
||||
|
||||
watch(settingsStore.local, (oldValue, newValue) => {
|
||||
// TODO handle local file saving
|
||||
const cenas = newValue;
|
||||
//This function watches for changes, and triggers a save of local settings
|
||||
saveSettingsToConfig();
|
||||
});
|
||||
|
||||
function saveSettingsToConfig() {
|
||||
nconf.set('local',settingsStore.local);
|
||||
nconf.save();
|
||||
console.log("Settings saved!");
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue