From: p4u Date: Tue, 25 Dec 2012 01:10:30 +0000 (+0100) Subject: Merry christmas! Redesign of JavaScript code and many other things (graph, nodes... X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=53da163724972e59408c46db90125c05e9b42f2d;p=feed%2Frouting.git Merry christmas! Redesign of JavaScript code and many other things (graph, nodes view, etc.) --- diff --git a/files/usr/lib/lua/luci/controller/bmx6.lua b/files/usr/lib/lua/luci/controller/bmx6.lua index b701309..ed02a84 100644 --- a/files/usr/lib/lua/luci/controller/bmx6.lua +++ b/files/usr/lib/lua/luci/controller/bmx6.lua @@ -28,6 +28,7 @@ function index() local place = {} local ucim = require "luci.model.uci" local uci = ucim.cursor() + -- checking if ignore is on if uci:get("luci-bmx6","luci","ignore") == "1" then return nil @@ -47,28 +48,34 @@ function index() -- Starting with the pages --------------------------- - --- neighbours/descriptions (default) - entry(place,call("action_neighbours_j"),place[#place]) + --- status (default) + entry(place,call("action_status_j"),place[#place]) - table.insert(place,"neighbours_nojs") - entry(place, call("action_neighbours"), nil) + -- not visible + table.insert(place,"nodes_nojs") + entry(place, call("action_nodes"), nil) table.remove(place) - --- status (this is default one) - table.insert(place,"Status") - entry(place,call("action_status"),"Status") + --- nodes + table.insert(place,"Nodes") + entry(place,call("action_nodes_j"),"Nodes",1) table.remove(place) - --- links + --- links table.insert(place,"Links") - entry(place,call("action_links"),"Links").leaf = true + entry(place,call("action_links"),"Links",2).leaf = true table.remove(place) - -- Gateways - table.insert(place,"Gateways") - entry(place,call("action_gateways_j"),"Gateways").leaf = true + -- Tunnels + table.insert(place,"Tunnels") + entry(place,call("action_tunnels_j"), "Tunnels", 3).leaf = true table.remove(place) + -- Gateways (deprecated) + --table.insert(place,"Gateways") + --entry(place,call("action_gateways_j"),"Gateways").leaf = true + --table.remove(place) + --- chat table.insert(place,"Chat") entry(place,call("action_chat"),"Chat") @@ -76,7 +83,7 @@ function index() --- Graph table.insert(place,"Graph") - entry(place, template("bmx6/graph"), "Graph") + entry(place, template("bmx6/graph",4), "Graph") table.remove(place) --- Topology (hidden) @@ -86,22 +93,30 @@ function index() --- configuration (CBI) table.insert(place,"Configuration") - entry(place, cbi("bmx6/main"), "Configuration").dependent=false + entry(place, cbi("bmx6/main"), "Configuration",6).dependent=false + + table.insert(place,"General") + entry(place, cbi("bmx6/main"), "General",1) + table.remove(place) table.insert(place,"Advanced") - entry(place, cbi("bmx6/advanced"), "Advanced") + entry(place, cbi("bmx6/advanced"), "Advanced",5) table.remove(place) table.insert(place,"Interfaces") - entry(place, cbi("bmx6/interfaces"), "Interfaces") + entry(place, cbi("bmx6/interfaces"), "Interfaces",2) table.remove(place) + table.insert(place,"Tunnels") + entry(place, cbi("bmx6/tunnels"), "Tunnels",3) + table.remove(place) + table.insert(place,"Plugins") - entry(place, cbi("bmx6/plugins"), "Plugins") + entry(place, cbi("bmx6/plugins"), "Plugins",6) table.remove(place) - table.insert(place,"HNA") - entry(place, cbi("bmx6/hna"), "HNA") + table.insert(place,"HNAv6") + entry(place, cbi("bmx6/hna"), "HNAv6",4) table.remove(place) table.remove(place) @@ -119,7 +134,12 @@ function action_status() end end -function action_neighbours() +function action_status_j() + luci.template.render("bmx6/status_j", {}) +end + + +function action_nodes() local orig_list = bmx6json.get("originators").originators or nil if orig_list == nil then @@ -143,38 +163,27 @@ function action_neighbours() name = o.name end - --Not sure about that, but trying to find main ipv4 from HNA6 published by each node - if desc.DESC_ADV ~= nil then - for _,h in ipairs(desc.DESC_ADV.extensions[2].HNA6_EXTENSION) do - - if h ~= nil and string.find(h.address,"::ffff:") then - ipv4=string.gsub(h.address,"::ffff:","") - break - end - end - end - - if ipv4 == "" then - ipv4="0.0.0.0" - end - - table.insert(originators,{name=name,ipv4=ipv4,orig=orig,desc=desc}) + table.insert(originators,{name=name,orig=orig,desc=desc}) end - luci.template.render("bmx6/neighbours", {originators=originators}) + luci.template.render("bmx6/nodes", {originators=originators}) end -function action_neighbours_j() +function action_nodes_j() local http = require "luci.http" - local link_non_js = "/cgi-bin/luci" .. http.getenv("PATH_INFO") .. '/neighbours_nojs' + local link_non_js = "/cgi-bin/luci" .. http.getenv("PATH_INFO") .. '/nodes_nojs' - luci.template.render("bmx6/neighbours_j", {link_non_js=link_non_js}) + luci.template.render("bmx6/nodes_j", {link_non_js=link_non_js}) end function action_gateways_j() luci.template.render("bmx6/gateways_j", {}) end +function action_tunnels_j() + luci.template.render("bmx6/tunnels_j", {}) +end + function action_links(host) local links = bmx6json.get("links", host) @@ -199,39 +208,65 @@ function action_topology() local originators = bmx6json.get("originators/all") local o,i,l,i2 local first = true - luci.http.prepare_content("application/json") - luci.http.write('[ ') - - for i,o in ipairs(originators) do - local links = bmx6json.get("links",o.primaryIp) - if links then - if first then - first = false - else - luci.http.write(', ') - end - - luci.http.write('{ "globalId": "%s", "links": [' %o.globalId:match("^[^%.]+")) - - local first2 = true + local topology = '[ ' + local cache = '/tmp/bmx6-topology.json' + local offset = 60 - for i2,l in ipairs(links.links) do - if first2 then - first2 = false - else - luci.http.write(', ') - end + local cachefd = io.open(cache,r) + local update = false - luci.http.write('{ "globalId": "%s", "rxRate": %s, "txRate": %s }' - %{ l.globalId:match("^[^%.]+"), l.rxRate, l.txRate }) - - end - - luci.http.write(']}') + if cachefd ~= nil then + local lastupdate = tonumber(cachefd:read("*line")) or 0 + if os.time() >= lastupdate + offset then + update = true + else + topology = cachefd:read("*all") end + cachefd:close() + end + if cachefd == nil or update then + for i,o in ipairs(originators) do + local links = bmx6json.get("links",o.primaryIp) + if links then + if first then + first = false + else + topology = topology .. ', ' + end + + topology = topology .. '{ "globalId": "%s", "links": [' %o.globalId:match("^[^%.]+") + + local first2 = true + + for i2,l in ipairs(links.links) do + if first2 then + first2 = false + else + topology = topology .. ', ' + end + + topology = topology .. '{ "globalId": "%s", "rxRate": %s, "txRate": %s }' + %{ l.globalId:match("^[^%.]+"), l.rxRate, l.txRate } + + end + + topology = topology .. ']}' + end + + end + + topology = topology .. ' ]' + + -- Upgrading the content of the cache file + cachefd = io.open(cache,'w+') + cachefd:write(os.time()..'\n') + cachefd:write(topology) + cachefd:close() end - luci.http.write(' ]') + + luci.http.prepare_content("application/json") + luci.http.write(topology) end diff --git a/files/usr/lib/lua/luci/model/bmx6json.lua b/files/usr/lib/lua/luci/model/bmx6json.lua index 09c793e..dfe9ab1 100644 --- a/files/usr/lib/lua/luci/model/bmx6json.lua +++ b/files/usr/lib/lua/luci/model/bmx6json.lua @@ -163,3 +163,57 @@ function wget(url, timeout) end end +function getOptions(name) + -- Getting json and Checking if bmx6-json is avaiable + local options = get("options") + if options == nil or options.OPTIONS == nil then + m.message = "bmx6-json plugin is not running or some mistake in luci-bmx6 configuration, check /etc/config/luci-bmx6" + return nil + else + options = options.OPTIONS + end + + -- Filtering by the option name + local i,_ + local namedopt = nil + if name ~= nil then + for _,i in ipairs(options) do + if i.name == name and i.CHILD_OPTIONS ~= nil then + namedopt = i.CHILD_OPTIONS + break + end + end + end + + return namedopt +end + +-- Rturns a help string formated to be used in HTML scope +function getHtmlHelp(opt) + if opt == nil then return nil end + + local help = "" + if opt.help ~= nil then + help = text2html(opt.help) + end + if opt.syntax ~= nil then + help = help .. "
Syntax: " .. text2html(opt.syntax) + end + + return help +end + +function testandreload() + local test = sys.call('bmx6 -c --test > /tmp/bmx6-luci.err.tmp') + if test ~= 0 then + return sys.exec("cat /tmp/bmx6-luci.err.tmp") + end + + local err = sys.call('bmx6 -c --configReload > /tmp/bmx6-luci.err.tmp') + if err ~= 0 then + return sys.exec("cat /tmp/bmx6-luci.err.tmp") + end + + return nil +end + diff --git a/files/usr/lib/lua/luci/model/cbi/bmx6/hna.lua b/files/usr/lib/lua/luci/model/cbi/bmx6/hna.lua index cdf1c1f..a05620b 100644 --- a/files/usr/lib/lua/luci/model/cbi/bmx6/hna.lua +++ b/files/usr/lib/lua/luci/model/cbi/bmx6/hna.lua @@ -23,18 +23,18 @@ local sys = require("luci.sys") m = Map("bmx6", "bmx6") -local hna = m:section(TypedSection,"hna","HNA") +local hna = m:section(TypedSection,"hna","IPv6 HNA") hna.addremove = true -hna.anonymous = false -local hna_option = hna:option(Value,"hna", "Host Network Announcement") - -function hna_option:validate(value) - local err = sys.call('bmx6 -c --test -a ' .. value) - if err ~= 0 then - return nil - end - return value -end +hna.anonymous = true +local hna_option = hna:option(Value,"hna", "Host Network Announcement IPv6") + +--function hna_option:validate(value) +-- local err = sys.call('bmx6 -c --test -a ' .. value) +-- if err ~= 0 then +-- return nil +-- end +-- return value +--end function m.on_commit(self,map) local err = sys.call('bmx6 -c --configReload > /tmp/bmx6-luci.err.tmp') diff --git a/files/usr/lib/lua/luci/model/cbi/bmx6/main.lua b/files/usr/lib/lua/luci/model/cbi/bmx6/main.lua index dfd9517..8c114bf 100644 --- a/files/usr/lib/lua/luci/model/cbi/bmx6/main.lua +++ b/files/usr/lib/lua/luci/model/cbi/bmx6/main.lua @@ -38,10 +38,10 @@ local eth_int = luci.sys.net.devices() -- Getting the most important options from general local general = m:section(NamedSection,"general","general","General") general.addremove = false -general:option(Value,"globalPrefix","Global ip prefix","Specify global prefix for interfaces: NETADDR/LENGTH") +general:option(Value,"globalPrefix","Global ip prefix","Specify global prefix for interfaces: NETADDR/LENGTH. If you are using IPv6 leave blank to let bmx6 autoassign an ULA IPv6 address.") if m:get("ipVersion","ipVersion") == "6" then - general:option(Value,"tun4Address","NIIT IPv4 tunnel address","specify default IPv4 tunnel address and announced range (IP SHOULD be assigned to niit4to6 interface!)") + general:option(Value,"tun4Address","IPv4 address or range","specify default IPv4 tunnel address and announced range") end -- IP section @@ -90,7 +90,7 @@ end -- Interfaces section local interfaces = m:section(TypedSection,"dev","Devices","") interfaces.addremove = true -interfaces.anonymous = false +interfaces.anonymous = true local intlv = interfaces:option(ListValue,"dev","Device") for _,i in ipairs(eth_int) do diff --git a/files/usr/lib/lua/luci/model/cbi/bmx6/plugins.lua b/files/usr/lib/lua/luci/model/cbi/bmx6/plugins.lua index 3701e03..518864e 100644 --- a/files/usr/lib/lua/luci/model/cbi/bmx6/plugins.lua +++ b/files/usr/lib/lua/luci/model/cbi/bmx6/plugins.lua @@ -18,14 +18,14 @@ The full GNU General Public License is included in this distribution in the file called "COPYING". --]] +local sys = require("luci.sys") m = Map("bmx6", "bmx6") - plugins_dir = {"/usr/lib/","/var/lib","/lib"} plugin = m:section(TypedSection,"plugin","Plugin") plugin.addremove = true -plugin.anonymous = false +plugin.anonymous = true plv = plugin:option(ListValue,"plugin", "Plugin") for _,d in ipairs(plugins_dir) do @@ -38,5 +38,13 @@ for _,d in ipairs(plugins_dir) do end +function m.on_commit(self,map) + local err = sys.call('/etc/init.d/bmx6 restart') + if err ~= 0 then + m.message = sys.exec("Cannot restart bmx6") + end +end + + return m diff --git a/files/usr/lib/lua/luci/model/cbi/bmx6/tunnels.lua b/files/usr/lib/lua/luci/model/cbi/bmx6/tunnels.lua new file mode 100644 index 0000000..7a6bfd3 --- /dev/null +++ b/files/usr/lib/lua/luci/model/cbi/bmx6/tunnels.lua @@ -0,0 +1,75 @@ +--[[ + Copyright (C) 2011 Pau Escrich + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + The full GNU General Public License is included in this distribution in + the file called "COPYING". +--]] + +local sys = require("luci.sys") +local bmx6json = require("luci.model.bmx6json") + +m = Map("bmx6", "bmx6") + +-- tunOut +local tunnelsOut = m:section(TypedSection,"tunOut",translate("Networks to fetch"),translate("Tunnel announcements to fetch if possible")) +tunnelsOut.addremove = true +tunnelsOut.anonymous = true +tunnelsOut:option(Value,"tunOut","Name") +tunnelsOut:option(Value,"network", translate("Network to fetch")) + +local tunoptions = bmx6json.getOptions("tunOut") +local _,o +for _,o in ipairs(tunoptions) do + if o.name ~= nil and o.name ~= "network" then + help = bmx6json.getHtmlHelp(o) + value = tunnelsOut:option(Value,o.name,o.name,help) + value.optional = true + end +end + + +--tunIn +local tunnelsIn = m:section(TypedSection,"tunInNet",translate("Networks to offer"),translate("Tunnels to announce in the network")) +tunnelsIn.addremove = true +tunnelsIn.anonymous = true + +local net = tunnelsIn:option(Value,"tunInNet", translate("Network to offer")) +net.default = "10.0.0.0/8" + +local bwd = tunnelsIn:option(Value,"bandwidth",translate("Bandwidth (Bytes)")) +bwd.default = "1000000" + +local tuninoptions = bmx6json.getOptions("tunInNet") +local _,o +for _,o in ipairs(tuninoptions) do + if o.name ~= nil and o.name ~= "tunInNet" and o.name ~= "bandwidth" then + help = bmx6json.getHtmlHelp(o) + value = tunnelsIn:option(Value,o.name,o.name,help) + value.optional = true + end +end + +function m.on_commit(self,map) + --Not working. If test returns error the changes are still commited + local msg = bmx6json.testandreload() + if msg ~= nil then + m.message = msg + end +end + +return m + diff --git a/files/usr/lib/lua/luci/view/bmx6/graph.htm b/files/usr/lib/lua/luci/view/bmx6/graph.htm index af20de3..a4dabb7 100644 --- a/files/usr/lib/lua/luci/view/bmx6/graph.htm +++ b/files/usr/lib/lua/luci/view/bmx6/graph.htm @@ -1,15 +1,23 @@ <%# -LuCI - Lua Configuration Interface -Copyright 2012 Jo-Philipp Wich +Copyright (C) 2011 Pau Escrich +Contributors Jo-Philip -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. - http://www.apache.org/licenses/LICENSE-2.0 +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. -$Id$ +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +The full GNU General Public License is included in this distribution in +the file called "COPYING". -%> <% @@ -26,6 +34,17 @@ $Id$ + + +
+

+ +<%:Collecting data...%> + +
+ +
+ - -
- <%+footer%> diff --git a/files/usr/lib/lua/luci/view/bmx6/nodes.htm b/files/usr/lib/lua/luci/view/bmx6/nodes.htm new file mode 100644 index 0000000..18e5cc9 --- /dev/null +++ b/files/usr/lib/lua/luci/view/bmx6/nodes.htm @@ -0,0 +1,87 @@ +<%+header%> + + +

<%:Nodes%>

+ + + + + + + + + + + + +<% for i,o in ipairs(originators) do %> + + + + + + + + + + +<%end%> +
NameIPv6Via DevVia IPRoutesMetricLast DescLast Ref
<%=o.name%><%=o.orig.primaryIp%><%=o.orig.viaDev%><%=o.orig.viaIp%><%=o.orig.routes%><%=o.orig.metric%><%=o.orig.lastDesc%><%=o.orig.lastRef%>
+ + + + + + + +<% for i,o in ipairs(originators) do %> + + + + +<% end %> +
NodeAnnounced networks
<%=o.name%> + <% if o.desc.DESC_ADV ~= nil then %> + <% for j,h in ipairs(o.desc.DESC_ADV.extensions[2].HNA6_EXTENSION) do %> + <%=h.address%>     + <% end %> + <% end %> +
+ +
+<%+footer%> diff --git a/files/usr/lib/lua/luci/view/bmx6/nodes_j.htm b/files/usr/lib/lua/luci/view/bmx6/nodes_j.htm new file mode 100644 index 0000000..0435655 --- /dev/null +++ b/files/usr/lib/lua/luci/view/bmx6/nodes_j.htm @@ -0,0 +1,193 @@ +<%# + Copyright (C) 2011 Pau Escrich + Contributors Lluis Esquerda + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + The full GNU General Public License is included in this distribution in + the file called "COPYING". +-%> + +<%+header%> + + + + + +
+ +

Node originators

+
+
+
+
+ Click icon to see individual node information +
+
+
+ <%:Mesh nodes%> + + + + + + + + + + + + + + +
<%:Hostname%><%:Primary IP%><%:Via Device%><%:Metric%><%:Last Desc%><%:Last Ref%><%:Blocked%>

<%:Collecting data...%>
+
+ +
+ +Go to non JavaScript view + + + +<%+footer%> + diff --git a/files/usr/lib/lua/luci/view/bmx6/status.htm b/files/usr/lib/lua/luci/view/bmx6/status.htm index 0fa38d9..11e9682 100644 --- a/files/usr/lib/lua/luci/view/bmx6/status.htm +++ b/files/usr/lib/lua/luci/view/bmx6/status.htm @@ -1,6 +1,13 @@ <%+header%> + + +Bmx6 is a routing protocol for Linux based operating systems. Visit bmx6.net for more info. + +
+
+

Status of bmx6

diff --git a/files/usr/lib/lua/luci/view/bmx6/status_j.htm b/files/usr/lib/lua/luci/view/bmx6/status_j.htm new file mode 100644 index 0000000..5a4ca6a --- /dev/null +++ b/files/usr/lib/lua/luci/view/bmx6/status_j.htm @@ -0,0 +1,114 @@ +<%+header%> + + + + + +
+
+ +
+
+a mesh routing protocol for Linux devices.
+Visit bmx6.net for more info. +
+
+
+ +

status

+
+
+ <%:status%> +
+ + + + + + + + + + + + + + + + +
<%:Version%><%:Compat%><%:Code Version%><%:Global ID%><%:Primary IP%><%:Tun6Address%><%:Tun4Address%><%:Local ID%><%:Uptime%><%:Cpu load%><%:Nodes seen%>

<%:Collecting data...%>
+ + +
+ + <%:Network devices%> + + + + + + + + + + + + + + +
<%:Name%><%:State%><%:Type%><%:Rate%><%:Local IP%><%:Global IP%><%:Multicast IP%><%:is Primary%>

<%:Collecting data...%>
+
+ + + + + + +<%+footer%> + diff --git a/files/usr/lib/lua/luci/view/bmx6/tunnels_j.htm b/files/usr/lib/lua/luci/view/bmx6/tunnels_j.htm new file mode 100644 index 0000000..1b7ce42 --- /dev/null +++ b/files/usr/lib/lua/luci/view/bmx6/tunnels_j.htm @@ -0,0 +1,107 @@ +<%# + Copyright (C) 2011 Pau Escrich + Contributors Lluis Esquerda + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + The full GNU General Public License is included in this distribution in + the file called "COPYING". +-%> + + +<%+header%> + + + + + +
+ +

Gateways tunnel announcements

+
+
+ <%:Mesh gateways%> + + + + + + + + + + + + + + + + + + +
<%:Tunnel%><%:Node%><%:Network%><%:Bandwidth%><%:SearchNet%><%:Type%><%:Path Metric%><%:IP metric%><%:Tun metric%><%:Bonus%><%:search id%>

<%:Collecting data...%>
+
+ +
+ + + +<%+footer%> + diff --git a/files/www/luci-static/resources/bmx6/bmx6logo.png b/files/www/luci-static/resources/bmx6/bmx6logo.png new file mode 100644 index 0000000..12f7526 Binary files /dev/null and b/files/www/luci-static/resources/bmx6/bmx6logo.png differ diff --git a/files/www/luci-static/resources/bmx6/js/polling.js b/files/www/luci-static/resources/bmx6/js/polling.js new file mode 100644 index 0000000..8f81443 --- /dev/null +++ b/files/www/luci-static/resources/bmx6/js/polling.js @@ -0,0 +1,81 @@ +/* + Copyright (C) 2011 Pau Escrich + Contributors Lluis Esquerda + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + The full GNU General Public License is included in this distribution in + the file called "COPYING". +*/ + + +/* + Table pooler is a function to easy call XHR poller. + + new TablePooler(5,"/cgi-bin/bmx6-info", {'status':''}, "status_table", function(st){ + var table = Array() + table.push(st.first,st.second) + return table + } + Parameters are: + polling_time: time between pollings + json_url: the json url to fetch the data + json_call: the json call + output_table_id: the table where javascript will put the data + callback_function: the function that will be executed each polling_time + + The callback_function must return an array of arrays (matrix). + In the code st is the data obtained from the json call +*/ + + function TablePooler (time, jsonurl, getparams, table_id, callback) { + this.table = document.getElementById(table_id); + this.callback = callback; + this.jsonurl = jsonurl; + this.getparams = getparams; + this.time = time; + + this.clear = function(){ + /* clear all rows */ + while( this.table.rows.length > 1 ) this.table.deleteRow(1); + } + this.start = function(){ + XHR.poll(this.time, this.jsonurl, this.getparams, function(x, st){ + var data = this.callback(st); + var content, tr, td; + this.clear(); + for (var i = 0; i < data.length; i++){ + tr = this.table.insertRow(-1); + tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1); + + for (var j = 0; j < data[i].length; j++){ + td = tr.insertCell(-1); + if (data[i][j].length == 2) { + td.colSpan = data[i][j][1]; + content = data[i][j][0]; + } + else content = data[i][j]; + td.innerHTML = content; + } + } + }.bind(this)); + } + + + this.start(); + } + + + diff --git a/files/www/luci-static/resources/bmx6/link.png b/files/www/luci-static/resources/bmx6/link.png index d73a5e7..58977ff 100644 Binary files a/files/www/luci-static/resources/bmx6/link.png and b/files/www/luci-static/resources/bmx6/link.png differ diff --git a/files/www/luci-static/resources/bmx6/world.png b/files/www/luci-static/resources/bmx6/world.png new file mode 100644 index 0000000..29b53c9 Binary files /dev/null and b/files/www/luci-static/resources/bmx6/world.png differ diff --git a/files/www/luci-static/resources/bmx6/world_small.png b/files/www/luci-static/resources/bmx6/world_small.png new file mode 100644 index 0000000..f5f3105 Binary files /dev/null and b/files/www/luci-static/resources/bmx6/world_small.png differ