summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-mod-admin-full/luasrc
diff options
context:
space:
mode:
authorAnsuel Smith <ansuelsmth@gmail.com>2018-06-05 22:12:19 +0200
committerJo-Philipp Wich <jo@mein.io>2018-07-03 17:34:10 +0200
commitddbde3caaae267d400316d584e90991a579250d7 (patch)
treed00e73156c466ecdfe19df49decfd9baa43f18e7 /modules/luci-mod-admin-full/luasrc
parentcde13dc2459fa20ad0f889dbee925c7bdddaf806 (diff)
luci-mod-admin-full: improve reboot page
This fix problem with empty controller, the check function will never stop to check if the device finish to reboot and we set more tries to wait the router for a longer times. Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com> [reworked markup, simplified logic, removed superfluous alert] Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-mod-admin-full/luasrc')
-rw-r--r--modules/luci-mod-admin-full/luasrc/view/admin_system/reboot.htm36
1 files changed, 20 insertions, 16 deletions
diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_system/reboot.htm b/modules/luci-mod-admin-full/luasrc/view/admin_system/reboot.htm
index 6ec2b310d2..d23664adac 100644
--- a/modules/luci-mod-admin-full/luasrc/view/admin_system/reboot.htm
+++ b/modules/luci-mod-admin-full/luasrc/view/admin_system/reboot.htm
@@ -16,18 +16,24 @@
<hr />
+<input class="cbi-button cbi-button-action important" type="button" value="<%:Perform reboot%>" onclick="reboot(this)" />
+
+<p class="alert-message notice reboot-message" style="display:none">
+ <img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" />
+ <span><%:Device is rebooting...%></span>
+</p>
+
<script type="text/javascript">//<![CDATA[
- var tries = 0;
+ var tries = 0,
+ message = document.querySelector('p.reboot-message'),
+ label = message.querySelector('span');
function ok() {
- window.location = '<%=controller%>/admin';
+ window.location = '<%=url("admin")%>';
}
function check() {
- if (tries++ < 12)
- window.setTimeout(ping, 5000);
- else
- alert('<%:Device unreachable%>');
+ window.setTimeout(ping, 5000);
}
function ping() {
@@ -37,22 +43,20 @@
img.onerror = check;
img.src = '<%=resource%>/icons/loading.gif?' + Math.random();
- document.getElementById('reboot-message').innerHTML = '<%:Waiting for device...%>';
+ if (tries++ >= 30) {
+ message.classList.remove('notice');
+ message.classList.add('warning');
+ label.innerHTML = '<%:Device unreachable! Still waiting for device...%>';
+ }
}
function reboot(button) {
button.style.display = 'none';
- document.getElementById('reboot-message').parentNode.style.display = '';
+ message.style.display = '';
+ label.innerHTML = '<%:Waiting for device...%>';
- (new XHR()).post('<%=controller%>/admin/system/reboot/call', { token: '<%=token%>' }, check);
+ (new XHR()).post('<%=url("admin/system/reboot/call")%>', { token: '<%=token%>' }, check);
}
//]]></script>
-<input class="cbi-button cbi-button-action important" 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%>