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">//<![CDATA[
48 XHR.poll(
10, '<%=REQUEST_URI%
>', { status:
1 },
51 var smartgwdiv = document.getElementById('olsrd_smartgw');
55 for (var idx =
0; idx < info.length; idx++)
57 var smartgw = info[idx];
58 s += '
<div class=
"tr cbi-section-table-row cbi-rowstyle-'+(1 + (idx % 2))+' proto-' + smartgw.proto + '">'
59 if (smartgw.proto == '
6') {
60 linkgw = '
<a href=
"http://[' + smartgw.ipAddress + ']/cgi-bin-status.html">' + smartgw.ipAddress + '
</a>'
62 linkgw = '
<a href=
"http://' + smartgw.ipAddress + '/cgi-bin-status.html">' + smartgw.ipAddress + '
</a>'
66 '
<div class=
"td cbi-section-table-cell">%s
</div>' +
67 '
<div class=
"td cbi-section-table-cell">%s
</div>' +
68 '
<div class=
"td cbi-section-table-cell">%s
</div>' +
69 '
<div class=
"td cbi-section-table-cell">%s
</div>' +
70 '
<div class=
"td cbi-section-table-cell">%s
</div>' +
71 '
<div class=
"td cbi-section-table-cell">%s
</div>' +
72 '
<div class=
"td cbi-section-table-cell">%s
</div>' +
73 '
<div class=
"td cbi-section-table-cell">%s
</div>' +
74 '
<div class=
"td cbi-section-table-cell">%s
</div>',
75 linkgw, smartgw.status, smartgw.tcPathCost, smartgw.hopCount, smartgw.uplinkSpeed, smartgw.downlinkSpeed, smartgw.v4, smartgw.v6, smartgw.externalPrefix
79 smartgwdiv.innerHTML = s;
88 <h2 name=
"content"><%:SmartGW announcements%
></h2>
90 <div id=
"togglebuttons"></div>
92 <% if has_smartgw then %
>
94 <fieldset class=
"cbi-section">
95 <legend><%:Overview of smart gateways in this network%
></legend>
96 <div class=
"table cbi-section-table">
98 <div class=
"tr cbi-section-table-titles">
99 <div class=
"th cbi-section-table-cell"><%:Gateway%
></div>
100 <div class=
"th cbi-section-table-cell"><%:Status%
></div>
101 <div class=
"th cbi-section-table-cell"><%:ETX%
></div>
102 <div class=
"th cbi-section-table-cell"><%:Hops%
></div>
103 <div class=
"th cbi-section-table-cell"><%:Uplink%
></div>
104 <div class=
"th cbi-section-table-cell"><%:Downlink%
></div>
105 <div class=
"th cbi-section-table-cell"><%:IPv4%
></div>
106 <div class=
"th cbi-section-table-cell"><%:IPv6%
></div>
107 <div class=
"th cbi-section-table-cell"><%:Prefix%
></div>
112 <div class=
"tbody" id=
"olsrd_smartgw">
113 <% for k, gw in ipairs(gws) do
115 gw.tcPathCost = tonumber(gw.tcPathCost)/
1024 or
0
116 if gw.tcPathCost ==
4096 then
121 <div class=
"tr cbi-section-table-row cbi-rowstyle-<%=i%> proto-<%=proto%>">
122 <% if gw.proto == '
6' then %
>
123 <div class=
"td cbi-section-table-cell"><a href=
"http://[<%=gw.ipAddress%>]/cgi-bin-status.html"><%=gw.ipAddress%
></a></div>
125 <div class=
"td cbi-section-table-cell"><a href=
"http://<%=gw.ipAddress%>/cgi-bin-status.html"><%=gw.ipAddress%
></a></div>
128 <div class=
"td cbi-section-table-cell"><%=gw.ipv4Status or gw.ipv6Status or '-' %
></div>
129 <div class=
"td cbi-section-table-cell"><%=string.format(
"%.3f", gw.tcPathCost)%
></div>
130 <div class=
"td cbi-section-table-cell"><%=gw.hopCount%
></div>
131 <div class=
"td cbi-section-table-cell"><%=gw.uplinkSpeed%
></div>
132 <div class=
"td cbi-section-table-cell"><%=gw.downlinkSpeed%
></div>
133 <div class=
"td cbi-section-table-cell"><%=gw.ipv4 and luci.i18n.translate('yes') or luci.i18n.translate('no')%
></div>
134 <div class=
"td cbi-section-table-cell"><%=gw.ipv6 and luci.i18n.translate('yes') or luci.i18n.translate('no')%
></div>
135 <div class=
"td cbi-section-table-cell"><%=gw.externalPrefix%
></div>
146 <%:SmartGateway is not configured on this system.%
>
150 <%+status-olsr/common_js%
>