2010-12-05 19:06:18 +00:00
< %#
2015-01-16 22:38:38 +00:00
Copyright 2008 Steven Barth < steven @ midlink . org >
2015-01-16 22:46:42 +00:00
Copyright 2008 Jo-Philipp Wich < jow @ openwrt . org >
2015-01-16 22:38:38 +00:00
Copyright 2011 Manuel Munz < freifunk at somakoma dot de >
Licensed to the public under the Apache License 2.0.
2010-12-05 19:06:18 +00:00
-%>
2010-12-17 02:14:28 +00:00
2010-12-05 19:06:18 +00:00
< %
2011-11-09 18:12:25 +00:00
local i = 1
2010-12-05 19:06:18 +00:00
require("luci.model.uci")
local uci = luci.model.uci.cursor_state()
uci:foreach("olsrd", "olsrd", function(s)
if s.SmartGateway and s.SmartGateway == "yes" then has_smartgw = true end
end)
2013-03-16 18:08:13 +00:00
if luci.http.formvalue("status") == "1" then
local rv = {}
2018-11-05 15:27:40 +00:00
for k, gw in ipairs(gws.ipv4, gws.ipv6) do
gw.cost = tonumber(gw.cost)/1024 or 0
2018-11-15 13:55:42 +00:00
if gw.cost >= 100 then
2018-11-05 15:27:40 +00:00
gw.cost = 0
2013-03-16 18:08:13 +00:00
end
rv[#rv+1] = {
2018-11-05 15:27:40 +00:00
proto = gw.IPv4 and '4' or '6',
originator = gw.originator,
selected = gw.selected and luci.i18n.translate('yes') or luci.i18n.translate('no'),
2018-11-15 13:55:42 +00:00
cost = gw.cost > 0 and string.format("%.3f", gw.cost) or luci.i18n.translate('infinate'),
2018-11-05 15:27:40 +00:00
hops = gw.hops,
uplink = gw.uplink,
downlink = gw.downlink,
v4 = gw.IPv4 and luci.i18n.translate('yes') or luci.i18n.translate('no'),
v6 = gw.IPv6 and luci.i18n.translate('yes') or luci.i18n.translate('no'),
prefix = gw.prefix
2013-03-16 18:08:13 +00:00
}
end
luci.http.prepare_content("application/json")
luci.http.write_json(rv)
return
end
2010-12-05 19:06:18 +00:00
%>
2013-03-16 18:08:13 +00:00
< %+header%>
< script type = "text/javascript" > / / < ! [ C D A T A [
XHR.poll(10, '< %=REQUEST_URI%>', { status: 1 },
function(x, info)
{
var smartgwdiv = document.getElementById('olsrd_smartgw');
if (smartgwdiv)
{
var s = '';
for (var idx = 0; idx < info.length ; idx + + )
{
var smartgw = info[idx];
2018-10-28 21:38:20 +00:00
var linkgw;
2018-05-28 12:57:54 +00:00
s += '< div class = "tr cbi-section-table-row cbi-rowstyle-'+(1 + (idx % 2))+' proto-' + smartgw.proto + '" > '
2013-03-16 18:08:13 +00:00
if (smartgw.proto == '6') {
2018-11-05 15:27:40 +00:00
linkgw = '< a href = "http://[' + smartgw.originator + ']/cgi-bin-status.html" > ' + smartgw.originator + '< / a > '
2013-03-16 18:08:13 +00:00
} else {
2018-11-05 15:27:40 +00:00
linkgw = '< a href = "http://' + smartgw.originator + '/cgi-bin-status.html" > ' + smartgw.originator + '< / a > '
2013-03-16 18:08:13 +00:00
}
s += String.format(
2018-11-15 13:55:42 +00:00
'< div class = "td cbi-section-table-cell" style = "text-align: left" > %s< / div > ' +
'< div class = "td cbi-section-table-cell" style = "text-align: left" > %s< / div > ' +
'< div class = "td cbi-section-table-cell" style = "text-align: left" > %s< / div > ' +
'< div class = "td cbi-section-table-cell" style = "text-align: left" > %s< / div > ' +
'< div class = "td cbi-section-table-cell" style = "text-align: left" > %s< / div > ' +
'< div class = "td cbi-section-table-cell" style = "text-align: left" > %s< / div > ' +
'< div class = "td cbi-section-table-cell" style = "text-align: left" > %s< / div > ' +
'< div class = "td cbi-section-table-cell" style = "text-align: left" > %s< / div > ' +
'< div class = "td cbi-section-table-cell" style = "text-align: left" > %s< / div > ',
2018-11-05 15:27:40 +00:00
linkgw, smartgw.selected, smartgw.cost, smartgw.hops, smartgw.uplink, smartgw.downlink, smartgw.v4, smartgw.v6, smartgw.prefix
2013-03-16 18:08:13 +00:00
)
2018-05-28 12:57:54 +00:00
s += '< / div > '
2013-03-16 18:08:13 +00:00
}
smartgwdiv.innerHTML = s;
}
}
);
//]]>< / script >
2015-10-06 11:29:43 +00:00
< h2 name = "content" > < %:SmartGW announcements%>< / h2 >
2011-11-09 18:12:25 +00:00
2013-03-16 18:08:13 +00:00
< div id = "togglebuttons" > < / div >
2010-12-05 19:06:18 +00:00
< % if has_smartgw then %>
2011-11-09 18:12:25 +00:00
< fieldset class = "cbi-section" >
< legend > < %:Overview of smart gateways in this network%>< / legend >
2018-05-28 12:57:54 +00:00
< div class = "table cbi-section-table" >
< div class = "tr cbi-section-table-titles" >
< div class = "th cbi-section-table-cell" > < %:Gateway%>< / div >
2018-11-05 15:27:40 +00:00
< div class = "th cbi-section-table-cell" > < %:Selected%>< / div >
2018-05-28 12:57:54 +00:00
< div class = "th cbi-section-table-cell" > < %:ETX%>< / div >
< div class = "th cbi-section-table-cell" > < %:Hops%>< / div >
< div class = "th cbi-section-table-cell" > < %:Uplink%>< / div >
< div class = "th cbi-section-table-cell" > < %:Downlink%>< / div >
< div class = "th cbi-section-table-cell" > < %:IPv4%>< / div >
< div class = "th cbi-section-table-cell" > < %:IPv6%>< / div >
< div class = "th cbi-section-table-cell" > < %:Prefix%>< / div >
< / div >
2018-11-15 13:55:42 +00:00
< % for k, gw in ipairs(gws.ipv4, gws.ipv6) do
2013-03-16 18:08:13 +00:00
2018-11-05 15:27:40 +00:00
gw.cost = tonumber(gw.cost)/1024 or 0
2018-11-15 13:55:42 +00:00
if gw.cost >= 100 then
2018-11-05 15:27:40 +00:00
gw.cost = 0
2013-03-16 18:08:13 +00:00
end
%>
2018-05-28 12:57:54 +00:00
< div class = "tr cbi-section-table-row cbi-rowstyle-<%=i%> proto-<%=proto%>" >
2013-03-16 18:08:13 +00:00
< % if gw.proto == '6' then %>
2018-11-15 13:55:42 +00:00
< div class = "td cbi-section-table-cell" style = "text-align: left" > < a href = "http://[<%=gw.originator%>]/cgi-bin-status.html" > < %=gw.originator%>< / a > < / div >
2013-03-16 18:08:13 +00:00
< % else %>
2018-11-15 13:55:42 +00:00
< div class = "td cbi-section-table-cell" style = "text-align: left" > < a href = "http://<%=gw.originator%>/cgi-bin-status.html" > < %=gw.originator%>< / a > < / div >
2013-03-16 18:08:13 +00:00
< % end %>
2018-11-15 13:55:42 +00:00
< div class = "td cbi-section-table-cell" style = "text-align: left" > < %=gw.selected and luci.i18n.translate('yes') or luci.i18n.translate('no')%>< / div >
< div class = "td cbi-section-table-cell" style = "text-align: left" > < %=gw.cost > 0 and string.format("%.3f", gw.cost) or luci.i18n.translate('infinate')%>< / div >
< div class = "td cbi-section-table-cell" style = "text-align: left" > < %=gw.hops%>< / div >
< div class = "td cbi-section-table-cell" style = "text-align: left" > < %=gw.uplink%>< / div >
< div class = "td cbi-section-table-cell" style = "text-align: left" > < %=gw.downlink%>< / div >
< div class = "td cbi-section-table-cell" style = "text-align: left" > < %=gw.IPv4 and luci.i18n.translate('yes') or luci.i18n.translate('no')%>< / div >
< div class = "td cbi-section-table-cell" style = "text-align: left" > < %=gw.IPv6 and luci.i18n.translate('yes') or luci.i18n.translate('no')%>< / div >
< div class = "td cbi-section-table-cell" style = "text-align: left" > < %=gw.prefix%>< / div >
2018-05-28 12:57:54 +00:00
< / div >
2011-11-09 18:12:25 +00:00
2011-11-13 12:34:09 +00:00
< % i = ((i % 2) + 1)
2011-11-09 18:12:25 +00:00
end %>
2018-05-28 12:57:54 +00:00
< / div >
2011-11-09 18:12:25 +00:00
< / fieldset >
2010-12-05 19:06:18 +00:00
< % else %>
2011-11-09 18:12:25 +00:00
< %:SmartGateway is not configured on this system.%>
2010-12-05 19:06:18 +00:00
< % end %>
2011-11-09 18:12:25 +00:00
2013-03-16 18:08:13 +00:00
< %+status-olsr/common_js%>
2010-12-05 19:06:18 +00:00
< %+footer%>