mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 10:04:33 +02:00
Save GUI local settings to config/config.json
This commit is contained in:
parent
4ea01f39b4
commit
0ca35be688
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -29,4 +29,7 @@ coverage.xml
|
||||||
#Ignore gui build items
|
#Ignore gui build items
|
||||||
/gui/dist
|
/gui/dist
|
||||||
/gui/release
|
/gui/release
|
||||||
/gui/dist-electron
|
/gui/dist-electron
|
||||||
|
|
||||||
|
#Ignore GUI config
|
||||||
|
/gui/config/config.json
|
13
gui/config/example.json
Normal file
13
gui/config/example.json
Normal file
|
@ -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",
|
"file-saver": "2.0.5",
|
||||||
"gridstack": "10.0.0",
|
"gridstack": "10.0.0",
|
||||||
"mime": "4.0.0",
|
"mime": "4.0.0",
|
||||||
|
"nconf": "^0.12.1",
|
||||||
"pinia": "2.1.6",
|
"pinia": "2.1.6",
|
||||||
"pouchdb": "8.0.1",
|
"pouchdb": "8.0.1",
|
||||||
"pouchdb-browser": "8.0.1",
|
"pouchdb-browser": "8.0.1",
|
||||||
|
@ -65,6 +66,7 @@
|
||||||
"vuemoji-picker": "0.2.0"
|
"vuemoji-picker": "0.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/nconf": "^0.10.6",
|
||||||
"@typescript-eslint/eslint-plugin": "6.7.4",
|
"@typescript-eslint/eslint-plugin": "6.7.4",
|
||||||
"@vitejs/plugin-vue": "4.5.2",
|
"@vitejs/plugin-vue": "4.5.2",
|
||||||
"electron": "28.0.0",
|
"electron": "28.0.0",
|
||||||
|
|
|
@ -2,17 +2,43 @@ import { reactive, ref, watch } from "vue";
|
||||||
|
|
||||||
import { getConfig, setConfig } from "../js/api";
|
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({
|
export const settingsStore = reactive({
|
||||||
local: {
|
local: {
|
||||||
host: "127.0.0.1",
|
host: "127.0.0.1",
|
||||||
port: "5000",
|
port: "5000",
|
||||||
enable_fft: false,
|
enable_fft: true,
|
||||||
spectrum: "waterfall",
|
spectrum: "waterfall",
|
||||||
wf_theme: 0,
|
wf_theme: 2,
|
||||||
theme: "default_light",
|
theme: "default_light",
|
||||||
high_graphics: true,
|
high_graphics: true,
|
||||||
update_channel: "alpha",
|
update_channel: "alpha",
|
||||||
enable_sys_notification: true,
|
enable_sys_notification: false,
|
||||||
},
|
},
|
||||||
remote: {
|
remote: {
|
||||||
AUDIO: {
|
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() {
|
export function onChange() {
|
||||||
setConfig(settingsStore.remote).then((conf) => {
|
setConfig(settingsStore.remote).then((conf) => {
|
||||||
settingsStore.remote = conf;
|
settingsStore.remote = conf;
|
||||||
|
@ -86,6 +116,13 @@ export function getRemote() {
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(settingsStore.local, (oldValue, newValue) => {
|
watch(settingsStore.local, (oldValue, newValue) => {
|
||||||
// TODO handle local file saving
|
//This function watches for changes, and triggers a save of local settings
|
||||||
const cenas = newValue;
|
saveSettingsToConfig();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function saveSettingsToConfig() {
|
||||||
|
nconf.set('local',settingsStore.local);
|
||||||
|
nconf.save();
|
||||||
|
console.log("Settings saved!");
|
||||||
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue