2 LuCI - Lua Configuration Interface
3 Copyright
2008 Steven Barth
<steven@midlink.org
>
4 Copyright
2008 Jo-Philipp Wich
<xm@leipzig.freifunk.net
>
5 Copyright
2011 Manuel Munz
<freifunk at somakoma dot de
>
7 Licensed under the Apache License, Version
2.0 (the
"License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-
2.0
16 require(
"luci.model.uci")
17 local uci = luci.model.uci.cursor_state()
19 uci:foreach(
"olsrd",
"olsrd", function(s)
20 if s.SmartGateway and s.SmartGateway ==
"yes" then has_smartgw = true end
24 if luci.http.formvalue(
"status") ==
"1" then
26 for k, gw in ipairs(gws) do
27 gw.tcPathCost = tonumber(gw.tcPathCost)/
1024 or
0
28 if gw.tcPathCost ==
4096 then
34 ipAddress = gw.ipAddress,
35 status = gw.ipv4Status or gw.ipv6Status,
36 tcPathCost = string.format(
"%.3f", gw.tcPathCost),
37 hopCount = gw.hopCount,
38 uplinkSpeed = gw.uplinkSpeed,
39 downlinkSpeed = gw.downlinkSpeed,
40 v4 = gw.ipv4 and luci.i18n.translate('yes') or luci.i18n.translate('no'),
41 v6 = gw.ipv6 and luci.i18n.translate('yes') or luci.i18n.translate('no'),
42 externalPrefix = gw.externalPrefix
45 luci.http.prepare_content(
"application/json")
46 luci.http.write_json(rv)
53 <script type=
"text/javascript" src=
"<%=resource%>/cbi.js"></script>
54 <script type=
"text/javascript">//<![CDATA[
55 XHR.poll(
10, '<%=REQUEST_URI%
>', { status:
1 },
58 var smartgwdiv = document.getElementById('olsrd_smartgw');
62 for (var idx =
0; idx < info.length; idx++)
64 var smartgw = info[idx];
65 s += '
<tr class=
"cbi-section-table-row cbi-rowstyle-'+(1 + (idx % 2))+' proto-' + smartgw.proto + '">'
66 if (smartgw.proto == '
6') {
67 linkgw = '
<a href=
"http://[' + smartgw.ipAddress + ']/cgi-bin-status.html">' + smartgw.ipAddress + '
</a>'
69 linkgw = '
<a href=
"http://' + smartgw.ipAddress + '/cgi-bin-status.html">' + smartgw.ipAddress + '
</a>'
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 '
<td class=
"cbi-section-table-cell">%s
</td>' +
77 '
<td class=
"cbi-section-table-cell">%s
</td>' +
78 '
<td class=
"cbi-section-table-cell">%s
</td>' +
79 '
<td class=
"cbi-section-table-cell">%s
</td>' +
80 '
<td class=
"cbi-section-table-cell">%s
</td>' +
81 '
<td class=
"cbi-section-table-cell">%s
</td>',
82 linkgw, smartgw.status, smartgw.tcPathCost, smartgw.hopCount, smartgw.uplinkSpeed, smartgw.downlinkSpeed, smartgw.v4, smartgw.v6, smartgw.externalPrefix
86 smartgwdiv.innerHTML = s;
95 <h2><a id=
"content" name=
"content"><%:SmartGW announcements%
></a></h2>
97 <div id=
"togglebuttons"></div>
99 <% if has_smartgw then %
>
101 <fieldset class=
"cbi-section">
102 <legend><%:Overview of smart gateways in this network%
></legend>
103 <table class=
"cbi-section-table">
105 <tr class=
"cbi-section-table-titles">
106 <th class=
"cbi-section-table-cell"><%:Gateway%
></th>
107 <th class=
"cbi-section-table-cell"><%:Status%
></th>
108 <th class=
"cbi-section-table-cell"><%:ETX%
></th>
109 <th class=
"cbi-section-table-cell"><%:Hops%
></th>
110 <th class=
"cbi-section-table-cell"><%:Uplink%
></th>
111 <th class=
"cbi-section-table-cell"><%:Downlink%
></th>
112 <th class=
"cbi-section-table-cell"><%:IPv4%
></th>
113 <th class=
"cbi-section-table-cell"><%:IPv6%
></th>
114 <th class=
"cbi-section-table-cell"><%:Prefix%
></th>
119 <tbody id=
"olsrd_smartgw">
120 <% for k, gw in ipairs(gws) do
122 gw.tcPathCost = tonumber(gw.tcPathCost)/
1024 or
0
123 if gw.tcPathCost ==
4096 then
128 <tr class=
"cbi-section-table-row cbi-rowstyle-<%=i%> proto-<%=proto%>">
129 <% if gw.proto == '
6' then %
>
130 <td class=
"cbi-section-table-cell"><a href=
"http://[<%=gw.ipAddress%>]/cgi-bin-status.html"><%=gw.ipAddress%
></a></td>
132 <td class=
"cbi-section-table-cell"><a href=
"http://<%=gw.ipAddress%>/cgi-bin-status.html"><%=gw.ipAddress%
></a></td>
135 <td class=
"cbi-section-table-cell"><%=gw.ipv4Status or gw.ipv6Status or '-' %
></td>
136 <td class=
"cbi-section-table-cell"><%=string.format(
"%.3f", gw.tcPathCost)%
></td>
137 <td class=
"cbi-section-table-cell"><%=gw.hopCount%
></td>
138 <td class=
"cbi-section-table-cell"><%=gw.uplinkSpeed%
></td>
139 <td class=
"cbi-section-table-cell"><%=gw.downlinkSpeed%
></td>
140 <td class=
"cbi-section-table-cell"><%=gw.ipv4 and luci.i18n.translate('yes') or luci.i18n.translate('no')%
></td>
141 <td class=
"cbi-section-table-cell"><%=gw.ipv6 and luci.i18n.translate('yes') or luci.i18n.translate('no')%
></td>
142 <td class=
"cbi-section-table-cell"><%=gw.externalPrefix%
></td>
153 <%:SmartGateway is not configured on this system.%
>
157 <%+status-olsr/common_js%
>