Load available cloud build options when selecting the firmware version to build (#3384)
* Load options when selecting the firmware version * Add the release to the request for options when setting defaults based on buildkey. * Adjusting to allow build key to be passed.master
parent
e94cb0cd1e
commit
95f4c6e75d
|
@ -10,7 +10,6 @@ export default class BuildApi {
|
|||
}
|
||||
|
||||
load(url, onSuccess, onFailure) {
|
||||
|
||||
const dataTag = `${url}_Data`;
|
||||
const cacheLastUpdateTag = `${url}_LastUpdate`;
|
||||
|
||||
|
@ -49,25 +48,21 @@ export default class BuildApi {
|
|||
}
|
||||
|
||||
loadTargets(callback) {
|
||||
|
||||
const url = `${this._url}/api/targets`;
|
||||
this.load(url, callback);
|
||||
}
|
||||
|
||||
loadTargetReleases(target, callback) {
|
||||
|
||||
const url = `${this._url}/api/targets/${target}`;
|
||||
this.load(url, callback);
|
||||
}
|
||||
|
||||
loadTarget(target, release, onSuccess, onFailure) {
|
||||
|
||||
const url = `${this._url}/api/builds/${release}/${target}`;
|
||||
this.load(url, onSuccess, onFailure);
|
||||
}
|
||||
|
||||
loadTargetHex(path, onSuccess, onFailure) {
|
||||
|
||||
const url = `${this._url}${path}`;
|
||||
$.get(url, function (data) {
|
||||
gui_log(i18n.getMessage('buildServerSuccess', [path]));
|
||||
|
@ -81,7 +76,6 @@ export default class BuildApi {
|
|||
}
|
||||
|
||||
getSupportCommands(onSuccess, onFailure) {
|
||||
|
||||
const url = `${this._url}/api/support/commands`;
|
||||
$.get(url, function (data) {
|
||||
onSuccess(data);
|
||||
|
@ -94,7 +88,6 @@ export default class BuildApi {
|
|||
}
|
||||
|
||||
submitSupportData(data, onSuccess, onFailure) {
|
||||
|
||||
const url = `${this._url}/api/support`;
|
||||
$.ajax({
|
||||
url: url,
|
||||
|
@ -115,7 +108,6 @@ export default class BuildApi {
|
|||
}
|
||||
|
||||
requestBuild(request, onSuccess, onFailure) {
|
||||
|
||||
const url = `${this._url}/api/builds`;
|
||||
$.ajax({
|
||||
url: url,
|
||||
|
@ -136,7 +128,6 @@ export default class BuildApi {
|
|||
}
|
||||
|
||||
requestBuildStatus(key, onSuccess, onFailure) {
|
||||
|
||||
const url = `${this._url}/api/builds/${key}/status`;
|
||||
$.get(url, function (data) {
|
||||
gui_log(i18n.getMessage('buildServerSuccess', [url]));
|
||||
|
@ -150,7 +141,6 @@ export default class BuildApi {
|
|||
}
|
||||
|
||||
requestBuildOptions(key, onSuccess, onFailure) {
|
||||
|
||||
const url = `${this._url}/api/builds/${key}/json`;
|
||||
$.get(url, function (data) {
|
||||
onSuccess(data);
|
||||
|
@ -161,14 +151,17 @@ export default class BuildApi {
|
|||
});
|
||||
}
|
||||
|
||||
loadOptions(onSuccess, onFailure) {
|
||||
loadOptions(release, onSuccess, onFailure) {
|
||||
const url = `${this._url}/api/options/${release}`;
|
||||
this.load(url, onSuccess, onFailure);
|
||||
}
|
||||
|
||||
const url = `${this._url}/api/options`;
|
||||
loadOptionsByBuildKey(release, key, onSuccess, onFailure) {
|
||||
const url = `${this._url}/api/options/${release}/${key}`;
|
||||
this.load(url, onSuccess, onFailure);
|
||||
}
|
||||
|
||||
loadCommits(release, onSuccess, onFailure) {
|
||||
|
||||
const url = `${this._url}/api/releases/${release}/commits`;
|
||||
this.load(url, onSuccess, onFailure);
|
||||
}
|
||||
|
|
|
@ -191,8 +191,6 @@ firmware_flasher.initialize = function (callback) {
|
|||
buildOptionsList($('select[name="motorProtocols"]'), data.motorProtocols);
|
||||
}
|
||||
|
||||
self.releaseLoader.loadOptions(buildOptions);
|
||||
|
||||
let buildTypesToShow;
|
||||
const buildType_e = $('select[name="build_type"]');
|
||||
function buildBuildTypeOptionsList() {
|
||||
|
@ -330,6 +328,12 @@ firmware_flasher.initialize = function (callback) {
|
|||
}
|
||||
|
||||
self.releaseLoader.loadTarget(target, release, onTargetDetail);
|
||||
|
||||
if (FC.CONFIG.buildKey.length === 32) {
|
||||
self.releaseLoader.loadOptionsByBuildKey(release, FC.CONFIG.buildKey, buildOptions);
|
||||
} else {
|
||||
self.releaseLoader.loadOptions(release, buildOptions);
|
||||
}
|
||||
}
|
||||
|
||||
function populateReleases(versions_element, target) {
|
||||
|
@ -571,44 +575,12 @@ firmware_flasher.initialize = function (callback) {
|
|||
MSP.send_message(MSPCodes.MSP_BOARD_INFO, false, false, onFinish);
|
||||
}
|
||||
|
||||
function presetBuildOptions(data) {
|
||||
const newOptions = [];
|
||||
|
||||
newOptions.generalOptions = [];
|
||||
newOptions.motorProtocols = [];
|
||||
newOptions.radioProtocols = [];
|
||||
newOptions.telemetryProtocols = [];
|
||||
|
||||
for (const option of data.generalOptions) {
|
||||
option.default = FC.CONFIG.buildOptions.some(opt => opt.includes(option.value));
|
||||
newOptions.generalOptions.push(option);
|
||||
}
|
||||
|
||||
for (const option of data.motorProtocols) {
|
||||
option.default = FC.CONFIG.buildOptions.some(opt => opt.includes(option.value));
|
||||
newOptions.motorProtocols.push(option);
|
||||
}
|
||||
|
||||
for (const option of data.radioProtocols) {
|
||||
option.default = FC.CONFIG.buildOptions.some(opt => opt.includes(option.value));
|
||||
newOptions.radioProtocols.push(option);
|
||||
}
|
||||
|
||||
for (const option of data.telemetryProtocols) {
|
||||
option.default = FC.CONFIG.buildOptions.some(opt => opt.includes(option.value));
|
||||
newOptions.telemetryProtocols.push(option);
|
||||
}
|
||||
|
||||
buildOptions(newOptions);
|
||||
}
|
||||
|
||||
function getBuildInfo() {
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) && navigator.onLine) {
|
||||
|
||||
function onLoadCloudBuild(options) {
|
||||
if (FC.CONFIG.buildKey.length === 32) {
|
||||
FC.CONFIG.buildOptions = options.Request.Options;
|
||||
self.releaseLoader.loadOptions(presetBuildOptions);
|
||||
}
|
||||
getBoardInfo();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue