L.ui.view.extend({
title: L.tr('Flash operations'),
- handle_flash_upload: function() {
+ testUpgrade: L.rpc.declare({
+ object: 'luci2.system',
+ method: 'upgrade_test',
+ expect: { '': { } }
+ }),
+
+ startUpgrade: L.rpc.declare({
+ object: 'luci2.system',
+ method: 'upgrade_start',
+ params: [ 'keep' ]
+ }),
+
+ cleanUpgrade: L.rpc.declare({
+ object: 'luci2.system',
+ method: 'upgrade_clean'
+ }),
+
+ restoreBackup: L.rpc.declare({
+ object: 'luci2.system',
+ method: 'backup_restore'
+ }),
+
+ cleanBackup: L.rpc.declare({
+ object: 'luci2.system',
+ method: 'backup_clean'
+ }),
+
+ getBackupConfig: L.rpc.declare({
+ object: 'luci2.system',
+ method: 'backup_config_get',
+ expect: { config: '' }
+ }),
+
+ setBackupConfig: L.rpc.declare({
+ object: 'luci2.system',
+ method: 'backup_config_set',
+ params: [ 'data' ]
+ }),
+
+ listBackup: L.rpc.declare({
+ object: 'luci2.system',
+ method: 'backup_list',
+ expect: { files: [ ] }
+ }),
+
+ testReset: L.rpc.declare({
+ object: 'luci2.system',
+ method: 'reset_test',
+ expect: { supported: false }
+ }),
+
+ startReset: L.rpc.declare({
+ object: 'luci2.system',
+ method: 'reset_start'
+ }),
+
+ handleFlashUpload: function() {
var self = this;
L.ui.upload(
L.tr('Firmware upload'),
L.tr('Select the sysupgrade image to flash and click "%s" to proceed.').format(L.tr('Ok')), {
filename: '/tmp/firmware.bin',
success: function(info) {
- self.handle_flash_verify(info);
+ self.handleFlashVerify(info);
}
}
);
},
- handle_flash_verify: function(info) {
+ handleFlashVerify: function(info) {
var self = this;
- L.system.testUpgrade().then(function(res) {
+ self.testUpgrade().then(function(res) {
if (res.code == 0)
{
L.ui.dialog(
], {
style: 'confirm',
confirm: function() {
- //L.system.startUpgrade().then(function() {
+ //self.startUpgrade().then(function() {
// L.ui.reconnect();
//});
], {
style: 'close',
close: function() {
- L.system.cleanUpgrade().then(function() {
+ self.cleanUpgrade().then(function() {
L.ui.dialog(false);
});
}
});
},
- handle_backup_upload: function() {
+ handleBackupUpload: function() {
var self = this;
L.ui.upload(
L.tr('Backup restore'),
L.tr('Select the backup archive to restore and click "%s" to proceed.').format(L.tr('Ok')), {
filename: '/tmp/backup.tar.gz',
success: function(info) {
- self.handle_backup_verify(info);
+ self.handleBackupVerify(info);
}
}
);
},
- handle_backup_verify: function(info) {
+ handleBackupVerify: function(info) {
var self = this;
L.ui.dialog(
L.tr('Backup restore'), [
], {
style: 'confirm',
confirm: function() {
- self.handle_backup_restore();
+ self.handleBackupRestore();
}
}
);
},
- handle_backup_restore: function() {
+ handleBackupRestore: function() {
var self = this;
- L.system.restoreBackup().then(function(res) {
+ self.restoreBackup().then(function(res) {
if (res.code == 0)
{
L.ui.dialog(
], {
style: 'close',
close: function() {
- L.system.cleanBackup().then(function() {
+ self.cleanBackup().then(function() {
L.ui.dialog(false);
});
}
], {
style: 'close',
close: function() {
- L.system.cleanBackup().then(function() {
+ self.cleanBackup().then(function() {
L.ui.dialog(false);
});
}
});
},
- handle_backup_download: function() {
+ handleBackupDownload: function() {
var form = $('#btn_backup').parent();
form.find('[name=sessionid]').val(L.globals.sid);
form.submit();
},
- handle_reset: function() {
+ handleReset: function() {
+ var self = this;
L.ui.dialog(L.tr('Really reset all changes?'), L.tr('This will reset the system to its initial configuration, all changes made since the initial flash will be lost!'), {
style: 'confirm',
confirm: function() {
- //L.system.startReset().then(function() {
+ //self.startReset().then(function() {
// L.ui.reconnect();
//});
execute: function() {
var self = this;
- L.system.testReset().then(function(reset_avail) {
+ self.testReset().then(function(reset_avail) {
if (!reset_avail) {
$('#btn_reset').prop('disabled', true);
}
$('#btn_restore, #btn_save, textarea').prop('disabled', true);
}
else {
- $('#btn_backup').click(function() { self.handle_backup_download(); });
- $('#btn_restore').click(function() { self.handle_backup_upload(); });
+ $('#btn_backup').click(function() { self.handleBackupDownload(); });
+ $('#btn_restore').click(function() { self.handleBackupUpload(); });
}
if (!self.options.acls.upgrade) {
$('#btn_flash, #btn_reset').prop('disabled', true);
}
else {
- $('#btn_flash').click(function() { self.handle_flash_upload(); });
- $('#btn_reset').click(function() { self.handle_reset(); });
+ $('#btn_flash').click(function() { self.handleFlashUpload(); });
+ $('#btn_reset').click(function() { self.handleReset(); });
}
- return L.system.getBackupConfig();
+ return self.getBackupConfig();
}).then(function(config) {
$('textarea')
.attr('rows', (config.match(/\n/g) || [ ]).length + 1)
.click(function() {
var data = ($('textarea').val() || '').replace(/\r/g, '').replace(/\n?$/, '\n');
L.ui.loading(true);
- L.system.setBackupConfig(data).then(function() {
+ self.setBackupConfig(data).then(function() {
$('textarea')
.attr('rows', (data.match(/\n/g) || [ ]).length + 1)
.val(data);
$('#btn_list')
.click(function() {
L.ui.loading(true);
- L.system.listBackup().then(function(list) {
+ self.listBackup().then(function(list) {
L.ui.loading(false);
L.ui.dialog(
L.tr('Backup file list'),
);
});
});
- }).then(function() {
- $('#tabs').show().tabs();
});
}
});