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";
|
import { processModemConfig } from "../js/settingsHandler.ts";
|
||||||
|
|
||||||
|
export function fetchSettings() {
|
||||||
|
// fetch Settings
|
||||||
export function fetchSettings(){
|
getFromServer("localhost", 5000, "config");
|
||||||
// fetch Settings
|
|
||||||
getFromServer('localhost', 5000, 'config')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getFromServer(host, port, endpoint) {
|
async function getFromServer(host, port, endpoint) {
|
||||||
// our central function for fetching the modems REST API by a specific 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
|
// TODO make this function using the host and port, specified in settings
|
||||||
// include better error handling
|
// include better error handling
|
||||||
|
|
||||||
const url = 'http://' + host + ':' + port + '/' + endpoint
|
const url = "http://" + host + ":" + port + "/" + endpoint;
|
||||||
const response = await fetch(url);
|
const response = await fetch(url);
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
// move received data to our data dispatcher
|
// move received data to our data dispatcher
|
||||||
restDataDispatcher(endpoint, data.data)
|
restDataDispatcher(endpoint, data.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function restDataDispatcher(endpoint, data){
|
function restDataDispatcher(endpoint, data) {
|
||||||
// dispatch received data by endpoint
|
// dispatch received data by endpoint
|
||||||
|
|
||||||
switch (endpoint) {
|
switch (endpoint) {
|
||||||
case 'config':
|
case "config":
|
||||||
processModemConfig(data)
|
processModemConfig(data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
console.log('Wrong endpoint:' + endpoint);
|
console.log("Wrong endpoint:" + endpoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ setActivePinia(pinia);
|
||||||
import { useSettingsStore } from "../store/settingsStore.js";
|
import { useSettingsStore } from "../store/settingsStore.js";
|
||||||
const settings = useSettingsStore(pinia);
|
const settings = useSettingsStore(pinia);
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------
|
// ---------------------------------
|
||||||
|
|
||||||
console.log(process.env);
|
console.log(process.env);
|
||||||
|
@ -84,7 +83,7 @@ export function loadSettings() {
|
||||||
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (key=="wftheme") {
|
if (key == "wftheme") {
|
||||||
setColormap(config[key]);
|
setColormap(config[key]);
|
||||||
}
|
}
|
||||||
if (key == "mycall") {
|
if (key == "mycall") {
|
||||||
|
@ -106,13 +105,11 @@ export function saveSettingsToFile() {
|
||||||
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function processModemConfig(data){
|
export function processModemConfig(data) {
|
||||||
console.log(data)
|
console.log(data);
|
||||||
// basic test if we received settings
|
// basic test if we received settings
|
||||||
// we should iterate through JSON, by using equal variables here like in modem config
|
// we should iterate through JSON, by using equal variables here like in modem config
|
||||||
// STATION SETTINGS
|
// STATION SETTINGS
|
||||||
settings.mycall = data["STATION"].mycall
|
settings.mycall = data["STATION"].mycall;
|
||||||
settings.mygrid = data["STATION"].mygrid
|
settings.mygrid = data["STATION"].mygrid;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue