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.
10 require(
"luci.model.uci")
11 local uci = luci.model.uci.cursor_state()
13 uci:foreach(
"olsrd",
"olsrd", function(s)
14 if s.SmartGateway and s.SmartGateway ==
"yes" then has_smartgw = true end
18 if luci.http.formvalue(
"status") ==
"1" then
20 for k, gw in ipairs(gws) do
21 gw.tcPathCost = tonumber(gw.tcPathCost)/
1024 or
0
22 if gw.tcPathCost ==
4096 then
28 ipAddress = gw.ipAddress,
29 status = gw.ipv4Status or gw.ipv6Status,
30 tcPathCost = string.format(
"%.3f", gw.tcPathCost),
31 hopCount = gw.hopCount,
32 uplinkSpeed = gw.uplinkSpeed,
33 downlinkSpeed = gw.downlinkSpeed,
34 v4 = gw.ipv4 and luci.i18n.translate('yes') or luci.i18n.translate('no'),
35 v6 = gw.ipv6 and luci.i18n.translate('yes') or luci.i18n.translate('no'),
36 externalPrefix = gw.externalPrefix
39 luci.http.prepare_content(
"application/json")
40 luci.http.write_json(rv)
47 <script type=
"text/javascript" src=
"<%=resource%>/cbi.js"></script>
48 <script type=
"text/javascript">//<![CDATA[
49 XHR.poll(
10, '<%=REQUEST_URI%
>', { status:
1 },
52 var smartgwdiv = document.getElementById('olsrd_smartgw');
56 for (var idx =
0; idx < info.length; idx++)
58 var smartgw = info[idx];
59 s += '
<tr class=
"cbi-section-table-row cbi-rowstyle-'+(1 + (idx % 2))+' proto-' + smartgw.proto + '">'
60 if (smartgw.proto == '
6') {
61 linkgw = '
<a href=
"http://[' + smartgw.ipAddress + ']/cgi-bin-status.html">' + smartgw.ipAddress + '
</a>'
63 linkgw = '
<a href=
"http://' + smartgw.ipAddress + '/cgi-bin-status.html">' + smartgw.ipAddress + '
</a>'
67 '
<td class=
"cbi-section-table-cell">%s
</td>' +
68 '
<td class=
"cbi-section-table-cell">%s
</td>' +
69 '
<td class=
"cbi-section-table-cell">%s
</td>' +
70 '
<td class=
"cbi-section-table-cell">%s
</td>' +
71 '
<td class=
"cbi-section-table-cell">%s
</td>' +
72 '
<td class=
"cbi-section-table-cell">%s
</td>' +
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">%s
</td>',
76 linkgw, smartgw.status, smartgw.tcPathCost, smartgw.hopCount, smartgw.uplinkSpeed, smartgw.downlinkSpeed, smartgw.v4, smartgw.v6, smartgw.externalPrefix
80 smartgwdiv.innerHTML = s;
89 <h2 name=
"content"><%:SmartGW announcements%
></h2>
91 <div id=
"togglebuttons"></div>
93 <% if has_smartgw then %
>
95 <fieldset class=
"cbi-section">
96 <legend><%:Overview of smart gateways in this network%
></legend>
97 <table class=
"cbi-section-table">
99 <tr class=
"cbi-section-table-titles">
100 <th class=
"cbi-section-table-cell"><%:Gateway%
></th>
101 <th class=
"cbi-section-table-cell"><%:Status%
></th>
102 <th class=
"cbi-section-table-cell"><%:ETX%
></th>
103 <th class=
"cbi-section-table-cell"><%:Hops%
></th>
104 <th class=
"cbi-section-table-cell"><%:Uplink%
></th>
105 <th class=
"cbi-section-table-cell"><%:Downlink%
></th>
106 <th class=
"cbi-section-table-cell"><%:IPv4%
></th>
107 <th class=
"cbi-section-table-cell"><%:IPv6%
></th>
108 <th class=
"cbi-section-table-cell"><%:Prefix%
></th>
113 <tbody id=
"olsrd_smartgw">
114 <% for k, gw in ipairs(gws) do
116 gw.tcPathCost = tonumber(gw.tcPathCost)/
1024 or
0
117 if gw.tcPathCost ==
4096 then
122 <tr class=
"cbi-section-table-row cbi-rowstyle-<%=i%> proto-<%=proto%>">
123 <% if gw.proto == '
6' then %
>
124 <td class=
"cbi-section-table-cell"><a href=
"http://[<%=gw.ipAddress%>]/cgi-bin-status.html"><%=gw.ipAddress%
></a></td>
126 <td class=
"cbi-section-table-cell"><a href=
"http://<%=gw.ipAddress%>/cgi-bin-status.html"><%=gw.ipAddress%
></a></td>
129 <td class=
"cbi-section-table-cell"><%=gw.ipv4Status or gw.ipv6Status or '-' %
></td>
130 <td class=
"cbi-section-table-cell"><%=string.format(
"%.3f", gw.tcPathCost)%
></td>
131 <td class=
"cbi-section-table-cell"><%=gw.hopCount%
></td>
132 <td class=
"cbi-section-table-cell"><%=gw.uplinkSpeed%
></td>
133 <td class=
"cbi-section-table-cell"><%=gw.downlinkSpeed%
></td>
134 <td class=
"cbi-section-table-cell"><%=gw.ipv4 and luci.i18n.translate('yes') or luci.i18n.translate('no')%
></td>
135 <td class=
"cbi-section-table-cell"><%=gw.ipv6 and luci.i18n.translate('yes') or luci.i18n.translate('no')%
></td>
136 <td class=
"cbi-section-table-cell"><%=gw.externalPrefix%
></td>
147 <%:SmartGateway is not configured on this system.%
>
151 <%+status-olsr/common_js%
>