Skip to content

Commit 4db2a10

Browse files
committed
added advanced menu
1 parent 91e56b4 commit 4db2a10

File tree

5 files changed

+259
-13
lines changed

5 files changed

+259
-13
lines changed

advanced.html

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta charset="UTF-8" />
6+
<meta http-equiv="Content-Security-Policy"
7+
content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'" />
8+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
9+
<!-- Bootstrap CSS -->
10+
<link rel="stylesheet" href="./node_modules/bootstrap/dist/css/bootstrap.min.css" />
11+
<script>let $ = require("jquery");</script>
12+
<script>require("popper.js");</script>
13+
<script>require("bootstrap");</script>
14+
</head>
15+
16+
<style>
17+
html, body {
18+
overflow-x: hidden;
19+
margin: 0;
20+
padding: 0;
21+
background-color: #303030;
22+
color: #c6c6c6;
23+
}
24+
25+
body {
26+
background-color: #303030;
27+
color: #c6c6c6;
28+
}
29+
30+
input[type="checkbox"] {
31+
accent-color: #b3b3b3;
32+
}
33+
34+
.card {
35+
background-color: #303030;
36+
color: #c6c6c6;
37+
border: 1px solid #727272;
38+
}
39+
40+
.card {
41+
position: fixed;
42+
top: 0;
43+
left: 0;
44+
width: 100%;
45+
height: 100%;
46+
}
47+
48+
.card-header,
49+
.card-footer {
50+
background-color: #1c1c1c;
51+
}
52+
53+
.btn-primary {
54+
background-color: #375a7f;
55+
border-color: #375a7f;
56+
}
57+
58+
.bottom-right {
59+
position: fixed;
60+
bottom: 0;
61+
right: 0;
62+
padding: 4px;
63+
}
64+
65+
.nav-link {
66+
height: 30px;
67+
padding: 0px;
68+
color: #c6c6c6;
69+
border: 1px solid #303030;
70+
}
71+
72+
.nav-tabs .nav-item.show .nav-link,
73+
.nav-tabs .nav-link.active {
74+
color: #c6c6c6;
75+
background-color: #303030;
76+
border: 1px solid #303030;
77+
}
78+
79+
.nav-tabs .nav-link {
80+
background-color: #262626;
81+
}
82+
83+
.log,
84+
.log-qrg,
85+
.log-text {
86+
margin: 4px;
87+
padding-left: 4px;
88+
padding-right: 4px;
89+
}
90+
91+
.form-control,
92+
.log {
93+
background-color: #1c1c1c;
94+
color: #b3b3b3;
95+
border: 1px solid #727272;
96+
}
97+
98+
.form-control:focus {
99+
color: inherit;
100+
background-color: #1c1c1c;
101+
}
102+
103+
.form-control:disabled, .form-control[readonly] {
104+
background-color: #3e3e3e;
105+
opacity: 1;
106+
}
107+
108+
#buttonsRow {
109+
position: fixed;
110+
bottom: 8px;
111+
width: 100%;
112+
padding: 10px;
113+
}
114+
115+
#reload_icon {
116+
width: 16px;
117+
height: 16px;
118+
margin-left: 4px;
119+
margin-bottom: 2px;
120+
vertical-align: middle;
121+
fill: white;
122+
}
123+
124+
label {
125+
display: flex;
126+
align-items: center;
127+
}
128+
129+
label svg {
130+
cursor: pointer;
131+
}
132+
</style>
133+
134+
<body>
135+
<div class="row">
136+
<div class="col">
137+
<div class="mb-3 col-mb-3">
138+
<label for="hamlib_host">Hamlib Host</label>
139+
<input type="text" class="form-control form-control-sm" name="hamlib_host"
140+
id="hamlib_host" value="" />
141+
</div>
142+
</div>
143+
<div class="col">
144+
<div class="mb-2 col-mb-2">
145+
<label for="hamlib_port">Hamlib Port</label>
146+
<input type="number" class="form-control form-control-sm" name="hamlib_port"
147+
id="hamlib_port" value="" />
148+
</div>
149+
</div>
150+
<div class="col">
151+
<div class="mb-1 col-mb-1">
152+
<label for="hamlib_ena">Hamlib Enabled</label>
153+
<input type="checkbox" value="1" class="form-control form-control-sm" name="hamlib_ena" id="hamlib_ena" value="" />
154+
</div>
155+
</div>
156+
</div>
157+
<div class="row" id="buttonsRow">
158+
<div class="col">
159+
<div class="mb-3 col-mb-3" style="text-align: left">
160+
<button type="button" class="btn btn-primary" id="save"></i>Save & reload</button>
161+
</div>
162+
</div>
163+
</div>
164+
<script src="./advanced.js"></script>
165+
</body>
166+
</html>

