diff --git a/gui/main.js b/gui/main.js index ec58e87d..93ec4a44 100644 --- a/gui/main.js +++ b/gui/main.js @@ -155,6 +155,9 @@ function createWindow() { win.once('ready-to-show', () => { + + autoUpdater.autoInstallOnAppQuit = true; + autoUpdater.autoDownload = true; autoUpdater.checkForUpdatesAndNotify(); }); @@ -181,11 +184,6 @@ app.whenReady().then(() => { console.log("Trying to start daemon binary") - - - - - if(os.platform()=='darwin'){ daemonProcess = exec(path.join(process.resourcesPath, 'tnc', 'daemon'), [], { @@ -213,7 +211,7 @@ app.whenReady().then(() => { }); console.log("-------------------------------") - + daemonProcess = exec(path.join(process.resourcesPath, 'tnc', 'daemon'), [], { cwd: path.join(process.resourcesPath, 'tnc'), @@ -236,7 +234,7 @@ app.whenReady().then(() => { // return process messages daemonProcess.on('error', (err) => { - console.log(err); + console.log(`error when starting daemon: ${err}`); }); daemonProcess.on('message', (data) => { @@ -346,8 +344,54 @@ ipcMain.on('request-update-rx-msg-buffer', (event, arg) => { autoUpdater.on('update-available', () => { console.log('update available'); -}); -autoUpdater.on('update-downloaded', () => { - console.log('update downloaded'); + let arg = { + status: "update-available" + }; + win.webContents.send('action-updater', arg); + }); +autoUpdater.on('update-not-available', () => { + console.log('update-not-available'); + let arg = { + status: "update-not-available" + }; + win.webContents.send('action-updater', arg); +}); + + +autoUpdater.on('update-downloaded', () => { + console.log('update downloaded'); + let arg = { + status: "update-downloaded" + }; + win.webContents.send('action-updater', arg); +}); + +autoUpdater.on('checking-for-update', () => { + let arg = { + status: "checking-for-update" + }; + win.webContents.send('action-updater', arg); +}); + +autoUpdater.on('download-progress', (progress) => { + let arg = { + status: "download-progress", + progress: progress + }; + win.webContents.send('action-updater', arg); +}); + +autoUpdater.on('error', (progress) => { + let arg = { + status: "error", + progress: progress + }; + win.webContents.send('action-updater', arg); +}); + + +ipcMain.on('restart_app', () => { + autoUpdater.quitAndInstall(); +}); diff --git a/gui/package.json b/gui/package.json index 8dfa4d70..c3a9f8d0 100644 --- a/gui/package.json +++ b/gui/package.json @@ -1,6 +1,6 @@ { "name": "FreeDATA", - "version": "0.0.1-alpha.1", + "version": "0.0.1-alpha", "description": "FreeDATA ", "main": "main.js", "scripts": { diff --git a/gui/preload-main.js b/gui/preload-main.js index cd80e46c..20f0e304 100644 --- a/gui/preload-main.js +++ b/gui/preload-main.js @@ -1612,3 +1612,65 @@ ipcRenderer.on('run-tnc-command', (event, arg) => { } }); + + +ipcRenderer.on('action-updater', (event, arg) => { + + console.log(arg.status) + + if (arg.status == "download-progress"){ + var progressinfo = '(' + Math.round(arg.progress.transferred/1024) + 'kB /' + Math.round(arg.progress.total/1024) + 'kB)'; + document.getElementById("toastUpdateProgressInfo").innerHTML = progressinfo; + document.getElementById("toastUpdateProgressSpeed").innerHTML = Math.round(arg.progress.bytesPerSecond/1024) + "kByte/s"; + + document.getElementById("toastUpdateProgressBar").setAttribute("aria-valuenow", arg.progress.percent) + document.getElementById("toastUpdateProgressBar").setAttribute("style", "width:" + arg.progress.percent + "%;") + + var toast = bootstrap.Toast.getOrCreateInstance( + document.getElementById('toastUpdateProgress') + ); // Returns a Bootstrap toast instance + + + let showing = document.getElementById("toastUpdateProgress").getAttribute("class").includes("showing"); + console.log(showing) + if(!showing){ + toast.show(); + + } + } + + if (arg.status == "checking-for-update"){ + var toast = bootstrap.Toast.getOrCreateInstance( + document.getElementById('toastUpdateChecking') + ); // Returns a Bootstrap toast instance + toast.show(); + } + if (arg.status == "update-downloaded"){ + var toast = bootstrap.Toast.getOrCreateInstance( + document.getElementById('toastUpdateDownloaded') + ); // Returns a Bootstrap toast instance + toast.show(); + } + if (arg.status == "update-not-available"){ + var toast = bootstrap.Toast.getOrCreateInstance( + document.getElementById('toastUpdateNotAvailable') + ); // Returns a Bootstrap toast instance + toast.show(); + } + if (arg.status == "update-available"){ + var toast = bootstrap.Toast.getOrCreateInstance( + document.getElementById('toastUpdateAvailable') + ); // Returns a Bootstrap toast instance + toast.show(); + } + + if (arg.status == "error"){ + var toast = bootstrap.Toast.getOrCreateInstance( + document.getElementById('toastUpdateNotChecking') + ); // Returns a Bootstrap toast instance + toast.show(); + } + + + +}); diff --git a/gui/src/index.html b/gui/src/index.html index 7fe752c8..a4fad95a 100644 --- a/gui/src/index.html +++ b/gui/src/index.html @@ -9,8 +9,6 @@ - - @@ -79,8 +77,6 @@ - - - - - -
+ +
+
+ + + + + + + + + + + + +
+
@@ -268,14 +311,11 @@
- - @@ -662,12 +702,9 @@
-
- IP - - : - - +
IP + : +
@@ -690,28 +727,24 @@ - - - - +
- -
- - -
- -
- - -
- -
- - -
- +
+ + +
+
+ + +
+
+ + +
@@ -784,7 +813,6 @@
-
@@ -861,12 +889,7 @@
- - - - +
@@ -1011,7 +1034,7 @@
-
Mode +
Mode - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - -
-
-
+
Theme + +
+
+
+