<%#
Opennet Firmware

Copyright 2010 Rene Ejury <opennet@absorb.it>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

	http://www.apache.org/licenses/LICENSE-2.0

$Id: index.htm 5448 2009-10-31 15:54:11Z jow $

-%>
<% require ("luci.model.opennet.on_status") %>

<%+header%>

<script type="text/javascript">//<![CDATA[

function fill_result_row(table_cell_name, request_url_suffix) {
	var xhr_request = new XHR();
	xhr_request.get('<%=luci.dispatcher.build_url("opennet", "on_status")%>/' + request_url_suffix, null,
		function(x) {
			var cell = document.getElementById(table_cell_name);
			if (!cell) {
				// die Zeile wurde nicht gefunden?
				return;
			// leider liefert luci in jedem Fall einen Text aus - notfalls "No page is registered at ..." :(
			} else if ((x.responseText) && (x.responseText.indexOf('No page is registered at') != 0)) {
				// die Zelle mit neuem Inhalt fuellen (und das "loading"-Icon ueberschreiben
				cell.innerHTML = x.responseText;
			} else {
				// keine Antwort - die ganze Zeile verstecken
				cell.parentNode.style.display = "none";
			}
	});
}

//]]></script>


<h2><a id="content" name="content"><%=get_firmware_title() %></a></h2>
<div class="cbi-map">
	<h3 class="on_title"><%:This is an Access-Point with Opennet-Firmware, a modification of OpenWrt to the requirements of the Opennet Initiative e.V.%></h3>
	<div id="status_opennet_logo" /><div id="status_openwrt_logo" />
</div>
<h3><%:Status Information%></h3>
<div class="cbi-map"><fieldset class="cbi-section">
	<table class="cbi-section-table" id="status_table">
		<%
		local hardware_info = luci.sys.exec("echo -e \"Model: \$(cat /proc/diag/model 2>/dev/null)\\n\$(cat /proc/cpuinfo)\" | awk 'BEGIN {FS=\":\"; no=0} /Processor|Hardware|system type|machine|Model|vendor_id/ {gsub(\"[\\t]\", \"\"); if (no > 0) printf \" | \"; if (\$2) { no=1; printf \$1\":\"\$2}} END {printf \"\\n\";}'")

		for _, item in ipairs({
				  {"networks_section", luci.i18n.translate("Networks"), url="on_status_network"},
				  {"wireless_section", luci.i18n.translate("Wireless"), url="on_status_wireless"},
				  {"neighbor_section", luci.i18n.translate("Neighbors"), url="on_status_neighbors"},
				  {"mig_connection_section", luci.i18n.translate("OpenVPN"), url="on_status_mig_connection"},
				  {"ugw_connection_section", luci.i18n.translate("Internet Sharing"), url="on_status_ugw_connection"},
				  {"issues_section", luci.i18n.translate("Issue Indicators"), url="on_status_issues"},
				  {"hardware_section", luci.i18n.translate("Hardware Information"), content=hardware_info},
				  {"uptime_section", luci.i18n.translate("Uptime"), content=luci.sys.exec("uptime")},
				  {"system_section", luci.i18n.translate("System"), content=luci.sys.exec("uname -a")},
			  }) do %>
			<tr class="cbi-section-table-titles">
				<td class="cbi-section-table-cell"><%=item[2]%>:</td>
				<td class="cbi-section-table-cell" id="<%=item[1]%>">
				<% if item.url then %>
					<img class="loading_img_small" src="<%=resource%>/icons/loading.gif"
						alt="<%:Loading%>" style="vertical-align:middle" />
					<script type="text/javascript">
						fill_result_row("<%=item[1]%>", "<%=item.url%>")
					</script>
				<% else %>
					<%=luci.util.pcdata(item.content)%>
				<% end %>
				</td>
			</tr>
		<% end %>
	</table>
</fieldset></div>
<%+footer%>