advanced.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const {ipcRenderer} = require('electron');
2+
3+
var cfg = {};
4+
5+
const bt_save=document.querySelector("#save");
6+
7+
$(document).ready(function() {
8+
cfg=ipcRenderer.sendSync("get_config", '');
9+
10+
$("#hamlib_host").val(cfg.hamlib_host);
11+
$("#hamlib_port").val(cfg.hamlib_port);
12+
$("#hamlib_ena").prop("checked", cfg.hamlib_ena);
13+
14+
bt_save.addEventListener('click', () => {
15+
cfg.hamlib_host=$("#hamlib_host").val().trim();
16+
cfg.hamlib_port=$("#hamlib_port").val().trim();
17+
cfg.hamlib_ena=$("#hamlib_ena").is(':checked');
18+
19+
if ($("#hamlib_ena").is(':checked') || cfg.flrig_ena){cfg.flrig_ena = false;}
20+
21+
x=ipcRenderer.sendSync("set_config", cfg);
22+
console.log(x);
23+
24+
ipcRenderer.sendSync("reload", '');
25+
});
26+
});

index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,14 @@
112112
vertical-align: middle;
113113
fill: white;
114114
}
115-
115+
116116
label {
117117
display: flex;
118118
align-items: center;
119119
}
120-
120+
121121
label svg {
122-
cursor: pointer;
122+
cursor: pointer;
123123
}
124124
</style>
125125

main.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ var defaultcfg = {
2525
flrig_host: '127.0.0.1',
2626
flrig_port: '12345',
2727
flrig_ena: false,
28+
hamlib_host: '127.0.0.1',
29+
hamlib_port: '4532',
30+
hamlib_ena: false,
2831
}
2932

3033
const storage = require('electron-json-storage');
@@ -66,6 +69,37 @@ function createWindow () {
6669
return mainWindow;
6770
}
6871

