mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
improved gui reconnecting
This commit is contained in:
parent
17bce4b0db
commit
ec34a690e9
3 changed files with 30 additions and 23 deletions
|
@ -69,8 +69,11 @@ export async function getVersion() {
|
|||
let data = await apiGet("/version").then((res) => {
|
||||
return res;
|
||||
});
|
||||
|
||||
if (typeof data !== "undefined" && typeof data.version !== "undefined") {
|
||||
return data.version;
|
||||
//return data["version"];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
export async function getConfig() {
|
||||
|
|
|
@ -24,7 +24,7 @@ setActivePinia(pinia);
|
|||
import { useStateStore } from "../store/stateStore.js";
|
||||
const stateStore = useStateStore(pinia);
|
||||
|
||||
import { settingsStore as settings } from "../store/settingsStore.js";
|
||||
import { settingsStore as settings, getRemote } from "../store/settingsStore.js";
|
||||
|
||||
export function connectionFailed(endpoint, event) {
|
||||
stateStore.modem_connection = "disconnected";
|
||||
|
@ -128,9 +128,16 @@ export function eventDispatcher(data) {
|
|||
message = "Connected to server";
|
||||
displayToast("success", "bi-ethernet", message, 5000);
|
||||
stateStore.modem_connection = "connected";
|
||||
|
||||
|
||||
getRemote().then(() => {
|
||||
//initConnections();
|
||||
getModemState();
|
||||
});
|
||||
|
||||
//getConfig();
|
||||
getModemState();
|
||||
getOverallHealth();
|
||||
getConfig();
|
||||
getAudioDevices();
|
||||
getSerialDevices();
|
||||
getFreedataMessages();
|
||||
|
|
|
@ -29,23 +29,8 @@ nconf.file({ file: configPath });
|
|||
//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",
|
||||
spectrum: "waterfall",
|
||||
wf_theme: 2,
|
||||
update_channel: "alpha",
|
||||
enable_sys_notification: false,
|
||||
grid_layout: "[]",
|
||||
grid_preset: "[]",
|
||||
grid_enabled: true,
|
||||
},
|
||||
});
|
||||
|
||||
nconf.required(["local:host", "local:port"]);
|
||||
|
||||
export const settingsStore = reactive({
|
||||
const defaultConfig = {
|
||||
local: {
|
||||
host: "127.0.0.1",
|
||||
port: "5000",
|
||||
|
@ -104,7 +89,7 @@ export const settingsStore = reactive({
|
|||
STATION: {
|
||||
enable_explorer: false,
|
||||
enable_stats: false,
|
||||
mycall: "",
|
||||
mycall: "DEFAULT",
|
||||
myssid: 0,
|
||||
mygrid: "",
|
||||
ssid_list: [],
|
||||
|
@ -114,7 +99,12 @@ export const settingsStore = reactive({
|
|||
tci_port: 0,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
nconf.defaults(defaultConfig.local);
|
||||
nconf.required(["local:host", "local:port"]);
|
||||
|
||||
export const settingsStore = reactive(defaultConfig);
|
||||
|
||||
//Save settings for GUI to config file
|
||||
settingsStore.local = nconf.get("local");
|
||||
|
@ -128,10 +118,17 @@ export function onChange() {
|
|||
|
||||
export function getRemote() {
|
||||
return getConfig().then((conf) => {
|
||||
if (typeof conf !== 'undefined') {
|
||||
settingsStore.remote = conf;
|
||||
onChange();
|
||||
} else {
|
||||
console.warn('Received undefined configuration, using default!');
|
||||
settingsStore.remote = defaultConfig.remote;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
watch(settingsStore.local, (oldValue, newValue) => {
|
||||
//This function watches for changes, and triggers a save of local settings
|
||||
saveLocalSettingsToConfig();
|
||||
|
|
Loading…
Reference in a new issue