Skip to content

Commit

Permalink
Always request hex via the post to API mechanism (#3149)
Browse files Browse the repository at this point in the history
* Always request hex via the post to API mechanism

- enables logging of requests for older versions via API rather than GA,
- gives flexibility in future if we need to return alternative hex files for any reason.

* The URL for the hex is now returned by the API

* Only apply these settings if expertmode is enabled.
  • Loading branch information
blckmn committed Dec 16, 2022
1 parent b6d8efc commit e8ef941
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
1 change: 0 additions & 1 deletion src/js/release_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ class ReleaseLoader {
contentType: "application/json",
dataType: "json",
success: function(data) {
data.url = `/api/builds/${data.key}/hex`;
onSuccess(data);
},
}).fail(xhr => {
Expand Down
33 changes: 17 additions & 16 deletions src/js/tabs/firmware_flasher.js
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ firmware_flasher.initialize = function (callback) {
classicBuild: false,
};

request.classicBuild = $('input[name="classicBuildModeCheckbox"]').is(':checked');
request.classicBuild = !summary.cloudBuild || $('input[name="classicBuildModeCheckbox"]').is(':checked');
if (!request.classicBuild) {
$('select[name="radioProtocols"] option:selected').each(function () {
request.radioProtocols.push($(this).val());
Expand All @@ -801,18 +801,27 @@ firmware_flasher.initialize = function (callback) {
$('select[name="motorProtocols"] option:selected').each(function () {
request.motorProtocols.push($(this).val());
});
}

if (summary.releaseType === "Unstable") {
request.commit = $('select[name="commits"] option:selected').val();
$('input[name="customDefines"]').val().split(' ').map(element => element.trim()).forEach(v => {
request.options.push(v);
});
if ($('input[name="expertModeCheckbox"]').is(':checked')) {
if (summary.releaseType === "Unstable") {
request.commit = $('select[name="commits"] option:selected').val();
}

$('input[name="customDefines"]').val().split(' ').map(element => element.trim()).forEach(v => {
request.options.push(v);
});
}
}

self.releaseLoader.requestBuild(request, (info) => {
console.info("Build requested:", info);

if (!summary.cloudBuild) {
// it is a previous release, so simply load the hex
self.releaseLoader.loadTargetHex(info.url, (hex) => onLoadSuccess(hex, info.file), onLoadFailed);
return;
}

updateStatus('Pending', info.key, 0, false);
let retries = 1;
self.releaseLoader.requestBuildStatus(info.key, (status) => {
Expand Down Expand Up @@ -855,21 +864,13 @@ firmware_flasher.initialize = function (callback) {
}, onLoadFailed);
}

function requestLegacyBuild(summary) {
self.releaseLoader.loadTargetHex(summary.url, (hex) => onLoadSuccess(hex, summary.file), onLoadFailed);
}

if (self.summary) { // undefined while list is loading or while running offline
$("a.load_remote_file").text(i18n.getMessage('firmwareFlasherButtonDownloading'));
$("a.load_remote_file").addClass('disabled');

showReleaseNotes(self.summary);

if (self.summary.cloudBuild === true) {
requestCloudBuild(self.summary);
} else {
requestLegacyBuild(self.summary);
}
requestCloudBuild(self.summary);
} else {
$('span.progressLabel').attr('i18n','firmwareFlasherFailedToLoadOnlineFirmware').removeClass('i18n-replaced');
i18n.localizePage();
Expand Down

0 comments on commit e8ef941

Please sign in to comment.