2 LuCI - Lua Configuration Interface
3 Copyright 2008 Steven Barth <steven@midlink.org>
4 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
5 Copyright 2011 Manuel Munz <freifunk at somakoma dot de>
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
16 local olsrtools = require "luci.tools.olsr"
19 if luci.http.formvalue("status") == "1" then
21 for k, route in ipairs(routes) do
23 hostname = route.Hostname,
24 dest = route.Destination,
25 gw = route["Gateway IP"],
26 interface = route.Interface,
27 metric = route.Metric,
28 etx = tonumber(route.ETX),
29 color = olsrtools.etx_color(tonumber(route.ETX)),
32 luci.http.prepare_content("application/json")
33 luci.http.write_json(rv)
41 <script type="text/javascript" src="<%=resource%>/cbi.js"></script>
42 <script type="text/javascript">//<![CDATA[
44 XHR.poll(20, '<%=REQUEST_URI%>', { status: 1 },
48 var rt = document.getElementById('olsrd_routes');
52 for (var idx = 0; idx < info.length; idx++)
54 var route = info[idx];
57 '<tr class="cbi-section-table-row cbi-rowstyle-'+(1 + (idx % 2))+'">' +
58 '<td class="cbi-section-table-cell">%s</td>' +
59 '<td class="cbi-section-table-cell">' +
60 '<a href="http://%s/cgi-bin-status.html">%s</a>',
61 route.dest, route.gw, route.gw
67 ' / <a href="http://%s/cgi-bin-status.html">%s</a>',
68 route.hostname, route.hostname || '?'
73 '<td class="cbi-section-table-cell">%s</td>' +
74 '<td class="cbi-section-table-cell">%s</td>' +
75 '<td class="cbi-section-table-cell" style="background-color:%s">%s</td>' +
77 route.interface, route.metric, route.color, route.etx || '?'
89 <h2><a id="content" name="content"><%:Known OLSR routes%></a></h2>
91 <fieldset class="cbi-section">
92 <legend><%:Overview of currently known routes to other OLSR nodes%></legend>
94 <table class="cbi-section-table">
96 <tr class="cbi-section-table-titles">
97 <th class="cbi-section-table-cell"><%:Announced network%></th>
98 <th class="cbi-section-table-cell"><%:OLSR gateway%></th>
99 <th class="cbi-section-table-cell"><%:Interface%></th>
100 <th class="cbi-section-table-cell"><%:Metric%></th>
101 <th class="cbi-section-table-cell">ETX</th>
105 <tbody id="olsrd_routes">
107 <% for k, route in ipairs(routes) do
108 color = olsrtools.etx_color(tonumber(route.ETX))
111 <tr class="cbi-section-table-row cbi-rowstyle-<%=i%>">
112 <td class="cbi-section-table-cell"><%=route.Destination%></td>
113 <td class="cbi-section-table-cell">
114 <a href="http://<%=route["Gateway IP"]%>/cgi-bin-status.html"><%=route["Gateway IP"]%></a>
115 <% if route.Hostname then %>
116 / <a href="http://<%=route.Hostname%>/cgi-bin-status.html"><%=route.Hostname%></a>
119 <td class="cbi-section-table-cell"><%=route.Interface%></td>
120 <td class="cbi-section-table-cell"><%=route.Metric%></td>
121 <td class="cbi-section-table-cell" style="background-color:<%=color%>"><%=string.format("%.3f", tonumber(route.ETX) or 0)%></td>