Merge pull request #615 from DJ2LS/hotfix

Hotfix: load GUI config
This commit is contained in:
DJ2LS 2024-01-17 20:00:02 +01:00 committed by GitHub
commit cd1a37ddbe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 43 additions and 34 deletions

View file

@ -2,7 +2,7 @@
"name": "FreeDATA",
"description": "FreeDATA",
"private": true,
"version": "0.12.0-alpha",
"version": "0.12.1-alpha",
"main": "dist-electron/main/index.js",
"scripts": {
"start": "vite",

View file

@ -14,6 +14,7 @@ import { useStateStore } from "../store/stateStore.js";
const state = useStateStore(pinia);
import { settingsStore as settings } from "../store/settingsStore.js";
import { getAppDataPath } from "../js/freedata";
import { displayToast } from "./popupHandler.js";
@ -99,34 +100,8 @@ PouchDB.plugin(require("pouchdb-find"));
//PouchDB.plugin(require('pouchdb-replication'));
PouchDB.plugin(require("pouchdb-upsert"));
// https://stackoverflow.com/a/26227660
if (typeof process.env["APPDATA"] !== "undefined") {
var appDataFolder = process.env["APPDATA"];
console.log(appDataFolder);
} else {
var appDataFolder: string;
switch (process.platform) {
case "darwin":
appDataFolder = process.env["HOME"] + "/Library/Application Support";
console.log(appDataFolder);
break;
case "linux":
appDataFolder = process.env["HOME"] + "/.config";
console.log(appDataFolder);
break;
case "win32":
appDataFolder = "undefined";
break;
default:
appDataFolder = "undefined";
break;
}
}
console.log("loading chat database...");
console.log("appdata folder:" + appDataFolder);
var configFolder = path.join(appDataFolder, "FreeDATA");
console.log("config folder:" + configFolder);
var appDataPath = getAppDataPath();
var configFolder = path.join(appDataPath, "FreeDATA");
var chatDB = path.join(configFolder, "chatDB");
console.log("database path:" + chatDB);

View file

@ -1,3 +1,6 @@
const os = require("os");
const path = require("path");
/**
* Binary to ASCII replacement
* @param {string} data in normal/usual utf-8 format
@ -97,3 +100,25 @@ export function validateCallsignWithoutSSID(callsign: string) {
}
return true;
}
export function getAppDataPath() {
const platform = os.platform();
let appDataPath;
switch (platform) {
case "darwin": // macOS
appDataPath = path.join(os.homedir(), "Library", "Application Support");
break;
case "win32": // Windows
appDataPath =
process.env.APPDATA || path.join(os.homedir(), "AppData", "Roaming");
break;
case "linux": // Linux
appDataPath = path.join(os.homedir(), ".config");
break;
default:
throw new Error("Unsupported platform");
}
return appDataPath;
}

View file

@ -1,9 +1,19 @@
import { reactive, ref, watch } from "vue";
import { getConfig, setConfig } from "../js/api";
import { getAppDataPath } from "../js/freedata";
import fs from "fs";
const path = require("path");
const nconf = require("nconf");
var nconf = require("nconf");
nconf.file({ file: "config/config.json" });
var appDataPath = getAppDataPath();
var configFolder = path.join(appDataPath, "FreeDATA");
var configPath = path.join(configFolder, "config.json");
console.log("AppData Path:", appDataPath);
console.log(configFolder);
console.log(configPath);
nconf.file({ file: configPath });
// +++
//GUI DEFAULT SETTINGS........

View file

@ -190,7 +190,6 @@ class radio:
try:
mode, bandwidth = response.split('\n', 1) # Split the response into mode and bandwidth
except ValueError:
print(response)
mode = 'err'
bandwidth = 'err'

View file

@ -22,7 +22,7 @@ app = Flask(__name__)
CORS(app)
CORS(app, resources={r"/*": {"origins": "*"}})
sock = Sock(app)
MODEM_VERSION = "0.12.0-alpha"
MODEM_VERSION = "0.12.1-alpha"
# set config file to use
def set_config():