add callbacks to backup and restore procedures, attach success messages in callbacks, hook up analytic events
parent
cd4c7a8160
commit
3d64b87578
|
@ -191,6 +191,12 @@
|
|||
"initialSetupBackupRestoreText": {
|
||||
"message": "<strong>Backup</strong> your configuration in case of an accident, <strong>CLI</strong> settings are not included"
|
||||
},
|
||||
"initialSetupBackupSuccess": {
|
||||
"message": "Backup saved <span style=\"color: green\">successfully</span>"
|
||||
},
|
||||
"initialSetupRestoreSuccess": {
|
||||
"message": "Configuration restored <span style=\"color: green\">successfully</span>"
|
||||
},
|
||||
"initialSetupButtonResetZaxis": {
|
||||
"message": "Reset Z axis, offset: 0 deg"
|
||||
},
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
function configuration_backup() {
|
||||
function configuration_backup(callback) {
|
||||
// request configuration data (one by one)
|
||||
|
||||
function get_ident_data() {
|
||||
MSP.send_message(MSP_codes.MSP_IDENT, false, false, get_status_data);
|
||||
}
|
||||
|
@ -108,6 +107,7 @@ function configuration_backup() {
|
|||
}
|
||||
|
||||
console.log('Write SUCCESSFUL');
|
||||
if (callback) callback();
|
||||
};
|
||||
|
||||
writer.write(blob);
|
||||
|
@ -127,7 +127,7 @@ function configuration_backup() {
|
|||
get_ident_data();
|
||||
}
|
||||
|
||||
function configuration_restore() {
|
||||
function configuration_restore(callback) {
|
||||
var chosenFileEntry = null;
|
||||
|
||||
var accepts = [{
|
||||
|
@ -178,7 +178,7 @@ function configuration_restore() {
|
|||
return;
|
||||
}
|
||||
|
||||
configuration_upload(deserialized_configuration_object);
|
||||
configuration_upload(deserialized_configuration_object, callback);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -187,7 +187,7 @@ function configuration_restore() {
|
|||
});
|
||||
}
|
||||
|
||||
function configuration_upload(configuration) {
|
||||
function configuration_upload(configuration, callback) {
|
||||
// check if all attributes that we will be saving exist inside the configuration object
|
||||
var validate = [
|
||||
'PID',
|
||||
|
@ -199,7 +199,7 @@ function configuration_upload(configuration) {
|
|||
];
|
||||
|
||||
for (var i = 0; i < validate.length; i++) {
|
||||
if (typeof (configuration[i]) === 'undefined') {
|
||||
if (typeof (configuration[validate[i]]) === 'undefined') {
|
||||
GUI.log(chrome.i18n.getMessage('backupFileIncompatible'));
|
||||
return;
|
||||
}
|
||||
|
@ -236,6 +236,7 @@ function configuration_upload(configuration) {
|
|||
function save_eeprom() {
|
||||
MSP.send_message(MSP_codes.MSP_EEPROM_WRITE, false, false, function () {
|
||||
GUI.log(chrome.i18n.getMessage('eeprom_saved_ok'));
|
||||
if (callback) callback();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -233,11 +233,11 @@ TABS.setup.initialize = function (callback) {
|
|||
}
|
||||
});
|
||||
|
||||
$('a.resetSettings').click(function() {
|
||||
$('a.resetSettings').click(function () {
|
||||
MSP.send_message(MSP_codes.MSP_RESET_CONF, false, false, function () {
|
||||
GUI.log(chrome.i18n.getMessage('initialSetupSettingsRestored'));
|
||||
|
||||
GUI.tab_switch_cleanup(function() {
|
||||
GUI.tab_switch_cleanup(function () {
|
||||
TABS.setup.initialize();
|
||||
});
|
||||
});
|
||||
|
@ -254,9 +254,24 @@ TABS.setup.initialize = function (callback) {
|
|||
console.log('YAW reset to 0 deg, fix: ' + self.yaw_fix + ' deg');
|
||||
});
|
||||
|
||||
$('#content .backup').click(configuration_backup);
|
||||
$('#content .backup').click(function () {
|
||||
configuration_backup(function () {
|
||||
GUI.log(chrome.i18n.getMessage('initialSetupBackupSuccess'));
|
||||
googleAnalytics.sendEvent('Configuration', 'Backup', 'true');
|
||||
});
|
||||
});
|
||||
|
||||
$('#content .restore').click(configuration_restore);
|
||||
$('#content .restore').click(function () {
|
||||
configuration_restore(function () {
|
||||
GUI.log(chrome.i18n.getMessage('initialSetupRestoreSuccess'));
|
||||
googleAnalytics.sendEvent('Configuration', 'Restore', 'true');
|
||||
|
||||
// get latest settings
|
||||
GUI.tab_switch_cleanup(function () {
|
||||
TABS.setup.initialize();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// data pulling functions used inside interval timer
|
||||
// this stuff will be reworked when compatibility period ends, to make the pulling more efficient
|
||||
|
|
Loading…
Reference in New Issue