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
>=
100 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 = gw.cost
> 0 and string.format(
"%.3f", gw.cost) or luci.i18n.translate('infinate'),
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');
54 var s = '
<div class=
"tr cbi-section-table-titles">' +
55 '
<div class=
"th cbi-section-table-cell"><%:Gateway%
></div>' +
56 '
<div class=
"th cbi-section-table-cell"><%:Selected%
></div>' +
57 '
<div class=
"th cbi-section-table-cell"><%:ETX%
></div>' +
58 '
<div class=
"th cbi-section-table-cell"><%:Hops%
></div>' +
59 '
<div class=
"th cbi-section-table-cell"><%:Uplink%
></div>' +
60 '
<div class=
"th cbi-section-table-cell"><%:Downlink%
></div>' +
61 '
<div class=
"th cbi-section-table-cell"><%:IPv4%
></div>' +
62 '
<div class=
"th cbi-section-table-cell"><%:IPv6%
></div>' +
63 '
<div class=
"th cbi-section-table-cell"><%:Prefix%
></div>' +
66 for (var idx =
0; idx < info.length; idx++)
68 var smartgw = info[idx];
70 s += '
<div class=
"tr cbi-section-table-row cbi-rowstyle-'+(1 + (idx % 2))+' proto-' + smartgw.proto + '">'
71 if (smartgw.proto == '
6') {
72 linkgw = '
<a href=
"http://[' + smartgw.originator + ']/cgi-bin-status.html">' + smartgw.originator + '
</a>'
74 linkgw = '
<a href=
"http://' + smartgw.originator + '/cgi-bin-status.html">' + smartgw.originator + '
</a>'
78 '
<div class=
"td cbi-section-table-cell left">%s
</div>' +
79 '
<div class=
"td cbi-section-table-cell left">%s
</div>' +
80 '
<div class=
"td cbi-section-table-cell left">%s
</div>' +
81 '
<div class=
"td cbi-section-table-cell left">%s
</div>' +
82 '
<div class=
"td cbi-section-table-cell left">%s
</div>' +
83 '
<div class=
"td cbi-section-table-cell left">%s
</div>' +
84 '
<div class=
"td cbi-section-table-cell left">%s
</div>' +
85 '
<div class=
"td cbi-section-table-cell left">%s
</div>' +
86 '
<div class=
"td cbi-section-table-cell left">%s
</div>',
87 linkgw, smartgw.selected, smartgw.cost, smartgw.hops, smartgw.uplink, smartgw.downlink, smartgw.v4, smartgw.v6, smartgw.prefix
91 smartgwdiv.innerHTML = s;
97 <h2 name=
"content"><%:SmartGW announcements%
></h2>
99 <div id=
"togglebuttons"></div>
101 <% if has_smartgw then %
>
103 <fieldset class=
"cbi-section">
104 <legend><%:Overview of smart gateways in this network%
></legend>
105 <div class=
"table cbi-section-table" id=
"olsrd_smartgw">
106 <div class=
"tr cbi-section-table-titles">
107 <div class=
"th cbi-section-table-cell"><%:Gateway%
></div>
108 <div class=
"th cbi-section-table-cell"><%:Selected%
></div>
109 <div class=
"th cbi-section-table-cell"><%:ETX%
></div>
110 <div class=
"th cbi-section-table-cell"><%:Hops%
></div>
111 <div class=
"th cbi-section-table-cell"><%:Uplink%
></div>
112 <div class=
"th cbi-section-table-cell"><%:Downlink%
></div>
113 <div class=
"th cbi-section-table-cell"><%:IPv4%
></div>
114 <div class=
"th cbi-section-table-cell"><%:IPv6%
></div>
115 <div class=
"th cbi-section-table-cell"><%:Prefix%
></div>
118 <% for k, gw in ipairs(gws.ipv4, gws.ipv6) do
120 gw.cost = tonumber(gw.cost)/
1024 or
0
121 if gw.cost
>=
100 then
126 <div class=
"tr cbi-section-table-row cbi-rowstyle-<%=i%> proto-<%=proto%>">
127 <% if gw.proto == '
6' then %
>
128 <div class=
"td cbi-section-table-cell left"><a href=
"http://[<%=gw.originator%>]/cgi-bin-status.html"><%=gw.originator%
></a></div>
130 <div class=
"td cbi-section-table-cell left"><a href=
"http://<%=gw.originator%>/cgi-bin-status.html"><%=gw.originator%
></a></div>
133 <div class=
"td cbi-section-table-cell left"><%=gw.selected and luci.i18n.translate('yes') or luci.i18n.translate('no')%
></div>
134 <div class=
"td cbi-section-table-cell left"><%=gw.cost
> 0 and string.format(
"%.3f", gw.cost) or luci.i18n.translate('infinate')%
></div>
135 <div class=
"td cbi-section-table-cell left"><%=gw.hops%
></div>
136 <div class=
"td cbi-section-table-cell left"><%=gw.uplink%
></div>
137 <div class=
"td cbi-section-table-cell left"><%=gw.downlink%
></div>
138 <div class=
"td cbi-section-table-cell left"><%=gw.IPv4 and luci.i18n.translate('yes') or luci.i18n.translate('no')%
></div>
139 <div class=
"td cbi-section-table-cell left"><%=gw.IPv6 and luci.i18n.translate('yes') or luci.i18n.translate('no')%
></div>
140 <div class=
"td cbi-section-table-cell left"><%=gw.prefix%
></div>
150 <%:SmartGateway is not configured on this system.%
>
154 <%+status-olsr/common_js%
>