luci-mod-admin-full: switch to POST action for reboot
[project/luci.git] / modules / luci-mod-admin-full / luasrc / view / admin_system / reboot.htm
1 <%#
2 Copyright 2008 Steven Barth <steven@midlink.org>
3 Copyright 2008-2015 Jo-Philipp Wich <jow@openwrt.org>
4 Licensed to the public under the Apache License 2.0.
5 -%>
6
7 <%+header%>
8
9 <h2 name="content"><%:Reboot%></h2>
10 <br />
11
12 <p><%:Reboots the operating system of your device%></p>
13
14 <%- local c = require("luci.model.uci").cursor():changes(); if c and next(c) then -%>
15 <p class="alert-message warning"><%:Warning: There are unsaved changes that will get lost on reboot!%></p>
16 <%- end -%>
17
18 <hr />
19
20 <script type="text/javascript">//<![CDATA[
21 var tries = 0;
22
23 function ok() {
24 window.location = '<%=controller%>/admin';
25 }
26
27 function check() {
28 if (tries++ < 12)
29 window.setTimeout(ping, 5000);
30 else
31 alert('<%:Device unreachable%>');
32 }
33
34 function ping() {
35 var img = document.createElement('img');
36
37 img.onload = ok;
38 img.onerror = check;
39 img.src = '<%=resource%>/icons/loading.gif?' + Math.random();
40
41 document.getElementById('reboot-message').innerHTML = '<%:Waiting for device...%>';
42 }
43
44 function reboot(button) {
45 button.style.display = 'none';
46 document.getElementById('reboot-message').parentNode.style.display = '';
47
48 (new XHR()).post('<%=controller%>/admin/system/reboot/call', { token: '<%=token%>' }, check);
49 }
50 //]]></script>
51
52 <input class="cbi-button cbi-button-apply" type="button" value="<%:Perform reboot%>" onclick="reboot(this)" />
53
54 <p class="alert-message" style="display:none">
55 <img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" />
56 <span id="reboot-message"><%:Device is rebooting...%></span>
57 </p>
58
59 <%+footer%>