diff --git a/updater/src/download/renderer.js b/updater/src/download/renderer.js deleted file mode 100644 index 3e0dcb0..0000000 --- a/updater/src/download/renderer.js +++ /dev/null @@ -1,16 +0,0 @@ -ipcRenderer.send("download", { - url: "URL is here", - properties: { directory: "Directory is here" } -}); - -const { ipcRenderer } = require("electron"); -ipcRenderer.on("download complete", (event, file) => { - console.log(file); // Full file path -}); - - -ipcRenderer.on("download progress", (event, progress) => { - console.log(progress); // Progress in fraction, between 0 and 1 - const progressInPercentages = progress * 100; // With decimal point and a bunch of numbers - const cleanProgressInPercentages = Math.floor(progress * 100); // Without decimal point -}); \ No newline at end of file diff --git a/updater/src/index.css b/updater/src/index.css index 8856f90..6a4607d 100644 --- a/updater/src/index.css +++ b/updater/src/index.css @@ -1,7 +1,6 @@ body { - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, - Arial, sans-serif; - margin: auto; - max-width: 38rem; - padding: 2rem; -} + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; + margin: auto; + max-width: 38rem; + padding: 2rem; +} \ No newline at end of file diff --git a/updater/src/index.html b/updater/src/index.html index 5b87bb8..e36b5d8 100644 --- a/updater/src/index.html +++ b/updater/src/index.html @@ -3,9 +3,20 @@ Sectorfile Updater + + + + + + + +

Hello World!

Welcome to your Electron application.

diff --git a/updater/src/index.js b/updater/src/index.js index c2b8ec9..2d1f6f8 100644 --- a/updater/src/index.js +++ b/updater/src/index.js @@ -1,7 +1,7 @@ -const { app, BrowserWindow, ipcMain } = require('electron'); +const { app, BrowserWindow, Menu, ipcMain, nativeTheme } = require('electron'); const path = require('path'); -const { download } = require("electron-dl"); -let window; +Menu.setApplicationMenu(false); + // Handle creating/removing shortcuts on Windows when installing/uninstalling. // eslint-disable-next-line global-require if (require('electron-squirrel-startup')) { @@ -17,14 +17,10 @@ const createWindow = () => { nodeIntegration: true, }, }); - - // and load the index.html of the app. - mainWindow.loadFile(path.join(__dirname, 'index.html')); - - // Open the DevTools. - mainWindow.webContents.openDevTools(); }; + + // This method will be called when Electron has finished // initialization and is ready to create browser windows. // Some APIs can only be used after this event occurs. diff --git a/updater/src/renderer.js b/updater/src/renderer.js new file mode 100644 index 0000000..9c22b24 --- /dev/null +++ b/updater/src/renderer.js @@ -0,0 +1,76 @@ +// Buttons +const startDownload = document.querySelector('startDownload'); +const stopDownload = document.querySelector('stopDownload'); +const startUnzip = document.querySelector('startUnzip'); +const stopUnzip = document.querySelector('stopUnzip'); +const selectVersionBtn = document.querySelector('selectVersion'); +const selectPathBtn = document.querySelector('selectPathBtn'); + + +const { remote } = require('electron'); +const { Menu } = remote; +const { writeFile } = require('fs'); + + +// Will not work +async function selectVersion() { + const versionMenu = Menu.buildFromTemplate( + inputSources.map(source => { + return { + label: release.name, + click: () => selectVersion(source) + }; + }) + ); + selectVersion.popup(); +} + +// Git version update Select +async function selectVersion(source) { + selectVersionBtn.innerText = source.name; + const constrains = { + // Maybe needed + } +} + +// select Euroscope folder - TBD +async function selectPath(source) { + selectPathBtn.innerText = source.name; + const constrains = { + // Maybe needed + } +} + +async function downloadVersion(e) { + shell = new ActiveXObject("WScript.Shell"); + const file; // File to download + + const { filepath } = await dialog.showSaveDialog({ + buttonLabel: 'Save Update Version', + defaultPath: shell.SpecialFolders('MyDocuments') + '\\Euroscope' + }); + + console.log(filepath); + writeFile(filepath, file, () => console.log('file saved successfully!')); +} + + + + + +ipcRenderer.send("download", { + url: "URL is here", + properties: { directory: "Directory is here" } +}); + +const { ipcRenderer } = require("electron"); +ipcRenderer.on("download complete", (event, file) => { + console.log(file); // Full file path +}); + + +ipcRenderer.on("download progress", (event, progress) => { + console.log(progress); // Progress in fraction, between 0 and 1 + const progressInPercentages = progress * 100; // With decimal point and a bunch of numbers + const cleanProgressInPercentages = Math.floor(progress * 100); // Without decimal point +}); \ No newline at end of file