[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,37 +8,33 @@ const settings = useSettingsStore(pinia);
import { processModemConfig } from "../js/settingsHandler.ts";
export function fetchSettings(){
// fetch Settings
getFromServer('localhost', 5000, 'config')
export function fetchSettings() {
// fetch Settings
getFromServer("localhost", 5000, "config");
}
async function getFromServer(host, port, endpoint) {
// our central function for fetching the modems REST API by a specific endpoint
// TODO make this function using the host and port, specified in settings
// include better error handling
// our central function for fetching the modems REST API by a specific endpoint
// TODO make this function using the host and port, specified in settings
// include better error handling
const url = 'http://' + host + ':' + port + '/' + endpoint
const response = await fetch(url);
const data = await response.json();
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)
// move received data to our data dispatcher
restDataDispatcher(endpoint, data.data);
}
function restDataDispatcher(endpoint, data){
// dispatch received data by endpoint
function restDataDispatcher(endpoint, data) {
// dispatch received data by endpoint
switch (endpoint) {
case 'config':
processModemConfig(data)
break;
switch (endpoint) {
case "config":
processModemConfig(data);
break;
default:
console.log('Wrong endpoint:' + endpoint);
}
default:
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);
@ -84,7 +83,7 @@ export function loadSettings() {
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
}
try {
if (key=="wftheme") {
if (key == "wftheme") {
setColormap(config[key]);
}
if (key == "mycall") {
@ -106,13 +105,11 @@ export function saveSettingsToFile() {
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
}
export function processModemConfig(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
}
export function processModemConfig(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;
}