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 if i == 1 then i = 0 elseif i == 0 then i = 1 end
34 luci.http.prepare_content("application/json")
35 luci.http.write_json(rv)
43 <script type="text/javascript" src="<%=resource%>/cbi.js"></script>
44 <script type="text/javascript">//<![CDATA[
46 XHR.poll(20, '<%=REQUEST_URI%>', { status: 1 },
50 var rt = document.getElementById('olsrd_routes');
54 for (var idx = 0; idx < info.length; idx++)
56 var route = info[idx];
59 '<tr class="cbi-section-table-row cbi-rowstyle-%s">' +
60 '<td class="cbi-section-table-cell">%s</td>' +
61 '<td class="cbi-section-table-cell">' +
62 '<a href="http://%s/cgi-bin-status.html">%s</a>',
63 route.rs, route.dest, route.gw, route.gw
69 ' / <a href="http://%s/cgi-bin-status.html">%s</a>',
70 route.hostname, route.hostname || '?'
75 '<td class="cbi-section-table-cell">%s</td>' +
76 '<td class="cbi-section-table-cell">%s</td>' +
77 '<td class="cbi-section-table-cell" style="background-color:%s">%s</td>' +
79 route.interface, route.metric, route.color, route.etx || '?'
91 <h2><a id="content" name="content"><%:Known OLSR routes%></a></h2>
93 <fieldset class="cbi-section">
94 <legend><%:Overview of currently known routes to other OLSR nodes%></legend>
96 <table class="cbi-section-table">
97 <tr class="cbi-section-table-titles">
98 <th class="cbi-section-table-cell"><%:Announced network%></th>
99 <th class="cbi-section-table-cell"><%:OLSR gateway%></th>
100 <th class="cbi-section-table-cell"><%:Interface%></th>
101 <th class="cbi-section-table-cell"><%:Metric%></th>
102 <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>
124 if i == 1 then i = 0 elseif i == 0 then i = 1 end