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, link in ipairs(links) do
22 link.linkCost = tonumber(link.linkCost)/
1024 or
0
23 if link.linkCost ==
4096 then
26 local color = olsrtools.etx_color(link.linkCost)
27 local snr_color = olsrtools.snr_color(link.snr)
29 if link.defaultgw ==
1 then
30 defaultgw_color =
"#ffff99"
38 lq = string.format(
"%.3f", link.linkQuality),
39 nlq = string.format(
"%.3f",link.neighborLinkQuality),
40 cost = string.format(
"%.3f", link.linkCost),
45 snr_color = snr_color,
46 dfgcolor = defaultgw_color,
50 luci.http.prepare_content(
"application/json")
51 luci.http.write_json(rv)
58 <script type=
"text/javascript" src=
"<%=resource%>/cbi.js"></script>
59 <script type=
"text/javascript">//<![CDATA[
61 XHR.poll(
10 , '<%=REQUEST_URI%
>', { status:
1 },
64 var nt = document.getElementById('olsr_neigh_table');
68 for (var idx =
0; idx < info.length; idx++)
70 var neigh = info[idx];
72 if (neigh.proto == '
6') {
74 '
<tr class=
"cbi-section-table-row cbi-rowstyle-'+(1 + (idx % 2))+' proto-%s">' +
75 '
<td class=
"cbi-section-table-titles" style=
"background-color:%s"><a href=
"http://[%s]/cgi-bin-status.html">%s
</a></td>',
76 neigh.proto, neigh.dfgcolor, neigh.rip, neigh.rip
80 '
<tr class=
"cbi-section-table-row cbi-rowstyle-'+(1 + (idx % 2))+' proto-%s">' +
81 '
<td class=
"cbi-section-table-titles" style=
"background-color:%s"><a href=
"http://%s/cgi-bin-status.html">%s
</a></td>',
82 neigh.proto, neigh.dfgcolor, neigh.rip, neigh.rip
87 '
<td class=
"cbi-section-table-titles" style=
"background-color:%s"><a href=
"http://%s/cgi-bin-status.html">%s
</a></td>',
88 neigh.dfgcolor, neigh.hn, neigh.hn
92 '
<td class=
"cbi-section-table-titles" style=
"background-color:%s">?
</td>',
97 '
<td class=
"cbi-section-table-titles" style=
"background-color:%s">%s
</td>' +
98 '
<td class=
"cbi-section-table-titles" style=
"background-color:%s">%s
</td>' +
99 '
<td class=
"cbi-section-table-titles" style=
"background-color:%s">%s
</td>' +
100 '
<td class=
"cbi-section-table-titles" style=
"background-color:%s">%s
</td>' +
101 '
<td class=
"cbi-section-table-titles" style=
"background-color:%s">%s
</td>' +
102 '
<td class=
"cbi-section-table-titles" style=
"background-color:%s" title=
"Signal: %s Noise: %s">%s
</td>' +
104 neigh.dfgcolor, neigh.ifn, neigh.dfgcolor, neigh.lip, neigh.dfgcolor, neigh.lq, neigh.dfgcolor, neigh.nlq, neigh.color, neigh.cost, neigh.snr_color, neigh.signal, neigh.noise, neigh.snr || '?'
115 <h2><a id=
"content" name=
"content"><%:OLSR connections%
></a></h2>
117 <div id=
"togglebuttons"></div>
119 <fieldset class=
"cbi-section">
120 <legend><%:Overview of currently established OLSR connections%
></legend>
122 <table class=
"cbi-section-table">
124 <tr class=
"cbi-section-table-titles">
125 <th class=
"cbi-section-table-cell"><%:Neighbour IP%
></th>
126 <th class=
"cbi-section-table-cell"><%:Hostname%
></th>
127 <th class=
"cbi-section-table-cell"><%:Interface%
></th>
128 <th class=
"cbi-section-table-cell"><%:Local interface IP%
></th>
129 <th class=
"cbi-section-table-cell">LQ
</th>
130 <th class=
"cbi-section-table-cell">NLQ
</th>
131 <th class=
"cbi-section-table-cell">ETX
</th>
132 <th class=
"cbi-section-table-cell">SNR
</th>
136 <tbody id=
"olsr_neigh_table">
138 for k, link in ipairs(links) do
139 link.linkCost = tonumber(link.linkCost)/
1024 or
0
140 if link.linkCost ==
4096 then
144 color = olsrtools.etx_color(link.linkCost)
145 snr_color = olsrtools.snr_color(link.snr)
147 if link.snr ==
0 then
152 if link.defaultgw ==
1 then
153 defaultgw_color =
"#ffff99"
157 <tr class=
"cbi-section-table-row cbi-rowstyle-<%=i%> proto-<%=link.proto%>">
158 <% if link.proto ==
"6" then %
>
159 <td class=
"cbi-section-table-titles" style=
"background-color:<%=defaultgw_color%>"><a href=
"http://[<%=link.remoteIP%>]/cgi-bin-status.html"><%=link.remoteIP%
></a></td>
161 <td class=
"cbi-section-table-titles" style=
"background-color:<%=defaultgw_color%>"><a href=
"http://<%=link.remoteIP%>/cgi-bin-status.html"><%=link.remoteIP%
></a></td>
163 <td class=
"cbi-section-table-titles" style=
"background-color:<%=defaultgw_color%>"><a href=
"http://<%=link.hostname%>/cgi-bin-status.html"><%=link.hostname%
></a></td>
164 <td class=
"cbi-section-table-titles" style=
"background-color:<%=defaultgw_color%>"><%=link.interface%
></td>
165 <td class=
"cbi-section-table-titles" style=
"background-color:<%=defaultgw_color%>"><%=link.localIP%
></td>
166 <td class=
"cbi-section-table-titles" style=
"background-color:<%=defaultgw_color%>"><%=string.format(
"%.3f", link.linkQuality)%
></td>
167 <td class=
"cbi-section-table-titles" style=
"background-color:<%=defaultgw_color%>"><%=string.format(
"%.3f", link.neighborLinkQuality)%
></td>
168 <td class=
"cbi-section-table-titles" style=
"background-color:<%=color%>"><%=string.format(
"%.3f", link.linkCost)%
></td>
169 <td class=
"cbi-section-table-titles" style=
"background-color:<%=snr_color%>" title=
"Signal: <%=link.signal%> Noise: <%=link.noise%>"><%=link.snr%
></td>
178 <%+status-olsr/legend%
>
180 <%+status-olsr/common_js%
>