Skip to content

Commit fb360f9

Browse files
authored
Merge pull request #2742 from haslinghuis/remove_backup_restore
2 parents 71fb7a6 + 8be5b1e commit fb360f9

File tree

2 files changed

+26
-33
lines changed

2 files changed

+26
-33
lines changed

src/js/tabs/setup.js

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,34 @@ TABS.setup.initialize = function (callback) {
2929
// translate to user-selected language
3030
i18n.localizePage();
3131

32-
const backupButton = $('#content .backup');
32+
if (CONFIGURATOR.virtualMode || semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
33+
const backupButton = $('#content .backup');
3334

34-
if (semver.lt(FC.CONFIG.apiVersion, CONFIGURATOR.API_VERSION_MIN_SUPPORTED_BACKUP_RESTORE)) {
35-
backupButton.addClass('disabled');
36-
$('#content .restore').addClass('disabled');
35+
if (semver.lt(FC.CONFIG.apiVersion, CONFIGURATOR.API_VERSION_MIN_SUPPORTED_BACKUP_RESTORE)) {
36+
backupButton.addClass('disabled');
37+
$('#content .restore').addClass('disabled');
3738

38-
GUI.log(i18n.getMessage('initialSetupBackupAndRestoreApiVersion', [FC.CONFIG.apiVersion, CONFIGURATOR.API_VERSION_MIN_SUPPORTED_BACKUP_RESTORE]));
39-
}
39+
GUI.log(i18n.getMessage('initialSetupBackupAndRestoreApiVersion', [FC.CONFIG.apiVersion, CONFIGURATOR.API_VERSION_MIN_SUPPORTED_BACKUP_RESTORE]));
40+
}
41+
42+
if (CONFIGURATOR.virtualMode) {
43+
// saving and uploading an imaginary config to hardware is a bad idea
44+
backupButton.addClass('disabled');
45+
}
46+
47+
backupButton.on('click', () => configuration_backup(() => GUI.log(i18n.getMessage('initialSetupBackupSuccess'))));
4048

41-
// saving and uploading an imaginary config to hardware is a bad idea
42-
if (CONFIGURATOR.virtualMode) {
43-
backupButton.addClass('disabled');
49+
$('#content .restore').on('click', () => {
50+
configuration_restore(() => {
51+
// get latest settings
52+
TABS.setup.initialize();
53+
54+
GUI.log(i18n.getMessage('initialSetupRestoreSuccess'));
55+
});
56+
});
57+
58+
} else {
59+
$('.backupRestore').hide();
4460
}
4561

4662
// initialize 3D Model
@@ -164,29 +180,6 @@ TABS.setup.initialize = function (callback) {
164180
console.log(`YAW reset to 0 deg, fix: ${self.yaw_fix} deg`);
165181
});
166182

167-
backupButton.click(function () {
168-
if ($(this).hasClass('disabled')) {
169-
return;
170-
}
171-
172-
configuration_backup(function () {
173-
GUI.log(i18n.getMessage('initialSetupBackupSuccess'));
174-
});
175-
});
176-
177-
$('#content .restore').click(function () {
178-
if ($(this).hasClass('disabled')) {
179-
return;
180-
}
181-
182-
configuration_restore(function () {
183-
// get latest settings
184-
TABS.setup.initialize();
185-
186-
GUI.log(i18n.getMessage('initialSetupRestoreSuccess'));
187-
});
188-
});
189-
190183
// cached elements
191184
const bat_voltage_e = $('.bat-voltage'),
192185
bat_mah_drawn_e = $('.bat-mah-drawn'),

src/tabs/setup.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
</div>
5656
</div>
5757
</div>
58-
<div class="grid-row">
58+
<div class="grid-row backupRestore">
5959
<div class="grid-col col3">
6060
<div class="grid-row">
6161
<div class="grid-col col6">

0 commit comments

Comments
 (0)