2023-11-27 02:37:28 +00:00
|
|
|
import { reactive, ref, watch } from "vue";
|
2023-10-03 13:15:17 +00:00
|
|
|
|
2023-11-18 09:44:17 +00:00
|
|
|
import { getConfig, setConfig } from "../js/api";
|
2023-10-04 17:54:50 +00:00
|
|
|
|
2023-12-10 20:58:12 +00:00
|
|
|
var nconf = require("nconf");
|
|
|
|
nconf.file({ file: "config/config.json" });
|
2023-12-10 20:51:19 +00:00
|
|
|
|
|
|
|
// +++
|
|
|
|
//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: {
|
2023-12-10 20:58:12 +00:00
|
|
|
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,
|
2023-12-17 15:58:19 +00:00
|
|
|
grid_layout: "[]",
|
2023-12-10 20:58:12 +00:00
|
|
|
},
|
2023-12-10 20:51:19 +00:00
|
|
|
});
|
|
|
|
|
2023-12-10 20:58:12 +00:00
|
|
|
nconf.required(["local:host", "local:port"]);
|
2023-12-10 20:51:19 +00:00
|
|
|
|
2023-11-18 15:53:54 +00:00
|
|
|
export const settingsStore = reactive({
|
|
|
|
local: {
|
|
|
|
host: "127.0.0.1",
|
|
|
|
port: "5000",
|
2023-12-10 20:51:19 +00:00
|
|
|
enable_fft: true,
|
2023-11-27 02:37:28 +00:00
|
|
|
spectrum: "waterfall",
|
2023-12-10 20:51:19 +00:00
|
|
|
wf_theme: 2,
|
2023-12-03 23:54:44 +00:00
|
|
|
theme: "default_light",
|
|
|
|
high_graphics: true,
|
|
|
|
update_channel: "alpha",
|
2023-12-10 20:51:19 +00:00
|
|
|
enable_sys_notification: false,
|
2023-12-17 15:58:19 +00:00
|
|
|
grid_layout: "[]",
|
2023-11-18 15:53:54 +00:00
|
|
|
},
|
2023-11-18 09:44:17 +00:00
|
|
|
remote: {
|
|
|
|
AUDIO: {
|
|
|
|
enable_auto_tune: false,
|
|
|
|
input_device: "",
|
|
|
|
output_device: "",
|
|
|
|
rx_audio_level: 0,
|
|
|
|
tx_audio_level: 0,
|
|
|
|
},
|
|
|
|
MESH: {
|
|
|
|
enable_protocol: false,
|
|
|
|
},
|
|
|
|
MODEM: {
|
|
|
|
enable_fft: false,
|
|
|
|
enable_fsk: false,
|
|
|
|
enable_low_bandwidth_mode: false,
|
|
|
|
respond_to_cq: false,
|
|
|
|
rx_buffer_size: 0,
|
|
|
|
tuning_range_fmax: 0,
|
|
|
|
tuning_range_fmin: 0,
|
|
|
|
tx_delay: 0,
|
2023-11-18 15:59:19 +00:00
|
|
|
beacon_interval: 0,
|
2023-11-19 08:56:00 +00:00
|
|
|
enable_hamc: false,
|
|
|
|
enable_morse_identifier: false,
|
2023-11-18 09:44:17 +00:00
|
|
|
},
|
|
|
|
RADIO: {
|
2023-11-18 11:57:36 +00:00
|
|
|
control: "disabled",
|
|
|
|
model_id: 0,
|
|
|
|
serial_port: "",
|
|
|
|
serial_speed: "",
|
|
|
|
data_bits: 0,
|
|
|
|
stop_bits: 0,
|
|
|
|
serial_handshake: "",
|
|
|
|
ptt_port: "",
|
|
|
|
ptt_type: "",
|
|
|
|
serial_dcd: "",
|
|
|
|
serial_dtr: "",
|
|
|
|
},
|
|
|
|
RIGCTLD: {
|
|
|
|
ip: "127.0.0.1",
|
|
|
|
port: 0,
|
|
|
|
path: "",
|
|
|
|
command: "",
|
|
|
|
arguments: "",
|
2023-11-18 09:44:17 +00:00
|
|
|
},
|
|
|
|
STATION: {
|
|
|
|
enable_explorer: false,
|
|
|
|
enable_stats: false,
|
|
|
|
mycall: "",
|
2023-11-18 11:57:36 +00:00
|
|
|
myssid: 0,
|
2023-11-18 09:44:17 +00:00
|
|
|
mygrid: "",
|
|
|
|
ssid_list: [],
|
|
|
|
},
|
|
|
|
TCI: {
|
|
|
|
tci_ip: "127.0.0.1",
|
|
|
|
tci_port: 0,
|
|
|
|
},
|
|
|
|
},
|
2023-11-18 15:53:54 +00:00
|
|
|
});
|
2023-10-03 13:15:17 +00:00
|
|
|
|
2023-12-10 20:51:19 +00:00
|
|
|
//Save settings for GUI to config file
|
2023-12-10 20:58:12 +00:00
|
|
|
settingsStore.local = nconf.get("local");
|
2023-12-10 20:51:19 +00:00
|
|
|
saveSettingsToConfig();
|
|
|
|
|
2023-11-18 09:44:17 +00:00
|
|
|
export function onChange() {
|
|
|
|
setConfig(settingsStore.remote).then((conf) => {
|
|
|
|
settingsStore.remote = conf;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-11-18 15:53:54 +00:00
|
|
|
export function getRemote() {
|
2023-11-20 13:24:45 +00:00
|
|
|
return getConfig().then((conf) => {
|
2023-11-18 15:53:54 +00:00
|
|
|
settingsStore.remote = conf;
|
|
|
|
});
|
|
|
|
}
|
2023-09-05 17:35:54 +00:00
|
|
|
|
2023-11-18 16:12:05 +00:00
|
|
|
watch(settingsStore.local, (oldValue, newValue) => {
|
2023-12-10 20:51:19 +00:00
|
|
|
//This function watches for changes, and triggers a save of local settings
|
|
|
|
saveSettingsToConfig();
|
2023-11-18 16:12:05 +00:00
|
|
|
});
|
2023-12-10 20:51:19 +00:00
|
|
|
|
2023-12-16 16:11:16 +00:00
|
|
|
export function saveSettingsToConfig() {
|
2023-12-10 20:58:12 +00:00
|
|
|
nconf.set("local", settingsStore.local);
|
2023-12-10 20:51:19 +00:00
|
|
|
nconf.save();
|
|
|
|
console.log("Settings saved!");
|
2023-12-10 20:58:12 +00:00
|
|
|
}
|