buttons, dropdown beginn -.-

This commit is contained in:
PaulaBras 2022-09-20 19:14:04 +02:00
parent 213c8c0885
commit f2ae18fba8
5 changed files with 97 additions and 31 deletions

View File

@ -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
});

View File

@ -1,7 +1,6 @@
body { body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
Arial, sans-serif; margin: auto;
margin: auto; max-width: 38rem;
max-width: 38rem; padding: 2rem;
padding: 2rem;
} }

View File

@ -3,9 +3,20 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<title>Sectorfile Updater</title> <title>Sectorfile Updater</title>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bulma@0.8.0/css/bulma.min.css"
/>
<link rel="stylesheet" href="index.css" /> <link rel="stylesheet" href="index.css" />
<script defer src="render.js"></script>
</head> </head>
<body> <body>
<button id="startDownload" class"button is-primary">Start Download</button>
<button id="stopDownload" class"button is-warning">Stop Download</button>
<button id="startUnzip" class"button is-primary">Start Unzip</button>
<button id="stopUnzip" class"button is-warning">Stop Unzip</button>
<button id="selectVersionBtn" class"button is-warning">Version</button>
<button id="selectPathBtn" class"button is-warning">Path</button>
<h1>Hello World!</h1> <h1>Hello World!</h1>
<p>Welcome to your Electron application.</p> <p>Welcome to your Electron application.</p>
</body> </body>

View File

@ -1,7 +1,7 @@
const { app, BrowserWindow, ipcMain } = require('electron'); const { app, BrowserWindow, Menu, ipcMain, nativeTheme } = require('electron');
const path = require('path'); const path = require('path');
const { download } = require("electron-dl"); Menu.setApplicationMenu(false);
let window;
// Handle creating/removing shortcuts on Windows when installing/uninstalling. // Handle creating/removing shortcuts on Windows when installing/uninstalling.
// eslint-disable-next-line global-require // eslint-disable-next-line global-require
if (require('electron-squirrel-startup')) { if (require('electron-squirrel-startup')) {
@ -17,14 +17,10 @@ const createWindow = () => {
nodeIntegration: true, 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 // This method will be called when Electron has finished
// initialization and is ready to create browser windows. // initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs. // Some APIs can only be used after this event occurs.

76
updater/src/renderer.js Normal file
View File

@ -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
});