diff --git a/gui/main.js b/gui/main.js index 47e8f687..8fd9524d 100644 --- a/gui/main.js +++ b/gui/main.js @@ -10,12 +10,13 @@ const path = require('path'); const fs = require('fs'); const os = require('os'); const spawn = require('child_process').spawn; -const exec = require('child_process').exec; const log = require('electron-log'); const mainLog = log.scope('main'); const daemonProcessLog = log.scope('freedata-daemon'); const mime = require('mime'); +const net = require('net'); + const sysInfo = log.scope('system information'); sysInfo.info("SYSTEM INFORMATION ----------------------------- "); @@ -168,10 +169,26 @@ let data = null; let logViewer = null; var daemonProcess = null; + +// create a splash screen +function createSplashScreen(){ + splashScreen = new BrowserWindow({ + height: 250, + width: 250, + transparent: true, + frame: false, + alwaysOnTop: true + }); + splashScreen.loadFile('src/splash.html'); + splashScreen.center(); +} + + function createWindow() { win = new BrowserWindow({ width: config.screen_width, height: config.screen_height, + show: false, autoHideMenuBar: true, icon: 'src/img/icon.png', webPreferences: { @@ -285,8 +302,19 @@ function createWindow() { } app.whenReady().then(() => { + + // show splash screen + createSplashScreen(); + + // create main window createWindow(); + // wait some time, then close splash screen and show main windows + setTimeout(function() { + splashScreen.close(); + win.show(); + }, 3000); + // start daemon by checking os mainLog.info('Starting freedata-daemon binary'); @@ -830,57 +858,31 @@ ipcMain.on('request-stop-rigctld',(event,data)=>{ -// CHECK RIGCTLD -ipcMain.on('request-check-rigctld',(data)=>{ +// CHECK RIGCTLD CONNECTION +ipcMain.on('request-check-rigctld',(event, data)=>{ + + try{ - try { let Data = { - state: "unknown", + state: "unknown", }; - isRunning('rigctld', (status) => { - if (status){ - Data["state"] = "running"; - } else { - Data["state"] = "unknown/stopped"; - } - if (win !== null && win !== ''){ - win.webContents.send('action-check-rigctld', Data); - } + var rigctld = new net.Socket(); + rigctld.connect(data.port, data.ip) + + rigctld.on('error', function() { + + Data["state"] = "unknown/stopped - (" + data.ip + ":" + data.port + ")"; + win.webContents.send('action-check-rigctld', Data); }) - } catch (e) { - mainLog.error(e) + rigctld.on('connect', function() { + Data["state"] = "connection possible - (" + data.ip + ":" + data.port + ")"; + win.webContents.send('action-check-rigctld', Data); + }) + + } catch(e) { + console.log(e) } }); - - - - -// https://stackoverflow.com/a/51084163 -// Function for checking if a process is running or not -/* -isRunning('rigctld', (status) => { - if (status){ - Data["state"] = "running"; - } else { - Data["state"] = "unknown"; - } - win.webContents.send('action-check-rigctld', Data); - }) -*/ -const isRunning = (query, cb) => { - let platform = process.platform; - let cmd = ''; - switch (platform) { - case 'win32' : cmd = `tasklist`; break; - case 'darwin' : cmd = `ps -ax | grep ${query}`; break; - case 'linux' : cmd = `ps -A`; break; - default: break; - } - exec(cmd, (err, stdout) => { - cb(stdout.toLowerCase().indexOf(query.toLowerCase()) > -1); - }); -} - diff --git a/gui/preload-chat.js b/gui/preload-chat.js index c9905661..e056cef3 100644 --- a/gui/preload-chat.js +++ b/gui/preload-chat.js @@ -174,18 +174,49 @@ window.addEventListener('DOMContentLoaded', () => { document.getElementById("chatModuleMessage").addEventListener("input", () => { var textarea = document.getElementById("chatModuleMessage"); var text = textarea.value; + + if(document.getElementById("expand_textarea").checked){ + var lines = 6 + } else { var lines = text.split("\n").length - if (lines >= 10){ - lines = 10; + + if (lines >= 6){ + lines = 6; } - var message_container_height_offset = 90 + (23*lines); + + } + var message_container_height_offset = 130 + (20*lines); var message_container_height = `calc(100% - ${message_container_height_offset}px)`; document.getElementById("message-container").style.height = message_container_height; textarea.rows = lines; + console.log(textarea.value) + }) + document.getElementById("expand_textarea").addEventListener("click", () => { + var textarea = document.getElementById("chatModuleMessage"); + +if(document.getElementById("expand_textarea").checked){ + var lines=6 + document.getElementById("expand_textarea_button").className = "bi bi-chevron-compact-down"; + +} else { + var lines=1 + document.getElementById("expand_textarea_button").className = "bi bi-chevron-compact-up"; +} + + var message_container_height_offset = 130 + (20*lines); + //var message_container_height_offset = 90 + (23*lines); + var message_container_height = `calc(100% - ${message_container_height_offset}px)`; + document.getElementById("message-container").style.height = message_container_height; + textarea.rows = lines; + console.log(textarea.rows) + + }) + + // NEW CHAT document.getElementById("createNewChatButton").addEventListener("click", () => { @@ -223,10 +254,12 @@ db.post({ var chatmessage = textarea.value; // reset textarea size - var message_container_height_offset = 110; + var message_container_height_offset = 150; var message_container_height = `calc(100% - ${message_container_height_offset}px)`; document.getElementById("message-container").style.height = message_container_height; textarea.rows = 1 + document.getElementById("expand_textarea_button").className = "bi bi-chevron-compact-up"; + document.getElementById("expand_textarea").checked = false; console.log(file); console.log(filename); diff --git a/gui/preload-main.js b/gui/preload-main.js index 233dd563..30744804 100644 --- a/gui/preload-main.js +++ b/gui/preload-main.js @@ -2306,9 +2306,18 @@ function set_setting_switch(setting_switch, enable_object, state){ setInterval(checkRigctld, 500) function checkRigctld(){ - ipcRenderer.send('request-check-rigctld'); + + var rigctld_ip = document.getElementById("hamlib_rigctld_ip").value; + var rigctld_port = document.getElementById("hamlib_rigctld_port").value; + + let Data = { + ip: rigctld_ip, + port: rigctld_port + }; + ipcRenderer.send('request-check-rigctld', Data); } + ipcRenderer.on('action-check-rigctld', (event, data) => { console.log(data) document.getElementById("hamlib_rigctld_status").value = data["state"]; -}); \ No newline at end of file +}); diff --git a/gui/src/chat-module.html b/gui/src/chat-module.html index 6ab0ad32..812a1336 100644 --- a/gui/src/chat-module.html +++ b/gui/src/chat-module.html @@ -54,11 +54,15 @@
-
+
+ + + +
diff --git a/gui/src/splash.html b/gui/src/splash.html new file mode 100644 index 00000000..07bbe511 --- /dev/null +++ b/gui/src/splash.html @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/gui/src/styles.css b/gui/src/styles.css index b8c6006e..25a6ee03 100644 --- a/gui/src/styles.css +++ b/gui/src/styles.css @@ -27,4 +27,12 @@ html { display: none; } +#chatModuleMessage { + resize: none; + border-radius:15px; +} +#expand_textarea_label{ + border: 0; + padding: 1px; +} \ No newline at end of file