diff --git a/gui/main.js b/gui/main.js index e669aa64..94f60334 100644 --- a/gui/main.js +++ b/gui/main.js @@ -507,6 +507,13 @@ ipcMain.on('save-file-to-folder',(event,data)=>{ }); + +//restart and install udpate +ipcMain.on('request-restart-and-install',(event,data)=>{ + close_sub_binaries() + autoUpdater.quitAndInstall(); +}); + // LISTENER FOR UPDATER EVENTS autoUpdater.on('update-available', (info) => { mainLog.info('update available'); @@ -574,10 +581,8 @@ autoUpdater.on('error', (error) => { - -function close_all() { - - // function for closing the application with closing all used processes +function close_sub_binaries(){ + mainLog.warn('closing sub binaries'); // closing the tnc binary if not closed when closing application and also our daemon which has been started by the gui try { @@ -619,6 +624,16 @@ function close_all() { app.quit(); } */ + +}; + + +function close_all() { + + // function for closing the application with closing all used processes + + close_sub_binaries(); + mainLog.warn('quitting app'); win.destroy(); diff --git a/gui/package.json b/gui/package.json index dabb31d3..628b1868 100644 --- a/gui/package.json +++ b/gui/package.json @@ -46,12 +46,13 @@ "uuid": "^8.3.2" }, "devDependencies": { - "electron": "^18.0.4", - "electron-builder": "^22.5.1" + "electron": "^18.1.0", + "electron-builder": "^23.0.3" }, "build": { "productName": "FreeDATA", "appId": "app.freedata", + "npmRebuild" : "false", "directories": { "buildResources": "src/img", "output": "dist" @@ -93,3 +94,4 @@ ] } } + diff --git a/gui/preload-main.js b/gui/preload-main.js index bde9863d..0a2c7bd4 100644 --- a/gui/preload-main.js +++ b/gui/preload-main.js @@ -458,6 +458,11 @@ document.getElementById('openReceivedFilesFolder').addEventListener('click', () + + // close app, update and restart + document.getElementById("update_and_install").addEventListener("click", () => { + ipcRenderer.send('request-restart-and-install'); + }); // open arq session document.getElementById("openARQSession").addEventListener("click", () => { @@ -1853,45 +1858,40 @@ ipcRenderer.on('action-updater', (event, arg) => { if (arg.status == "download-progress"){ - bootstrap.Toast.getOrCreateInstance(document.getElementById('toastUpdateAvailable')).hide(); // close our update available notification + var progressinfo = '(' + + Math.round(arg.progress.transferred/1024) + + 'kB /' + + Math.round(arg.progress.total/1024) + + 'kB)' + + ' @ ' + + Math.round(arg.progress.bytesPerSecond/1024) + + "kByte/s";; + document.getElementById("UpdateProgressInfo").innerHTML = progressinfo; - - 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 + "%;") + document.getElementById("UpdateProgressBar").setAttribute("aria-valuenow", arg.progress.percent) + document.getElementById("UpdateProgressBar").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"); - 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(); + document.title = "FreeDATA by DJ2LS" + ' - v' + arg.version; - document.getElementById("updater_status").innerHTML = "checking for update..." - document.getElementById("updater_status").setAttribute("class") = "btn btn-secondary btn-sm" + document.getElementById("updater_status").innerHTML = '' + + + + + + document.getElementById("updater_status").className = "btn btn-secondary btn-sm"; document.getElementById("update_and_install").style.display = 'none'; } if (arg.status == "update-downloaded"){ - var toast = bootstrap.Toast.getOrCreateInstance( - document.getElementById('toastUpdateDownloaded') - ); // Returns a Bootstrap toast instance - toast.show(); - document.getElementById("updater_status").innerHTML = "update downloaded..." - document.getElementById("updater_status").setAttribute("class") = "btn btn-secondary btn-sm" - document.getElementById("update_and_install").style.display = 'block'; + + + document.getElementById("update_and_install").removeAttribute("style"); + document.getElementById("updater_status").innerHTML = ''; + document.getElementById("updater_status").className = "btn btn-success btn-sm"; // HERE WE NEED TO RUN THIS SOMEHOW... //mainLog.info('quit application and install update'); @@ -1900,35 +1900,26 @@ ipcRenderer.on('action-updater', (event, arg) => { } if (arg.status == "update-not-available"){ bootstrap.Toast.getOrCreateInstance(document.getElementById('toastUpdateChecking')).hide(); - var toast = bootstrap.Toast.getOrCreateInstance( - document.getElementById('toastUpdateNotAvailable') - ); // Returns a Bootstrap toast instance - toast.show(); - document.getElementById("updater_status").innerHTML = "update not available" - document.getElementById("updater_status").setAttribute("class") = "btn btn-secondary btn-sm" + + document.getElementById("updater_status").innerHTML = ''; + document.getElementById("updater_status").className = "btn btn-success btn-sm"; document.getElementById("update_and_install").style.display = 'none'; } if (arg.status == "update-available"){ bootstrap.Toast.getOrCreateInstance(document.getElementById('toastUpdateChecking')).hide(); - var toast = bootstrap.Toast.getOrCreateInstance( - document.getElementById('toastUpdateAvailable') - ); // Returns a Bootstrap toast instance - toast.show(); - document.getElementById("updater_status").innerHTML = "update available..." - document.getElementById("updater_status").setAttribute("class") = "btn btn-secondary btn-sm" - document.getElementById("update_and_install").style.display = 'block'; + + document.getElementById("updater_status").innerHTML = "update available..."; + document.getElementById("updater_status").className = "btn btn-warning btn-sm"; + document.getElementById("update_and_install").style.display = 'none'; } if (arg.status == "error"){ - var toast = bootstrap.Toast.getOrCreateInstance( - document.getElementById('toastUpdateNotChecking') - ); // Returns a Bootstrap toast instance - toast.show(); - document.getElementById("updater_status").innerHTML = "update error..." - document.getElementById("updater_status").setAttribute("class") = "btn btn-danger btn-sm" + + document.getElementById("updater_status").innerHTML = ''; + document.getElementById("updater_status").className = "btn btn-danger btn-sm"; document.getElementById("update_and_install").style.display = 'none'; } diff --git a/gui/src/index.html b/gui/src/index.html index c4b79f40..a8d638e6 100644 --- a/gui/src/index.html +++ b/gui/src/index.html @@ -97,61 +97,7 @@
- -
-
- - - - - - - - - - - - - - - -
-
+
@@ -756,31 +702,25 @@
-
+
- Auto-Updater + UPDATER + +
+
+
+
+ + +
- + + - - - - -