1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-15 12:25:15 +03:00

Refactor flashing progress bar code (#1523)

Refactor flashing progress bar code
This commit is contained in:
Michael Keller 2019-07-07 15:20:13 +12:00 committed by GitHub
commit 9b8b17b219
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 97 additions and 59 deletions

View file

@ -143,10 +143,8 @@ STM32_protocol.prototype.initialize = function () {
self.upload_process_alive = false; self.upload_process_alive = false;
// reset progress bar to initial state // reset progress bar to initial state
self.progress_bar_e = $('.progress'); TABS.firmware_flasher.flashingMessage(null, TABS.firmware_flasher.FLASH_MESSAGE_TYPES.NEUTRAL)
self.progress_bar_e.val(0); .flashProgress(0);
self.progress_label_e = $('span.progressLabel');
self.progress_label_e.removeClass('valid invalid actionRequired');
// lock some UI elements TODO needs rework // lock some UI elements TODO needs rework
$('select[name="release"]').prop('disabled', true); $('select[name="release"]').prop('disabled', true);
@ -161,8 +159,7 @@ STM32_protocol.prototype.initialize = function () {
} else { } else {
console.log('STM32 - timed out, programming failed ...'); console.log('STM32 - timed out, programming failed ...');
$('span.progressLabel').text(i18n.getMessage('stm32TimedOut')); TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32TimedOut'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.INVALID);
self.progress_label_e.addClass('invalid');
// protocol got stuck, clear timer and disconnect // protocol got stuck, clear timer and disconnect
GUI.interval_remove('STM32_timeout'); GUI.interval_remove('STM32_timeout');
@ -244,8 +241,7 @@ STM32_protocol.prototype.verify_response = function (val, data) {
if (val != data[0]) { if (val != data[0]) {
var message = 'STM32 Communication failed, wrong response, expected: ' + val + ' (0x' + val.toString(16) + ') received: ' + data[0] + ' (0x' + data[0].toString(16) + ')'; var message = 'STM32 Communication failed, wrong response, expected: ' + val + ' (0x' + val.toString(16) + ') received: ' + data[0] + ' (0x' + data[0].toString(16) + ')';
console.error(message); console.error(message);
$('span.progressLabel').text(i18n.getMessage('stm32WrongResponse',[val, val.toString(16), data[0], data[0].toString(16)])); TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32WrongResponse',[val, val.toString(16), data[0], data[0].toString(16)]), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.INVALID);
self.progress_label_e.addClass('invalid');
// disconnect // disconnect
this.upload_procedure(99); this.upload_procedure(99);
@ -357,7 +353,7 @@ STM32_protocol.prototype.upload_procedure = function (step) {
switch (step) { switch (step) {
case 1: case 1:
// initialize serial interface on the MCU side, auto baud rate settings // initialize serial interface on the MCU side, auto baud rate settings
$('span.progressLabel').text(i18n.getMessage('stm32ContactingBootloader')); TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32ContactingBootloader'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.NEUTRAL);
var send_counter = 0; var send_counter = 0;
GUI.interval_add('stm32_initialize_mcu', function () { // 200 ms interval (just in case mcu was already initialized), we need to break the 2 bytes command requirement GUI.interval_add('stm32_initialize_mcu', function () { // 200 ms interval (just in case mcu was already initialized), we need to break the 2 bytes command requirement
@ -369,8 +365,7 @@ STM32_protocol.prototype.upload_procedure = function (step) {
// proceed to next step // proceed to next step
self.upload_procedure(2); self.upload_procedure(2);
} else { } else {
$('span.progressLabel').text(i18n.getMessage('stm32ContactingBootloaderFailed')); TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32ContactingBootloaderFailed'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.INVALID);
self.progress_label_e.addClass('invalid');
GUI.interval_remove('stm32_initialize_mcu'); GUI.interval_remove('stm32_initialize_mcu');
@ -383,8 +378,7 @@ STM32_protocol.prototype.upload_procedure = function (step) {
// stop retrying, its too late to get any response from MCU // stop retrying, its too late to get any response from MCU
console.log('STM32 - no response from bootloader, disconnecting'); console.log('STM32 - no response from bootloader, disconnecting');
$('span.progressLabel').text(i18n.getMessage('stm32ResponseBootloaderFailed')); TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32ResponseBootloaderFailed'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.INVALID);
self.progress_label_e.addClass('invalid');
GUI.interval_remove('stm32_initialize_mcu'); GUI.interval_remove('stm32_initialize_mcu');
GUI.interval_remove('STM32_timeout'); GUI.interval_remove('STM32_timeout');
@ -436,7 +430,7 @@ STM32_protocol.prototype.upload_procedure = function (step) {
var message = 'Executing global chip erase (via extended erase)'; var message = 'Executing global chip erase (via extended erase)';
console.log(message); console.log(message);
$('span.progressLabel').text(i18n.getMessage('stm32GlobalEraseExtended')); TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32GlobalEraseExtended'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.NEUTRAL);
self.send([self.command.extended_erase, 0xBB], 1, function (reply) { self.send([self.command.extended_erase, 0xBB], 1, function (reply) {
if (self.verify_response(self.status.ACK, reply)) { if (self.verify_response(self.status.ACK, reply)) {
@ -452,7 +446,7 @@ STM32_protocol.prototype.upload_procedure = function (step) {
} else { } else {
var message = 'Executing local erase (via extended erase)'; var message = 'Executing local erase (via extended erase)';
console.log(message); console.log(message);
$('span.progressLabel').text(i18n.getMessage('stm32LocalEraseExtended')); TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32LocalEraseExtended'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.NEUTRAL);
self.send([self.command.extended_erase, 0xBB], 1, function (reply) { self.send([self.command.extended_erase, 0xBB], 1, function (reply) {
if (self.verify_response(self.status.ACK, reply)) { if (self.verify_response(self.status.ACK, reply)) {
@ -504,7 +498,7 @@ STM32_protocol.prototype.upload_procedure = function (step) {
if (self.options.erase_chip) { if (self.options.erase_chip) {
var message = 'Executing global chip erase' ; var message = 'Executing global chip erase' ;
console.log(message); console.log(message);
$('span.progressLabel').text(i18n.getMessage('stm32GlobalErase')); TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32GlobalErase'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.NEUTRAL);
self.send([self.command.erase, 0xBC], 1, function (reply) { // 0x43 ^ 0xFF self.send([self.command.erase, 0xBC], 1, function (reply) { // 0x43 ^ 0xFF
if (self.verify_response(self.status.ACK, reply)) { if (self.verify_response(self.status.ACK, reply)) {
@ -520,7 +514,7 @@ STM32_protocol.prototype.upload_procedure = function (step) {
} else { } else {
var message = 'Executing local erase'; var message = 'Executing local erase';
console.log(message); console.log(message);
$('span.progressLabel').text(i18n.getMessage('stm32LocalErase')); TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32LocalErase'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.NEUTRAL);
self.send([self.command.erase, 0xBC], 1, function (reply) { // 0x43 ^ 0xFF self.send([self.command.erase, 0xBC], 1, function (reply) { // 0x43 ^ 0xFF
if (self.verify_response(self.status.ACK, reply)) { if (self.verify_response(self.status.ACK, reply)) {
@ -553,7 +547,7 @@ STM32_protocol.prototype.upload_procedure = function (step) {
case 5: case 5:
// upload // upload
console.log('Writing data ...'); console.log('Writing data ...');
$('span.progressLabel').text(i18n.getMessage('stm32Flashing')); TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32Flashing'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.NEUTRAL);
var blocks = self.hex.data.length - 1, var blocks = self.hex.data.length - 1,
flashing_block = 0, flashing_block = 0,
@ -598,7 +592,7 @@ STM32_protocol.prototype.upload_procedure = function (step) {
}); });
// update progress bar // update progress bar
self.progress_bar_e.val(Math.round(bytes_flashed_total / (self.hex.bytes_total * 2) * 100)); TABS.firmware_flasher.flashProgress(Math.round(bytes_flashed_total / (self.hex.bytes_total * 2) * 100));
} }
}); });
} }
@ -628,7 +622,7 @@ STM32_protocol.prototype.upload_procedure = function (step) {
case 6: case 6:
// verify // verify
console.log('Verifying data ...'); console.log('Verifying data ...');
$('span.progressLabel').text(i18n.getMessage('stm32Verifying')); TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32Verifying'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.NEUTRAL);
var blocks = self.hex.data.length - 1, var blocks = self.hex.data.length - 1,
reading_block = 0, reading_block = 0,
@ -674,7 +668,7 @@ STM32_protocol.prototype.upload_procedure = function (step) {
}); });
// update progress bar // update progress bar
self.progress_bar_e.val(Math.round((self.hex.bytes_total + bytes_verified_total) / (self.hex.bytes_total * 2) * 100)); TABS.firmware_flasher.flashProgress(Math.round((self.hex.bytes_total + bytes_verified_total) / (self.hex.bytes_total * 2) * 100));
} }
}); });
} }
@ -701,16 +695,14 @@ STM32_protocol.prototype.upload_procedure = function (step) {
if (verify) { if (verify) {
console.log('Programming: SUCCESSFUL'); console.log('Programming: SUCCESSFUL');
// update progress bar // update progress bar
$('span.progressLabel').text(i18n.getMessage('stm32ProgrammingSuccessful')); TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32ProgrammingSuccessful'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.VALID);
self.progress_label_e.addClass('valid');
// proceed to next step // proceed to next step
self.upload_procedure(7); self.upload_procedure(7);
} else { } else {
console.log('Programming: FAILED'); console.log('Programming: FAILED');
// update progress bar // update progress bar
$('span.progressLabel').text(i18n.getMessage('stm32ProgrammingFailed')); TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32ProgrammingFailed'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.INVALID);
self.progress_label_e.addClass('invalid');
// disconnect // disconnect
self.upload_procedure(99); self.upload_procedure(99);

View file

@ -85,10 +85,9 @@ STM32DFU_protocol.prototype.connect = function (device, hex, options, callback)
self.verify_hex = []; self.verify_hex = [];
// reset progress bar to initial state // reset progress bar to initial state
self.progress_bar_e = $('.progress'); TABS.firmware_flasher.flashingMessage(null, TABS.firmware_flasher.FLASH_MESSAGE_TYPES.NEUTRAL)
self.progress_bar_e.val(0); .flashProgress(0);
self.progress_label_e = $('span.progressLabel');
self.progress_label_e.removeClass('valid invalid actionRequired');
chrome.usb.getDevices(device, function (result) { chrome.usb.getDevices(device, function (result) {
if (result.length) { if (result.length) {
@ -579,9 +578,9 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
var unprotect = function() { var unprotect = function() {
console.log('Initiate read unprotect'); console.log('Initiate read unprotect');
GUI.log(i18n.getMessage('stm32ReadProtected')); let messageReadProtected = i18n.getMessage('stm32ReadProtected');
$('span.progressLabel').text(i18n.getMessage('stm32ReadProtected')); GUI.log(messageReadProtected);
self.progress_label_e.addClass('actionRequired'); TABS.firmware_flasher.flashingMessage(messageReadProtected, TABS.firmware_flasher.FLASH_MESSAGE_TYPES.ACTION)
self.controlTransfer('out', self.request.DNLOAD, 0, 0, 0, [0x92], function () { // 0x92 initiates read unprotect self.controlTransfer('out', self.request.DNLOAD, 0, 0, 0, [0x92], function () { // 0x92 initiates read unprotect
self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function (data) { self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function (data) {
@ -591,7 +590,9 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
var timeSpentWaiting = 0; var timeSpentWaiting = 0;
var incr = 1000; // one sec incements var incr = 1000; // one sec incements
var waitForErase = setInterval(function () { var waitForErase = setInterval(function () {
self.progress_bar_e.val( Math.min(timeSpentWaiting/total_delay,1) * 100);
TABS.firmware_flasher.flashProgress(Math.min(timeSpentWaiting / total_delay, 1) * 100);
if(timeSpentWaiting < total_delay) if(timeSpentWaiting < total_delay)
{ {
timeSpentWaiting += incr; timeSpentWaiting += incr;
@ -602,15 +603,18 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
if(error) { // we encounter an error, but this is expected. should be a stall. if(error) { // we encounter an error, but this is expected. should be a stall.
console.log('Unprotect memory command ran successfully. Unplug flight controller. Connect again in DFU mode and try flashing again.'); console.log('Unprotect memory command ran successfully. Unplug flight controller. Connect again in DFU mode and try flashing again.');
GUI.log(i18n.getMessage('stm32UnprotectSuccessful')); GUI.log(i18n.getMessage('stm32UnprotectSuccessful'));
GUI.log(i18n.getMessage('stm32UnprotectUnplug'));
$('span.progressLabel').text(i18n.getMessage('stm32UnprotectUnplug')); let messageUnprotectUnplug = i18n.getMessage('stm32UnprotectUnplug');
self.progress_bar_e.val(0); GUI.log(messageUnprotectUnplug);
self.progress_label_e.addClass('actionRequired');
TABS.firmware_flasher.flashingMessage(messageUnprotectUnplug, TABS.firmware_flasher.FLASH_MESSAGE_TYPES.ACTION)
.flashProgress(0);
} else { // unprotecting the flight controller did not work. It did not reboot. } else { // unprotecting the flight controller did not work. It did not reboot.
console.log('Failed to execute unprotect memory command'); console.log('Failed to execute unprotect memory command');
GUI.log(i18n.getMessage('stm32UnprotectFailed')); GUI.log(i18n.getMessage('stm32UnprotectFailed'));
$('span.progressLabel').text(i18n.getMessage('stm32UnprotectFailed')); TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32UnprotectFailed'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.INVALID);
self.progress_label_e.addClass('invalid');
console.log(data); console.log(data);
self.upload_procedure(99); self.upload_procedure(99);
} }
@ -618,9 +622,9 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
}, incr); }, incr);
} else { } else {
console.log('Failed to initiate unprotect memory command'); console.log('Failed to initiate unprotect memory command');
GUI.log(i18n.getMessage('stm32UnprotectInitFailed')); let messageUnprotectInitFailed = i18n.getMessage('stm32UnprotectInitFailed')
$('span.progressLabel').text(i18n.getMessage('stm32UnprotectInitFailed')); GUI.log(messageUnprotectInitFailed);
self.progress_label_e.addClass('invalid'); TABS.firmware_flasher.flashingMessage(messageUnprotectInitFailed, TABS.firmware_flasher.FLASH_MESSAGE_TYPES.INVALID)
self.upload_procedure(99); self.upload_procedure(99);
} }
}); });
@ -735,7 +739,8 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
} }
} }
} }
$('span.progressLabel').text(i18n.getMessage('stm32Erase'));
TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32Erase'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.NEUTRAL);
console.log('Executing local chip erase'); console.log('Executing local chip erase');
var page = 0; var page = 0;
@ -758,7 +763,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function (data) { self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function (data) {
if (data[4] == self.state.dfuDNLOAD_IDLE) { if (data[4] == self.state.dfuDNLOAD_IDLE) {
// update progress bar // update progress bar
self.progress_bar_e.val((page + 1) / erase_pages.length * 100); TABS.firmware_flasher.flashProgress((page + 1) / erase_pages.length * 100);
page++; page++;
if(page == erase_pages.length) { if(page == erase_pages.length) {
@ -790,7 +795,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
// upload // upload
// we dont need to clear the state as we are already using DFU_DNLOAD // we dont need to clear the state as we are already using DFU_DNLOAD
console.log('Writing data ...'); console.log('Writing data ...');
$('span.progressLabel').text(i18n.getMessage('stm32Flashing')); TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32Flashing'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.NEUTRAL);
var blocks = self.hex.data.length - 1; var blocks = self.hex.data.length - 1;
var flashing_block = 0; var flashing_block = 0;
@ -819,7 +824,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function (data) { self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function (data) {
if (data[4] == self.state.dfuDNLOAD_IDLE) { if (data[4] == self.state.dfuDNLOAD_IDLE) {
// update progress bar // update progress bar
self.progress_bar_e.val(bytes_flashed_total / (self.hex.bytes_total * 2) * 100); TABS.firmware_flasher.flashProgress(bytes_flashed_total / (self.hex.bytes_total * 2) * 100);
// flash another page // flash another page
write(); write();
@ -862,7 +867,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
case 5: case 5:
// verify // verify
console.log('Verifying data ...'); console.log('Verifying data ...');
$('span.progressLabel').text(i18n.getMessage('stm32Verifying')); TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32Verifying'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.NEUTRAL);
var blocks = self.hex.data.length - 1; var blocks = self.hex.data.length - 1;
var reading_block = 0; var reading_block = 0;
@ -898,7 +903,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
bytes_verified_total += bytes_to_read; bytes_verified_total += bytes_to_read;
// update progress bar // update progress bar
self.progress_bar_e.val((self.hex.bytes_total + bytes_verified_total) / (self.hex.bytes_total * 2) * 100); TABS.firmware_flasher.flashProgress((self.hex.bytes_total + bytes_verified_total) / (self.hex.bytes_total * 2) * 100);
// verify another page // verify another page
read(); read();
@ -930,16 +935,14 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
if (verify) { if (verify) {
console.log('Programming: SUCCESSFUL'); console.log('Programming: SUCCESSFUL');
// update progress bar // update progress bar
$('span.progressLabel').text(i18n.getMessage('stm32ProgrammingSuccessful')); TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32ProgrammingSuccessful'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.VALID);
self.progress_label_e.addClass('valid');
// proceed to next step // proceed to next step
self.upload_procedure(6); self.upload_procedure(6);
} else { } else {
console.log('Programming: FAILED'); console.log('Programming: FAILED');
// update progress bar // update progress bar
$('span.progressLabel').text(i18n.getMessage('stm32ProgrammingFailed')); TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32ProgrammingFailed'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.INVALID);
self.progress_label_e.addClass('invalid');
// disconnect // disconnect
self.upload_procedure(99); self.upload_procedure(99);

View file

@ -63,7 +63,8 @@ TABS.firmware_flasher.initialize = function (callback) {
FirmwareCache.put(summary, intel_hex); FirmwareCache.put(summary, intel_hex);
} }
$('span.progressLabel').html('<a class="save_firmware" href="#" title="Save Firmware">' + i18n.getMessage('firmwareFlasherFirmwareOnlineLoaded', parsed_hex.bytes_total) + '</a>'); self.flashingMessage('<a class="save_firmware" href="#" title="Save Firmware">' + i18n.getMessage('firmwareFlasherFirmwareOnlineLoaded', parsed_hex.bytes_total) + '</a>',
self.FLASH_MESSAGE_TYPES.NEUTRAL);
self.enableFlashing(true); self.enableFlashing(true);
@ -83,7 +84,7 @@ TABS.firmware_flasher.initialize = function (callback) {
$('div.release_info').slideDown(); $('div.release_info').slideDown();
} else { } else {
$('span.progressLabel').text(i18n.getMessage('firmwareFlasherHexCorrupted')); self.flashingMessage(i18n.getMessage('firmwareFlasherHexCorrupted'), self.FLASH_MESSAGE_TYPES.INVALID);
} }
}); });
} }
@ -316,8 +317,9 @@ TABS.firmware_flasher.initialize = function (callback) {
var target = $(this).val(); var target = $(this).val();
if (!GUI.connect_lock) { if (!GUI.connect_lock) {
$('.progress').val(0).removeClass('valid invalid'); self.flashingMessage(i18n.getMessage('firmwareFlasherLoadFirmwareFile'), self.FLASH_MESSAGE_TYPES.NEUTRAL)
$('span.progressLabel').text(i18n.getMessage('firmwareFlasherLoadFirmwareFile')); .flashProgress(0);
$('div.git_info').slideUp(); $('div.git_info').slideUp();
$('div.release_info').slideUp(); $('div.release_info').slideUp();
@ -336,7 +338,7 @@ TABS.firmware_flasher.initialize = function (callback) {
$("<option value='{0}'>{0} - {1} - {2}</option>".format( $("<option value='{0}'>{0} - {1} - {2}</option>".format(
descriptor.version, descriptor.version,
descriptor.target, descriptor.target,
descriptor.date, descriptor.date
)) ))
.css("font-weight", FirmwareCache.has(descriptor) .css("font-weight", FirmwareCache.has(descriptor)
? "bold" ? "bold"
@ -397,9 +399,9 @@ TABS.firmware_flasher.initialize = function (callback) {
self.enableFlashing(true); self.enableFlashing(true);
$('span.progressLabel').text(i18n.getMessage('firmwareFlasherFirmwareLocalLoaded', parsed_hex.bytes_total)); self.flashingMessage(i18n.getMessage('firmwareFlasherFirmwareLocalLoaded', parsed_hex.bytes_total), self.FLASH_MESSAGE_TYPES.NEUTRAL);
} else { } else {
$('span.progressLabel').text(i18n.getMessage('firmwareFlasherHexCorrupted')); self.flashingMessage(i18n.getMessage('firmwareFlasherHexCorrupted'), self.FLASH_MESSAGE_TYPES.INVALID);
} }
}); });
} }
@ -708,3 +710,44 @@ TABS.firmware_flasher.enableFlashing = function (enabled) {
$('a.flash_firmware').addClass('disabled'); $('a.flash_firmware').addClass('disabled');
} }
} }
TABS.firmware_flasher.FLASH_MESSAGE_TYPES = {NEUTRAL : 'NEUTRAL',
VALID : 'VALID',
INVALID : 'INVALID',
ACTION : 'ACTION'};
TABS.firmware_flasher.flashingMessage = function(message, type) {
let self = this;
let progressLabel_e = $('span.progressLabel');
switch (type) {
case self.FLASH_MESSAGE_TYPES.VALID:
progressLabel_e.removeClass('invalid actionRequired')
.addClass('valid');
break;
case self.FLASH_MESSAGE_TYPES.INVALID:
progressLabel_e.removeClass('valid actionRequired')
.addClass('invalid');
break;
case self.FLASH_MESSAGE_TYPES.ACTION:
progressLabel_e.removeClass('valid invalid')
.addClass('actionRequired');
break;
case self.FLASH_MESSAGE_TYPES.NEUTRAL:
default:
progressLabel_e.removeClass('valid invalid actionRequired');
break;
}
if (message != null) {
progressLabel_e.html(message);
}
return self;
};
TABS.firmware_flasher.flashProgress = function(value) {
$('.progress').val(value);
return this;
};