mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-20 14:55:15 +03:00
initial go at flashing unified target with a config
This commit is contained in:
parent
386c757e45
commit
16cabc93a4
2 changed files with 268 additions and 60 deletions
|
@ -66,7 +66,7 @@ PortHandler.check = function () {
|
||||||
|
|
||||||
// auto-select last used port (only during initialization)
|
// auto-select last used port (only during initialization)
|
||||||
if (!self.initial_ports) {
|
if (!self.initial_ports) {
|
||||||
chrome.storage.local.get('last_used_port', function (result) {
|
ConfigStorage.get('last_used_port', function (result) {
|
||||||
// if last_used_port was set, we try to select it
|
// if last_used_port was set, we try to select it
|
||||||
if (result.last_used_port) {
|
if (result.last_used_port) {
|
||||||
current_ports.forEach(function(port) {
|
current_ports.forEach(function(port) {
|
||||||
|
|
|
@ -18,6 +18,18 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
var intel_hex = false; // standard intel hex in string format
|
var intel_hex = false; // standard intel hex in string format
|
||||||
var parsed_hex = false; // parsed raw hex in array format
|
var parsed_hex = false; // parsed raw hex in array format
|
||||||
var targetConfig; // the Unified Target configuration to be spliced into the configuration
|
var targetConfig; // the Unified Target configuration to be spliced into the configuration
|
||||||
|
var isConfigLocal = false; // Set to true if the user loads one locally
|
||||||
|
var unifiedConfig; // Unified target configuration loaded from the menu, used when throwing out a local config
|
||||||
|
|
||||||
|
// Is there a list of these elsewhere?, used in parseUnifiedBuilds and ... look for unifiedTargets[0]
|
||||||
|
var unifiedTargets = [ 'STM32F411', 'STM32F405', 'STM32F745', 'STM32F7X2' ];
|
||||||
|
self.peekTargetConfig = function () { // This maybe should get removed before merging.
|
||||||
|
return targetConfig;
|
||||||
|
}
|
||||||
|
var unifiedSource = 'https://api.github.com/repos/betaflight/unified-targets/contents/configs';
|
||||||
|
//unifiedSource = 'https://api.github.com/repos/betaflight/betaflight/contents/unified_targets/configs';
|
||||||
|
//unifiedSource = 'http://localhost'; // handy way to force a failure
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change boldness of firmware option depending on cache status
|
* Change boldness of firmware option depending on cache status
|
||||||
|
@ -48,22 +60,7 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
// send data/string over for processing
|
// send data/string over for processing
|
||||||
worker.postMessage(str);
|
worker.postMessage(str);
|
||||||
}
|
}
|
||||||
|
function show_loaded_hex(summary) {
|
||||||
function process_hex(data, summary) {
|
|
||||||
intel_hex = data;
|
|
||||||
|
|
||||||
analytics.setFirmwareData(analytics.DATA.FIRMWARE_CHECKSUM, objectHash.sha1(intel_hex));
|
|
||||||
|
|
||||||
parse_hex(intel_hex, function (data) {
|
|
||||||
parsed_hex = data;
|
|
||||||
|
|
||||||
if (parsed_hex) {
|
|
||||||
analytics.setFirmwareData(analytics.DATA.FIRMWARE_SIZE, parsed_hex.bytes_total);
|
|
||||||
|
|
||||||
if (!FirmwareCache.has(summary)) {
|
|
||||||
FirmwareCache.put(summary, intel_hex);
|
|
||||||
}
|
|
||||||
|
|
||||||
self.flashingMessage('<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.FLASH_MESSAGE_TYPES.NEUTRAL);
|
||||||
|
|
||||||
|
@ -81,8 +78,23 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
$('div.release_info .notes').find('a').each(function() {
|
$('div.release_info .notes').find('a').each(function() {
|
||||||
$(this).attr('target', '_blank');
|
$(this).attr('target', '_blank');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('div.release_info').slideDown();
|
$('div.release_info').slideDown();
|
||||||
|
}
|
||||||
|
function process_hex(data, summary) {
|
||||||
|
intel_hex = data;
|
||||||
|
|
||||||
|
analytics.setFirmwareData(analytics.DATA.FIRMWARE_CHECKSUM, objectHash.sha1(intel_hex));
|
||||||
|
|
||||||
|
parse_hex(intel_hex, function (data) {
|
||||||
|
parsed_hex = data;
|
||||||
|
|
||||||
|
if (parsed_hex) {
|
||||||
|
analytics.setFirmwareData(analytics.DATA.FIRMWARE_SIZE, parsed_hex.bytes_total);
|
||||||
|
|
||||||
|
if (!FirmwareCache.has(summary)) {
|
||||||
|
FirmwareCache.put(summary, intel_hex);
|
||||||
|
}
|
||||||
|
show_loaded_hex(summary)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
self.flashingMessage('firmwareFlasherHexCorrupted', self.FLASH_MESSAGE_TYPES.INVALID);
|
self.flashingMessage('firmwareFlasherHexCorrupted', self.FLASH_MESSAGE_TYPES.INVALID);
|
||||||
|
@ -91,6 +103,7 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onLoadSuccess(data, summary) {
|
function onLoadSuccess(data, summary) {
|
||||||
|
// The path from getting a firmware doesn't fill in summary.
|
||||||
summary = typeof summary === "object"
|
summary = typeof summary === "object"
|
||||||
? summary
|
? summary
|
||||||
: $('select[name="firmware_version"] option:selected').data('summary');
|
: $('select[name="firmware_version"] option:selected').data('summary');
|
||||||
|
@ -99,7 +112,7 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
$("a.load_remote_file").text(i18n.getMessage('firmwareFlasherButtonLoadOnline'));
|
$("a.load_remote_file").text(i18n.getMessage('firmwareFlasherButtonLoadOnline'));
|
||||||
};
|
};
|
||||||
|
|
||||||
function buildJenkinsBoardOptions(builds) {
|
function populateBoardOptions(builds) {
|
||||||
if (!builds) {
|
if (!builds) {
|
||||||
$('select[name="board"]').empty().append('<option value="0">Offline</option>');
|
$('select[name="board"]').empty().append('<option value="0">Offline</option>');
|
||||||
$('select[name="firmware_version"]').empty().append('<option value="0">Offline</option>');
|
$('select[name="firmware_version"]').empty().append('<option value="0">Offline</option>');
|
||||||
|
@ -121,7 +134,7 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
var select_e =
|
var select_e =
|
||||||
$("<option value='{0}'>{0}</option>".format(
|
$("<option value='{0}'>{0}</option>".format(
|
||||||
descriptor.target
|
descriptor.target
|
||||||
)).data('summary', descriptor);
|
));
|
||||||
boards_e.append(select_e);
|
boards_e.append(select_e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -129,7 +142,7 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
|
|
||||||
TABS.firmware_flasher.releases = builds;
|
TABS.firmware_flasher.releases = builds;
|
||||||
|
|
||||||
chrome.storage.local.get('selected_board', function (result) {
|
ConfigStorage.get('selected_board', function (result) {
|
||||||
if (result.selected_board) {
|
if (result.selected_board) {
|
||||||
var boardBuilds = builds[result.selected_board]
|
var boardBuilds = builds[result.selected_board]
|
||||||
$('select[name="board"]').val(boardBuilds ? result.selected_board : 0).trigger('change');
|
$('select[name="board"]').val(boardBuilds ? result.selected_board : 0).trigger('change');
|
||||||
|
@ -137,6 +150,63 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function processBoardOptions(releaseData, showDevReleases) {
|
||||||
|
var releases = {};
|
||||||
|
var sortedTargets = [];
|
||||||
|
var unsortedTargets = [];
|
||||||
|
releaseData.forEach(function(release){
|
||||||
|
release.assets.forEach(function(asset){
|
||||||
|
var targetFromFilenameExpression = /betaflight_([\d.]+)?_?(\w+)(\-.*)?\.(.*)/;
|
||||||
|
var match = targetFromFilenameExpression.exec(asset.name);
|
||||||
|
if ((!showDevReleases && release.prerelease) || !match) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var target = match[2];
|
||||||
|
if($.inArray(target, unsortedTargets) == -1) {
|
||||||
|
unsortedTargets.push(target);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
sortedTargets = unsortedTargets.sort();
|
||||||
|
});
|
||||||
|
sortedTargets.forEach(function(release) {
|
||||||
|
releases[release] = [];
|
||||||
|
});
|
||||||
|
releaseData.forEach(function(release){
|
||||||
|
var versionFromTagExpression = /v?(.*)/;
|
||||||
|
var matchVersionFromTag = versionFromTagExpression.exec(release.tag_name);
|
||||||
|
var version = matchVersionFromTag[1];
|
||||||
|
release.assets.forEach(function(asset){
|
||||||
|
var targetFromFilenameExpression = /betaflight_([\d.]+)?_?(\w+)(\-.*)?\.(.*)/;
|
||||||
|
var match = targetFromFilenameExpression.exec(asset.name);
|
||||||
|
if ((!showDevReleases && release.prerelease) || !match) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var target = match[2];
|
||||||
|
var format = match[4];
|
||||||
|
if (format != 'hex') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var date = new Date(release.published_at);
|
||||||
|
var formattedDate = ("0" + date.getDate()).slice(-2) + "-" + ("0"+(date.getMonth()+1)).slice(-2) + "-" + date.getFullYear() + " " + ("0" + date.getHours()).slice(-2) + ":" + ("0" + date.getMinutes()).slice(-2);
|
||||||
|
var descriptor = {
|
||||||
|
"releaseUrl": release.html_url,
|
||||||
|
"name" : version,
|
||||||
|
"version" : version,
|
||||||
|
"url" : asset.browser_download_url,
|
||||||
|
"file" : asset.name,
|
||||||
|
"target" : target,
|
||||||
|
"date" : formattedDate,
|
||||||
|
"notes" : release.body
|
||||||
|
};
|
||||||
|
releases[target].push(descriptor);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
loadUnifiedBuilds(releases);
|
||||||
|
//TABS.firmware_flasher.saveReleases = releases;
|
||||||
|
//console.log('loaded some board options for later');
|
||||||
|
};
|
||||||
|
|
||||||
|
// not used?
|
||||||
function buildBoardOptions(releaseData, showDevReleases) {
|
function buildBoardOptions(releaseData, showDevReleases) {
|
||||||
if (!releaseData) {
|
if (!releaseData) {
|
||||||
$('select[name="board"]').empty().append('<option value="0">Offline</option>');
|
$('select[name="board"]').empty().append('<option value="0">Offline</option>');
|
||||||
|
@ -221,7 +291,7 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
});
|
});
|
||||||
TABS.firmware_flasher.releases = releases;
|
TABS.firmware_flasher.releases = releases;
|
||||||
|
|
||||||
chrome.storage.local.get('selected_board', function (result) {
|
ConfigStorage.get('selected_board', function (result) {
|
||||||
if (result.selected_board) {
|
if (result.selected_board) {
|
||||||
var boardReleases = releases[result.selected_board]
|
var boardReleases = releases[result.selected_board]
|
||||||
$('select[name="board"]').val(boardReleases ? result.selected_board : 0).trigger('change');
|
$('select[name="board"]').val(boardReleases ? result.selected_board : 0).trigger('change');
|
||||||
|
@ -230,21 +300,104 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function loadUnifiedBuilds(builds) {
|
||||||
|
var expirationPeriod = 3600; // One of your earth hours.
|
||||||
|
var checkTime = Math.floor(Date.now()/1000); // Lets deal in seconds.
|
||||||
|
// unifiedTargets[0] is STM32F411
|
||||||
|
if (builds && builds[unifiedTargets[0]]) {
|
||||||
|
console.log('loaded some builds for later');
|
||||||
|
var storageTag = 'unifiedSourceCache';
|
||||||
|
chrome.storage.local.get(storageTag, function (result) {
|
||||||
|
let storageObj = result[storageTag];
|
||||||
|
if(!storageObj || !storageObj.lastUpdate || checkTime - storageObj.lastUpdate > expirationPeriod ) {
|
||||||
|
console.log('go get', unifiedSource);
|
||||||
|
$.get(unifiedSource, function(data,textStatus,jqXHR) {
|
||||||
|
let newObj = {};
|
||||||
|
newObj[storageTag]={};
|
||||||
|
newObj[storageTag].lastUpdate=checkTime;
|
||||||
|
newObj[storageTag].data=data;
|
||||||
|
chrome.storage.local.set(newObj);
|
||||||
|
parseUnifiedBuilds(data, builds);
|
||||||
|
}).fail(xhr => {
|
||||||
|
console.log('failed to get new', unifiedSource, 'cached data',Math.floor((checkTime - storageObj.lastUpdate)/60),'mins old');
|
||||||
|
parseUnifiedBuilds(storageObj.data, builds);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// In the event that the cache is okay
|
||||||
|
console.log('unified config cached data',Math.floor((checkTime - storageObj.lastUpdate)/60),'mins old');
|
||||||
|
parseUnifiedBuilds(storageObj.data, builds);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
populateBoardOptions(builds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseUnifiedBuilds(data, builds) {
|
||||||
|
if (!data) { return; }
|
||||||
|
let releases = {};
|
||||||
|
let unifiedConfigs = {};
|
||||||
|
let items = {};
|
||||||
|
data.forEach(function(target) {
|
||||||
|
let targetName = target.name;
|
||||||
|
if (targetName.endsWith('.config')) {
|
||||||
|
targetName = targetName.slice(0,targetName.indexOf('.config'));
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
unifiedConfigs[targetName]=target.download_url;
|
||||||
|
items[targetName] = target.download_url;
|
||||||
|
});
|
||||||
|
Object.keys(builds).forEach(function (key) {
|
||||||
|
if (unifiedTargets.includes(key)) {
|
||||||
|
items[key] = "something";
|
||||||
|
releases[key] = builds[key];
|
||||||
|
} else {
|
||||||
|
var legacyKey = key + " (Legacy)";
|
||||||
|
items[legacyKey] = "something";
|
||||||
|
releases[legacyKey] = builds[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('select[name="board"]').empty()
|
||||||
|
.append($("<option value='0' i18n='firmwareFlasherOptionLabelSelectBoard'></option>"));
|
||||||
|
|
||||||
|
$('select[name="firmware_version"]').empty()
|
||||||
|
.append($("<option value='0' i18n='firmwareFlasherOptionLabelSelectFirmwareVersion'></option>"));
|
||||||
|
var boards_e = $('select[name="board"]');
|
||||||
|
var versions_e = $('select[name="firmware_version"]');
|
||||||
|
var selectTargets = [];
|
||||||
|
Object.keys(items)
|
||||||
|
.sort()
|
||||||
|
.forEach(function(target, i) {
|
||||||
|
var select_e = $("<option value='{0}'>{0}</option>".format(target));
|
||||||
|
boards_e.append(select_e);
|
||||||
|
});
|
||||||
|
TABS.firmware_flasher.releases = releases;
|
||||||
|
TABS.firmware_flasher.unifiedConfigs = unifiedConfigs;
|
||||||
|
|
||||||
|
ConfigStorage.get('selected_board', function (result) {
|
||||||
|
if (result.selected_board) {
|
||||||
|
var boardReleases = unifiedConfigs[result.selected_board]
|
||||||
|
$('select[name="board"]').val(boardReleases ? result.selected_board : 0).trigger('change');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var buildTypes = [
|
var buildTypes = [
|
||||||
{
|
{
|
||||||
tag: 'firmwareFlasherOptionLabelBuildTypeRelease',
|
tag: 'firmwareFlasherOptionLabelBuildTypeRelease',
|
||||||
loader: () => self.releaseChecker.loadReleaseData(releaseData => buildBoardOptions(releaseData, false))
|
loader: () => self.releaseChecker.loadReleaseData(releaseData => processBoardOptions(releaseData, false))
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
tag: 'firmwareFlasherOptionLabelBuildTypeReleaseCandidate',
|
tag: 'firmwareFlasherOptionLabelBuildTypeReleaseCandidate',
|
||||||
loader: () => self.releaseChecker.loadReleaseData(releaseData => buildBoardOptions(releaseData, true))
|
loader: () => self.releaseChecker.loadReleaseData(releaseData => processBoardOptions(releaseData, true))
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
var ciBuildsTypes = self.jenkinsLoader._jobs.map(job => {
|
var ciBuildsTypes = self.jenkinsLoader._jobs.map(job => {
|
||||||
return {
|
return {
|
||||||
title: job.title,
|
title: job.title,
|
||||||
loader: () => self.jenkinsLoader.loadBuilds(job.name, buildJenkinsBoardOptions)
|
loader: () => self.jenkinsLoader.loadBuilds(job.name, loadUnifiedBuilds)
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
var buildTypesToShow;
|
var buildTypesToShow;
|
||||||
|
@ -288,7 +441,7 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
|
|
||||||
var expertMode_e = $('.tab-firmware_flasher input.expert_mode');
|
var expertMode_e = $('.tab-firmware_flasher input.expert_mode');
|
||||||
expertMode_e.prop('checked', globalExpertMode_e.is(':checked'));
|
expertMode_e.prop('checked', globalExpertMode_e.is(':checked'));
|
||||||
$('input.show_development_releases').change(showOrHideBuildTypes).change();
|
$('input.show_development_releases').change(showOrHideBuildTypes); //.change();
|
||||||
expertMode_e.change(showOrHideBuildTypeSelect).change();
|
expertMode_e.change(showOrHideBuildTypeSelect).change();
|
||||||
|
|
||||||
// translate to user-selected language
|
// translate to user-selected language
|
||||||
|
@ -307,6 +460,7 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
.append($("<option value='0' i18n='firmwareFlasherOptionLabelSelectFirmwareVersion'></option>"));
|
.append($("<option value='0' i18n='firmwareFlasherOptionLabelSelectFirmwareVersion'></option>"));
|
||||||
|
|
||||||
if (!GUI.connect_lock) {
|
if (!GUI.connect_lock) {
|
||||||
|
TABS.firmware_flasher.unifiedConfigs = {};
|
||||||
buildTypesToShow[build_type].loader();
|
buildTypesToShow[build_type].loader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,9 +468,33 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
i18n.localizePage();
|
i18n.localizePage();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function populateVersions(versions_element, targetVersions, target) {
|
||||||
|
if (targetVersions) {
|
||||||
|
versions_element.append($("<option value='0'>{0} {1}</option>".format(i18n.getMessage('firmwareFlasherOptionLabelSelectFirmwareVersionFor'), target)));
|
||||||
|
targetVersions.forEach(function(descriptor) {
|
||||||
|
var select_e =
|
||||||
|
$("<option value='{0}'>{0} - {1} - {2}</option>".format(
|
||||||
|
descriptor.version,
|
||||||
|
descriptor.target,
|
||||||
|
descriptor.date
|
||||||
|
))
|
||||||
|
.css("font-weight", FirmwareCache.has(descriptor)
|
||||||
|
? "bold"
|
||||||
|
: "normal"
|
||||||
|
);
|
||||||
|
select_e.data('summary', descriptor);
|
||||||
|
versions_element.append(select_e);
|
||||||
|
});
|
||||||
|
// Assume flashing latest, so default to it.
|
||||||
|
versions_element.prop("selectedIndex", 1).change();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$('select[name="board"]').change(function() {
|
$('select[name="board"]').change(function() {
|
||||||
$("a.load_remote_file").addClass('disabled');
|
$("a.load_remote_file").addClass('disabled');
|
||||||
var target = $(this).val();
|
var target = $(this).val();
|
||||||
|
ConfigStorage.set({'selected_board': target});
|
||||||
|
console.log('board changed to', target);
|
||||||
|
|
||||||
if (!GUI.connect_lock) {
|
if (!GUI.connect_lock) {
|
||||||
self.flashingMessage('firmwareFlasherLoadFirmwareFile', self.FLASH_MESSAGE_TYPES.NEUTRAL)
|
self.flashingMessage('firmwareFlasherLoadFirmwareFile', self.FLASH_MESSAGE_TYPES.NEUTRAL)
|
||||||
|
@ -333,29 +511,58 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
if(target == 0) {
|
if(target == 0) {
|
||||||
versions_e.append($("<option value='0'>{0}</option>".format(i18n.getMessage('firmwareFlasherOptionLabelSelectFirmwareVersion'))));
|
versions_e.append($("<option value='0'>{0}</option>".format(i18n.getMessage('firmwareFlasherOptionLabelSelectFirmwareVersion'))));
|
||||||
} else {
|
} else {
|
||||||
versions_e.append($("<option value='0'>{0} {1}</option>".format(i18n.getMessage('firmwareFlasherOptionLabelSelectFirmwareVersionFor'), target)));
|
let selecteBuild = buildTypesToShow[$('select[name="build_type"]').val()];
|
||||||
|
if (TABS.firmware_flasher.unifiedConfigs[target]) {
|
||||||
TABS.firmware_flasher.releases[target].forEach(function(descriptor) {
|
var storageTag = 'unifiedConfigLast';
|
||||||
var select_e =
|
var expirationPeriod = 3600; // One of your earth hours.
|
||||||
$("<option value='{0}'>{0} - {1} - {2}</option>".format(
|
var checkTime = Math.floor(Date.now()/1000); // Lets deal in seconds.
|
||||||
descriptor.version,
|
chrome.storage.local.get(storageTag, function (result) {
|
||||||
descriptor.target,
|
let storageObj = result[storageTag];
|
||||||
descriptor.date
|
let bareBoard = null;
|
||||||
))
|
//bareBoard = 'STM32F405';
|
||||||
.css("font-weight", FirmwareCache.has(descriptor)
|
if (!storageObj || !storageObj.target || storageObj.target != target) {
|
||||||
? "bold"
|
// Have to go and try and get the unified config, and then do stuff
|
||||||
: "normal"
|
//console.log('url',TABS.firmware_flasher.unifiedConfigs[target]);
|
||||||
)
|
$.get(TABS.firmware_flasher.unifiedConfigs[target], function(data) {
|
||||||
.data('summary', descriptor);
|
console.log('got unified config');
|
||||||
|
let tempObj = {};
|
||||||
versions_e.append(select_e);
|
tempObj['data'] = data;
|
||||||
|
tempObj['target'] = target;
|
||||||
|
tempObj['checkTime'] = checkTime;
|
||||||
|
targetConfig = data;
|
||||||
|
isConfigLocal = false;
|
||||||
|
unifiedConfig = data;
|
||||||
|
bareBoard = data.split("\n")[0].split(' ')[3];
|
||||||
|
populateVersions(versions_e, TABS.firmware_flasher.releases[bareBoard],target);
|
||||||
|
}).fail(xhr => {
|
||||||
|
//TODO error, populate nothing?
|
||||||
|
targetConfig = undefined;
|
||||||
|
isConfigLocal = false;
|
||||||
|
unifiedConfig= undefined;
|
||||||
|
GUI.log('failed to load a unified config');
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
console.log('We have the config cached for', target);
|
||||||
|
var data = storageObj.data;
|
||||||
|
targetConfig = data;
|
||||||
|
isConfigLocal = false;
|
||||||
|
unifiedConfig = data;
|
||||||
|
bareBoard = data.split("\n")[0].split(' ')[3];
|
||||||
|
populateVersions(versions_e, TABS.firmware_flasher.releases[bareBoard],target);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if (!isConfigLocal) {
|
||||||
|
targetConfig = undefined;
|
||||||
|
unifiedConfig = undefined;
|
||||||
|
} else {
|
||||||
|
unifiedConfig = undefined;
|
||||||
|
}
|
||||||
|
populateVersions(versions_e, TABS.firmware_flasher.releases[target], target);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assume flashing latest, so default to it.
|
|
||||||
versions_e.prop("selectedIndex", 1).change();
|
|
||||||
}
|
}
|
||||||
chrome.storage.local.set({'selected_board': target});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// UI Hooks
|
// UI Hooks
|
||||||
|
@ -604,7 +811,7 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
buildType_e.val(result.selected_build_type || 0).trigger('change');
|
buildType_e.val(result.selected_build_type || 0).trigger('change');
|
||||||
});
|
});
|
||||||
|
|
||||||
chrome.storage.local.get('no_reboot_sequence', function (result) {
|
ConfigStorage.get('no_reboot_sequence', function (result) {
|
||||||
if (result.no_reboot_sequence) {
|
if (result.no_reboot_sequence) {
|
||||||
$('input.updating').prop('checked', true);
|
$('input.updating').prop('checked', true);
|
||||||
$('.flash_on_connect_wrapper').show();
|
$('.flash_on_connect_wrapper').show();
|
||||||
|
@ -623,13 +830,13 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
$('.flash_on_connect_wrapper').hide();
|
$('.flash_on_connect_wrapper').hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
chrome.storage.local.set({'no_reboot_sequence': status});
|
ConfigStorage.set({'no_reboot_sequence': status});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('input.updating').change();
|
$('input.updating').change();
|
||||||
});
|
});
|
||||||
|
|
||||||
chrome.storage.local.get('flash_manual_baud', function (result) {
|
ConfigStorage.get('flash_manual_baud', function (result) {
|
||||||
if (result.flash_manual_baud) {
|
if (result.flash_manual_baud) {
|
||||||
$('input.flash_manual_baud').prop('checked', true);
|
$('input.flash_manual_baud').prop('checked', true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -639,19 +846,19 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
// bind UI hook so the status is saved on change
|
// bind UI hook so the status is saved on change
|
||||||
$('input.flash_manual_baud').change(function() {
|
$('input.flash_manual_baud').change(function() {
|
||||||
var status = $(this).is(':checked');
|
var status = $(this).is(':checked');
|
||||||
chrome.storage.local.set({'flash_manual_baud': status});
|
ConfigStorage.set({'flash_manual_baud': status});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('input.flash_manual_baud').change();
|
$('input.flash_manual_baud').change();
|
||||||
});
|
});
|
||||||
|
|
||||||
chrome.storage.local.get('flash_manual_baud_rate', function (result) {
|
ConfigStorage.get('flash_manual_baud_rate', function (result) {
|
||||||
$('#flash_manual_baud_rate').val(result.flash_manual_baud_rate);
|
$('#flash_manual_baud_rate').val(result.flash_manual_baud_rate);
|
||||||
|
|
||||||
// bind UI hook so the status is saved on change
|
// bind UI hook so the status is saved on change
|
||||||
$('#flash_manual_baud_rate').change(function() {
|
$('#flash_manual_baud_rate').change(function() {
|
||||||
var baud = parseInt($('#flash_manual_baud_rate').val());
|
var baud = parseInt($('#flash_manual_baud_rate').val());
|
||||||
chrome.storage.local.set({'flash_manual_baud_rate': baud});
|
ConfigStorage.set({'flash_manual_baud_rate': baud});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('input.flash_manual_baud_rate').change();
|
$('input.flash_manual_baud_rate').change();
|
||||||
|
@ -688,7 +895,7 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
}
|
}
|
||||||
}).change();
|
}).change();
|
||||||
|
|
||||||
chrome.storage.local.get('erase_chip', function (result) {
|
ConfigStorage.get('erase_chip', function (result) {
|
||||||
if (result.erase_chip) {
|
if (result.erase_chip) {
|
||||||
$('input.erase_chip').prop('checked', true);
|
$('input.erase_chip').prop('checked', true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -696,7 +903,7 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$('input.erase_chip').change(function () {
|
$('input.erase_chip').change(function () {
|
||||||
chrome.storage.local.set({'erase_chip': $(this).is(':checked')});
|
ConfigStorage.set({'erase_chip': $(this).is(':checked')});
|
||||||
}).change();
|
}).change();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -706,6 +913,7 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
.change(function () {
|
.change(function () {
|
||||||
chrome.storage.local.set({'show_development_releases': $(this).is(':checked')});
|
chrome.storage.local.set({'show_development_releases': $(this).is(':checked')});
|
||||||
}).change();
|
}).change();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).keypress(function (e) {
|
$(document).keypress(function (e) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue