[CodeFactor] Apply fixes

This commit is contained in:
codefactor-io 2023-11-08 10:25:25 +00:00
parent 0e21c33376
commit 67a2bc8f98
No known key found for this signature in database
GPG key ID: B66B2D63282C190F
2 changed files with 29 additions and 36 deletions

View file

@ -8,11 +8,9 @@ const settings = useSettingsStore(pinia);
import { processModemConfig } from "../js/settingsHandler.ts";
export function fetchSettings() {
// fetch Settings
getFromServer('localhost', 5000, 'config')
getFromServer("localhost", 5000, "config");
}
async function getFromServer(host, port, endpoint) {
@ -20,25 +18,23 @@ async function getFromServer(host, port, endpoint) {
// TODO make this function using the host and port, specified in settings
// include better error handling
const url = 'http://' + host + ':' + port + '/' + endpoint
const url = "http://" + host + ":" + port + "/" + endpoint;
const response = await fetch(url);
const data = await response.json();
// move received data to our data dispatcher
restDataDispatcher(endpoint, data.data)
restDataDispatcher(endpoint, data.data);
}
function restDataDispatcher(endpoint, data) {
// dispatch received data by endpoint
switch (endpoint) {
case 'config':
processModemConfig(data)
case "config":
processModemConfig(data);
break;
default:
console.log('Wrong endpoint:' + endpoint);
console.log("Wrong endpoint:" + endpoint);
}
}

View file

@ -9,7 +9,6 @@ setActivePinia(pinia);
import { useSettingsStore } from "../store/settingsStore.js";
const settings = useSettingsStore(pinia);
// ---------------------------------
console.log(process.env);
@ -107,12 +106,10 @@ export function saveSettingsToFile() {
}
export function processModemConfig(data) {
console.log(data)
console.log(data);
// basic test if we received settings
// we should iterate through JSON, by using equal variables here like in modem config
// STATION SETTINGS
settings.mycall = data["STATION"].mycall
settings.mygrid = data["STATION"].mygrid
settings.mycall = data["STATION"].mycall;
settings.mygrid = data["STATION"].mygrid;
}