diff --git a/index.html b/index.html
index 089e389..0c7bc3c 100644
--- a/index.html
+++ b/index.html
@@ -87,11 +87,39 @@
border: 1px solid #727272;
}
+ .form-control:focus {
+ color: inherit;
+ background-color: #1c1c1c;
+ }
+
+ .form-control:disabled, .form-control[readonly] {
+ background-color: #3e3e3e;
+ opacity: 1;
+ }
+
#buttonsRow {
position: fixed;
bottom: 8px;
width: 100%;
- padding: 10px; /* Optional: Füge Padding hinzu, um die Knöpfe zu trennen */
+ padding: 10px;
+ }
+
+ #reload_icon {
+ width: 16px;
+ height: 16px;
+ margin-left: 4px;
+ margin-bottom: 2px;
+ vertical-align: middle;
+ fill: white;
+ }
+
+ label {
+ display: flex;
+ align-items: center;
+ }
+
+ label svg {
+ cursor: pointer;
}
@@ -142,10 +170,16 @@
-
-
-
+
+
+
diff --git a/main.js b/main.js
index 3e95725..c6a7023 100644
--- a/main.js
+++ b/main.js
@@ -42,7 +42,7 @@ storage.has('basic', function(error, hasKey) {
function createWindow () {
const mainWindow = new BrowserWindow({
- width: 420,
+ width: 430,
height: 250,
resizable: false,
autoHideMenuBar: app.isPackaged,
diff --git a/renderer.js b/renderer.js
index ef81bc6..6c138dd 100644
--- a/renderer.js
+++ b/renderer.js
@@ -14,6 +14,8 @@ const {ipcRenderer} = require('electron')
const bt_save=select("#save");
const bt_quit=select("#quit");
const bt_test=select("#test");
+const input_key=select("#wavelog_key");
+const input_url=select("#wavelog_url");
var oldCat={ vfo: 0, mode: "SSB" };
$(document).ready(function() {
@@ -21,7 +23,7 @@ $(document).ready(function() {
cfg=ipcRenderer.sendSync("get_config", '');
$("#wavelog_url").val(cfg.wavelog_url);
$("#wavelog_key").val(cfg.wavelog_key);
- $("#wavelog_id").val(cfg.wavelog_id);
+ // $("#wavelog_id").val(cfg.wavelog_id);
$("#wavelog_radioname").val(cfg.wavelog_radioname);
$("#flrig_host").val(cfg.flrig_host);
$("#flrig_port").val(cfg.flrig_port);
@@ -67,6 +69,19 @@ $(document).ready(function() {
console.log(x);
});
+ input_key.addEventListener('change', () => {
+ getStations();
+ });
+ input_url.addEventListener('change', () => {
+ getStations();
+ });
+ $('#reload_icon').on('click', () => {
+ getStations();
+ });
+ if (cfg.wavelog_key != "" && cfg.wavelog_url != "") {
+ getStations();
+ }
+
getsettrx();
$("#flrig_ena").on( "click",function() {
@@ -78,7 +93,7 @@ $(document).ready(function() {
$("#config-tab").on("click",function() {
obj={};
- obj.width=420;
+ obj.width=430;
obj.height=550;
obj.ani=false;
resizeme(obj);
@@ -86,7 +101,7 @@ $(document).ready(function() {
$("#status-tab").on("click",function() {
obj={};
- obj.width=420;
+ obj.width=430;
obj.height=250;
obj.ani=false;
resizeme(obj);
@@ -120,6 +135,12 @@ async function get_trx() {
let currentCat={};
currentCat.vfo=await getInfo('rig.get_vfo');
currentCat.mode=await getInfo('rig.get_mode');
+ currentCat.ptt=await getInfo('rig.get_ptt');
+ currentCat.power=await getInfo('rig.get_power') ?? 0;
+ currentCat.split=await getInfo('rig.get_split');
+ currentCat.vfoB=await getInfo('rig.get_vfoB');
+ currentCat.modeB=await getInfo('rig.get_modeB');
+
$("#current_trx").html((currentCat.vfo/(1000*1000))+" MHz / "+currentCat.mode);
if (!(isDeepEqual(oldCat,currentCat))) {
// console.log(currentCat);
@@ -131,21 +152,21 @@ async function get_trx() {
async function getInfo(which) {
const response = await fetch(
- "http://"+$("#flrig_host").val()+':'+$("#flrig_port").val(),
- {
+ "http://"+$("#flrig_host").val()+':'+$("#flrig_port").val(), {
method: 'POST',
// mode: 'no-cors',
- headers: {
- 'Accept': 'application/json, application/xml, text/plain, text/html, *.*',
- 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8'
- },
- body: ''+which+''
- });
- const data = await response.text();
+ headers: {
+ 'Accept': 'application/json, application/xml, text/plain, text/html, *.*',
+ 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8'
+ },
+ body: ''+which+''
+ }
+ );
+ const data = await response.text();
var parser = new DOMParser();
- var xmlDoc = parser.parseFromString(data, "text/xml");
- var qrgplain = xmlDoc.getElementsByTagName("value")[0].textContent;
- return qrgplain;
+ var xmlDoc = parser.parseFromString(data, "text/xml");
+ var qrgplain = xmlDoc.getElementsByTagName("value")[0].textContent;
+ return qrgplain;
}
async function getsettrx() {
@@ -184,7 +205,28 @@ const isObject = (object) => {
};
async function informWavelog(CAT) {
- let data={ radio: "WLGate", key: cfg.wavelog_key, radio: cfg.wavelog_radioname, frequency: (CAT.vfo), mode: CAT.mode };
+ let data = {
+ radio: "WLGate",
+ key: cfg.wavelog_key,
+ radio: cfg.wavelog_radioname
+ };
+ if (CAT.power !== undefined && CAT.power !== 0) {
+ data.power = CAT.power;
+ }
+ // if (CAT.ptt !== undefined) { // not impleented yet in Wavelog, so maybe later
+ // data.ptt = CAT.ptt;
+ // }
+ if (CAT.split == '1') {
+ // data.split=true; // not implemented yet in Wavelog
+ data.frequency=CAT.vfoB;
+ data.mode=CAT.modeB;
+ data.frequency_rx=CAT.vfo;
+ data.mode_rx=CAT.mode;
+ } else {
+ data.frequency=CAT.vfo;
+ data.mode=CAT.mode;
+ }
+
let x=await fetch(cfg.wavelog_url + '/api/radio', {
method: 'POST',
rejectUnauthorized: false,
@@ -208,3 +250,48 @@ function updateUtcTime() {
document.getElementById('utc').innerHTML = formattedTime;
}
+
+async function getStations() {
+ let select = $('#wavelog_id');
+ select.empty();
+ select.prop('disabled', true);
+ try {
+ let x = await fetch($('#wavelog_url').val().trim() + '/api/station_info/' + $('#wavelog_key').val().trim(), {
+ method: 'GET',
+ rejectUnauthorized: false,
+ headers: {
+ Accept: 'application/json',
+ 'Content-Type': 'application/json',
+ },
+ });
+
+ if (!x.ok) {
+ throw new Error(`HTTP error! Status: ${x.status}`);
+ }
+
+ let data = await x.json();
+ fillDropdown(data);
+
+ } catch (error) {
+ select.append(new Option('Failed to load stations', '0'));
+ console.error('Could not load station locations:', error.message);
+ }
+}
+
+function fillDropdown(data) {
+ let select = $('#wavelog_id');
+ select.empty();
+ select.prop('disabled', false);
+
+ data.forEach(function(station) {
+ let optionText = station.station_profile_name + " (" + station.station_callsign + ", ID: " + station.station_id + ")";
+ let optionValue = station.station_id;
+ select.append(new Option(optionText, optionValue));
+ });
+
+ if (cfg.wavelog_id && data.some(station => station.station_id == cfg.wavelog_id)) {
+ select.val(cfg.wavelog_id);
+ } else {
+ select.val(data.length > 0 ? data[0].station_id : null);
+ }
+}
\ No newline at end of file