From b1ef4c398bc2d35b333331ac5f823bc17bf56ff2 Mon Sep 17 00:00:00 2001 From: Manuel Munz Date: Wed, 9 Nov 2011 18:12:25 +0000 Subject: applications/luci-olsr: Update all statuspages; use json reloading on overview, neighbors and topology pages --- .../luci-olsr/luasrc/view/status-olsr/routes.htm | 154 +++++++++++++++------ 1 file changed, 114 insertions(+), 40 deletions(-) (limited to 'applications/luci-olsr/luasrc/view/status-olsr/routes.htm') diff --git a/applications/luci-olsr/luasrc/view/status-olsr/routes.htm b/applications/luci-olsr/luasrc/view/status-olsr/routes.htm index cad9c35884..5281f70834 100644 --- a/applications/luci-olsr/luasrc/view/status-olsr/routes.htm +++ b/applications/luci-olsr/luasrc/view/status-olsr/routes.htm @@ -2,55 +2,129 @@ LuCI - Lua Configuration Interface Copyright 2008 Steven Barth Copyright 2008 Jo-Philipp Wich +Copyright 2011 Manuel Munz 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%> -

<%:Known OLSR routes%>

-

<%:Overview of currently known routes to other OLSR nodes%>

-
- - - - - - - - -<% 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)), + rs = i + } + 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 + %> - - - - - - - -<% end %> + +<%+header%> + + + + + + +

<%:Known OLSR routes%>

+ +
+<%:Overview of currently known routes to other OLSR nodes%> + +
<%:Announced network%><%:OLSR gateway%><%:Interface%><%:Metric%>ETX
<%=route.Destination%> -/cgi-bin-status.html"><%=route["Gateway IP"]%> -<% if route.Hostname then %> - / <%=route.Hostname%> -<% end %> -<%=route.Interface%><%=route.Metric%><%=string.format("%.3f", tonumber(route.ETX) or 0)%>
+ + + + + + + + + + + <% for k, route in ipairs(routes) do + color = olsrtools.etx_color(tonumber(route.ETX)) + %> + + + + + + + + + <% + if i == 1 then i = 0 elseif i == 0 then i = 1 end + end %> +
<%:Announced network%><%:OLSR gateway%><%:Interface%><%:Metric%>ETX
<%=route.Destination%> + /cgi-bin-status.html"><%=route["Gateway IP"]%> + <% if route.Hostname then %> + / <%=route.Hostname%> + <% end %> + <%=route.Interface%><%=route.Metric%><%=string.format("%.3f", tonumber(route.ETX) or 0)%>
-
+ + <%+footer%> -- cgit v1.2.3