Merge pull request #1845 from dibdot/lxc_fix
[project/luci.git] / applications / luci-app-olsr / luasrc / view / status-olsr / hna.htm
1 <%#
2 Copyright 2008 Steven Barth <steven@midlink.org>
3 Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
4 Copyright 2011 Manuel Munz <freifunk at somakoma dot de>
5 Licensed to the public under the Apache License 2.0.
6 -%>
7
8 <%
9 local i = 1
10
11 if luci.http.formvalue("status") == "1" then
12 local rv = {}
13 for k, hna in ipairs(hna) do
14 rv[#rv+1] = {
15 proto = hna["proto"],
16 destination = hna["destination"],
17 genmask = hna["genmask"],
18 gateway = hna["gateway"],
19 hostname = hna["hostname"],
20 validityTime = hna["validityTime"]
21 }
22 end
23 luci.http.prepare_content("application/json")
24 luci.http.write_json(rv)
25 return
26 end
27 %>
28
29 <%+header%>
30
31 <script type="text/javascript" src="<%=resource%>/cbi.js"></script>
32 <script type="text/javascript">//<![CDATA[
33 XHR.poll(10, '<%=REQUEST_URI%>', { status: 1 },
34 function(x, info)
35 {
36 var hnadiv = document.getElementById('olsrd_hna');
37 if (hnadiv)
38 {
39 var s = '';
40 for (var idx = 0; idx < info.length; idx++)
41 {
42 var hna = info[idx];
43 var linkgw = ''
44 s += '<div class="tr cbi-section-table-row cbi-rowstyle-'+(1 + (idx % 2))+' proto-' + hna.proto + '">'
45 if (hna.proto == '6') {
46 linkgw = '<a href="http://[' + hna.gateway + ']/cgi-bin-status.html">' + hna.gateway + '</a>'
47 } else {
48 linkgw = '<a href="http://' + hna.gateway + '/cgi-bin-status.html">' + hna.gateway + '</a>'
49 }
50
51 if (hna.validityTime != undefined) {
52 validity = hna.validityTime + 's'
53 } else {
54 validity = '-'
55 }
56
57 if (hna.hostname != undefined) {
58 hostname = ' / <a href="http://' + hna.hostname + '/cgi-bin-status.html">' + hna.hostname + '</a>'
59 } else {
60 hostname = ''
61 }
62
63 s += String.format(
64 '<div class="td cbi-section-table-cell">%s</div>' +
65 '<div class="td cbi-section-table-cell">%s</div>' +
66 '<div class="td cbi-section-table-cell">%s</div>', hna.destination + '/' + hna.genmask, linkgw + hostname, validity
67 )
68 s += '</div>'
69 }
70 hnadiv.innerHTML = s;
71 }
72 }
73 );
74 //]]></script>
75
76 <h2 name="content"><%:Active host net announcements%></h2>
77
78 <div id="togglebuttons"></div>
79 <fieldset class="cbi-section">
80
81 <legend><%:Overview of currently active OLSR host net announcements%></legend>
82 <div class="table cbi-section-table">
83 <div class="thead">
84 <div class="tr cbi-section-table-titles">
85 <div class="th cbi-section-table-cell"><%:Announced network%></div>
86 <div class="th cbi-section-table-cell"><%:OLSR gateway%></div>
87 <div class="th cbi-section-table-cell"><%:Validity Time%></div>
88 </div>
89
90 </div>
91 <div class="tbody" id="olsrd_hna">
92 <% for k, route in ipairs(hna) do %>
93
94 <div class="tr cbi-section-table-row cbi-rowstyle-<%=i%> proto-<%=hna[k].proto%>">
95 <div class="td cbi-section-table-cell"><%=hna[k].destination%>/<%=hna[k].genmask%> </div>
96 <div class="td cbi-section-table-cell">
97 <% if hna[k].proto == '6' then %>
98 <a href="http://[<%=hna[k].gateway%>]/cgi-bin-status.html"><%=hna[k].gateway%></a>
99 <% else %>
100 <a href="http://<%=hna[k].gateway%>/cgi-bin-status.html"><%=hna[k].gateway%></a>
101 <% end %>
102 <% if hna[k].hostname then %>
103 / <a href="http://<%=hna[k].hostname%>/cgi-bin-status.html"><%=hna[k].hostname%></a>
104 <% end %>
105 </div>
106 <% if hna[k].validityTime then
107 validity = hna[k].validityTime .. 's'
108 else
109 validity = '-'
110 end %>
111
112 <div class="td cbi-section-table-cell"><%=validity%></div>
113 </div>
114
115 <% i = ((i % 2) + 1)
116 end %>
117 </div>
118 </div>
119 </fieldset>
120
121 <%+status-olsr/common_js%>
122 <%+footer%>