Working local file uploads
Needs lots of error checking, but should be functional. Only tested on Macos
This commit is contained in:
parent
ce49bec4a3
commit
c66df2bdc2
|
@ -45,12 +45,12 @@
|
|||
<select name="firmwares" class="select" id="versionsSelect" size="10" width="20" onClick="refreshBasetunes();"></select>
|
||||
<ul class="actions">
|
||||
<li><input type='button' id="btnChoosePort" value="Choose Port" /></li>
|
||||
<li><input type='button' id="btnSelectLocal" value="Use Local Firmware" /></li>
|
||||
</ul>
|
||||
<p>Other actions:</p>
|
||||
<ul class="actions">
|
||||
<li><input type='button' id="btnDetails" value="View Firmware Notes" /></li>
|
||||
<li><input type='button' value="Get Base Tune" id="btnBasetune" /></li>
|
||||
<li><input type='button' id="btnSelectLocal" value="Use Local Firmware" /></li>
|
||||
</ul>
|
||||
</p>
|
||||
<div id="error"></div>
|
||||
|
|
4
main.js
4
main.js
|
@ -142,8 +142,8 @@ ipcMain.on('installWinDrivers', (e, args) => {
|
|||
ipcMain.on('selectLocalFirmware', (e, args) => {
|
||||
localFirmware = dialog.showOpenDialogSync({
|
||||
properties: ['openFile'],
|
||||
title: "Select hex file",
|
||||
filters: [{ name: 'Firmware hex', extensions: ['hex'] }] })
|
||||
title: "Select firmware file",
|
||||
filters: [{ name: 'Firmware binary', extensions: ['hex', 'bin'] }] })
|
||||
|
||||
if(localFirmware != undefined)
|
||||
{
|
||||
|
|
78
renderer.js
78
renderer.js
|
@ -4,6 +4,8 @@ const {ipcRenderer} = require("electron")
|
|||
const { shell } = require('electron')
|
||||
|
||||
var basetuneList = [];
|
||||
var useLocalTune = false;
|
||||
var localTuneFile = "";
|
||||
|
||||
function getTeensyVersion(id)
|
||||
{
|
||||
|
@ -411,6 +413,7 @@ function refreshBasetunesDescription()
|
|||
ipcRenderer.on("add local hex", (event, filename, state) =>
|
||||
{
|
||||
//Check if Local option already exists
|
||||
/*
|
||||
var lastOption = document.getElementById('versionsSelect').lastElementChild
|
||||
if(lastOption.innerHTML == "Local")
|
||||
{
|
||||
|
@ -425,6 +428,11 @@ ipcRenderer.on("add local hex", (event, filename, state) =>
|
|||
var select = document.getElementById('versionsSelect');
|
||||
select.appendChild(newOption);
|
||||
}
|
||||
*/
|
||||
useLocalTune = true;
|
||||
localTuneFile = filename;
|
||||
document.getElementById('versionsSelect').disabled = true;
|
||||
//console.log("Local hex file selected: " + filename);
|
||||
|
||||
//Jump to the port selection screen
|
||||
$("[href='#port']").trigger('click');
|
||||
|
@ -474,7 +482,7 @@ function downloadHex(board, localFile="")
|
|||
function downloadIni()
|
||||
{
|
||||
var e = document.getElementById('versionsSelect');
|
||||
if(e.options[e.selectedIndex].innerHTML == "Local")
|
||||
if(useLocalTune)
|
||||
{
|
||||
console.log("Local version selected, not downloading ini");
|
||||
return;
|
||||
|
@ -520,37 +528,11 @@ function installDrivers()
|
|||
|
||||
}
|
||||
|
||||
function uploadFW()
|
||||
function downloadComplete(file)
|
||||
{
|
||||
|
||||
//Start the spinner
|
||||
var spinner = document.getElementById('progressSpinner');
|
||||
//Disable the Re-burn/re-install button
|
||||
var reinstallButton = document.getElementById("btnReinstall")
|
||||
reinstallButton.disabled = true;
|
||||
//Remove any old icons
|
||||
spinner.classList.remove('fa-pause');
|
||||
spinner.classList.remove('fa-check');
|
||||
spinner.classList.remove('fa-times');
|
||||
spinner.classList.add('fa-spinner');
|
||||
|
||||
//Lookup what platform we're using
|
||||
var portSelect = document.getElementById('portsSelect');
|
||||
var uploadBoard = portSelect.options[portSelect.selectedIndex].getAttribute("board");
|
||||
|
||||
//Hide the terminal section incase it was there from a previous burn attempt
|
||||
document.getElementById('terminalSection').style.display = "none";
|
||||
//Same for the ini location link
|
||||
document.getElementById('iniFileText').style.display = "none";
|
||||
|
||||
var statusText = document.getElementById('statusText');
|
||||
var burnPercentText = document.getElementById('burnPercent');
|
||||
statusText.innerHTML = "Downloading INI file"
|
||||
downloadIni();
|
||||
|
||||
ipcRenderer.on("download complete", (event, file, state) => {
|
||||
console.log("Saved file: " + file); // Full file path
|
||||
|
||||
var extension = file.substr(file.length - 3);
|
||||
if(extension == "ini")
|
||||
{
|
||||
|
@ -600,6 +582,46 @@ function uploadFW()
|
|||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function uploadFW()
|
||||
{
|
||||
|
||||
//Start the spinner
|
||||
var spinner = document.getElementById('progressSpinner');
|
||||
//Disable the Re-burn/re-install button
|
||||
var reinstallButton = document.getElementById("btnReinstall")
|
||||
reinstallButton.disabled = true;
|
||||
//Remove any old icons
|
||||
spinner.classList.remove('fa-pause');
|
||||
spinner.classList.remove('fa-check');
|
||||
spinner.classList.remove('fa-times');
|
||||
spinner.classList.add('fa-spinner');
|
||||
|
||||
//Hide the terminal section incase it was there from a previous burn attempt
|
||||
document.getElementById('terminalSection').style.display = "none";
|
||||
//Same for the ini location link
|
||||
document.getElementById('iniFileText').style.display = "none";
|
||||
|
||||
var statusText = document.getElementById('statusText');
|
||||
var burnPercentText = document.getElementById('burnPercent');
|
||||
|
||||
|
||||
if(useLocalTune)
|
||||
{
|
||||
//ipcRenderer.send("download complete", { file: localTuneFile, state: "complete" });
|
||||
downloadComplete(localTuneFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
statusText.innerHTML = "Downloading INI file"
|
||||
downloadIni();
|
||||
}
|
||||
|
||||
ipcRenderer.on("download complete", (event, file, state) => {
|
||||
console.log("Saved file: " + file); // Full file path
|
||||
downloadComplete(file);
|
||||
|
||||
});
|
||||
|
||||
ipcRenderer.on("upload completed", (event, code) => {
|
||||
|
|
Loading…
Reference in New Issue