Allow old API version to be used but disable LED strip tab and
backup/restore functionality in certain cases. Cleanup of tab switching.10.3.x-maintenance
parent
ebbf3de5e1
commit
34b7b87c3e
|
@ -138,7 +138,7 @@
|
|||
},
|
||||
|
||||
"tabSwitchUpgradeRequired": {
|
||||
"message": "You need to <strong>upgrade</strong> your firmware before you can view any of the tabs."
|
||||
"message": "You need to <strong>upgrade</strong> your firmware before you can use the $1 tab."
|
||||
},
|
||||
"firmwareVersion": {
|
||||
"message": "Firmware Version: <strong>$1</strong>"
|
||||
|
@ -220,6 +220,9 @@
|
|||
"defaultDonateText": {
|
||||
"message": "This utility is fully <strong>open source</strong> and is available free of charge to all <strong>cleanflight</strong> users.<br />If you found the cleanflight or cleanflight configurator useful, please consider <strong>supporting</strong> its development by donating."
|
||||
},
|
||||
"initialSetupBackupAndRestoreApiVersion": {
|
||||
"message": "<span style=\"color: red\">Backup and restore functionality disabled.</span> You have firmware with API version <span style=\"color: red\">$1</span>, backup and restore requires <span style=\"color: green\">$2</span>. Please backup your settings via the CLI, see Cleanflight documentation for procedure."
|
||||
},
|
||||
"initialSetupButtonCalibrateAccel": {
|
||||
"message": "Calibrate Accelerometer"
|
||||
},
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
var CONFIGURATOR = {
|
||||
'releaseDate': 1421431075334, // new Date().getTime() - 2015.01.16
|
||||
'apiVersionAccepted': 1.4,
|
||||
'apiVersionAccepted': 1.2,
|
||||
'backupRestoreMinApiVersionAccepted': 1.4,
|
||||
'backupFileMinVersionAccepted': '0.55', // chrome.runtime.getManifest().version is stored as string, so does this one
|
||||
'connectionValid': false,
|
||||
'connectionValidCliOnly': false,
|
||||
|
|
22
js/gui.js
22
js/gui.js
|
@ -13,6 +13,28 @@ var GUI_control = function () {
|
|||
this.optional_usb_permissions = false; // controlled by usb permissions code
|
||||
this.interval_array = [];
|
||||
this.timeout_array = [];
|
||||
this.defaultAllowedTabsWhenDisconnected = [
|
||||
'landing',
|
||||
'firmware_flasher'
|
||||
];
|
||||
this.defaultAllowedTabsWhenConnected = [
|
||||
'adjustments',
|
||||
'auxiliary',
|
||||
'cli',
|
||||
'configuration',
|
||||
'gps',
|
||||
'led_strip',
|
||||
'logging',
|
||||
'modes',
|
||||
'motors',
|
||||
'pid_tuning',
|
||||
'ports',
|
||||
'receiver',
|
||||
'sensors',
|
||||
'servos',
|
||||
'setup'
|
||||
];
|
||||
this.allowedTabs = this.defaultAllowedTabsWhenDisconnected;
|
||||
|
||||
// check which operating system is user running
|
||||
if (navigator.appVersion.indexOf("Win") != -1) this.operating_system = "Windows";
|
||||
|
|
|
@ -27,7 +27,7 @@ $(document).ready(function () {
|
|||
|
||||
GUI.connected_to = false;
|
||||
CONFIGURATOR.connectionValid = false;
|
||||
CONFIGURATOR.connectionValidCliOnly = false;
|
||||
GUI.allowedTabs = GUI.defaultAllowedTabsWhenDisconnected.slice();
|
||||
MSP.disconnect_cleanup();
|
||||
PortUsage.reset();
|
||||
|
||||
|
@ -46,14 +46,10 @@ $(document).ready(function () {
|
|||
// reset active sensor indicators
|
||||
sensor_status(0);
|
||||
|
||||
// de-select any selected tabs
|
||||
$('#tabs > ul li').removeClass('active');
|
||||
|
||||
// detach listeners and remove element data
|
||||
$('#content').empty();
|
||||
|
||||
// load default html
|
||||
TABS.landing.initialize();
|
||||
|
||||
$('#tabs .tab_landing a').click();
|
||||
}
|
||||
|
||||
$(this).data("clicks", !clicks);
|
||||
|
@ -164,15 +160,16 @@ function onOpen(openInfo) {
|
|||
MSP.send_message(MSP_codes.MSP_UID, false, false, function () {
|
||||
GUI.log(chrome.i18n.getMessage('uniqueDeviceIdReceived', [CONFIG.uid[0].toString(16) + CONFIG.uid[1].toString(16) + CONFIG.uid[2].toString(16)]));
|
||||
|
||||
GUI.timeout_remove('connecting'); // kill connecting timer
|
||||
|
||||
// continue as usually
|
||||
CONFIGURATOR.connectionValid = true;
|
||||
GUI.allowedTabs = GUI.defaultAllowedTabsWhenConnected.slice();
|
||||
if (CONFIG.apiVersion < 1.4) {
|
||||
GUI.allowedTabs.splice(GUI.allowedTabs.indexOf('led_strip'), 1);
|
||||
}
|
||||
|
||||
$('div#port-picker a.connect').text(chrome.i18n.getMessage('disconnect')).addClass('active');
|
||||
$('#tabs ul.mode-disconnected').hide();
|
||||
$('#tabs ul.mode-connected').show();
|
||||
$('#tabs ul.mode-connected li a:first').click();
|
||||
onConnect();
|
||||
|
||||
$('#tabs ul.mode-connected .tab_setup a').click();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -181,10 +178,9 @@ function onOpen(openInfo) {
|
|||
} else {
|
||||
GUI.log(chrome.i18n.getMessage('firmwareVersionNotSupported', [CONFIGURATOR.apiVersionAccepted]));
|
||||
CONFIGURATOR.connectionValid = true; // making it possible to open the CLI tab
|
||||
$('div#port-picker a.connect').text(chrome.i18n.getMessage('disconnect')).addClass('active');
|
||||
$('#tabs li a:last').click(); // open CLI tab
|
||||
GUI.timeout_remove('connecting'); // kill connecting timer
|
||||
CONFIGURATOR.connectionValidCliOnly = true;
|
||||
GUI.allowedTabs = ['cli'];
|
||||
onConnect();
|
||||
$('#tabs .tab_cli a').click();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
@ -202,15 +198,22 @@ function onOpen(openInfo) {
|
|||
}
|
||||
}
|
||||
|
||||
function onConnect() {
|
||||
GUI.timeout_remove('connecting'); // kill connecting timer
|
||||
$('div#port-picker a.connect').text(chrome.i18n.getMessage('disconnect')).addClass('active');
|
||||
$('#tabs ul.mode-disconnected').hide();
|
||||
$('#tabs ul.mode-connected').show();
|
||||
}
|
||||
|
||||
function onClosed(result) {
|
||||
if (result) { // All went as expected
|
||||
GUI.log(chrome.i18n.getMessage('serialPortClosedOk'));
|
||||
} else { // Something went wrong
|
||||
GUI.log(chrome.i18n.getMessage('serialPortClosedFail'));
|
||||
}
|
||||
$('#tabs ul.mode-disconnected').show();
|
||||
|
||||
$('#tabs ul.mode-connected').hide();
|
||||
$('#tabs ul.mode-disconnected li a:first').click();
|
||||
$('#tabs ul.mode-disconnected').show();
|
||||
}
|
||||
|
||||
function read_serial(info) {
|
||||
|
|
46
main.js
46
main.js
|
@ -60,10 +60,13 @@ $(document).ready(function () {
|
|||
$('a', ui_tabs).click(function () {
|
||||
if ($(this).parent().hasClass('active') == false && !GUI.tab_switch_in_progress) { // only initialize when the tab isn't already active
|
||||
var self = this,
|
||||
tab = $(self).parent().prop('class');
|
||||
tabClass = $(self).parent().prop('class');
|
||||
|
||||
var tabRequiresConnection = $(self).parent().hasClass('mode-connected');
|
||||
|
||||
var tab = tabClass.substring(4);
|
||||
var tabName = $(self).text();
|
||||
|
||||
if (tabRequiresConnection && !CONFIGURATOR.connectionValid) {
|
||||
GUI.log(chrome.i18n.getMessage('tabSwitchConnectionRequired'));
|
||||
return;
|
||||
|
@ -74,9 +77,8 @@ $(document).ready(function () {
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
if (CONFIGURATOR.connectionValidCliOnly) {
|
||||
GUI.log(chrome.i18n.getMessage('tabSwitchUpgradeRequired'));
|
||||
if (GUI.allowedTabs.indexOf(tab) < 0) {
|
||||
GUI.log(chrome.i18n.getMessage('tabSwitchUpgradeRequired', [tabName]));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -101,62 +103,62 @@ $(document).ready(function () {
|
|||
}
|
||||
|
||||
switch (tab) {
|
||||
case 'tab_landing':
|
||||
case 'landing':
|
||||
TABS.landing.initialize(content_ready);
|
||||
break;
|
||||
case 'tab_firmware_flasher':
|
||||
case 'firmware_flasher':
|
||||
TABS.firmware_flasher.initialize(content_ready);
|
||||
break;
|
||||
|
||||
case 'tab_auxiliary':
|
||||
case 'auxiliary':
|
||||
TABS.auxiliary.initialize(content_ready);
|
||||
break;
|
||||
case 'tab_adjustments':
|
||||
case 'adjustments':
|
||||
TABS.adjustments.initialize(content_ready);
|
||||
break;
|
||||
case 'tab_ports':
|
||||
case 'ports':
|
||||
TABS.ports.initialize(content_ready);
|
||||
break;
|
||||
case 'tab_led_strip':
|
||||
case 'led_strip':
|
||||
TABS.led_strip.initialize(content_ready);
|
||||
break;
|
||||
|
||||
case 'tab_setup':
|
||||
case 'setup':
|
||||
TABS.setup.initialize(content_ready);
|
||||
break;
|
||||
case 'tab_configuration':
|
||||
case 'configuration':
|
||||
TABS.configuration.initialize(content_ready);
|
||||
break;
|
||||
case 'tab_pid_tuning':
|
||||
case 'pid_tuning':
|
||||
TABS.pid_tuning.initialize(content_ready);
|
||||
break;
|
||||
case 'tab_receiver':
|
||||
case 'receiver':
|
||||
TABS.receiver.initialize(content_ready);
|
||||
break;
|
||||
case 'tab_modes':
|
||||
case 'modes':
|
||||
TABS.modes.initialize(content_ready);
|
||||
break;
|
||||
case 'tab_servos':
|
||||
case 'servos':
|
||||
TABS.servos.initialize(content_ready);
|
||||
break;
|
||||
case 'tab_gps':
|
||||
case 'gps':
|
||||
TABS.gps.initialize(content_ready);
|
||||
break;
|
||||
case 'tab_motors':
|
||||
case 'motors':
|
||||
TABS.motors.initialize(content_ready);
|
||||
break;
|
||||
case 'tab_sensors':
|
||||
case 'sensors':
|
||||
TABS.sensors.initialize(content_ready);
|
||||
break;
|
||||
case 'tab_logging':
|
||||
case 'logging':
|
||||
TABS.logging.initialize(content_ready);
|
||||
break;
|
||||
case 'tab_cli':
|
||||
case 'cli':
|
||||
TABS.cli.initialize(content_ready);
|
||||
break;
|
||||
|
||||
default:
|
||||
console.log('Tab not found');
|
||||
console.log('Tab not found:' + tab);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -38,6 +38,12 @@ TABS.setup.initialize = function (callback) {
|
|||
// translate to user-selected language
|
||||
localize();
|
||||
|
||||
if (CONFIG.apiVersion < CONFIGURATOR.backupRestoreMinApiVersionAccepted) {
|
||||
$('#content .backup').addClass('disabled');
|
||||
$('#content .restore').addClass('disabled');
|
||||
|
||||
GUI.log(chrome.i18n.getMessage('initialSetupBackupAndRestoreApiVersion', [CONFIG.apiVersion, CONFIGURATOR.backupRestoreMinApiVersionAccepted]));
|
||||
}
|
||||
// initialize 3D
|
||||
self.initialize3D();
|
||||
|
||||
|
@ -112,6 +118,9 @@ TABS.setup.initialize = function (callback) {
|
|||
});
|
||||
|
||||
$('#content .backup').click(function () {
|
||||
if ($(this).hasClass('disabled')) {
|
||||
return;
|
||||
}
|
||||
configuration_backup(function () {
|
||||
GUI.log(chrome.i18n.getMessage('initialSetupBackupSuccess'));
|
||||
googleAnalytics.sendEvent('Configuration', 'Backup', 'true');
|
||||
|
@ -119,6 +128,9 @@ TABS.setup.initialize = function (callback) {
|
|||
});
|
||||
|
||||
$('#content .restore').click(function () {
|
||||
if ($(this).hasClass('disabled')) {
|
||||
return;
|
||||
}
|
||||
configuration_restore(function () {
|
||||
GUI.log(chrome.i18n.getMessage('initialSetupRestoreSuccess'));
|
||||
googleAnalytics.sendEvent('Configuration', 'Restore', 'true');
|
||||
|
|
Loading…
Reference in New Issue