Merge pull request #65 from KuchenKerze/master
added caching for betaflight releases in the firmware flasher10.3.x-maintenance
commit
517dbca0f0
|
@ -1408,6 +1408,9 @@
|
|||
"firmwareFlasherButtonLoadOnline": {
|
||||
"message": "Load Firmware [Online]"
|
||||
},
|
||||
"firmwareFlasherButtonUpdateReleasesList": {
|
||||
"message": "Force Releases update"
|
||||
},
|
||||
"firmwareFlasherFlashFirmware": {
|
||||
"message": "Flash Firmware"
|
||||
},
|
||||
|
@ -1543,32 +1546,17 @@
|
|||
"pidTuningGps": {
|
||||
"message": "GPS Navigation"
|
||||
},
|
||||
"pidTuningStrength": {
|
||||
"message": "Strength"
|
||||
"pidTuningLevelP": {
|
||||
"message": "Strength (Angle)"
|
||||
},
|
||||
"pidTuningTransition": {
|
||||
"message": "Transition"
|
||||
"pidTuningLevelI": {
|
||||
"message": "Strength (Horizon)"
|
||||
},
|
||||
"pidTuningHorizon": {
|
||||
"message": "Horizon"
|
||||
},
|
||||
"pidTuningAngle": {
|
||||
"message": "Angle"
|
||||
"pidTuningLevelD": {
|
||||
"message": "Transition (Horizon)"
|
||||
},
|
||||
"pidTuningLevelHelp": {
|
||||
"message": "The values below change the behaviour of the ANGLE and HORIZON flight modes. Different PID controllers handle the values differently. Please check the documentation."
|
||||
},
|
||||
"pidTuningLfpFilters": {
|
||||
"message": "LFP Filters"
|
||||
},
|
||||
"pidTuningGyro": {
|
||||
"message": "Gyro Soft (Hz)"
|
||||
},
|
||||
"pidTuningDTerm": {
|
||||
"message": "D Term (Hz)"
|
||||
},
|
||||
"pidTuningYaw": {
|
||||
"message": "Yaw (Hz)"
|
||||
"message": "The values below change the behaviour of the ANGLE and HORIZON flight modes. Different PID controllers handle the LEVEL values differently. Please check the documentation."
|
||||
},
|
||||
"configHelp2": {
|
||||
"message": "Arbitrary board rotation in degrees, to allow mounting it sideways / upside down / rotated etc. When running external sensors, use the sensor alignments (Gyro, Acc, Mag) to define sensor position independent from board orientation. "
|
||||
|
@ -1691,7 +1679,7 @@
|
|||
"message": "Magnetometer (if supported)"
|
||||
},
|
||||
"PIDTip": {
|
||||
"message": "<b>Derivative from Error</b> provides more direct stick response and is mostly prefered for Racing.<br><br><b>Derivative from Measurement</b> provides smoother stick response what is more usefull for freestyling"
|
||||
"message": "<strong><i>Derivative from Error</i></strong> provides more direct stick response and is mostly prefered for Racing.<br><strong><i>Derivative from Measurement</i></strong> provides smoother stick response what is more usefull for freestyling"
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -7,7 +7,12 @@
|
|||
<td><select name="release">
|
||||
<option value="0">Loading ...</option>
|
||||
</select></td>
|
||||
<td><span class="description" i18n="firmwareFlasherOnlineReleasesDescription"></span></td>
|
||||
<td>
|
||||
<span class="description" i18n="firmwareFlasherOnlineReleasesDescription"></span>
|
||||
<div class="btn">
|
||||
<a class="updateReleasesList" href="#" i18n="firmwareFlasherButtonUpdateReleasesList"></a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label> <input class="updating toggle" type="checkbox" /> <span
|
||||
|
|
|
@ -134,29 +134,57 @@ TABS.firmware_flasher.initialize = function (callback) {
|
|||
})
|
||||
};
|
||||
|
||||
$.get('https://api.github.com/repos/betaflight/betaflight/releases', function (releases){
|
||||
processReleases(releases);
|
||||
TABS.firmware_flasher.releases = releases;
|
||||
var updateReleases = function (){
|
||||
$.get('https://api.github.com/repos/betaflight/betaflight/releases', function (releases){
|
||||
processReleases(releases);
|
||||
updateReleasesList(releases);
|
||||
|
||||
// bind events
|
||||
$('select[name="release"]').change(function() {
|
||||
if (!GUI.connect_lock) {
|
||||
$('.progress').val(0).removeClass('valid invalid');
|
||||
$('span.progressLabel').text(chrome.i18n.getMessage('firmwareFlasherLoadFirmwareFile'));
|
||||
$('div.git_info').slideUp();
|
||||
$('div.release_info').slideUp();
|
||||
$('a.flash_firmware').addClass('disabled');
|
||||
}
|
||||
});
|
||||
chrome.storage.local.set({'releases': releases, 'lastReleasesSync': Date()}, function() {
|
||||
console.log('Releases saved');
|
||||
});
|
||||
|
||||
}).fail(function (data){
|
||||
if (data["responseJSON"]){
|
||||
GUI.log("<b>GITHUB Query Failed: <code>{0}</code></b>".format(data["responseJSON"].message));
|
||||
}).fail(function (data){
|
||||
if (data["responseJSON"]){
|
||||
GUI.log("<b>GITHUB Query Failed: <code>{0}</code></b>".format(data["responseJSON"].message));
|
||||
}
|
||||
$('select[name="release"]').empty().append('<option value="0">Offline</option>');
|
||||
});
|
||||
};
|
||||
|
||||
var updateReleasesList = function(releases){
|
||||
TABS.firmware_flasher.releases = releases;
|
||||
|
||||
// bind events
|
||||
$('select[name="release"]').change(function() {
|
||||
if (!GUI.connect_lock) {
|
||||
$('.progress').val(0).removeClass('valid invalid');
|
||||
$('span.progressLabel').text(chrome.i18n.getMessage('firmwareFlasherLoadFirmwareFile'));
|
||||
$('div.git_info').slideUp();
|
||||
$('div.release_info').slideUp();
|
||||
$('a.flash_firmware').addClass('disabled');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
chrome.storage.local.get('lastReleasesSync', function (result) {
|
||||
// calculate time between last online sync and now
|
||||
var lastReleasesSync = new Date(result.lastReleasesSync);
|
||||
var currentDate = new Date();
|
||||
var timeDiff = Math.abs(currentDate.getTime() - lastReleasesSync.getTime());
|
||||
var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));
|
||||
console.log(result.lastReleasesSync);
|
||||
if(diffDays > 1) {
|
||||
console.log("Last sync older than one day, updating releases");
|
||||
updateReleases();
|
||||
} else {
|
||||
console.log("Last sync younger than one day, using stored releases");
|
||||
chrome.storage.local.get('releases', function (result) {
|
||||
updateReleasesList(result.releases);
|
||||
buildFirmwareOptions();
|
||||
});
|
||||
}
|
||||
$('select[name="release"]').empty().append('<option value="0">Offline</option>');
|
||||
});
|
||||
|
||||
|
||||
// UI Hooks
|
||||
$('a.load_file').click(function () {
|
||||
chrome.fileSystem.chooseEntry({type: 'openFile', accepts: [{extensions: ['hex']}]}, function (fileEntry) {
|
||||
|
@ -356,6 +384,10 @@ TABS.firmware_flasher.initialize = function (callback) {
|
|||
}
|
||||
});
|
||||
|
||||
$('a.updateReleasesList').click(function() {
|
||||
updateReleases();
|
||||
});
|
||||
|
||||
$(document).on('click', 'span.progressLabel a.save_firmware', function () {
|
||||
chrome.fileSystem.chooseEntry({type: 'saveFile', suggestedName: 'baseflight', accepts: [{extensions: ['hex']}]}, function (fileEntry) {
|
||||
if (chrome.runtime.lastError) {
|
||||
|
|
Loading…
Reference in New Issue