029f585473931752f078e87d95ba98c3ff4686f8
[project/luci.git] / applications / luci-olsr / luasrc / view / status-olsr / neighbors.htm
1 <%#
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>
6
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
10
11 http://www.apache.org/licenses/LICENSE-2.0
12
13 -%>
14
15 <%
16 local olsrtools = require "luci.tools.olsr"
17 local i = 1
18
19 if luci.http.formvalue("status") == "1" then
20 local rv = {}
21 for k, link in ipairs(links) do
22 link.Cost = tonumber(link.Cost) or 0
23 local color = olsrtools.etx_color(link.Cost)
24 defaultgw_color = ""
25 if link.defaultgw == 1 then
26 defaultgw_color = "#ffff99"
27 end
28
29 rv[#rv+1] = {
30 rip = link["Remote IP"],
31 hn = link["Hostname"],
32 lip = link["Local IP"],
33 dev = link["Local Device"],
34 lq = link.LQ,
35 nlq = link.NLQ,
36 cost = string.format("%.3f", link.Cost),
37 color = color,
38 dfgcolor = defaultgw_color
39 }
40 end
41 luci.http.prepare_content("application/json")
42 luci.http.write_json(rv)
43 return
44 end
45 %>
46
47 <%+header%>
48
49 <script type="text/javascript" src="<%=resource%>/cbi.js"></script>
50 <script type="text/javascript">//<![CDATA[
51
52 XHR.poll(10 , '<%=REQUEST_URI%>', { status: 1 },
53 function(x, info)
54 {
55 var nt = document.getElementById('olsr_neigh_table');
56 if (nt)
57 {
58 var s = '';
59 for (var idx = 0; idx < info.length; idx++)
60 {
61 var neigh = info[idx];
62
63 s += String.format(
64 '<tr class="cbi-section-table-row cbi-rowstyle-'+(1 + (idx % 2))+'">' +
65 '<td class="cbi-section-table-cell" style="background-color:%s"><a href="http://%s/cgi-bin-status.html">%s</a></td>',
66 neigh.dfgcolor, neigh.rip, neigh.rip
67 );
68 if (neigh.hn) {
69 s += String.format(
70 '<td class="cbi-section-table-cell" style="background-color:%s"><a href="http://%s/cgi-bin-status.html">%s</a></td>',
71 neigh.dfgcolor, neigh.hn, neigh.hn
72 );
73 }
74 else {
75 s += String.format(
76 '<td class="cbi-section-table-cell" style="background-color:%s">?</td>',
77 neigh.dfgcolor
78 );
79 }
80 s += String.format(
81 '<td class="cbi-section-table-cell" style="background-color:%s">%s</td>' +
82 '<td class="cbi-section-table-cell" style="background-color:%s">%s</td>' +
83 '<td class="cbi-section-table-cell" style="background-color:%s">%s</td>' +
84 '<td class="cbi-section-table-cell" style="background-color:%s">%s</td>' +
85 '<td class="cbi-section-table-cell" style="background-color:%s">%s</td>' +
86 '</tr>',
87
88 neigh.dfgcolor, neigh.lip, neigh.dfgcolor, neigh.dev, neigh.dfgcolor, neigh.lq, neigh.dfgcolor, neigh.nlq, neigh.color, neigh.cost || '?'
89 );
90 }
91
92 nt.innerHTML = s;
93 }
94 }
95 );
96 //]]></script>
97
98
99 <h2><a id="content" name="content"><%:OLSR connections%></a></h2>
100
101 <fieldset class="cbi-section">
102 <legend><%:Overview of currently established OLSR connections%></legend>
103
104 <table class="cbi-section-table">
105 <thead>
106 <tr class="cbi-section-table-titles">
107 <th class="cbi-section-table-cell"><%:Neighbour IP%></th>
108 <th class="cbi-section-table-cell"><%:Hostname%></th>
109 <th class="cbi-section-table-cell"><%:Local interface IP%></th>
110 <th class="cbi-section-table-cell"><%:Device%></th>
111 <th class="cbi-section-table-cell">LQ</th>
112 <th class="cbi-section-table-cell">NLQ</th>
113 <th class="cbi-section-table-cell">ETX</th>
114 </tr>
115 </thead>
116
117 <tbody id="olsr_neigh_table">
118 <% local i = 1
119 for k, link in ipairs(links) do
120 link.Cost = tonumber(link.Cost) or 0
121 color = olsrtools.etx_color(link.Cost)
122
123 defaultgw_color = ""
124 if link.defaultgw == 1 then
125 defaultgw_color = "#ffff99"
126 end
127 %>
128
129 <tr class="cbi-section-table-row cbi-rowstyle-<%=i%>">
130 <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>
131 <td class="cbi-section-table-cell" style="background-color:<%=defaultgw_color%>"><a href="http://<%=link["Hostname"]%>/cgi-bin-status.html"><%=link["Hostname"]%></a></td>
132 <td class="cbi-section-table-cell" style="background-color:<%=defaultgw_color%>"><%=link["Local IP"]%></td>
133 <td class="cbi-section-table-cell" style="background-color:<%=defaultgw_color%>"><%=link["Local Device"]%></td>
134 <td class="cbi-section-table-cell" style="background-color:<%=defaultgw_color%>"><%=link.LQ%></td>
135 <td class="cbi-section-table-cell" style="background-color:<%=defaultgw_color%>"><%=link.NLQ%></td>
136 <td class="cbi-section-table-cell" style="background-color:<%=color%>"><%=string.format("%.3f", link.Cost)%></td>
137 </tr>
138 <%
139 i = ((i % 2) + 1)
140 end %>
141 </tbody>
142 </table>
143 <br />
144
145 <h3><%:Legend%>:</h3>
146 <ul>
147 <li><strong>LQ: </strong><%:Success rate of packages received from the neighbour%></li>
148 <li><strong>NLQ: </strong><%:Success rate of packages sent to the neighbour%></li>
149 <li><strong>ETX: </strong><%:Expected retransmission count%></li>
150 </ul>
151 </fieldset>
152 <%+footer%>