summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-ahcp/luasrc/view/ahcp_status.htm
blob: 4e043aaf365ce9a5019a6652ee864f7f8cc6e0fe (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
<script type="text/javascript">//<![CDATA[
	XHR.poll(-1, '<%=url('admin/network/ahcpd/status')%>', null,
		function(x, st)
		{
			var tb = document.getElementById('ahcpd_status_table');
			var tx = document.getElementById('ahcpd_status_text');
			if (st && tb && tx)
			{
				/* clear all rows */
				while (tb.firstElementChild !== tb.lastElementChild)
					tb.removeChild(tb.lastElementChild);

				for (var i = 0; i < st.leases.length; i++)
				{
					tb.appendChild(E('<div class="tr cbi-section-table-row cbi-rowstyle-%d">'.format((i % 2) + 1), [
						E('<div class="td">', st.leases[i].addr),
						E('<div class="td">', '%t'.format(st.leases[i].age))
					]));
				}

				if (tb.firstElementChild === tb.lastElementChild)
					tb.appendChild(E('<div class="tr cbi-section-table-row"><div class="td"><em><br /><%:There are no active leases.%></em></div></div>'));

				if (st.uid == '00:00:00:00:00:00:00:00')
					tx.innerHTML = '<%:The AHCP Service is not running.%>';
				else
					tx.innerHTML = String.format('<%:The AHCP Service is running with ID %s.%>', st.uid);
			}
		}
	);
//]]></script>

<fieldset class="cbi-section">
	<legend><%:Active AHCP Leases%></legend>
	<p id="ahcpd_status_text"></p>
	<div class="table cbi-section-table" id="ahcpd_status_table">
		<div class="tr cbi-section-table-titles">
			<div class="th cbi-section-table-cell"><%:Address%></div>
			<div class="th cbi-section-table-cell"><%:Age%></div>
		</div>
		<div class="tr cbi-section-table-row">
			<div class="td" colspan="5"><em><br /><%:Collecting data...%></em></div>
		</div>
	</div>
</fieldset>