mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
[CodeFactor] Apply fixes
This commit is contained in:
parent
0e21c33376
commit
67a2bc8f98
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue