Adding a progress bar for CLOUD BUILD progress (#3081)

* Adding simple progress bar for build request

* Adding language support.
10.9-maintenance
J Blackman 2022-11-15 07:48:12 +11:00 committed by GitHub
parent 30340c17bd
commit 717d7f6685
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 14 deletions

View File

@ -3084,7 +3084,7 @@
"message": "Select commit"
},
"firmwareFlasherReleaseSummaryHead": {
"message": "Release info"
"message": "Release and Build info"
},
"firmwareFlasherReleaseManufacturer": {
"message": "Manufacturer ID:"
@ -3116,6 +3116,24 @@
"firmwareFlasherCloudBuildStatus": {
"message": "Status:"
},
"firmwareFlasherCloudBuildPending": {
"message": "pending"
},
"firmwareFlasherCloudBuildProcessing": {
"message": "processing"
},
"firmwareFlasherCloudBuildSuccessCached": {
"message": "success (cached)"
},
"firmwareFlasherCloudBuildSuccess": {
"message": "success"
},
"firmwareFlasherCloudBuildTimedOut": {
"message": "timed out (please retry)"
},
"firmwareFlasherCloudBuildFailed": {
"message": "failed (please check log)"
},
"firmwareFlasherReleaseFileUrl": {
"message": "Download manually."
},

View File

@ -354,7 +354,11 @@ button {
}
.release_info {
.target {
color: #98ddff;
color: white;
}
.buildProgress {
border: 1px solid var(--subtleAccent);
border-radius: 2px;
}
}
.cf_table {

View File

@ -772,11 +772,12 @@ firmware_flasher.initialize = function (callback) {
i18n.localizePage();
}
function updateStatus(status, key) {
if (status === 'success' || status === 'fail') {
$('div.release_info #cloudTargetLog').text('Build Log').prop('href', `https://build.betaflight.com/api/builds/${key}/log`);
function updateStatus(status, key, val, showLog) {
if (showLog === true) {
$('div.release_info #cloudTargetLog').text(i18n.getMessage(`firmwareFlasherCloudBuildLogUrl`)).prop('href', `https://build.betaflight.com/api/builds/${key}/log`);
}
$('div.release_info #cloudTargetStatus').text(status);
$('div.release_info #cloudTargetStatus').text(i18n.getMessage(`firmwareFlasherCloudBuild${status}`));
$('.buildProgress').val(val);
}
function requestCloudBuild(summary) {
@ -817,14 +818,17 @@ firmware_flasher.initialize = function (callback) {
analytics.setFirmwareData(analytics.DATA.FIRMWARE_NAME, info.file);
let retries = 0;
updateStatus('Pending', info.key, 0, false);
let retries = 1;
self.releaseLoader.requestBuildStatus(info.key, (status) => {
if (status.status !== "queued") {
updateStatus(status.status, info.key);
// will be cached already, no need to wait.
if (status.status === 'success') {
updateStatus('SuccessCached', info.key, 100, true);
$('.buildProgress').val(100);
self.releaseLoader.loadTargetHex(info.url, (hex) => onLoadSuccess(hex, info.file), onLoadFailed);
} else {
updateStatus('Failed', info.key, 0, true);
onLoadFailed();
}
return;
@ -832,20 +836,26 @@ firmware_flasher.initialize = function (callback) {
const timer = setInterval(() => {
self.releaseLoader.requestBuildStatus(info.key, (status) => {
if (status.status !== 'queued' || retries > 8) {
updateStatus(status.status, info.key);
if (status.status !== 'queued' || retries > 10) {
clearInterval(timer);
if (status.status === 'success') {
updateStatus('Success', info.key, 100, true);
self.releaseLoader.loadTargetHex(info.url, (hex) => onLoadSuccess(hex, info.file), onLoadFailed);
} else {
if (retries > 10) {
updateStatus('TimedOut', info.key, 0, true);
} else {
updateStatus('Failed', info.key, 0, true);
}
onLoadFailed();
}
return;
}
updateStatus(`${status.status} (${retries})`, info.key);
updateStatus('Processing', info.key, retries * 10, false);
retries = retries + 1;
});
}, 5000);
}, 4000);
});
}, onLoadFailed);
}

View File

@ -244,11 +244,14 @@
<a i18n_title="firmwareFlasherCloudBuildLogUrl" id="cloudTargetLog" href="#" target="_blank"></a>
<br />
<strong i18n="firmwareFlasherCloudBuildStatus"></strong>
<progress class="buildProgress" value="0" min="0" max="100"></progress>
<span id="cloudTargetStatus"></span>
<br />
</div>
<strong i18n="firmwareFlasherReleaseNotes"></strong>
<div class=notes></div>
<div class="margin-bottom">
<strong i18n="firmwareFlasherReleaseNotes"></strong>
<div class=notes></div>
</div>
</div>
</div>