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.ipv4, gws.ipv6) do
21 gw.cost = tonumber(gw.cost)/
1024 or
0
22 if gw.cost ==
4096 then
27 proto = gw.IPv4 and '
4' or '
6',
28 originator = gw.originator,
29 selected = gw.selected and luci.i18n.translate('yes') or luci.i18n.translate('no'),
30 cost = string.format(
"%.3f", gw.cost),
33 downlink = gw.downlink,
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'),
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];
59 s += '
<div class=
"tr cbi-section-table-row cbi-rowstyle-'+(1 + (idx % 2))+' proto-' + smartgw.proto + '">'
60 if (smartgw.proto == '
6') {
61 linkgw = '
<a href=
"http://[' + smartgw.originator + ']/cgi-bin-status.html">' + smartgw.originator + '
</a>'
63 linkgw = '
<a href=
"http://' + smartgw.originator + '/cgi-bin-status.html">' + smartgw.originator + '
</a>'
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 '
<div class=
"td cbi-section-table-cell">%s
</div>',
76 linkgw, smartgw.selected, smartgw.cost, smartgw.hops, smartgw.uplink, smartgw.downlink, smartgw.v4, smartgw.v6, smartgw.prefix
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 <div class=
"table cbi-section-table">
99 <div class=
"tr cbi-section-table-titles">
100 <div class=
"th cbi-section-table-cell"><%:Gateway%
></div>
101 <div class=
"th cbi-section-table-cell"><%:Selected%
></div>
102 <div class=
"th cbi-section-table-cell"><%:ETX%
></div>
103 <div class=
"th cbi-section-table-cell"><%:Hops%
></div>
104 <div class=
"th cbi-section-table-cell"><%:Uplink%
></div>
105 <div class=
"th cbi-section-table-cell"><%:Downlink%
></div>
106 <div class=
"th cbi-section-table-cell"><%:IPv4%
></div>
107 <div class=
"th cbi-section-table-cell"><%:IPv6%
></div>
108 <div class=
"th cbi-section-table-cell"><%:Prefix%
></div>
113 <div class=
"tbody" id=
"olsrd_smartgw">
114 <% for k, gw in ipairs(gws) do
116 gw.cost = tonumber(gw.cost)/
1024 or
0
117 if gw.cost ==
4096 then
122 <div class=
"tr cbi-section-table-row cbi-rowstyle-<%=i%> proto-<%=proto%>">
123 <% if gw.proto == '
6' then %
>
124 <div class=
"td cbi-section-table-cell"><a href=
"http://[<%=gw.originator%>]/cgi-bin-status.html"><%=gw.originator%
></a></div>
126 <div class=
"td cbi-section-table-cell"><a href=
"http://<%=gw.originator%>/cgi-bin-status.html"><%=gw.originator%
></a></div>
129 <div class=
"td cbi-section-table-cell"><%=gw.selected and luci.i18n.translate('yes') or luci.i18n.translate('no')%
></div>
130 <div class=
"td cbi-section-table-cell"><%=string.format(
"%.3f", gw.cost)%
></div>
131 <div class=
"td cbi-section-table-cell"><%=gw.hops%
></div>
132 <div class=
"td cbi-section-table-cell"><%=gw.uplink%
></div>
133 <div class=
"td cbi-section-table-cell"><%=gw.downlink%
></div>
134 <div class=
"td cbi-section-table-cell"><%=gw.IPv4 and luci.i18n.translate('yes') or luci.i18n.translate('no')%
></div>
135 <div class=
"td cbi-section-table-cell"><%=gw.IPv6 and luci.i18n.translate('yes') or luci.i18n.translate('no')%
></div>
136 <div class=
"td cbi-section-table-cell"><%=gw.prefix%
></div>
147 <%:SmartGateway is not configured on this system.%
>
151 <%+status-olsr/common_js%
>