2 title: L.tr('Flash operations'),
4 handle_flash_upload: function() {
7 L.tr('Firmware upload'),
8 L.tr('Select the sysupgrade image to flash and click "%s" to proceed.').format(L.tr('Ok')), {
9 filename: '/tmp/firmware.bin',
10 success: function(info) {
11 self.handle_flash_verify(info);
17 handle_flash_verify: function(info) {
19 L.system.testUpgrade().then(function(res) {
23 L.tr('Verify firmware'), [
24 $('<p />').text(L.tr('The firmware image was uploaded completely. Please verify the checksum and file size below, then click "%s" to start the flash procedure.').format(L.tr('Ok'))),
27 .append($('<strong />').text(L.tr('Checksum') + ': '))
28 .append(info.checksum))
30 .append($('<strong />').text(L.tr('Size') + ': '))
31 .append('%1024mB'.format(info.size))),
33 .append($('<input />')
34 .attr('type', 'checkbox')
35 .prop('checked', true))
37 .append(L.tr('Keep configuration when reflashing'))
41 //L.system.startUpgrade().then(function() {
53 L.tr('Invalid image'), [
54 $('<p />').text(L.tr('Firmware image verification failed, the "sysupgrade" command responded with the message below:')),
56 .addClass('alert-message')
57 .text(res.stdout || res.stderr),
58 $('<p />').text(L.tr('Image verification failed with code %d.').format(res.code))
62 L.system.cleanUpgrade().then(function() {
72 handle_backup_upload: function() {
75 L.tr('Backup restore'),
76 L.tr('Select the backup archive to restore and click "%s" to proceed.').format(L.tr('Ok')), {
77 filename: '/tmp/backup.tar.gz',
78 success: function(info) {
79 self.handle_backup_verify(info);
85 handle_backup_verify: function(info) {
88 L.tr('Backup restore'), [
89 $('<p />').text(L.tr('The backup archive was uploaded completely. Please verify the checksum and file size below, then click "%s" to restore the archive.').format(L.tr('Ok'))),
92 .append($('<strong />').text(L.tr('Checksum') + ': '))
93 .append(info.checksum))
95 .append($('<strong />').text(L.tr('Size') + ': '))
96 .append('%1024mB'.format(info.size)))
100 self.handle_backup_restore();
106 handle_backup_restore: function() {
108 L.system.restoreBackup().then(function(res) {
112 L.tr('Backup restore'), [
113 $('<p />').text(L.tr('The backup was successfully restored, it is advised to reboot the system now in order to apply all configuration changes.')),
115 .addClass('cbi-button')
116 .attr('type', 'button')
117 .attr('value', L.tr('Reboot system'))
118 .click(function() { alert('Reboot...'); })
122 L.system.cleanBackup().then(function() {
132 L.tr('Backup restore'), [
133 $('<p />').text(L.tr('Backup restoration failed, the "sysupgrade" command responded with the message below:')),
135 .addClass('alert-message')
136 .text(res.stdout || res.stderr),
137 $('<p />').text(L.tr('Backup restoration failed with code %d.').format(res.code))
141 L.system.cleanBackup().then(function() {
151 handle_backup_download: function() {
152 var form = $('#btn_backup').parent();
154 form.find('[name=sessionid]').val(L.globals.sid);
158 handle_reset: function() {
159 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!'), {
161 confirm: function() {
162 //L.system.startReset().then(function() {
171 execute: function() {
174 L.system.testReset().then(function(reset_avail) {
176 $('#btn_reset').prop('disabled', true);
179 if (!self.options.acls.backup) {
180 $('#btn_restore, #btn_save, textarea').prop('disabled', true);
183 $('#btn_backup').click(function() { self.handle_backup_download(); });
184 $('#btn_restore').click(function() { self.handle_backup_upload(); });
187 if (!self.options.acls.upgrade) {
188 $('#btn_flash, #btn_reset').prop('disabled', true);
191 $('#btn_flash').click(function() { self.handle_flash_upload(); });
192 $('#btn_reset').click(function() { self.handle_reset(); });
195 return L.system.getBackupConfig();
196 }).then(function(config) {
198 .attr('rows', (config.match(/\n/g) || [ ]).length + 1)
203 var data = ($('textarea').val() || '').replace(/\r/g, '').replace(/\n?$/, '\n');
205 L.system.setBackupConfig(data).then(function() {
207 .attr('rows', (data.match(/\n/g) || [ ]).length + 1)
217 L.system.listBackup().then(function(list) {
220 L.tr('Backup file list'),
222 .css('width', '100%')
223 .attr('rows', list.length)
224 .prop('readonly', true)
225 .addClass('form-control')
226 .val(list.join('\n')),