72+
function createAdvancedWindow (mainWindow) {
73+
let advancedWindow;
74+
globalShortcut.register('Control+Shift+D', () => {
75+
if (!advancedWindow || advancedWindow.isDestroyed()) {
76+
const bounds = mainWindow.getBounds();
77+
advancedWindow = new BrowserWindow({
78+
width: 430,
79+
height: 250,
80+
//resizable: false,
81+
autoHideMenuBar: app.isPackaged,
82+
webPreferences: {
83+
contextIsolation: false,
84+
nodeIntegration: true,
85+
devTools: !app.isPackaged,
86+
enableRemoteModule: true,
87+
},
88+
x: bounds.x + bounds.width + 10,
89+
y: bounds.y,
90+
});
91+
if (app.isPackaged) {
92+
advancedWindow.setMenu(null);
93+
}
94+
advancedWindow.loadFile('advanced.html');
95+
advancedWindow.setTitle(require('./package.json').name + " V" + require('./package.json').version);
96+
} else {
97+
advancedWindow.focus();
98+
}
99+
100+
});
101+
}
102+
69103
ipcMain.on("set_config", async (event,arg) => {
70104
// event.returnValue="aha";
71105
defaultcfg=arg;
@@ -94,6 +128,12 @@ ipcMain.on("setCAT", async (event,arg) => {
94128
event.returnValue=true;
95129
});
96130

131+
ipcMain.on("reload", async (event,arg) => {
132+
app.relaunch();
133+
app.quit();
134+
event.returnValue=true;
135+
});
136+
97137
ipcMain.on("quit", async (event,arg) => {
98138
app.quit();
99139
event.returnValue=true;
@@ -120,6 +160,7 @@ ipcMain.on("test", async (event,arg) => {
120160

121161
app.whenReady().then(() => {
122162
s_mainWindow=createWindow();
163+
createAdvancedWindow(s_mainWindow);
123164
globalShortcut.register('Control+Shift+I', () => { return false; });
124165
app.on('activate', function () {
125166
if (BrowserWindow.getAllWindows().length === 0) createWindow()

renderer.js

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ $(document).ready(function() {
5656
cfg.flrig_ena=$("#flrig_ena").is(':checked');
5757
cfg.hamlib_ena=$("#hamlib_ena").is(':checked');
5858
cfg.wavelog_pmode=$("#wavelog_pmode").is(':checked');
59+
60+
// advanced
61+
if ($("#flrig_ena").is(':checked') || cfg.hamlib_ena){cfg.hamlib_ena = false;}
62+
5963
x=ipcRenderer.sendSync("set_config", cfg);
6064
console.log(x);
6165
});
@@ -166,7 +170,7 @@ async function get_trx() {
166170
if (!(isDeepEqual(oldCat,currentCat))) {
167171
// console.log(currentCat);
168172
console.log(await informWavelog(currentCat));
169-
}
173+
}
170174
oldCat=currentCat;
171175
return currentCat;
172176
}
@@ -193,8 +197,13 @@ async function getInfo(which) {
193197
if (cfg.hamlib_ena) {
194198
var commands = {"rig.get_vfo": "f", "rig.get_mode": "m", "rig.get_ptt": 0, "rig.get_power": 0, "rig.get_split": 0, "rig.get_vfoB": 0, "rig.get_modeB": 0};
195199

200+
<<<<<<< HEAD
201+
const host = cfg.hamlib_host;
202+
const port = parseInt(cfg.hamlib_port, 10);
203+
=======
196204
const host = $("#flrig_host").val();
197205
const port = parseInt($("#flrig_port").val(), 10);
206+
>>>>>>> 91e56b49cbd4df4dbaca9a018270e49ce6eed908
198207

199208
return new Promise((resolve, reject) => {
200209
if (commands[which]) {
@@ -218,7 +227,11 @@ async function getInfo(which) {
218227
}
219228

220229
async function getsettrx() {
230+
<<<<<<< HEAD
231+
if ($("#flrig_ena").is(':checked') || cfg.hamlib_ena) {
232+
=======
221233
if ($("#flrig_ena").is(':checked') || $("#hamlib_ena").is(':checked')) {
234+
>>>>>>> 91e56b49cbd4df4dbaca9a018270e49ce6eed908
222235
x=await get_trx();
223236
setTimeout(() => {
224237
getsettrx();
@@ -240,10 +253,10 @@ const isDeepEqual = (object1, object2) => {
240253
const isObjects = isObject(value1) && isObject(value2);
241254

242255
if ((isObjects && !isDeepEqual(value1, value2)) ||
243-
(!isObjects && value1 !== value2)
244-
) {
245-
return false;
246-
}
256+
(!isObjects && value1 !== value2)
257+
) {
258+
return false;
259+
}
247260
}
248261
return true;
249262
};
@@ -253,9 +266,9 @@ const isObject = (object) => {
253266
};
254267

255268
async function informWavelog(CAT) {
256-
let data = {
257-
radio: "WLGate",
258-
key: cfg.wavelog_key,
269+
let data = {
270+
radio: "WLGate",
271+
key: cfg.wavelog_key,
259272
radio: cfg.wavelog_radioname
260273
};
261274
if (CAT.power !== undefined && CAT.power !== 0) {
@@ -274,7 +287,7 @@ async function informWavelog(CAT) {
274287
data.frequency=CAT.vfo;
275288
data.mode=CAT.mode;
276289
}
277-
290+
278291
let x=await fetch(cfg.wavelog_url + '/api/radio', {
279292
method: 'POST',
280293
rejectUnauthorized: false,
@@ -330,7 +343,7 @@ function fillDropdown(data) {
330343
let select = $('#wavelog_id');
331344
select.empty();
332345
select.prop('disabled', false);
333-
346+
334347
data.forEach(function(station) {
335348
let optionText = station.station_profile_name + " (" + station.station_callsign + ", ID: " + station.station_id + ")";
336349
let optionValue = station.station_id;

0 commit comments

Comments
 (0)