)
end
-function action_neigh()
- local data = fetch_txtinfo("links")
+local function compare_links(a, b)
+ local c = tonumber(a.Cost)
+ local d = tonumber(b.Cost)
- if not data or not data.Links then
- luci.template.render("status-olsr/error_olsr")
- return nil
+ if not c or c == 0 then
+ return false
end
- local function compare(a, b)
- local c = tonumber(a.Cost)
- local d = tonumber(b.Cost)
-
- if not c or c == 0 then
- return false
- end
+ if not d or d == 0 then
+ return true
+ end
+ return c < d
+end
- if not d or d == 0 then
- return true
- end
+function action_neigh(json)
+ local data = fetch_txtinfo("links")
- return c < d
+ if not data or not data.Links then
+ luci.template.render("status-olsr/error_olsr")
+ return nil
end
- table.sort(data.Links, compare)
+ table.sort(data.Links, compare_links)
luci.template.render("status-olsr/neighbors", {links=data.Links})
end
--- /dev/null
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2011 Manuel Munz <freifunk at somakoma dot de>
+
+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
+]]--
+
+module("luci.tools.olsr", package.seeall)
+
+function etx_color(etx)
+ local color = "#bb3333"
+ if etx == 0 then
+ color = "#bb3333"
+ elseif etx < 4 then
+ color = "#00cc00"
+ elseif etx < 10 then
+ color = "#ffcb05"
+ elseif etx < 100 then
+ color = "#ff6600"
+ end
+ return color
+end
+
LuCI - Lua Configuration Interface
Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+Copyright 2011 Manuel Munz <freifunk at somakoma dot de>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
$Id$
-%>
+<%
+local i = 1
+%>
+
<%+header%>
+
<h2><a id="content" name="content"><%:Active host net announcements%></a></h2>
-<p><%:Overview of currently active OLSR host net announcements%></p>
-<br />
-<table class="smalltext" cellspacing="0" cellpadding="6">
-<tr>
-<th><%:Announced network%></th>
-<th><%:OLSR gateway%></th>
-</tr>
-<% for k, route in ipairs(routes) do %>
-<tr>
-<td><%=route.Destination%></td>
-<td>
-<a href="http://<%=route.Gateway%>/cgi-bin-status.html"><%=route.Gateway%></a>
-<% if route.Hostname then %>
- / <a href="http://<%=route.Hostname%>/cgi-bin-status.html"><%=route.Hostname%></a>
-<% end %>
-</td>
-</tr>
-<% end %>
-</table>
-<br />
+
+<fieldset class="cbi-section">
+ <legend><%:Overview of currently active OLSR host net announcements%></legend>
+ <table class="cbi-section-table">
+ <tr class="cbi-section-table-titles">
+ <th class="cbi-section-table-cell"><%:Announced network%></th>
+ <th class="cbi-section-table-cell"><%:OLSR gateway%></th>
+ </tr>
+
+ <% for k, route in ipairs(routes) do %>
+
+ <tr class="cbi-section-table-row cbi-rowstyle-<%=i%>">
+ <td class="cbi-section-table-cell"><%=route.Destination%></td>
+ <td class="cbi-section-table-cell">
+ <a href="http://<%=route.Gateway%>/cgi-bin-status.html"><%=route.Gateway%></a>
+ <% if route.Hostname then %>
+ / <a href="http://<%=route.Hostname%>/cgi-bin-status.html"><%=route.Hostname%></a>
+ <% end %>
+ </td>
+ </tr>
+
+ <% i = ((i % 2) + 1)
+ end %>
+ </table>
+</fieldset>
<%+footer%>
LuCI - Lua Configuration Interface
Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-Copyright 2010 Manuel Munz <freifunk at somakoma dot de>
+Copyright 2011 Manuel Munz <freifunk at somakoma dot de>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
$Id: mid.htm 5448 2009-10-31 15:54:11Z jow $
-%>
+
+<%
+local i = 1
+%>
+
<%+header%>
+
<h2><a id="content" name="content"><%:Interfaces%></a></h2>
-<p><%:Overview of interfaces where OLSR is running%></p>
-<br />
-<table class="smalltext" cellspacing="0" cellpadding="6">
-<tr>
-<th><%:Interface%></th>
-<th><%:State%></th>
-<th><%:MTU%></th>
-<th><%:WLAN%></th>
-<th><%:Source address%></th>
-<th><%:Netmask%></th>
-<th><%:Broadcast address%></th>
-</tr>
-
-<% for k, i in ipairs(iface) do %>
-<tr>
-<td><%=i.Name%></td>
-<td><%=i.State%></td>
-<td><%=i.MTU%></td>
-<td><%=i.WLAN%></td>
-<td><%=i["Src-Adress"]%></td>
-<td><%=i.Mask%></td>
-<td><%=i["Dst-Adress"]%></td>
-</tr>
-<% end %>
-
-</table>
-<br />
+
+<fieldset class="cbi-section">
+ <legend><%:Overview of interfaces where OLSR is running%></legend>
+
+ <table class="cbi-section-table">
+ <tr>
+ <th class="cbi-section-table-cell"><%:Interface%></th>
+ <th class="cbi-section-table-cell"><%:State%></th>
+ <th class="cbi-section-table-cell"><%:MTU%></th>
+ <th class="cbi-section-table-cell"><%:WLAN%></th>
+ <th class="cbi-section-table-cell"><%:Source address%></th>
+ <th class="cbi-section-table-cell"><%:Netmask%></th>
+ <th class="cbi-section-table-cell"><%:Broadcast address%></th>
+ </tr>
+
+ <% for k, iface in ipairs(iface) do %>
+
+ <tr class="cbi-section-table-row cbi-rowstyle-<%=i%>">
+ <td class="cbi-section-table-cell"><%=iface.Name%></td>
+ <td class="cbi-section-table-cell"><%=iface.State%></td>
+ <td class="cbi-section-table-cell"><%=iface.MTU%></td>
+ <td class="cbi-section-table-cell"><%=iface.WLAN%></td>
+ <td class="cbi-section-table-cell"><%=iface["Src-Adress"]%></td>
+ <td class="cbi-section-table-cell"><%=iface.Mask%></td>
+ <td class="cbi-section-table-cell"><%=iface["Dst-Adress"]%></td>
+ </tr>
+ <% i = ((i % 2) + 1)
+ end %>
+ </table>
+</fieldset>
<%+footer%>
LuCI - Lua Configuration Interface
Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+Copyright 2011 Manuel Munz <freifunk at somakoma dot de>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
$Id$
-%>
+<%
+local i = 1
+%>
+
<%+header%>
<h2><a id="content" name="content"><%:Active MID announcements%></a></h2>
-<p><%:Overview of known multiple interface announcements%></p>
-<br />
-<table class="smalltext" cellspacing="0" cellpadding="6">
-<tr>
-<th><%:OLSR node%></th>
-<th><%:Secondary OLSR interfaces%></th>
-</tr>
-<% for k, mid in ipairs(mids) do %>
-<tr>
-<td><a href="http://<%=mid["IP address"]%>"><%=mid["IP address"]%></a></td>
-<td><%=mid.Aliases%></td>
-</tr>
-<% end %>
-</table>
-<br />
+
+<fieldset class="cbi-section">
+ <legend><%:Overview of known multiple interface announcements%></legend>
+ <table class="cbi-section-table">
+ <tr class="cbi-section-table-titles">
+ <th class="cbi-section-table-cell"><%:OLSR node%></th>
+ <th class="cbi-section-table-cell" ><%:Secondary OLSR interfaces%></th>
+ </tr>
+
+ <% for k, mid in ipairs(mids) do %>
+
+ <tr class="cbi-section-table-row cbi-rowstyle-<%=i%>">
+ <td class="cbi-section-table-cell"><a href="http://<%=mid["IP address"]%>/cgi-bin-status.html"><%=mid["IP address"]%></a></td>
+ <td class="cbi-section-table-cell"><%=mid.Aliases%></td>
+ </tr>
+
+ <% i = ((i % 2) + 1)
+ end %>
+ </table>
+</fieldset>
<%+footer%>
LuCI - Lua Configuration Interface
Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
+Copyright 2011 Manuel Munz <freifunk at somakoma dot de>
+
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 6619 2010-12-05 15:02:44Z soma $
-
-%>
-<%+header%>
-<h2><a id="content" name="content"><%:OLSR connections%></a></h2>
-<p><%:Overview of currently established OLSR connections%></p>
-<br />
-<table class="smalltext" cellspacing="0" cellpadding="6">
-<tr>
-<th><%:Neighbour IP%></th>
-<th><%:Hostname%></th>
-<th><%:Local interface IP%></th>
-<th><%:Device%></th>
-<th>LQ</th>
-<th>NLQ</th>
-<th>ETX</th>
-</tr>
-<% for k, link in ipairs(links) do
- local color = "#bb3333"
-
- link.Cost = tonumber(link.Cost) or 0
- if link.Cost == 0 then
- color = "#bb3333"
- elseif link.Cost < 4 then
- color = "#00cc00"
- elseif link.Cost < 10 then
- color = "#ffcb05"
- elseif link.Cost < 100 then
- color = "#ff6600"
- end
- defaultgw_color = ""
- if link.defaultgw == 1 then
- defaultgw_color = "#ffff99"
+<%
+local olsrtools = require "luci.tools.olsr"
+local i = 1
+
+if luci.http.formvalue("status") == "1" then
+ local rv = {}
+ for k, link in ipairs(links) do
+ link.Cost = tonumber(link.Cost) or 0
+ local color = olsrtools.etx_color(link.Cost)
+ defaultgw_color = ""
+ if link.defaultgw == 1 then
+ defaultgw_color = "#ffff99"
+ end
+
+ rv[#rv+1] = {
+ rip = link["Remote IP"],
+ hn = link["Hostname"],
+ lip = link["Local IP"],
+ dev = link["Local Device"],
+ lq = link.LQ,
+ nlq = link.NLQ,
+ cost = string.format("%.3f", link.Cost),
+ color = color,
+ dfgcolor = defaultgw_color
+ }
end
+ luci.http.prepare_content("application/json")
+ luci.http.write_json(rv)
+ return
+end
%>
-<tr>
-<td style="background-color:<%=defaultgw_color%>"><a href="http://<%=link["Remote IP"]%>/cgi-bin-status.html"><%=link["Remote IP"]%></a></td>
-<td style="background-color:<%=defaultgw_color%>"><a href="http://<%=link["Hostname"]%>/cgi-bin-status.html"><%=link["Hostname"]%></a></td>
-<td style="background-color:<%=defaultgw_color%>"><%=link["Local IP"]%></td>
-<td style="background-color:<%=defaultgw_color%>"><%=link["Local Device"]%></td>
-<td style="background-color:<%=defaultgw_color%>"><%=link.LQ%></td>
-<td style="background-color:<%=defaultgw_color%>"><%=link.NLQ%></td>
-<td style="background-color:<%=color%>"><%=string.format("%.3f", link.Cost)%></td>
-</tr>
-<% end %>
-</table>
+
+<%+header%>
+
+<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
+<script type="text/javascript">//<![CDATA[
+
+ XHR.poll(10 , '<%=REQUEST_URI%>', { status: 1 },
+ function(x, info)
+ {
+ var nt = document.getElementById('olsr_neigh_table');
+ if (nt)
+ {
+ var s = '';
+ for (var idx = 0; idx < info.length; idx++)
+ {
+ var neigh = info[idx];
+
+ s += String.format(
+ '<tr class="cbi-section-table-row cbi-rowstyle-'+(1 + (idx % 2))+'">' +
+ '<td class="cbi-section-table-cell" style="background-color:%s"><a href="http://%s/cgi-bin-status.html">%s</a></td>',
+ neigh.dfgcolor, neigh.rip, neigh.rip
+ );
+ if (neigh.hn) {
+ s += String.format(
+ '<td class="cbi-section-table-cell" style="background-color:%s"><a href="http://%s/cgi-bin-status.html">%s</a></td>',
+ neigh.dfgcolor, neigh.hn, neigh.hn
+ );
+ }
+ else {
+ s += String.format(
+ '<td class="cbi-section-table-cell" style="background-color:%s">?</td>',
+ neigh.dfgcolor
+ );
+ }
+ s += String.format(
+ '<td class="cbi-section-table-cell" style="background-color:%s">%s</td>' +
+ '<td class="cbi-section-table-cell" style="background-color:%s">%s</td>' +
+ '<td class="cbi-section-table-cell" style="background-color:%s">%s</td>' +
+ '<td class="cbi-section-table-cell" style="background-color:%s">%s</td>' +
+ '<td class="cbi-section-table-cell" style="background-color:%s">%s</td>' +
+ '</tr>',
+
+ neigh.dfgcolor, neigh.lip, neigh.dfgcolor, neigh.dev, neigh.dfgcolor, neigh.lq, neigh.dfgcolor, neigh.nlq, neigh.color, neigh.cost || '?'
+ );
+ }
+
+ nt.innerHTML = s;
+ }
+ }
+ );
+//]]></script>
+
+
+<h2><a id="content" name="content"><%:OLSR connections%></a></h2>
+
+<fieldset class="cbi-section">
+ <legend><%:Overview of currently established OLSR connections%></legend>
+
+ <table class="cbi-section-table">
+ <thead>
+ <tr class="cbi-section-table-titles">
+ <th class="cbi-section-table-cell"><%:Neighbour IP%></th>
+ <th class="cbi-section-table-cell"><%:Hostname%></th>
+ <th class="cbi-section-table-cell"><%:Local interface IP%></th>
+ <th class="cbi-section-table-cell"><%:Device%></th>
+ <th class="cbi-section-table-cell">LQ</th>
+ <th class="cbi-section-table-cell">NLQ</th>
+ <th class="cbi-section-table-cell">ETX</th>
+ </tr>
+ </thead>
+
+ <tbody id="olsr_neigh_table">
+ <% local i = 1
+ for k, link in ipairs(links) do
+ link.Cost = tonumber(link.Cost) or 0
+ color = olsrtools.etx_color(link.Cost)
+
+ defaultgw_color = ""
+ if link.defaultgw == 1 then
+ defaultgw_color = "#ffff99"
+ end
+ %>
+
+ <tr class="cbi-section-table-row cbi-rowstyle-<%=i%>">
+ <td class="cbi-section-table-cell" style="background-color:<%=defaultgw_color%>"><a href="http://<%=link["Remote IP"]%>/cgi-bin-status.html"><%=link["Remote IP"]%></a></td>
+ <td class="cbi-section-table-cell" style="background-color:<%=defaultgw_color%>"><a href="http://<%=link["Hostname"]%>/cgi-bin-status.html"><%=link["Hostname"]%></a></td>
+ <td class="cbi-section-table-cell" style="background-color:<%=defaultgw_color%>"><%=link["Local IP"]%></td>
+ <td class="cbi-section-table-cell" style="background-color:<%=defaultgw_color%>"><%=link["Local Device"]%></td>
+ <td class="cbi-section-table-cell" style="background-color:<%=defaultgw_color%>"><%=link.LQ%></td>
+ <td class="cbi-section-table-cell" style="background-color:<%=defaultgw_color%>"><%=link.NLQ%></td>
+ <td class="cbi-section-table-cell" style="background-color:<%=color%>"><%=string.format("%.3f", link.Cost)%></td>
+ </tr>
+ <%
+ i = ((i % 2) + 1)
+ end %>
+ </tbody>
+ </table>
<br />
+
<h3><%:Legend%>:</h3>
<ul>
-<li><strong>LQ: </strong><%:Success rate of packages received from the neighbour%></li>
-<li><strong>NLQ: </strong><%:Success rate of packages sent to the neighbour%></li>
-<li><strong>ETX: </strong><%:Expected retransmission count%></li>
+ <li><strong>LQ: </strong><%:Success rate of packages received from the neighbour%></li>
+ <li><strong>NLQ: </strong><%:Success rate of packages sent to the neighbour%></li>
+ <li><strong>ETX: </strong><%:Expected retransmission count%></li>
</ul>
+</fieldset>
<%+footer%>
LuCI - Lua Configuration Interface
Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-Copyright 2010 Manuel Munz <freifunk at somakoma dot de>
+Copyright 2011 Manuel Munz <freifunk at somakoma dot de>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
local meshfactor = string.format("%.2f", nr_topo / nr_nodes)
+if luci.http.formvalue("status") == "1" then
+ rv = {
+ nr_neighbors = nr_neigbors,
+ neighbors = neighbors,
+ interfaces = interfaces,
+ nr_ifaces = nr_ifaces,
+ nr_links = nr_links,
+ nr_topo = nr_topo,
+ nr_nodes = nr_nodes,
+ meshfactor = meshfactor
+ }
+ luci.http.prepare_content("application/json")
+ luci.http.write_json(rv)
+ return
+end
+
+
local ipv = luci.model.uci.cursor():get_first("olsrd", "olsrd", "IpVersion", "4")
function write_conf(conf, file)
%>
<%+header%>
+
+<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
+<script type="text/javascript">//<![CDATA[
+
+XHR.poll(30, '<%=REQUEST_URI%>', { status: 1 },
+ function(x, info)
+ {
+ var e;
+
+ if (e = document.getElementById('nr_neighbors'))
+ e.innerHTML = info.nr_neighbors;
+
+ if (e = document.getElementById('neighbors'))
+ e.innerHTML = info.neighbors;
+
+ if (e = document.getElementById('nr_ifaces'))
+ e.innerHTML = info.nr_ifaces;
+
+ if (e = document.getElementById('interfaces'))
+ e.innerHTML = info.interfaces;
+
+ if (e = document.getElementById('nr_links'))
+ e.innerHTML = info.nr_links;
+
+ if (e = document.getElementById('nr_topo'))
+ e.innerHTML = info.nr_topo;
+
+ if (e = document.getElementById('nr_nodes'))
+ e.innerHTML = info.nr_nodes;
+
+ if (e = document.getElementById('meshfactor'))
+ e.innerHTML = info.meshfactor;
+ }
+ );
+//]]></script>
+
+
<h2><a id="content" name="content">OLSR <%:Overview%></a></h2>
<div class="cbi-map">
<div class="cbi-section-node">
- <div class="cbi-value"><label class="cbi-value-title"><%:Interfaces%></label>
+ <div class="cbi-value">
+ <div style="width: 15em; float:left;">
+ <label class="cbi-value-title"><%:Interfaces%></label>
+ </div>
<div class="cbi-value-field">
<div style="width: 6em; float:left;">
- <a href="<%=luci.dispatcher.build_url("freifunk", "olsr", "interfaces")%>"><%=nr_ifaces%></a>
+ <a href="<%=luci.dispatcher.build_url("freifunk", "olsr", "interfaces")%>">
+ <span id="nr_ifaces">
+ <%=nr_ifaces%>
+ <span>
+ </a>
</div>
- <div style="padding-left: 6em;">
- <%=interfaces%>
+ <div style="padding-left: 21em;">
+ <span id="interfaces">
+ <%=interfaces%>
+ </span>
</div>
</div>
+ <br/>
</div>
-
- <div class="cbi-value"><label class="cbi-value-title"><%:Neighbors%></label>
+
+ <div class="cbi-value">
+ <div style="width: 15em; float:left;">
+ <%:Neighbors%>
+ </div>
<div class="cbi-value-field">
<div style="width: 6em; float:left;">
- <a href="<%=luci.dispatcher.build_url("freifunk", "olsr", "neighbors")%>"><%=nr_neigh%></a>
+ <a href="<%=luci.dispatcher.build_url("freifunk", "olsr", "neighbors")%>">
+ <span id="nr_neigh">
+ <%=nr_neigh%>
+ </span>
+ </a>
</div>
- <div style="padding-left: 6em;">
- <%=neighbors%>
+ <div style="padding-left: 21em;">
+ <span id="neighbors">
+ <%=neighbors%>
+ </span>
</div>
</div>
+ <br/>
</div>
- <div class="cbi-value"><label class="cbi-value-title"><%:Nodes%></label>
- <div class="cbi-value-field"><a href="<%=luci.dispatcher.build_url("freifunk", "olsr", "topology")%>"><%=nr_nodes%></a>
+ <div class="cbi-value">
+ <div style="width: 15em; float:left;">
+ <%:Nodes%>
</div>
+ <div class="cbi-value-field">
+ <div style="width: 6em; float:left;">
+ <a href="<%=luci.dispatcher.build_url("freifunk", "olsr", "topology")%>">
+ <span id="nr_nodes">
+ <%=nr_nodes%>
+ </span>
+ </a>
+ </div>
+ </div>
+ <br/>
</div>
- <div class="cbi-value"><label class="cbi-value-title"><%:HNA%></label>
- <div class="cbi-value-field"><a href="<%=luci.dispatcher.build_url("freifunk", "olsr", "hna")%>"><%=nr_hna%></a>
+ <div class="cbi-value">
+ <div style="width: 15em; float:left;">
+ <%:HNA%>
+ </div>
+ <div class="cbi-value-field">
+ <div style="width: 6em; float:left;">
+ <a href="<%=luci.dispatcher.build_url("freifunk", "olsr", "hna")%>">
+ <span id="nr_hna">
+ <%=nr_hna%>
+ </span>
+ </a>
+ </div>
</div>
+ <br/>
</div>
- <div class="cbi-value"><label class="cbi-value-title"><%:Links total%></label>
- <div class="cbi-value-field"><a href="<%=luci.dispatcher.build_url("freifunk", "olsr", "topology")%>"><%=nr_topo%></a>
+ <div class="cbi-value">
+ <div style="width: 15em; float:left;">
+ <%:Links total%>
</div>
+ <div class="cbi-value-field">
+ <div style="width: 6em; float:left;">
+ <a href="<%=luci.dispatcher.build_url("freifunk", "olsr", "topology")%>">
+ <span id="nr_topo">
+ <%=nr_topo%>
+ </span>
+ </a>
+ </div>
+ </div>
+ <br/>
</div>
- <div class="cbi-value"><label class="cbi-value-title"><%:Links per node (average)%></label>
- <div class="cbi-value-field"><%=meshfactor%>
+ <div class="cbi-value">
+ <div style="width: 15em; float:left;">
+ <%:Links per node (average)%>
</div>
+ <div class="cbi-value-field">
+ <div style="width: 6em; float:left;">
+ <span id="meshfactor">
+ <%=meshfactor%>
+ </span>
+ </div>
+ </div>
+ <br/>
</div>
</div>
</div>
+<br/>
<h2><a id="content" name="content">OLSR <%:Configuration%></a></h2>
<div class="cbi-map">
<div class="cbi-section-node">
- <div class="cbi-value"><label class="cbi-value-title"><%:Version%></label>
- <div class="cbi-value-field"><%=ver.version%> (built <%=ver.date%> on <%=ver.host%>)
+ <div class="cbi-value">
+ <div style="width: 15em; float:left;">
+ <%:Version%>
+ </div>
+ <div class="cbi-value-field">
+ <%=ver.version%> (built <%=ver.date%> on <%=ver.host%>)
</div>
+ <br/>
</div>
- <div class="cbi-value"><label class="cbi-value-title"><%:Download Config%></label>
+ <div class="cbi-value">
+ <div style="width: 15em; float:left;">
+ <%:Download Config%>
+ </div>
<div class="cbi-value-field">
<a href="<%=REQUEST_URI%>?openwrt">OpenWrt</a>,
<% if ipv == "6and4" then %>
<a href="<%=REQUEST_URI%>?conf">OLSRD</a>
<% end %>
</div>
+ <br/>
</div>
</div>
</div>
LuCI - Lua Configuration Interface
Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+Copyright 2011 Manuel Munz <freifunk at somakoma dot de>
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$
+<%
--%>
-<%+header%>
-<h2><a id="content" name="content"><%:Known OLSR routes%></a></h2>
-<p><%:Overview of currently known routes to other OLSR nodes%></p>
-<br />
-<table class="smalltext" cellspacing="0" cellpadding="6">
-<tr>
-<th><%:Announced network%></th>
-<th><%:OLSR gateway%></th>
-<th><%:Interface%></th>
-<th><%:Metric%></th>
-<th>ETX</th>
-</tr>
-<% for k, route in ipairs(routes) do
- local color = "#bb3333"
-
- route.ETX = tonumber(route.ETX)
- if route.ETX == 0 then
- color = "#bb3333"
- elseif route.ETX < 4 then
- color = "#00cc00"
- elseif route.ETX < 10 then
- color = "#ffcb05"
- elseif route.ETX < 100 then
- color = "#ff6600"
+local olsrtools = require "luci.tools.olsr"
+local i = 1
+
+if luci.http.formvalue("status") == "1" then
+ local rv = {}
+ for k, route in ipairs(routes) do
+ rv[#rv+1] = {
+ hostname = route.Hostname,
+ dest = route.Destination,
+ gw = route["Gateway IP"],
+ interface = route.Interface,
+ metric = route.Metric,
+ etx = tonumber(route.ETX),
+ color = olsrtools.etx_color(tonumber(route.ETX)),
+ }
end
+ luci.http.prepare_content("application/json")
+ luci.http.write_json(rv)
+ return
+end
+
%>
-<tr>
-<td><%=route.Destination%></td>
-<td>
-<a href="http://<%=route["Gateway IP"]%>/cgi-bin-status.html"><%=route["Gateway IP"]%></a>
-<% if route.Hostname then %>
- / <a href="http://<%=route.Hostname%>/cgi-bin-status.html"><%=route.Hostname%></a>
-<% end %>
-</td>
-<td><%=route.Interface%></td>
-<td><%=route.Metric%></td>
-<td style="background-color:<%=color%>"><%=string.format("%.3f", tonumber(route.ETX) or 0)%></td>
-</tr>
-<% end %>
+
+<%+header%>
+
+<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
+<script type="text/javascript">//<![CDATA[
+
+XHR.poll(20, '<%=REQUEST_URI%>', { status: 1 },
+ function(x, info)
+ {
+
+ var rt = document.getElementById('olsrd_routes');
+ if (rt)
+ {
+ var s = '';
+ for (var idx = 0; idx < info.length; idx++)
+ {
+ var route = info[idx];
+
+ s += String.format(
+ '<tr class="cbi-section-table-row cbi-rowstyle-'+(1 + (idx % 2))+'">' +
+ '<td class="cbi-section-table-cell">%s</td>' +
+ '<td class="cbi-section-table-cell">' +
+ '<a href="http://%s/cgi-bin-status.html">%s</a>',
+ route.dest, route.gw, route.gw
+ )
+
+ if (route.hostname)
+ {
+ s += String.format(
+ ' / <a href="http://%s/cgi-bin-status.html">%s</a>',
+ route.hostname, route.hostname || '?'
+ );
+ }
+ s += String.format(
+ '</td>' +
+ '<td class="cbi-section-table-cell">%s</td>' +
+ '<td class="cbi-section-table-cell">%s</td>' +
+ '<td class="cbi-section-table-cell" style="background-color:%s">%s</td>' +
+ '</tr>',
+ route.interface, route.metric, route.color, route.etx || '?'
+ );
+ }
+ }
+ rt.innerHTML = s;
+
+ }
+ );
+//]]></script>
+
+
+
+<h2><a id="content" name="content"><%:Known OLSR routes%></a></h2>
+
+<fieldset class="cbi-section">
+<legend><%:Overview of currently known routes to other OLSR nodes%></legend>
+
+<table class="cbi-section-table">
+ <thead>
+ <tr class="cbi-section-table-titles">
+ <th class="cbi-section-table-cell"><%:Announced network%></th>
+ <th class="cbi-section-table-cell"><%:OLSR gateway%></th>
+ <th class="cbi-section-table-cell"><%:Interface%></th>
+ <th class="cbi-section-table-cell"><%:Metric%></th>
+ <th class="cbi-section-table-cell">ETX</th>
+ </tr>
+ </thead>
+
+ <tbody id="olsrd_routes">
+
+ <% for k, route in ipairs(routes) do
+ color = olsrtools.etx_color(tonumber(route.ETX))
+ %>
+
+ <tr class="cbi-section-table-row cbi-rowstyle-<%=i%>">
+ <td class="cbi-section-table-cell"><%=route.Destination%></td>
+ <td class="cbi-section-table-cell">
+ <a href="http://<%=route["Gateway IP"]%>/cgi-bin-status.html"><%=route["Gateway IP"]%></a>
+ <% if route.Hostname then %>
+ / <a href="http://<%=route.Hostname%>/cgi-bin-status.html"><%=route.Hostname%></a>
+ <% end %>
+ </td>
+ <td class="cbi-section-table-cell"><%=route.Interface%></td>
+ <td class="cbi-section-table-cell"><%=route.Metric%></td>
+ <td class="cbi-section-table-cell" style="background-color:<%=color%>"><%=string.format("%.3f", tonumber(route.ETX) or 0)%></td>
+ </tr>
+ <%
+ i = ((i % 2) + 1)
+ end %>
+ </tbody>
</table>
-<br />
+
+</fieldset>
<%+footer%>
LuCI - Lua Configuration Interface
Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-Copyright 2010 Manuel Munz <freifunk at somakoma dot de>
+Copyright 2011 Manuel Munz <freifunk at somakoma dot de>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
-%>
<%
+local i = 1
require("luci.model.uci")
local uci = luci.model.uci.cursor_state()
<%+header%>
<h2><a id="content" name="content"><%:SmartGW announcements%></a></h2>
+
<% if has_smartgw then %>
-<p><%:Overview of smart gateways in this network%></p>
-<br />
-<table class="smalltext" cellspacing="0" cellpadding="6">
-<tr>
-<th><%:Gateway%></th>
-<th><%:Status%></th>
-<th><%:ETX%></th>
-<th><%:Hops%></th>
-<th><%:Uplink%></th>
-<th><%:Downlink%></th>
-<th><%:IPv4%></th>
-<th><%:IPv6%></th>
-<th><%:Prefix%></th>
-
-</tr>
-<% for k, gw in ipairs(gws) do %>
-<tr>
-<td><a href="http://<%=gw["Gateway IP"]%>/cgi-bin-status.html"><%=gw["Gateway IP"]%></a></td>
-<td><%=gw.Status%></td>
-<td><%=gw.ETX%></td>
-<td><%=gw.Hopcnt%></td>
-<td><%=gw.Uplink%></td>
-<td><%=gw.Downlnk%></td>
-<td><%=gw.IPv4%></td>
-<td><%=gw.IPv6%></td>
-<td><%=gw.Prefix%></td>
-</tr>
-<% end %>
-</table>
-<br />
+
+ <fieldset class="cbi-section">
+ <legend><%:Overview of smart gateways in this network%></legend>
+ <table class="cbi-section-table">
+ <tr class="cbi-section-table-titles">
+ <th class="cbi-section-table-cell"><%:Gateway%></th>
+ <th class="cbi-section-table-cell"><%:Status%></th>
+ <th class="cbi-section-table-cell"><%:ETX%></th>
+ <th class="cbi-section-table-cell"><%:Hops%></th>
+ <th class="cbi-section-table-cell"><%:Uplink%></th>
+ <th class="cbi-section-table-cell"><%:Downlink%></th>
+ <th class="cbi-section-table-cell"><%:IPv4%></th>
+ <th class="cbi-section-table-cell"><%:IPv6%></th>
+ <th class="cbi-section-table-cell"><%:Prefix%></th>
+
+ </tr>
+
+ <% for k, gw in ipairs(gws) do %>
+
+ <tr class="cbi-section-table-row cbi-rowstyle-<%=i%>">
+ <td class="cbi-section-table-cell"><a href="http://<%=gw["Gateway IP"]%>/cgi-bin-status.html"><%=gw["Gateway IP"]%></a></td>
+ <td class="cbi-section-table-cell"><%=gw.Status%></td>
+ <td class="cbi-section-table-cell"><%=gw.ETX%></td>
+ <td class="cbi-section-table-cell"><%=gw.Hopcnt%></td>
+ <td class="cbi-section-table-cell"><%=gw.Uplink%></td>
+ <td class="cbi-section-table-cell"><%=gw.Downlnk%></td>
+ <td class="cbi-section-table-cell"><%=gw.IPv4%></td>
+ <td class="cbi-section-table-cell"><%=gw.IPv6%></td>
+ <td class="cbi-section-table-cell"><%=gw.Prefix%></td>
+ </tr>
+
+ <% i = ((i % 2) + 1)
+ end %>
+ </table>
+ </fieldset>
<% else %>
-<%:SmartGateway is not configured on this system.%>
+
+ <%:SmartGateway is not configured on this system.%>
+
<% end %>
+
<%+footer%>
LuCI - Lua Configuration Interface
Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+Copyright 2011 Manuel Munz <freifunk at somakoma dot de>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
$Id$
-%>
+<%
+local i = 1
+local olsrtools = require "luci.tools.olsr"
+%>
+
<%+header%>
<h2><a id="content" name="content"><%:Active OLSR nodes%></a></h2>
-<p><%:Overview of currently known OLSR nodes%></p>
-<br />
-<table class="smalltext" cellspacing="0" cellpadding="6">
-<tr>
-<th><%:OLSR node%></th>
-<th><%:Last hop%></th>
-<th>LQ</th>
-<th>ILQ</th>
-<th>ETX</th>
-</tr>
-<% for k, route in ipairs(routes) do
-%>
-<tr>
-<td><a href="http://<%=route["Dest. IP"]%>"><%=route["Dest. IP"]%></a></td>
-<td><a href="http://<%=route["Last hop IP"]%>"><%=route["Last hop IP"]%></a></td>
-<td><%=route.LQ%></td>
-<td><%=route.NLQ%></td>
-<td><%=string.format("%.3f", tonumber(route.Cost) or 0)%></td>
-</tr>
-<% end %>
-</table>
-<br />
+
+<fieldset class="cbi-section">
+ <legend><%:Overview of currently known OLSR nodes%></legend>
+ <table class="cbi-section-table">
+ <tr class="cbi-section-table-titles">
+ <th class="cbi-section-table-cell"><%:OLSR node%></th>
+ <th class="cbi-section-table-cell"><%:Last hop%></th>
+ <th class="cbi-section-table-cell"><%:LQ%></th>
+ <th class="cbi-section-table-cell"><%:NLQ%></th>
+ <th class="cbi-section-table-cell"><%:ETX%></th>
+ </tr>
+
+ <% for k, route in ipairs(routes) do
+ local cost = string.format("%.3f", tonumber(route.Cost) or 0)
+ local color = olsrtools.etx_color(tonumber(cost))
+ %>
+
+ <tr class="cbi-section-table-row cbi-rowstyle-<%=i%>">
+ <td class="cbi-section-table-cell"><a href="http://<%=route["Dest. IP"]%>/cgi-bin-status.html"><%=route["Dest. IP"]%></a></td>
+ <td class="cbi-section-table-cell"><a href="http://<%=route["Last hop IP"]%>/cgi-bin-status.html"><%=route["Last hop IP"]%></a></td>
+ <td class="cbi-section-table-cell"><%=route.LQ%></td>
+ <td class="cbi-section-table-cell"><%=route.NLQ%></td>
+ <td class="cbi-section-table-cell" style="background-color:<%=color%>"><%=cost%></td>
+ </tr>
+
+ <% i = ((i % 2) + 1)
+ end %>
+ </table>
+</fieldset>
+
<%+footer%>