luci-mod-admin-full: switch to POST action for reboot
Also rework the reboot tmeplate a little bit. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
This commit is contained in:
parent
ada4a0ea98
commit
38a9993bd1
2 changed files with 54 additions and 23 deletions
|
@ -34,7 +34,8 @@ function index()
|
|||
entry({"admin", "system", "flashops"}, call("action_flashops"), _("Backup / Flash Firmware"), 70)
|
||||
entry({"admin", "system", "flashops", "backupfiles"}, form("admin_system/backupfiles"))
|
||||
|
||||
entry({"admin", "system", "reboot"}, call("action_reboot"), _("Reboot"), 90)
|
||||
entry({"admin", "system", "reboot"}, template("admin_system/reboot"), _("Reboot"), 90)
|
||||
entry({"admin", "system", "reboot", "call"}, post("action_reboot"))
|
||||
end
|
||||
|
||||
function action_clock_status()
|
||||
|
@ -316,11 +317,7 @@ function action_passwd()
|
|||
end
|
||||
|
||||
function action_reboot()
|
||||
local reboot = luci.http.formvalue("reboot")
|
||||
luci.template.render("admin_system/reboot", {reboot=reboot})
|
||||
if reboot then
|
||||
luci.sys.reboot()
|
||||
end
|
||||
luci.sys.reboot()
|
||||
end
|
||||
|
||||
function fork_exec(command)
|
||||
|
|
|
@ -1,25 +1,59 @@
|
|||
<%#
|
||||
Copyright 2008 Steven Barth <steven@midlink.org>
|
||||
Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
|
||||
Copyright 2008-2015 Jo-Philipp Wich <jow@openwrt.org>
|
||||
Licensed to the public under the Apache License 2.0.
|
||||
-%>
|
||||
|
||||
<%+header%>
|
||||
<h2 name="content"><%:System%></h2>
|
||||
<h3><%:Reboot%></h3>
|
||||
|
||||
<h2 name="content"><%:Reboot%></h2>
|
||||
<br />
|
||||
|
||||
<p><%:Reboots the operating system of your device%></p>
|
||||
<%-
|
||||
local c = require("luci.model.uci").cursor():changes()
|
||||
if c and next(c) then
|
||||
-%>
|
||||
<p class="warning"><%:Warning: There are unsaved changes that will be lost while rebooting!%></p>
|
||||
<%-
|
||||
end
|
||||
if not reboot then
|
||||
-%>
|
||||
<p><a href="<%=controller%>/admin/system/reboot?reboot=1"><%:Perform reboot%></a></p>
|
||||
<%- else -%>
|
||||
<p><%:Please wait: Device rebooting...%></p>
|
||||
<script type="text/javascript">setTimeout("location='<%=controller%>/admin'", 60000)</script>
|
||||
|
||||
<%- local c = require("luci.model.uci").cursor():changes(); if c and next(c) then -%>
|
||||
<p class="alert-message warning"><%:Warning: There are unsaved changes that will get lost on reboot!%></p>
|
||||
<%- end -%>
|
||||
<%+footer%>
|
||||
|
||||
<hr />
|
||||
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
var tries = 0;
|
||||
|
||||
function ok() {
|
||||
window.location = '<%=controller%>/admin';
|
||||
}
|
||||
|
||||
function check() {
|
||||
if (tries++ < 12)
|
||||
window.setTimeout(ping, 5000);
|
||||
else
|
||||
alert('<%:Device unreachable%>');
|
||||
}
|
||||
|
||||
function ping() {
|
||||
var img = document.createElement('img');
|
||||
|
||||
img.onload = ok;
|
||||
img.onerror = check;
|
||||
img.src = '<%=resource%>/icons/loading.gif?' + Math.random();
|
||||
|
||||
document.getElementById('reboot-message').innerHTML = '<%:Waiting for device...%>';
|
||||
}
|
||||
|
||||
function reboot(button) {
|
||||
button.style.display = 'none';
|
||||
document.getElementById('reboot-message').parentNode.style.display = '';
|
||||
|
||||
(new XHR()).post('<%=controller%>/admin/system/reboot/call', { token: '<%=token%>' }, check);
|
||||
}
|
||||
//]]></script>
|
||||
|
||||
<input class="cbi-button cbi-button-apply" type="button" value="<%:Perform reboot%>" onclick="reboot(this)" />
|
||||
|
||||
<p class="alert-message" style="display:none">
|
||||
<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" />
|
||||
<span id="reboot-message"><%:Device is rebooting...%></span>
|
||||
</p>
|
||||
|
||||
<%+footer%>
|
||||
|
|
Loading…
Reference in a new issue