From 67a2bc8f98ae5faf417c38ffa7cd1b9c200000f9 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Wed, 8 Nov 2023 10:25:25 +0000 Subject: [PATCH] [CodeFactor] Apply fixes --- gui/src/js/rest.js | 44 ++++++++++++++++------------------- gui/src/js/settingsHandler.ts | 21 +++++++---------- 2 files changed, 29 insertions(+), 36 deletions(-) diff --git a/gui/src/js/rest.js b/gui/src/js/rest.js index 123c6674..81869b38 100644 --- a/gui/src/js/rest.js +++ b/gui/src/js/rest.js @@ -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); + } } - - diff --git a/gui/src/js/settingsHandler.ts b/gui/src/js/settingsHandler.ts index da7c759d..aa33c114 100644 --- a/gui/src/js/settingsHandler.ts +++ b/gui/src/js/settingsHandler.ts @@ -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 - - -} \ No newline at end of file +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; +}