mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-14 20:10:11 +03:00
Allow old API version to be used but disable LED strip tab and
backup/restore functionality in certain cases. Cleanup of tab switching.
This commit is contained in:
parent
ebbf3de5e1
commit
34b7b87c3e
6 changed files with 86 additions and 43 deletions
|
@ -138,7 +138,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
"tabSwitchUpgradeRequired": {
|
"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": {
|
"firmwareVersion": {
|
||||||
"message": "Firmware Version: <strong>$1</strong>"
|
"message": "Firmware Version: <strong>$1</strong>"
|
||||||
|
@ -220,6 +220,9 @@
|
||||||
"defaultDonateText": {
|
"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."
|
"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": {
|
"initialSetupButtonCalibrateAccel": {
|
||||||
"message": "Calibrate Accelerometer"
|
"message": "Calibrate Accelerometer"
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
var CONFIGURATOR = {
|
var CONFIGURATOR = {
|
||||||
'releaseDate': 1421431075334, // new Date().getTime() - 2015.01.16
|
'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
|
'backupFileMinVersionAccepted': '0.55', // chrome.runtime.getManifest().version is stored as string, so does this one
|
||||||
'connectionValid': false,
|
'connectionValid': false,
|
||||||
'connectionValidCliOnly': 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.optional_usb_permissions = false; // controlled by usb permissions code
|
||||||
this.interval_array = [];
|
this.interval_array = [];
|
||||||
this.timeout_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
|
// check which operating system is user running
|
||||||
if (navigator.appVersion.indexOf("Win") != -1) this.operating_system = "Windows";
|
if (navigator.appVersion.indexOf("Win") != -1) this.operating_system = "Windows";
|
||||||
|
|
|
@ -27,7 +27,7 @@ $(document).ready(function () {
|
||||||
|
|
||||||
GUI.connected_to = false;
|
GUI.connected_to = false;
|
||||||
CONFIGURATOR.connectionValid = false;
|
CONFIGURATOR.connectionValid = false;
|
||||||
CONFIGURATOR.connectionValidCliOnly = false;
|
GUI.allowedTabs = GUI.defaultAllowedTabsWhenDisconnected.slice();
|
||||||
MSP.disconnect_cleanup();
|
MSP.disconnect_cleanup();
|
||||||
PortUsage.reset();
|
PortUsage.reset();
|
||||||
|
|
||||||
|
@ -46,14 +46,10 @@ $(document).ready(function () {
|
||||||
// reset active sensor indicators
|
// reset active sensor indicators
|
||||||
sensor_status(0);
|
sensor_status(0);
|
||||||
|
|
||||||
// de-select any selected tabs
|
|
||||||
$('#tabs > ul li').removeClass('active');
|
|
||||||
|
|
||||||
// detach listeners and remove element data
|
// detach listeners and remove element data
|
||||||
$('#content').empty();
|
$('#content').empty();
|
||||||
|
|
||||||
// load default html
|
$('#tabs .tab_landing a').click();
|
||||||
TABS.landing.initialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$(this).data("clicks", !clicks);
|
$(this).data("clicks", !clicks);
|
||||||
|
@ -164,15 +160,16 @@ function onOpen(openInfo) {
|
||||||
MSP.send_message(MSP_codes.MSP_UID, false, false, function () {
|
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.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
|
// continue as usually
|
||||||
CONFIGURATOR.connectionValid = true;
|
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');
|
onConnect();
|
||||||
$('#tabs ul.mode-disconnected').hide();
|
|
||||||
$('#tabs ul.mode-connected').show();
|
$('#tabs ul.mode-connected .tab_setup a').click();
|
||||||
$('#tabs ul.mode-connected li a:first').click();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -181,10 +178,9 @@ function onOpen(openInfo) {
|
||||||
} else {
|
} else {
|
||||||
GUI.log(chrome.i18n.getMessage('firmwareVersionNotSupported', [CONFIGURATOR.apiVersionAccepted]));
|
GUI.log(chrome.i18n.getMessage('firmwareVersionNotSupported', [CONFIGURATOR.apiVersionAccepted]));
|
||||||
CONFIGURATOR.connectionValid = true; // making it possible to open the CLI tab
|
CONFIGURATOR.connectionValid = true; // making it possible to open the CLI tab
|
||||||
$('div#port-picker a.connect').text(chrome.i18n.getMessage('disconnect')).addClass('active');
|
GUI.allowedTabs = ['cli'];
|
||||||
$('#tabs li a:last').click(); // open CLI tab
|
onConnect();
|
||||||
GUI.timeout_remove('connecting'); // kill connecting timer
|
$('#tabs .tab_cli a').click();
|
||||||
CONFIGURATOR.connectionValidCliOnly = true;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} 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) {
|
function onClosed(result) {
|
||||||
if (result) { // All went as expected
|
if (result) { // All went as expected
|
||||||
GUI.log(chrome.i18n.getMessage('serialPortClosedOk'));
|
GUI.log(chrome.i18n.getMessage('serialPortClosedOk'));
|
||||||
} else { // Something went wrong
|
} else { // Something went wrong
|
||||||
GUI.log(chrome.i18n.getMessage('serialPortClosedFail'));
|
GUI.log(chrome.i18n.getMessage('serialPortClosedFail'));
|
||||||
}
|
}
|
||||||
$('#tabs ul.mode-disconnected').show();
|
|
||||||
$('#tabs ul.mode-connected').hide();
|
$('#tabs ul.mode-connected').hide();
|
||||||
$('#tabs ul.mode-disconnected li a:first').click();
|
$('#tabs ul.mode-disconnected').show();
|
||||||
}
|
}
|
||||||
|
|
||||||
function read_serial(info) {
|
function read_serial(info) {
|
||||||
|
|
46
main.js
46
main.js
|
@ -60,10 +60,13 @@ $(document).ready(function () {
|
||||||
$('a', ui_tabs).click(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
|
if ($(this).parent().hasClass('active') == false && !GUI.tab_switch_in_progress) { // only initialize when the tab isn't already active
|
||||||
var self = this,
|
var self = this,
|
||||||
tab = $(self).parent().prop('class');
|
tabClass = $(self).parent().prop('class');
|
||||||
|
|
||||||
var tabRequiresConnection = $(self).parent().hasClass('mode-connected');
|
var tabRequiresConnection = $(self).parent().hasClass('mode-connected');
|
||||||
|
|
||||||
|
var tab = tabClass.substring(4);
|
||||||
|
var tabName = $(self).text();
|
||||||
|
|
||||||
if (tabRequiresConnection && !CONFIGURATOR.connectionValid) {
|
if (tabRequiresConnection && !CONFIGURATOR.connectionValid) {
|
||||||
GUI.log(chrome.i18n.getMessage('tabSwitchConnectionRequired'));
|
GUI.log(chrome.i18n.getMessage('tabSwitchConnectionRequired'));
|
||||||
return;
|
return;
|
||||||
|
@ -74,9 +77,8 @@ $(document).ready(function () {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (GUI.allowedTabs.indexOf(tab) < 0) {
|
||||||
if (CONFIGURATOR.connectionValidCliOnly) {
|
GUI.log(chrome.i18n.getMessage('tabSwitchUpgradeRequired', [tabName]));
|
||||||
GUI.log(chrome.i18n.getMessage('tabSwitchUpgradeRequired'));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,62 +103,62 @@ $(document).ready(function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (tab) {
|
switch (tab) {
|
||||||
case 'tab_landing':
|
case 'landing':
|
||||||
TABS.landing.initialize(content_ready);
|
TABS.landing.initialize(content_ready);
|
||||||
break;
|
break;
|
||||||
case 'tab_firmware_flasher':
|
case 'firmware_flasher':
|
||||||
TABS.firmware_flasher.initialize(content_ready);
|
TABS.firmware_flasher.initialize(content_ready);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'tab_auxiliary':
|
case 'auxiliary':
|
||||||
TABS.auxiliary.initialize(content_ready);
|
TABS.auxiliary.initialize(content_ready);
|
||||||
break;
|
break;
|
||||||
case 'tab_adjustments':
|
case 'adjustments':
|
||||||
TABS.adjustments.initialize(content_ready);
|
TABS.adjustments.initialize(content_ready);
|
||||||
break;
|
break;
|
||||||
case 'tab_ports':
|
case 'ports':
|
||||||
TABS.ports.initialize(content_ready);
|
TABS.ports.initialize(content_ready);
|
||||||
break;
|
break;
|
||||||
case 'tab_led_strip':
|
case 'led_strip':
|
||||||
TABS.led_strip.initialize(content_ready);
|
TABS.led_strip.initialize(content_ready);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'tab_setup':
|
case 'setup':
|
||||||
TABS.setup.initialize(content_ready);
|
TABS.setup.initialize(content_ready);
|
||||||
break;
|
break;
|
||||||
case 'tab_configuration':
|
case 'configuration':
|
||||||
TABS.configuration.initialize(content_ready);
|
TABS.configuration.initialize(content_ready);
|
||||||
break;
|
break;
|
||||||
case 'tab_pid_tuning':
|
case 'pid_tuning':
|
||||||
TABS.pid_tuning.initialize(content_ready);
|
TABS.pid_tuning.initialize(content_ready);
|
||||||
break;
|
break;
|
||||||
case 'tab_receiver':
|
case 'receiver':
|
||||||
TABS.receiver.initialize(content_ready);
|
TABS.receiver.initialize(content_ready);
|
||||||
break;
|
break;
|
||||||
case 'tab_modes':
|
case 'modes':
|
||||||
TABS.modes.initialize(content_ready);
|
TABS.modes.initialize(content_ready);
|
||||||
break;
|
break;
|
||||||
case 'tab_servos':
|
case 'servos':
|
||||||
TABS.servos.initialize(content_ready);
|
TABS.servos.initialize(content_ready);
|
||||||
break;
|
break;
|
||||||
case 'tab_gps':
|
case 'gps':
|
||||||
TABS.gps.initialize(content_ready);
|
TABS.gps.initialize(content_ready);
|
||||||
break;
|
break;
|
||||||
case 'tab_motors':
|
case 'motors':
|
||||||
TABS.motors.initialize(content_ready);
|
TABS.motors.initialize(content_ready);
|
||||||
break;
|
break;
|
||||||
case 'tab_sensors':
|
case 'sensors':
|
||||||
TABS.sensors.initialize(content_ready);
|
TABS.sensors.initialize(content_ready);
|
||||||
break;
|
break;
|
||||||
case 'tab_logging':
|
case 'logging':
|
||||||
TABS.logging.initialize(content_ready);
|
TABS.logging.initialize(content_ready);
|
||||||
break;
|
break;
|
||||||
case 'tab_cli':
|
case 'cli':
|
||||||
TABS.cli.initialize(content_ready);
|
TABS.cli.initialize(content_ready);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
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
|
// translate to user-selected language
|
||||||
localize();
|
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
|
// initialize 3D
|
||||||
self.initialize3D();
|
self.initialize3D();
|
||||||
|
|
||||||
|
@ -112,6 +118,9 @@ TABS.setup.initialize = function (callback) {
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#content .backup').click(function () {
|
$('#content .backup').click(function () {
|
||||||
|
if ($(this).hasClass('disabled')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
configuration_backup(function () {
|
configuration_backup(function () {
|
||||||
GUI.log(chrome.i18n.getMessage('initialSetupBackupSuccess'));
|
GUI.log(chrome.i18n.getMessage('initialSetupBackupSuccess'));
|
||||||
googleAnalytics.sendEvent('Configuration', 'Backup', 'true');
|
googleAnalytics.sendEvent('Configuration', 'Backup', 'true');
|
||||||
|
@ -119,6 +128,9 @@ TABS.setup.initialize = function (callback) {
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#content .restore').click(function () {
|
$('#content .restore').click(function () {
|
||||||
|
if ($(this).hasClass('disabled')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
configuration_restore(function () {
|
configuration_restore(function () {
|
||||||
GUI.log(chrome.i18n.getMessage('initialSetupRestoreSuccess'));
|
GUI.log(chrome.i18n.getMessage('initialSetupRestoreSuccess'));
|
||||||
googleAnalytics.sendEvent('Configuration', 'Restore', 'true');
|
googleAnalytics.sendEvent('Configuration', 'Restore', 'true');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue