applications/luci-olsr: Update all statuspages; use json reloading on overview, neighbors and topology pages

This commit is contained in:
Manuel Munz 2011-11-09 18:12:25 +00:00
parent b0dbb7bd3d
commit b1ef4c398b
10 changed files with 546 additions and 227 deletions

View file

@ -91,15 +91,7 @@ function index()
) )
end end
function action_neigh() local function compare_links(a, b)
local data = fetch_txtinfo("links")
if not data or not data.Links then
luci.template.render("status-olsr/error_olsr")
return nil
end
local function compare(a, b)
local c = tonumber(a.Cost) local c = tonumber(a.Cost)
local d = tonumber(b.Cost) local d = tonumber(b.Cost)
@ -110,11 +102,18 @@ function action_neigh()
if not d or d == 0 then if not d or d == 0 then
return true return true
end end
return c < d return c < d
end
function action_neigh(json)
local data = fetch_txtinfo("links")
if not data or not data.Links then
luci.template.render("status-olsr/error_olsr")
return nil
end end
table.sort(data.Links, compare) table.sort(data.Links, compare_links)
luci.template.render("status-olsr/neighbors", {links=data.Links}) luci.template.render("status-olsr/neighbors", {links=data.Links})
end end

View file

@ -0,0 +1,28 @@
--[[
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

View file

@ -2,6 +2,7 @@
LuCI - Lua Configuration Interface LuCI - Lua Configuration Interface
Copyright 2008 Steven Barth <steven@midlink.org> Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> 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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -12,26 +13,36 @@ You may obtain a copy of the License at
$Id$ $Id$
-%> -%>
<%
local i = 1
%>
<%+header%> <%+header%>
<h2><a id="content" name="content"><%:Active host net announcements%></a></h2> <h2><a id="content" name="content"><%:Active host net announcements%></a></h2>
<p><%:Overview of currently active OLSR host net announcements%></p>
<br /> <fieldset class="cbi-section">
<table class="smalltext" cellspacing="0" cellpadding="6"> <legend><%:Overview of currently active OLSR host net announcements%></legend>
<tr> <table class="cbi-section-table">
<th><%:Announced network%></th> <tr class="cbi-section-table-titles">
<th><%:OLSR gateway%></th> <th class="cbi-section-table-cell"><%:Announced network%></th>
</tr> <th class="cbi-section-table-cell"><%:OLSR gateway%></th>
<% for k, route in ipairs(routes) do %> </tr>
<tr>
<td><%=route.Destination%></td> <% for k, route in ipairs(routes) do %>
<td>
<a href="http://<%=route.Gateway%>/cgi-bin-status.html"><%=route.Gateway%></a> <tr class="cbi-section-table-row cbi-rowstyle-<%=i%>">
<% if route.Hostname then %> <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> / <a href="http://<%=route.Hostname%>/cgi-bin-status.html"><%=route.Hostname%></a>
<% end %> <% end %>
</td> </td>
</tr> </tr>
<% end %>
</table> <% if i == 1 then i = 0 elseif i == 0 then i = 1 end
<br /> end %>
</table>
</fieldset>
<%+footer%> <%+footer%>

View file

@ -2,7 +2,7 @@
LuCI - Lua Configuration Interface LuCI - Lua Configuration Interface
Copyright 2008 Steven Barth <steven@midlink.org> Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> 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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -13,33 +13,42 @@ You may obtain a copy of the License at
$Id: mid.htm 5448 2009-10-31 15:54:11Z jow $ $Id: mid.htm 5448 2009-10-31 15:54:11Z jow $
-%> -%>
<%
local i = 1
%>
<%+header%> <%+header%>
<h2><a id="content" name="content"><%:Interfaces%></a></h2> <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 %> <fieldset class="cbi-section">
<tr> <legend><%:Overview of interfaces where OLSR is running%></legend>
<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> <table class="cbi-section-table">
<br /> <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>
<% if i == 1 then i = 0 elseif i == 0 then i = 1 end
end %>
</table>
</fieldset>
<%+footer%> <%+footer%>

View file

@ -2,6 +2,7 @@
LuCI - Lua Configuration Interface LuCI - Lua Configuration Interface
Copyright 2008 Steven Barth <steven@midlink.org> Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> 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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -12,21 +13,30 @@ You may obtain a copy of the License at
$Id$ $Id$
-%> -%>
<%
local i = 1
%>
<%+header%> <%+header%>
<h2><a id="content" name="content"><%:Active MID announcements%></a></h2> <h2><a id="content" name="content"><%:Active MID announcements%></a></h2>
<p><%:Overview of known multiple interface announcements%></p>
<br /> <fieldset class="cbi-section">
<table class="smalltext" cellspacing="0" cellpadding="6"> <legend><%:Overview of known multiple interface announcements%></legend>
<tr> <table class="cbi-section-table">
<th><%:OLSR node%></th> <tr class="cbi-section-table-titles">
<th><%:Secondary OLSR interfaces%></th> <th class="cbi-section-table-cell"><%:OLSR node%></th>
</tr> <th class="cbi-section-table-cell" ><%:Secondary OLSR interfaces%></th>
<% for k, mid in ipairs(mids) do %> </tr>
<tr>
<td><a href="http://<%=mid["IP address"]%>"><%=mid["IP address"]%></a></td> <% for k, mid in ipairs(mids) do %>
<td><%=mid.Aliases%></td>
</tr> <tr class="cbi-section-table-row cbi-rowstyle-<%=i%>">
<% end %> <td class="cbi-section-table-cell"><a href="http://<%=mid["IP address"]%>/cgi-bin-status.html"><%=mid["IP address"]%></a></td>
</table> <td class="cbi-section-table-cell"><%=mid.Aliases%></td>
<br /> </tr>
<% if i == 1 then i = 0 elseif i == 0 then i = 1 end
end %>
</table>
</fieldset>
<%+footer%> <%+footer%>

View file

@ -2,6 +2,7 @@
LuCI - Lua Configuration Interface LuCI - Lua Configuration Interface
Copyright 2008 Steven Barth <steven@midlink.org> Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> 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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -9,58 +10,145 @@ You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 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"
<%
local olsrtools = require "luci.tools.olsr"
if luci.http.formvalue("status") == "1" then
local rv = {}
local i = 1
for k, link in ipairs(links) do
link.Cost = tonumber(link.Cost) or 0 link.Cost = tonumber(link.Cost) or 0
if link.Cost == 0 then local color = olsrtools.etx_color(link.Cost)
color = "#bb3333" defaultgw_color = ""
elseif link.Cost < 4 then if link.defaultgw == 1 then
color = "#00cc00" defaultgw_color = "#ffff99"
elseif link.Cost < 10 then
color = "#ffcb05"
elseif link.Cost < 100 then
color = "#ff6600"
end 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,
rs = i,
dfgcolor = defaultgw_color
}
if i == 1 then i = 0 elseif i == 0 then i = 1 end
end
luci.http.prepare_content("application/json")
luci.http.write_json(rv)
return
end
%>
<%+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-%s">' +
'<td class="cbi-section-table-cell" style="background-color:%s"><a href="http://%s/cgi-bin-status.html">%s</a></td>',
neigh.rs, 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">
<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>
<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 = "" defaultgw_color = ""
if link.defaultgw == 1 then if link.defaultgw == 1 then
defaultgw_color = "#ffff99" defaultgw_color = "#ffff99"
end end
%> %>
<tr>
<td style="background-color:<%=defaultgw_color%>"><a href="http://<%=link["Remote IP"]%>/cgi-bin-status.html"><%=link["Remote IP"]%></a></td> <tr class="cbi-section-table-row cbi-rowstyle-<%=i%>">
<td 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%>"><a href="http://<%=link["Remote IP"]%>/cgi-bin-status.html"><%=link["Remote IP"]%></a></td>
<td style="background-color:<%=defaultgw_color%>"><%=link["Local IP"]%></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 style="background-color:<%=defaultgw_color%>"><%=link["Local Device"]%></td> <td class="cbi-section-table-cell" style="background-color:<%=defaultgw_color%>"><%=link["Local IP"]%></td>
<td style="background-color:<%=defaultgw_color%>"><%=link.LQ%></td> <td class="cbi-section-table-cell" style="background-color:<%=defaultgw_color%>"><%=link["Local Device"]%></td>
<td style="background-color:<%=defaultgw_color%>"><%=link.NLQ%></td> <td class="cbi-section-table-cell" style="background-color:<%=defaultgw_color%>"><%=link.LQ%></td>
<td style="background-color:<%=color%>"><%=string.format("%.3f", link.Cost)%></td> <td class="cbi-section-table-cell" style="background-color:<%=defaultgw_color%>"><%=link.NLQ%></td>
</tr> <td class="cbi-section-table-cell" style="background-color:<%=color%>"><%=string.format("%.3f", link.Cost)%></td>
<% end %> </tr>
</table> <%
if i == 1 then i = 0 elseif i == 0 then i = 1 end
end %>
</tbody>
</table>
<br /> <br />
<h3><%:Legend%>:</h3> <h3><%:Legend%>:</h3>
<ul> <ul>
<li><strong>LQ: </strong><%:Success rate of packages received from the neighbour%></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>NLQ: </strong><%:Success rate of packages sent to the neighbour%></li>
<li><strong>ETX: </strong><%:Expected retransmission count%></li> <li><strong>ETX: </strong><%:Expected retransmission count%></li>
</ul> </ul>
</fieldset>
<%+footer%> <%+footer%>

View file

@ -2,7 +2,7 @@
LuCI - Lua Configuration Interface LuCI - Lua Configuration Interface
Copyright 2008 Steven Barth <steven@midlink.org> Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> 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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -69,6 +69,23 @@ local nr_hna = #data.HNA
local meshfactor = string.format("%.2f", nr_topo / nr_nodes) 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") local ipv = luci.model.uci.cursor():get_first("olsrd", "olsrd", "IpVersion", "4")
function write_conf(conf, file) function write_conf(conf, file)
@ -104,6 +121,43 @@ end
%> %>
<%+header%> <%+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> <h2><a id="content" name="content">OLSR <%:Overview%></a></h2>
<div class="cbi-map"> <div class="cbi-map">
@ -111,10 +165,15 @@ end
<div class="cbi-value"><label class="cbi-value-title"><%:Interfaces%></label> <div class="cbi-value"><label class="cbi-value-title"><%:Interfaces%></label>
<div class="cbi-value-field"> <div class="cbi-value-field">
<div style="width: 6em; float:left;"> <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%></a>
<span>
</div> </div>
<div style="padding-left: 6em;"> <div style="padding-left: 6em;">
<span id="interfaces">
<%=interfaces%> <%=interfaces%>
</span>
</div> </div>
</div> </div>
</div> </div>
@ -122,31 +181,48 @@ end
<div class="cbi-value"><label class="cbi-value-title"><%:Neighbors%></label> <div class="cbi-value"><label class="cbi-value-title"><%:Neighbors%></label>
<div class="cbi-value-field"> <div class="cbi-value-field">
<div style="width: 6em; float:left;"> <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%></a>
</span>
</div> </div>
<div style="padding-left: 6em;"> <div style="padding-left: 6em;">
<span id="neighbors">
<%=neighbors%> <%=neighbors%>
</span>
</div> </div>
</div> </div>
</div> </div>
<div class="cbi-value"><label class="cbi-value-title"><%:Nodes%></label> <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-field"><a href="<%=luci.dispatcher.build_url("freifunk", "olsr", "topology")%>">
<span id="nr_nodes">
<%=nr_nodes%></a>
</span>
</div> </div>
</div> </div>
<div class="cbi-value"><label class="cbi-value-title"><%:HNA%></label> <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-field"><a href="<%=luci.dispatcher.build_url("freifunk", "olsr", "hna")%>">
<span id="nr_hna">
<%=nr_hna%></a>
</span>
</div> </div>
</div> </div>
<div class="cbi-value"><label class="cbi-value-title"><%:Links total%></label> <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-field"><a href="<%=luci.dispatcher.build_url("freifunk", "olsr", "topology")%>">
<span id="nr_topo">
<%=nr_topo%></a>
</span>
</div> </div>
</div> </div>
<div class="cbi-value"><label class="cbi-value-title"><%:Links per node (average)%></label> <div class="cbi-value"><label class="cbi-value-title"><%:Links per node (average)%></label>
<div class="cbi-value-field"><%=meshfactor%> <div class="cbi-value-field">
<span id="meshfactor">
<%=meshfactor%>
</span>
</div> </div>
</div> </div>
</div> </div>

View file

@ -2,55 +2,129 @@
LuCI - Lua Configuration Interface LuCI - Lua Configuration Interface
Copyright 2008 Steven Barth <steven@midlink.org> Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> 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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 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" local olsrtools = require "luci.tools.olsr"
elseif route.ETX < 4 then local i = 1
color = "#00cc00"
elseif route.ETX < 10 then if luci.http.formvalue("status") == "1" then
color = "#ffcb05" local rv = {}
elseif route.ETX < 100 then for k, route in ipairs(routes) do
color = "#ff6600" 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)),
rs = i
}
if i == 1 then i = 0 elseif i == 0 then i = 1 end
end end
luci.http.prepare_content("application/json")
luci.http.write_json(rv)
return
end
%> %>
<tr>
<td><%=route.Destination%></td> <%+header%>
<td>
<a href="http://<%=route["Gateway IP"]%>/cgi-bin-status.html"><%=route["Gateway IP"]%></a> <script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<% if route.Hostname then %> <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-%s">' +
'<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.rs, 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">
<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>
<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> / <a href="http://<%=route.Hostname%>/cgi-bin-status.html"><%=route.Hostname%></a>
<% end %> <% end %>
</td> </td>
<td><%=route.Interface%></td> <td class="cbi-section-table-cell"><%=route.Interface%></td>
<td><%=route.Metric%></td> <td class="cbi-section-table-cell"><%=route.Metric%></td>
<td style="background-color:<%=color%>"><%=string.format("%.3f", tonumber(route.ETX) or 0)%></td> <td class="cbi-section-table-cell" style="background-color:<%=color%>"><%=string.format("%.3f", tonumber(route.ETX) or 0)%></td>
</tr> </tr>
<% end %> <%
if i == 1 then i = 0 elseif i == 0 then i = 1 end
end %>
</tbody>
</table> </table>
<br />
</fieldset>
<%+footer%> <%+footer%>

View file

@ -2,7 +2,7 @@
LuCI - Lua Configuration Interface LuCI - Lua Configuration Interface
Copyright 2008 Steven Barth <steven@midlink.org> Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> 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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -12,6 +12,7 @@ You may obtain a copy of the License at
-%> -%>
<% <%
local i = 1
require("luci.model.uci") require("luci.model.uci")
local uci = luci.model.uci.cursor_state() local uci = luci.model.uci.cursor_state()
@ -23,39 +24,48 @@ end)
<%+header%> <%+header%>
<h2><a id="content" name="content"><%:SmartGW announcements%></a></h2> <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> <% if has_smartgw then %>
<% for k, gw in ipairs(gws) do %>
<tr> <fieldset class="cbi-section">
<td><a href="http://<%=gw["Gateway IP"]%>/cgi-bin-status.html"><%=gw["Gateway IP"]%></a></td> <legend><%:Overview of smart gateways in this network%></legend>
<td><%=gw.Status%></td> <table class="cbi-section-table">
<td><%=gw.ETX%></td> <tr class="cbi-section-table-titles">
<td><%=gw.Hopcnt%></td> <th class="cbi-section-table-cell"><%:Gateway%></th>
<td><%=gw.Uplink%></td> <th class="cbi-section-table-cell"><%:Status%></th>
<td><%=gw.Downlnk%></td> <th class="cbi-section-table-cell"><%:ETX%></th>
<td><%=gw.IPv4%></td> <th class="cbi-section-table-cell"><%:Hops%></th>
<td><%=gw.IPv6%></td> <th class="cbi-section-table-cell"><%:Uplink%></th>
<td><%=gw.Prefix%></td> <th class="cbi-section-table-cell"><%:Downlink%></th>
</tr> <th class="cbi-section-table-cell"><%:IPv4%></th>
<% end %> <th class="cbi-section-table-cell"><%:IPv6%></th>
</table> <th class="cbi-section-table-cell"><%:Prefix%></th>
<br />
</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>
<% if i == 1 then i = 0 elseif i == 0 then i = 1 end
end %>
</table>
</fieldset>
<% else %> <% else %>
<%:SmartGateway is not configured on this system.%>
<%:SmartGateway is not configured on this system.%>
<% end %> <% end %>
<%+footer%> <%+footer%>

