diff --git a/css/styles.css b/css/styles.css index f0b258c..ef193fe 100644 --- a/css/styles.css +++ b/css/styles.css @@ -65,9 +65,15 @@ canvas { z-index: 3; } +.device-update-labels { + display: flex; + justify-content: space-between; + align-items: flex-start; +} + #deviceUpdateLabel, #deviceVersionLabel, #deviceLatestVersionLabel { margin-top: 2px; - margin-bottom: 2px; + margin-bottom: 5px; } #updateTitle { @@ -740,6 +746,7 @@ legend { .update-progress-container { text-align: center; + padding: 5px; padding-top: 15px; } @@ -1904,6 +1911,7 @@ i { .progress-container { + margin: 5px; margin-top: 10px; height: 20px; background-color: #e0e0e0; diff --git a/js/UpdatePanel.js b/js/UpdatePanel.js index 63f7399..3898c87 100644 --- a/js/UpdatePanel.js +++ b/js/UpdatePanel.js @@ -41,7 +41,7 @@ export default class UpdatePanel extends Panel { await this.fetchAndFlashFirmware(); updateProgress.textContent = 'Firmware flashing completed!'; - Notification.success('Firmware updated successfully.'); + Notification.success(this.vortexPort.name + ' firmware updated successfully.'); } catch (error) { updateProgress.textContent = 'Firmware flash failed.'; Notification.failure('Firmware flash failed: ' + error.message); @@ -170,9 +170,11 @@ export default class UpdatePanel extends Panel { async flashFirmware(files) { const blockSize = 0x4000; // Flash memory block size - for (const file of files) { - const progressBar = document.getElementById('updateProgress'); + const progressBar = document.getElementById('overallProgressBar'); + let totalBytes = files.reduce((sum, file) => sum + file.data.length, 0); + let bytesFlashed = 0; + for (const file of files) { try { console.log(`Preparing to flash: ${file.path}, Size: ${file.data.length} bytes`); @@ -198,12 +200,11 @@ export default class UpdatePanel extends Panel { }; const contents = await readUploadedFileAsArrayBuffer(fileObject); - console.log(`Flashing: ` + JSON.stringify(fileObject)); await this.espStub.flashData( contents, (bytesWritten, totalBytes) => { - progressBar.style.width = - Math.floor((bytesWritten / totalBytes) * 100) + "%"; + bytesFlashed += bytesWritten; + progressBar.style.width = Math.floor((bytesFlashed / totalBytes) * 100) + '%'; }, file.address ); @@ -228,10 +229,18 @@ export default class UpdatePanel extends Panel { displayFirmwareUpdateInfo(device, currentVersion, latestVersion, downloadUrl) { const lowerDevice = device.toLowerCase(); + const deviceIconUrl = `./public/images/${lowerDevice}-logo-square-64.png`; let content = ` -

Device: ${device}

-

Current Version: ${currentVersion}

-

Latest Version: ${latestVersion}

+
+
+

Device: ${device}

+

Current Version: ${currentVersion}

+

Latest Version: ${latestVersion}

+
+
+ ${device} Icon +
+
`; // Show download links for orbit, handles, and gloves @@ -254,7 +263,7 @@ export default class UpdatePanel extends Panel {
- +
`; } diff --git a/js/VortexEditor.js b/js/VortexEditor.js index e2d93fd..bd39ca7 100644 --- a/js/VortexEditor.js +++ b/js/VortexEditor.js @@ -95,14 +95,20 @@ export default class VortexEditor { async checkVersion(device, version) { // the results are lowercased let lowerDevice = device.toLowerCase(); - if (lowerDevice === 'none') { - // not connected? - return; + if (!lowerDevice || lowerDevice === 'none') { + lowerDevice = this.modesPanel.selectedDevice.toLowerCase(); + if (!lowerDevice || lowerDevice === 'none') { + // not connected? + return; + } } // Fetch the latest firmware versions from vortex.community - const response = await fetch('https://vortex.community/downloads/json'); - const latestFirmwareVersions = await response.json(); + //const response = await fetch('https://vortex.community/downloads/json'); + //const latestFirmwareVersions = await response.json(); + + // example result that can be used for debugging: + //const latestFirmwareVersions = JSON.parse('{"gloves":{"firmware":{"_id":"6746b9c217de589dbc81c805", "device":"gloves", "version":"1.4.29", "category":"firmware", "fileUrl":"https://vortex.community/firmwares/VortexEngine-gloves-1.4.29.uf2", "fileSize":178688, "downloadCount":0, "releaseDate":"2024-11-27T06:18:42.708Z", "__v":0}}, "orbit":{"firmware":{"_id":"6746b9d417de589dbc81c807", "device":"orbit", "version":"1.4.31", "category":"firmware", "fileUrl":"https://vortex.community/firmwares/VortexEngine-orbit-1.4.31.uf2", "fileSize":189440, "downloadCount":0, "releaseDate":"2024-11-27T06:19:00.806Z", "__v":0}}, "handle":{"firmware":{"_id":"6746b9ec17de589dbc81c809", "device":"handle", "version":"1.4.31", "category":"firmware", "fileUrl":"https://vortex.community/firmwares/VortexEngine-handle-1.4.31.uf2", "fileSize":160768, "downloadCount":0, "releaseDate":"2024-11-27T06:19:24.621Z", "__v":0}}, "duo":{"firmware":{"_id":"674ebd4c17de589dbc81d6d6", "device":"duo", "version":"1.4.32", "category":"firmware", "fileUrl":"https://vortex.community/firmwares/VortexEngine-duo-1.4.32.bin", "fileSize":31612, "downloadCount":0, "releaseDate":"2024-12-03T08:11:56.380Z", "__v":0}}, "chromadeck":{"firmware":{"_id":"6758db20bc1e490fcc46cffd", "device":"chromadeck", "version":"1.4.34", "category":"firmware", "fileUrl":"https://vortex.community/firmwares/VortexEngine-chromadeck-1.4.34.zip", "fileSize":233557, "downloadCount":0, "releaseDate":"2024-12-11T00:21:52.767Z", "__v":0}}, "spark":{"firmware":{"_id":"6757fc1cbc1e490fcc46ceaf", "device":"spark", "version":"1.4.36", "category":"firmware", "fileUrl":"https://vortex.community/firmwares/VortexEngine-spark-1.4.36.zip", "fileSize":229031, "downloadCount":0, "releaseDate":"2024-12-10T08:30:20.822Z", "__v":0}}, "desktop":{"editor":{"_id":"66c3f4b5ec075d0abbdf3bb3", "device":"desktop", "version":"1.0.1.2", "category":"editor", "fileUrl":"https://vortex.community/firmwares/VortexEditor-desktop-1.0.1.2.exe", "fileSize":978432, "downloadCount":0, "releaseDate":"2024-08-20T01:43:17.125Z", "__v":0}, "library":{"_id":"6746b96817de589dbc81c7ff", "device":"desktop", "version":"1.4.34", "category":"library", "fileUrl":"https://vortex.community/firmwares/VortexDesktopLibrary-desktop-1.4.34.zip", "fileSize":9103976, "downloadCount":0, "releaseDate":"2024-11-27T06:17:12.475Z", "__v":0}}}'); // Compare versions if (latestFirmwareVersions && latestFirmwareVersions[lowerDevice]) {