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": {
|
"firmwareFlasherButtonLoadOnline": {
|
||||||
"message": "Load Firmware [Online]"
|
"message": "Load Firmware [Online]"
|
||||||
},
|
},
|
||||||
|
"firmwareFlasherButtonUpdateReleasesList": {
|
||||||
|
"message": "Force Releases update"
|
||||||
|
},
|
||||||
"firmwareFlasherFlashFirmware": {
|
"firmwareFlasherFlashFirmware": {
|
||||||
"message": "Flash Firmware"
|
"message": "Flash Firmware"
|
||||||
},
|
},
|
||||||
|
@ -1543,32 +1546,17 @@
|
||||||
"pidTuningGps": {
|
"pidTuningGps": {
|
||||||
"message": "GPS Navigation"
|
"message": "GPS Navigation"
|
||||||
},
|
},
|
||||||
"pidTuningStrength": {
|
"pidTuningLevelP": {
|
||||||
"message": "Strength"
|
"message": "Strength (Angle)"
|
||||||
},
|
},
|
||||||
"pidTuningTransition": {
|
"pidTuningLevelI": {
|
||||||
"message": "Transition"
|
"message": "Strength (Horizon)"
|
||||||
},
|
},
|
||||||
"pidTuningHorizon": {
|
"pidTuningLevelD": {
|
||||||
"message": "Horizon"
|
"message": "Transition (Horizon)"
|
||||||
},
|
|
||||||
"pidTuningAngle": {
|
|
||||||
"message": "Angle"
|
|
||||||
},
|
},
|
||||||
"pidTuningLevelHelp": {
|
"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."
|
"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."
|
||||||
},
|
|
||||||
"pidTuningLfpFilters": {
|
|
||||||
"message": "LFP Filters"
|
|
||||||
},
|
|
||||||
"pidTuningGyro": {
|
|
||||||
"message": "Gyro Soft (Hz)"
|
|
||||||
},
|
|
||||||
"pidTuningDTerm": {
|
|
||||||
"message": "D Term (Hz)"
|
|
||||||
},
|
|
||||||
"pidTuningYaw": {
|
|
||||||
"message": "Yaw (Hz)"
|
|
||||||
},
|
},
|
||||||
"configHelp2": {
|
"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. "
|
"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)"
|
"message": "Magnetometer (if supported)"
|
||||||
},
|
},
|
||||||
"PIDTip": {
|
"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">
|
<td><select name="release">
|
||||||
<option value="0">Loading ...</option>
|
<option value="0">Loading ...</option>
|
||||||
</select></td>
|
</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>
|
||||||
<tr>
|
<tr>
|
||||||
<td><label> <input class="updating toggle" type="checkbox" /> <span
|
<td><label> <input class="updating toggle" type="checkbox" /> <span
|
||||||
|
|
|
@ -134,8 +134,24 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var updateReleases = function (){
|
||||||
$.get('https://api.github.com/repos/betaflight/betaflight/releases', function (releases){
|
$.get('https://api.github.com/repos/betaflight/betaflight/releases', function (releases){
|
||||||
processReleases(releases);
|
processReleases(releases);
|
||||||
|
updateReleasesList(releases);
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
$('select[name="release"]').empty().append('<option value="0">Offline</option>');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var updateReleasesList = function(releases){
|
||||||
TABS.firmware_flasher.releases = releases;
|
TABS.firmware_flasher.releases = releases;
|
||||||
|
|
||||||
// bind events
|
// bind events
|
||||||
|
@ -148,14 +164,26 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
$('a.flash_firmware').addClass('disabled');
|
$('a.flash_firmware').addClass('disabled');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}).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>');
|
|
||||||
});
|
|
||||||
|
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// UI Hooks
|
// UI Hooks
|
||||||
$('a.load_file').click(function () {
|
$('a.load_file').click(function () {
|
||||||
|
@ -356,6 +384,10 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('a.updateReleasesList').click(function() {
|
||||||
|
updateReleases();
|
||||||
|
});
|
||||||
|
|
||||||
$(document).on('click', 'span.progressLabel a.save_firmware', function () {
|
$(document).on('click', 'span.progressLabel a.save_firmware', function () {
|
||||||
chrome.fileSystem.chooseEntry({type: 'saveFile', suggestedName: 'baseflight', accepts: [{extensions: ['hex']}]}, function (fileEntry) {
|
chrome.fileSystem.chooseEntry({type: 'saveFile', suggestedName: 'baseflight', accepts: [{extensions: ['hex']}]}, function (fileEntry) {
|
||||||
if (chrome.runtime.lastError) {
|
if (chrome.runtime.lastError) {
|
||||||
|
|
Loading…
Reference in New Issue