View file

@ -2,6 +2,7 @@
LuCI - Lua Configuration Interface LuCI - Lua Configuration Interface
Copyright 2008 Steven Barth <steven@midlink.org> Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> 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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -12,28 +13,41 @@ You may obtain a copy of the License at
$Id$ $Id$
-%> -%>
<%
local i = 1
local olsrtools = require "luci.tools.olsr"
%>
<%+header%> <%+header%>
<h2><a id="content" name="content"><%:Active OLSR nodes%></a></h2> <h2><a id="content" name="content"><%:Active OLSR nodes%></a></h2>
<p><%:Overview of currently known OLSR nodes%></p>
<br /> <fieldset class="cbi-section">
<table class="smalltext" cellspacing="0" cellpadding="6"> <legend><%:Overview of currently known OLSR nodes%></legend>
<tr> <table class="cbi-section-table">
<th><%:OLSR node%></th> <tr class="cbi-section-table-titles">
<th><%:Last hop%></th> <th class="cbi-section-table-cell"><%:OLSR node%></th>
<th>LQ</th> <th class="cbi-section-table-cell"><%:Last hop%></th>
<th>ILQ</th> <th class="cbi-section-table-cell"><%:LQ%></th>
<th>ETX</th> <th class="cbi-section-table-cell"><%:NLQ%></th>
</tr> <th class="cbi-section-table-cell"><%:ETX%></th>
<% for k, route in ipairs(routes) do </tr>
%>
<tr> <% for k, route in ipairs(routes) do
<td><a href="http://<%=route["Dest. IP"]%>"><%=route["Dest. IP"]%></a></td> local cost = string.format("%.3f", tonumber(route.Cost) or 0)
<td><a href="http://<%=route["Last hop IP"]%>"><%=route["Last hop IP"]%></a></td> local color = olsrtools.etx_color(tonumber(cost))
<td><%=route.LQ%></td> %>
<td><%=route.NLQ%></td>
<td><%=string.format("%.3f", tonumber(route.Cost) or 0)%></td> <tr class="cbi-section-table-row cbi-rowstyle-<%=i%>">
</tr> <td class="cbi-section-table-cell"><a href="http://<%=route["Dest. IP"]%>/cgi-bin-status.html"><%=route["Dest. IP"]%></a></td>
<% end %> <td class="cbi-section-table-cell"><a href="http://<%=route["Last hop IP"]%>/cgi-bin-status.html"><%=route["Last hop IP"]%></a></td>
</table> <td class="cbi-section-table-cell"><%=route.LQ%></td>
<br /> <td class="cbi-section-table-cell"><%=route.NLQ%></td>
<td class="cbi-section-table-cell" style="background-color:<%=color%>"><%=cost%></td>
</tr>
<% if i == 1 then i = 0 elseif i == 0 then i = 1 end
end %>
</table>
</fieldset>
<%+footer%> <%+footer%>