summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-mod-admin-full/luasrc/view/admin_system/reboot.htm
blob: c9551804d2aa352248920e85f28658f3cac40920 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<%#
 Copyright 2008 Steven Barth <steven@midlink.org>
 Copyright 2008-2015 Jo-Philipp Wich <jow@openwrt.org>
 Licensed to the public under the Apache License 2.0.
-%>

<%+header%>

<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="alert-message warning"><%:Warning: There are unsaved changes that will get lost on reboot!%></p>
<%- end -%>

<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%>