0a144655590a6235fe39b797f0efd6870e3c4163
[project/luci.git] / modules / luci-mod-system / htdocs / luci-static / resources / view / system / reboot.js
1 'use strict';
2 'require fs';
3 'require ui';
4 'require uci';
5 'require rpc';
6
7 var callReboot = rpc.declare({
8 object: 'luci',
9 method: 'setReboot',
10 expect: { result: false }
11 });
12
13 return L.view.extend({
14 load: function() {
15 return uci.changes();
16 },
17
18 render: function(changes) {
19 var body = E([
20 E('h2', _('Reboot')),
21 E('p', {}, _('Reboots the operating system of your device'))
22 ]);
23
24 for (var config in (changes || {})) {
25 body.appendChild(E('p', { 'class': 'alert-message warning' },
26 _('Warning: There are unsaved changes that will get lost on reboot!')));
27 break;
28 }
29
30 body.appendChild(E('hr'));
31 body.appendChild(E('button', {
32 'class': 'cbi-button cbi-button-action important',
33 'click': ui.createHandlerFn(this, 'handleReboot')
34 }, _('Perform reboot')));
35
36 return body;
37 },
38
39 handleReboot: function(ev) {
40 return callReboot().then(function() {
41 L.ui.showModal(_('Rebooting…'), [
42 E('p', { 'class': 'spinning' }, _('Waiting for device...'))
43 ]);
44
45 window.setTimeout(function() {
46 L.ui.showModal(_('Rebooting…'), [
47 E('p', { 'class': 'spinning alert-message warning' },
48 _('Device unreachable! Still waiting for device...'))
49 ]);
50 }, 150000);
51
52 L.ui.awaitReconnect();
53 });
54 },
55
56 handleSaveApply: null,
57 handleSave: null,
58 handleReset: null
59 });