Revert "added caching for betaflight releases in the firmware flasher"

This reverts commit 27e8dcc963.
10.3.x-maintenance
U-DESKTOP-12PPI61\boris.bozic 2016-06-30 21:32:32 +02:00
parent 517dbca0f0
commit 9fe4a6bb5d
3 changed files with 49 additions and 74 deletions

View File

@ -1408,9 +1408,6 @@
"firmwareFlasherButtonLoadOnline": { "firmwareFlasherButtonLoadOnline": {
"message": "Load Firmware [Online]" "message": "Load Firmware [Online]"
}, },
"firmwareFlasherButtonUpdateReleasesList": {
"message": "Force Releases update"
},
"firmwareFlasherFlashFirmware": { "firmwareFlasherFlashFirmware": {
"message": "Flash Firmware" "message": "Flash Firmware"
}, },
@ -1546,17 +1543,32 @@
"pidTuningGps": { "pidTuningGps": {
"message": "GPS Navigation" "message": "GPS Navigation"
}, },
"pidTuningLevelP": { "pidTuningStrength": {
"message": "Strength (Angle)" "message": "Strength"
}, },
"pidTuningLevelI": { "pidTuningTransition": {
"message": "Strength (Horizon)" "message": "Transition"
}, },
"pidTuningLevelD": { "pidTuningHorizon": {
"message": "Transition (Horizon)" "message": "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 LEVEL 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 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. "
@ -1679,7 +1691,7 @@
"message": "Magnetometer (if supported)" "message": "Magnetometer (if supported)"
}, },
"PIDTip": { "PIDTip": {
"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" "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"
} }

View File

@ -7,12 +7,7 @@
<td><select name="release"> <td><select name="release">
<option value="0">Loading ...</option> <option value="0">Loading ...</option>
</select></td> </select></td>
<td> <td><span class="description" i18n="firmwareFlasherOnlineReleasesDescription"></span></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

View File

@ -134,24 +134,8 @@ 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
@ -164,27 +148,15 @@ TABS.firmware_flasher.initialize = function (callback) {
$('a.flash_firmware').addClass('disabled'); $('a.flash_firmware').addClass('disabled');
} }
}); });
}
chrome.storage.local.get('lastReleasesSync', function (result) { }).fail(function (data){
// calculate time between last online sync and now if (data["responseJSON"]){
var lastReleasesSync = new Date(result.lastReleasesSync); GUI.log("<b>GITHUB Query Failed: <code>{0}</code></b>".format(data["responseJSON"].message));
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 // UI Hooks
$('a.load_file').click(function () { $('a.load_file').click(function () {
chrome.fileSystem.chooseEntry({type: 'openFile', accepts: [{extensions: ['hex']}]}, function (fileEntry) { chrome.fileSystem.chooseEntry({type: 'openFile', accepts: [{extensions: ['hex']}]}, function (fileEntry) {
@ -384,10 +356,6 @@ 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) {