diff options
author | Jo-Philipp Wich <jo@mein.io> | 2019-10-07 10:51:28 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2019-10-07 11:53:39 +0200 |
commit | b637cf67502735d6ab9ee8a6deb1d1f323a2b15b (patch) | |
tree | 7d46ff7dda4aa19f725247836142e75711ca5690 /modules/luci-mod-system/htdocs/luci-static/resources/view/system/reboot.js | |
parent | 1d68853ccec6a04ffe180263d0b1367e824c091f (diff) |
luci-mod-system: port reboot view to client side js
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-mod-system/htdocs/luci-static/resources/view/system/reboot.js')
-rw-r--r-- | modules/luci-mod-system/htdocs/luci-static/resources/view/system/reboot.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/reboot.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/reboot.js new file mode 100644 index 0000000000..0a14465559 --- /dev/null +++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/reboot.js @@ -0,0 +1,59 @@ +'use strict'; +'require fs'; +'require ui'; +'require uci'; +'require rpc'; + +var callReboot = rpc.declare({ + object: 'luci', + method: 'setReboot', + expect: { result: false } +}); + +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 callReboot().then(function() { + 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(); + }); + }, + + handleSaveApply: null, + handleSave: null, + handleReset: null +}); |