luci/modules/luci-mod-system/htdocs/luci-static/resources/view/system/reboot.js
Jo-Philipp Wich c67d2ddc2c luci-base, luci-mod-system: replace luci/setReboot with fs.exec
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-11-01 12:03:33 +01:00

58 lines
1.4 KiB
JavaScript

'use strict';
'require fs';
'require ui';
'require uci';
return L.view.extend({
load: function() {
return uci.changes();
},
render: function(changes) {
var body = E([
E('h2', _('Reboot')),
E('p', {}, _('Reboots the operating system of your device'))
]);
for (var config in (changes || {})) {
body.appendChild(E('p', { 'class': 'alert-message warning' },
_('Warning: There are unsaved changes that will get lost on reboot!')));
break;
}
body.appendChild(E('hr'));
body.appendChild(E('button', {
'class': 'cbi-button cbi-button-action important',
'click': ui.createHandlerFn(this, 'handleReboot')
}, _('Perform reboot')));
return body;
},
handleReboot: function(ev) {
return fs.exec('/sbin/reboot').then(function(res) {
if (res.code != 0) {
L.ui.addNotification(null, E('p', _('The reboot command failed with code %d').format(res.code)));
L.raise('Error', 'Reboot failed');
}
L.ui.showModal(_('Rebooting…'), [
E('p', { 'class': 'spinning' }, _('Waiting for device...'))
]);
window.setTimeout(function() {
L.ui.showModal(_('Rebooting…'), [
E('p', { 'class': 'spinning alert-message warning' },
_('Device unreachable! Still waiting for device...'))
]);
}, 150000);
L.ui.awaitReconnect();
})
.catch(function(e) { L.ui.addNotification(null, E('p', e.message)) });
},
handleSaveApply: null,
handleSave: null,
handleReset: null
});