Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Unreal-Dan committed Dec 12, 2024
1 parent 15bfd4a commit 471fe11
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 16 deletions.
10 changes: 9 additions & 1 deletion css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -740,6 +746,7 @@ legend {

.update-progress-container {
text-align: center;
padding: 5px;
padding-top: 15px;
}

Expand Down Expand Up @@ -1904,6 +1911,7 @@ i {


.progress-container {
margin: 5px;
margin-top: 10px;
height: 20px;
background-color: #e0e0e0;
Expand Down
29 changes: 19 additions & 10 deletions js/UpdatePanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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`);

Expand All @@ -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
);
Expand All @@ -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 = `
<p id="deviceUpdateLabel"><strong>Device:</strong> ${device}</p>
<p id="deviceVersionLabel"><strong>Current Version:</strong> ${currentVersion}</p>
<p id="deviceLatestVersionLabel"><strong>Latest Version:</strong> ${latestVersion}</p>
<div class="device-update-labels">
<div>
<p id="deviceUpdateLabel"><strong>Device:</strong> ${device}</p>
<p id="deviceVersionLabel"><strong>Current Version:</strong> ${currentVersion}</p>
<p id="deviceLatestVersionLabel"><strong>Latest Version:</strong> ${latestVersion}</p>
</div>
<div>
<img src="${deviceIconUrl}" alt="${device} Icon" class="device-icon">
</div>
</div>
`;

// Show download links for orbit, handles, and gloves
Expand All @@ -254,7 +263,7 @@ export default class UpdatePanel extends Panel {
</div>
</div>
<div class="update-progress-container">
<span id="updateProgress" style="margin-top: 10px;"></span>
<span id="updateProgress"></span>
</div>
`;
}
Expand Down
16 changes: 11 additions & 5 deletions js/VortexEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand Down

0 comments on commit 471fe11

Please sign in to comment.