diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2014-12-03 15:17:05 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2015-01-08 16:26:20 +0100 |
commit | 1bb4822dca6113f73e3bc89e2acf15935e6f8e92 (patch) | |
tree | 35e16f100466e4e00657199b38bb3d87d52bf73f /modules/luci-mod-freifunk/luasrc/view | |
parent | 9edd0e46c3f880727738ce8ca6ff1c8b85f99ef4 (diff) |
Rework LuCI build system
* Rename subdirectories to their repective OpenWrt package names
* Make each LuCI module its own standalone package
* Deploy a shared luci.mk which is used by each module Makefile
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Diffstat (limited to 'modules/luci-mod-freifunk/luasrc/view')
9 files changed, 857 insertions, 0 deletions
diff --git a/modules/luci-mod-freifunk/luasrc/view/cbi/osmll_value.htm b/modules/luci-mod-freifunk/luasrc/view/cbi/osmll_value.htm new file mode 100644 index 0000000000..78b4dff91f --- /dev/null +++ b/modules/luci-mod-freifunk/luasrc/view/cbi/osmll_value.htm @@ -0,0 +1,55 @@ +<%# +cc-by-sa Andreas Pittrich <andreas.pittrich@web.de> +in behalf of the german pirate party (Piratenpartei) +www.piratenpartei.de + +$Id$ + +-%> +<%+cbi/valueheader%> + + <% if self:cfgvalue(section) ~= false then %> + <% if self.latfield and self.lonfield then %> + <input type="hidden" <%= attr("value", string.format('cbid.%s.%s.%s', self.config, section, self.latfield))..attr("id", cbid..".latfield")..attr("name", cbid..".latfield")%>/> + <input type="hidden" <%= attr("value", string.format('cbid.%s.%s.%s', self.config, section, self.lonfield))..attr("id", cbid..".lonfield")..attr("name", cbid..".lonfield")%>/> + <% end %> + <input type="hidden" <%= attr("value", self.centerlat)..attr("id", cbid..".centerlat")..attr("name", cbid..".centerlat")%>/> + <input type="hidden" <%= attr("value", self.centerlon)..attr("id", cbid..".centerlon")..attr("name", cbid..".centerlon")%>/> + <input type="hidden" <%= attr("value", self.zoom)..attr("id", cbid..".zoom")..attr("name", cbid..".zoom")%>/> + <% end %> + + <% if self.popup then %> + <input class="cbi-button cbi-input-button" type="button"<%= attr("name", cbid..".button")..attr("id", cbid..".button")..attr("value", self.displaytext)%> + onclick=" + popup=window.open('/luci-static/resources/OSMLatLon.htm', '<%=cbid%>.window', 'innerWidth=<%=self.width%>, innerHeight=<%=self.height%>, location=no, menubar=no, scrollbars=no, status=no, toolbar=no'); + popup.focus(); + " + /> + </div> + <div> + <% else %> + <input class="cbi-button cbi-input-button" type="button"<%= attr("name", cbid..".displayosm")..attr("id", cbid..".displayosm")..attr("value", self.displaytext)%> + onclick=" + document.getElementById('<%=cbid..".hideosm"%>').style.display='inline'; + document.getElementById('<%=cbid..".displayosm"%>').style.display='none'; + for(var i = 0; Math.min(i, window.frames.length)!=window.frames.lengths; i++){ + if(frames[i].name=='<%=cbid..".iframe"%>'){ + document.getElementById('<%=cbid..".iframediv"%>').style.display='block'; + frames[i].location.href='/luci-static/resources/OSMLatLon.htm'; + } + } + " + /> + <input class="cbi-button cbi-input-button" style="display:none" type="button"<%= attr("name", cbid..".hideosm")..attr("id", cbid..".hideosm")..attr("value", self.hidetext)%> + onclick=" + document.getElementById('<%=cbid..".displayosm"%>').style.display='inline'; + document.getElementById('<%=cbid..".hideosm"%>').style.display='none'; + document.getElementById('<%=cbid..".iframediv"%>').style.display='none'; + " + /> + </div> + <div class="cbi-value-osmiframesection" id="<%=cbid..".iframediv"%>" style="display:none"> + <iframe src="" <%= attr("id", cbid..".iframe")..attr("name", cbid..".iframe")..attr("width", self.width)..attr("height", self.height)%> frameborder="0" scrolling="no"></iframe> + <%end%> + +<%+cbi/valuefooter%> diff --git a/modules/luci-mod-freifunk/luasrc/view/freifunk-map/frame.htm b/modules/luci-mod-freifunk/luasrc/view/freifunk-map/frame.htm new file mode 100644 index 0000000000..b2e168363f --- /dev/null +++ b/modules/luci-mod-freifunk/luasrc/view/freifunk-map/frame.htm @@ -0,0 +1,29 @@ +<%+header%> + +<% + local has_latlon = false + local uci = require "luci.model.uci".cursor() + uci:foreach("olsrd", "LoadPlugin", function(s) + if s.library == "olsrd_nameservice.so.0.3" and s.latlon_file then + has_latlon = true + end + end) +%> + +<% if has_latlon then %> + <iframe style="width:100%; height:640px; border:none" src="<%=luci.dispatcher.build_url("freifunk/map/content")%>"></iframe> + <h3><%:Legend%>:</h3> + <ul> + <li><strong><span style="color:#00cc00"><%:Green%></span></strong>:<%:Very good (ETX < 2)%></li> + <li><strong><span style="color:#ffcb05"><%:Yellow%></span></strong>:<%:Good (2 < ETX < 4)%></li> + <li><strong><span style="color:#ff6600"><%:Orange%></span></strong>:<%:Still usable (4 < ETX < 10)%></li> + <li><strong><span style="color:#bb3333"><%:Red%></span></strong>:<%:Bad (ETX > 10)%></li> + </ul> + +<% else %> + <h2><%:Map Error%></h2> + <p><%_The OLSRd service is not configured to capture position data from the network.<br /> + Please make sure that the nameservice plugin is properly configured and that the <em>latlon_file</em> option is enabled.%></p> +<% end %> +<%+footer%> + diff --git a/modules/luci-mod-freifunk/luasrc/view/freifunk-map/map.htm b/modules/luci-mod-freifunk/luasrc/view/freifunk-map/map.htm new file mode 100644 index 0000000000..c3951f9c63 --- /dev/null +++ b/modules/luci-mod-freifunk/luasrc/view/freifunk-map/map.htm @@ -0,0 +1,118 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> + <head> + <title>Map</title> + </head> + + <body style="margin:0"> + <script src="//dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1&s=1" type="text/javascript"></script> + <script type="text/javascript"> + var alias = new Array; + var points = new Array; + var unkpos = new Array; + var lineid = 0; + onload=new Function("if(null!=window.ffmapinit)ffmapinit();"); + + function Mid(mainip,aliasip) + { + alias[aliasip]=mainip; + } + + function Node(mainip,lat,lon,ishna,hnaip,name) + { + points[mainip] = new VELatLong(lat, lon); + map.AddPushpin(new VEPushpin(mainip, points[mainip], + '<%=luci.config.main.resourcebase%>/freifunk-map/'+(ishna?'hna':'node')+'.gif', 'Node:'+name, + '<br><img src="<%=luci.config.main.resourcebase%>/freifunk-map/'+(ishna?'hna':'node')+'.gif">'+ + '<br>IP:'+mainip+'<br>DefGW:'+hnaip)); + } + + function Self(mainip,lat,lon,ishna,hnaip,name) + { + //map.SetDashboardSize(VEDashboardSize.Small); + map.LoadMap(new VELatLong(lat, lon), 15, VEMapStyle.Hybrid); + map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers); + map.ShowMiniMap(14, 474); + Node(mainip,lat,lon,ishna,hnaip,name); + } + + function Link(fromip,toip,lq,nlq,etx) + { + if (0==lineid && null!=window.ffmapstatic) ffmapstatic(); + if (null != alias[toip]) toip = alias[toip]; + if (null != alias[fromip]) fromip = alias[fromip]; + if (null != points[fromip] && null != points[toip]) + { + var color; + var red = 240; + var green = 0; + var blue = 0; + var w = 1 + + if (etx < 100) {red=252;green=102;blue=0;w=2}; + if (etx < 10) {red=255;green=203;blue=5;w=3}; + if (etx < 4) {red=240;green=255;blue=0;w=4}; + if (etx < 2) {red=0;green=204;blue=0;w=5}; + if (etx < 1) {red=80;green=0;blue=0;w=1}; + + map.AddPolyline(new VEPolyline('id'+lineid, [points[fromip], points[toip]], + new VEColor(red, green, blue, 0.5), w)); + + + } + else + { + if (null == points[toip]) unkpos[toip] = ''; + if (null == points[fromip]) unkpos[fromip] = ''; + } + lineid++; + } + + function PLink(fromip,toip,lq,nlq,etx,lata,lona,ishnaa,latb,lonb,ishnab) + { + Link(fromip,toip,lq,nlq,etx); + } + + function ffmapinit() + { + if(null!=window.map)map.Dispose(); + + var INFINITE = 99.99; + + map = new VEMap('ffmap'); + <% + local fd + local uci = require "luci.model.uci".cursor() + + uci:foreach("olsrd", "LoadPlugin", function(s) + if s.library == "olsrd_nameservice.so.0.3" and s.latlon_file then + fd = io.open(s.latlon_file) + end + end) + + if fd then + local data = fd:read("*a") + fd:close() + + if data then + local line + for line in data:gmatch("[^\n]+") do + if line:match(";$") then + write(line .. "\n") + else + break + end + end + end + end + %> + } + + function ffgoto(ip) + { + map.SetCenter(points[ip]); + } + </script> + <div id="ffmap" style="position:relative; width:100%; height:640px;"></div> + </body> +</html> diff --git a/modules/luci-mod-freifunk/luasrc/view/freifunk/adminindex.htm b/modules/luci-mod-freifunk/luasrc/view/freifunk/adminindex.htm new file mode 100644 index 0000000000..e0252ba891 --- /dev/null +++ b/modules/luci-mod-freifunk/luasrc/view/freifunk/adminindex.htm @@ -0,0 +1,51 @@ +<%+header%> +<% +local uci = require "luci.model.uci".cursor() +local contact = uci:get_all("freifunk", "contact") +local contacturl = luci.dispatcher.build_url(luci.dispatcher.context.path[1], "freifunk", "contact") +local hostname = uci:get_first ("system", "system", "hostname") +local latitude = uci:get_first ("system", "system", "latitude") +local longitude = uci:get_first ("system", "system", "longitude") +local location = uci:get_first ("system", "system", "location") +local basicsurl = luci.dispatcher.build_url(luci.dispatcher.context.path[1], "freifunk", "basics") +local nickname, name, mail +if not contact then + nickname, name, mail = "" +else + nickname = contact.nickname + name = contact.name + mail = contact.mail +end + +%> + +<h2><%:Freifunk Overview%></h2> + +<%:These pages will assist you in setting up your router for Freifunk or similar wireless community networks.%> +<p /> + +<% if not (hostname and latitude and longitude and location) then%> +<div class="error"> + <%:Basic settings are incomplete. Please go to%> <a href='<%=basicsurl%>'><%:Basic settings%></a> <%:and fill out all required fields.%> +</div> +<%end%> +<p /> + +<% if not (nickname and name and mail) then%> +<div class="error"> + <%:Contact information is incomplete. Please go to%> <a href='<%=contacturl%>'><%:Contact%></a> <%:and fill out all required fields.%> + <p /> +</div> +<%end%> + +<% uci:foreach("wireless", "wifi-device", function(section) + local device = section[".name"] + local url = luci.dispatcher.build_url(luci.dispatcher.context.path[1], "network", "wireless") + if section.diversity ~= "0" and section.disabled ~= "1" and section.type ~= "mac80211" then + print('<div class="error">' .. translate("Diversity is enabled for device") .. ' <b>' .. section[".name"] .. '</b>. ' + .. translate("Go to") .. ' <a href="' .. url .. '">' .. translate("wireless settings") .. '</a> ' .. + translate("to disable it.") .. '</div><p />') + end +end) %> + +<%+footer%> diff --git a/modules/luci-mod-freifunk/luasrc/view/freifunk/contact.htm b/modules/luci-mod-freifunk/luasrc/view/freifunk/contact.htm new file mode 100644 index 0000000000..2d79ccd406 --- /dev/null +++ b/modules/luci-mod-freifunk/luasrc/view/freifunk/contact.htm @@ -0,0 +1,70 @@ +<%# +LuCI - Lua Configuration Interface +Copyright 2008 Steven Barth <steven@midlink.org> +Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> +Copyright 2011 Manuel Munz <freifunk at somakoma dot de> + +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 + + http://www.apache.org/licenses/LICENSE-2.0 +-%> + +<%+header%> + +<% +local uci = require "luci.model.uci".cursor() +local contact = uci:get_all("freifunk", "contact") +local nickname, name, mail, phone, location, note +local lon = uci:get_first("system", "system", "longitude") +local lat = uci:get_first("system", "system", "latitude") + +if not contact then + nickname, name, homepage, mail, phone, location, note = "" +else + nickname = contact.nickname or "" + name = contact.name or "" + homepage = contact.homepage or {} + mail = contact.mail or "" + phone = contact.phone or "" + location = uci:get_first("system", "system", "location") or contact.location + note = contact.note or "" +end +%> + +<h2><a id="content" name="content"><%:Contact%></a></h2> + +<fieldset xmlns="http://www.w3.org/1999/xhtml" class="cbi-section"> +<legend><%:Operator%></legend> + <table cellspacing="10" width="100%" style="text-align:left"> + <tr><th width="33%"><%:Nickname%>:</th><td><%=nickname%></td></tr> + <tr><th width="33%"><%:Realname%>:</th><td><%=name%></td></tr> + <tr><th width="33%"><%:Homepage%>:</th><td> + <% for k, v in ipairs(homepage) do %> + <a href="<%=v%>"><%=v%></a><br /> + <% end %> + </td></tr> + <tr><th width="33%"><%:E-Mail%>:</th><td><a href="mailto:<%=mail%>"><%=mail%></a></td></tr> + <tr><th width="33%"><%:Phone%>:</th><td><%=phone%></td></tr> + </table> +</fieldset> + +<fieldset xmlns="http://www.w3.org/1999/xhtml" class="cbi-section"> +<legend><%:Location%></legend> + <table cellspacing="10" width="100%" style="text-align:left"> + <tr><th width="33%"><%:Location%>:</th><td><%=location%></td></tr> + <tr><th width="33%"><%:Coordinates%>:</th><td><%=lat%> <%=lon%> (<a href="<%=pcdata(luci.dispatcher.build_url("freifunk/map"))%>"><%:Show on map%>)</a></td></tr> + </table> +</fieldset> + +<% if note then %> +<fieldset xmlns="http://www.w3.org/1999/xhtml" class="cbi-section"> +<legend><%:Notice%></legend> + <table cellspacing="10" width="100%" style="text-align:left"> + <tr><td><%=note%></td></tr> + </table> +</fieldset> +<%end%> + +<%+footer%> diff --git a/modules/luci-mod-freifunk/luasrc/view/freifunk/index.htm b/modules/luci-mod-freifunk/luasrc/view/freifunk/index.htm new file mode 100644 index 0000000000..0fcec45971 --- /dev/null +++ b/modules/luci-mod-freifunk/luasrc/view/freifunk/index.htm @@ -0,0 +1,92 @@ +<%# +LuCI - Lua Configuration Interface +Copyright 2008 Steven Barth <steven@midlink.org> +Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> + +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 + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ + +-%> +<%+header%> +<% +local uci = require "luci.model.uci".cursor() +local tpl = require "luci.template" +local fs = require "luci.fs" +local ff = {} +local ff = uci:get_all("freifunk") + +if not ff or not ff.community.name then + community = "Freifunk" + DefaultText = "" + nickname = "No Nickname set" +else + community = ff.community.name + DefaultText = ff.community.DefaultText + nickname = ff.contact.nickname +end + +local co = "profile_" .. community +--local community = uci:get_first(co, "community", "name") or "Freifunk" +local url = uci:get_first(co, "community", "homepage") or "http://www.freifunk.net" + + +local usertext = fs.readfile("/www/luci-static/index_user.html") + +if DefaultText ~= "disabled" then + + defaulttext = '<h2><a id="content" name="content">'.. + (translate("Hello and welcome in the network of")).. + ' '.. + (community or "Freifunk Deutschland").. + '!</a></h2><p>'.. + translate("We are an initiative to establish a free, independent and open wireless mesh network.").. + '<br />'.. + translate("This is the access point").. + ' '.. + luci.sys.hostname().. + '. '.. + translate("It is operated by").. + ' <a href="'.. + luci.dispatcher.build_url("freifunk", "contact").. + '">'.. + (nickname or translate("Please set your contact information")).. + '</a>.</p><p>'.. + translate("You can find further information about the global Freifunk initiative at").. + ' <a href="http://freifunk.net">Freifunk.net</a>.<br />'.. + translate("If you are interested in our project then contact the local community").. + ' <a href="'..url..'">'..community..'</a>.</p><p><strong>'.. + translate("Notice").. + '</strong>: '.. + translate("Internet access depends on technical and organisational conditions and may or may not work for you.").. + '</p>' +end +%> + +<%=defaulttext%> +<%=usertext%> + +<% +-- add custom widgets from view/freifunk/widgets +local widgets = {} +local dir = "/usr/lib/lua/luci/view/freifunk/widgets" + +uci:foreach("freifunk-widgets", "widget", + function(s) + if s.enabled == "1" then + table.insert(widgets, s) + end + end) + +for k, v in ipairs(widgets) do + if v['template'] and fs.access(dir .. "/" .. v['template'] .. "/main.htm") then + tpl.render("freifunk/widgets/" .. v['template'] .. "/main", { data = v }) + end +end + +%> +<%+footer%> diff --git a/modules/luci-mod-freifunk/luasrc/view/freifunk/profile_error.htm b/modules/luci-mod-freifunk/luasrc/view/freifunk/profile_error.htm new file mode 100644 index 0000000000..984fa0acfc --- /dev/null +++ b/modules/luci-mod-freifunk/luasrc/view/freifunk/profile_error.htm @@ -0,0 +1,11 @@ +<%+header%> + +<% +local profileurl = luci.dispatcher.build_url(luci.dispatcher.context.path[1], "freifunk", "basics") +%> + +<h2><%:Error%></h2> +<%:You need to select a profile before you can edit it. To select a profile go to%> <a href='<%=profileurl%>'><%:Basic settings%></a>. +<p/> + +<%+footer%> diff --git a/modules/luci-mod-freifunk/luasrc/view/freifunk/public_status.htm b/modules/luci-mod-freifunk/luasrc/view/freifunk/public_status.htm new file mode 100644 index 0000000000..10bd849d7d --- /dev/null +++ b/modules/luci-mod-freifunk/luasrc/view/freifunk/public_status.htm @@ -0,0 +1,372 @@ +<% +local sys = require "luci.sys" +local twa = require "luci.tools.webadmin" + +-- System +local model, system, memtotal, memcached, membuffers, memfree, bogomips = sys.sysinfo() +local uptime = twa.date_format(tonumber(sys.uptime())) +local time = os.date("%a, %d %b %Y, %H:%M:%S") +local load1, load5, load15 = sys.loadavg() +local load = string.format("%.2f, %.2f, %.2f", load1, load5, load15) + +local mem = string.format( + "%.2f MB (%.2f %s, %.2f %s, %.2f %s, %.2f %s)", + tonumber(memtotal) / 1024, + tonumber(memtotal - memfree) / 1024, + tostring(i18n.translate("used")), + memfree / 1024, + tostring(i18n.translate("free")), + memcached / 1024, + tostring(i18n.translate("cached")), + membuffers / 1024, + tostring(i18n.translate("buffered")) +) + +-- update interval +local bogomips = bogomips or 100 +local interval = 10 +if bogomips > 350 then + interval = 5 +end + +-- wireless +local ntm = require "luci.model.network".init() +local devices = ntm:get_wifidevs() +local netlist = { } +local netdevs = { } +local dev +for _, dev in ipairs(devices) do + local net + for _, net in ipairs(dev:get_wifinets()) do + netlist[#netlist+1] = net:ifname() + netdevs[net:ifname()] = dev:name() + end +end +local has_iwinfo = pcall(require, "iwinfo") + +-- Routes +local defroutev4 = sys.net.defaultroute() +local defroutev6 = sys.net.defaultroute6() + +if defroutev4 then + defroutev4.dest = defroutev4.dest:string() + defroutev4.gateway = defroutev4.gateway:string() +else + -- probably policy routing activated, try olsr-default table + local dr4 = sys.exec("ip r s t olsr-default") + if dr4 then + defroutev4 = { } + defroutev4.dest, defroutev4.gateway, defroutev4.device, defroutev4.metric = dr4:match("^(%w+) via (%d+.%d+.%d+.%d+) dev ([%w-]+) +metric (%d+)") + end +end + +if defroutev6 then + defroutev6.dest = defroutev6.dest:string() + defroutev6.nexthop = defroutev6.nexthop:string() +end + +if luci.http.formvalue("status") == "1" then + local rv = { } + for dev in pairs(netdevs) do + local j = { id = dev } + local iw = luci.sys.wifi.getiwinfo(dev) + if iw then + local f + for _, f in ipairs({ + "channel", "txpower", "bitrate", "signal", "noise", + "quality", "quality_max", "mode", "ssid", "bssid", "encryption", "ifname" + }) do + j[f] = iw[f] + end + end + rv[#rv+1] = j + end + + if defroutev6 then + def6 = { + gateway = defroutev6.nexthop, + dest = defroutev6.dest, + dev = defroutev6.device, + metr = defroutev6.metric + } + end + + if defroutev4 then + def4 = { + gateway = defroutev4.gateway, + dest = defroutev4.dest, + dev = defroutev4.device, + metr = defroutev4.metric + } + end + + rv[#rv+1] = { + time = time, + uptime = uptime, + load = load, + mem = mem, + defroutev4 = def4, + defroutev6 = def6 + } + + luci.http.prepare_content("application/json") + luci.http.write_json(rv) + return +end +-%> + +<%+header%> + +<script type="text/javascript" src="<%=resource%>/cbi.js"></script> + +<script type="text/javascript">//<![CDATA[ + XHR.poll(<%=interval%> , '<%=REQUEST_URI%>', { status: 1 }, + function(x, st) + { + if (st) + { + for( var i = 0; i < st.length; i++ ) + { + var iw = st[i]; + var is_assoc = (iw.bssid && iw.channel); + var p = (100 / iw.quality_max * iw.quality); + var q = is_assoc ? p : -1; + + var icon; + if (q < 0) + icon = "<%=resource%>/icons/signal-none.png"; + else if (q == 0) + icon = "<%=resource%>/icons/signal-0.png"; + else if (q < 25) + icon = "<%=resource%>/icons/signal-0-25.png"; + else if (q < 50) + icon = "<%=resource%>/icons/signal-25-50.png"; + else if (q < 75) + icon = "<%=resource%>/icons/signal-50-75.png"; + else + icon = "<%=resource%>/icons/signal-75-100.png"; + + var power = document.getElementById(iw.id + '-txpower'); + if (power) + power.innerHTML = String.format('%s dbm', iw.txpower); + + var signal = document.getElementById(iw.id + '-signal'); + if (signal) + signal.innerHTML = String.format( + '<img src="%s" title="Signal: %s db / Noise: %s db" alt="Signal Quality" />', + icon, iw.signal, iw.noise + ); + + var bitrate = document.getElementById(iw.id + '-bitrate'); + if (bitrate) + bitrate.innerHTML = String.format('%s Mb/s', iw.bitrate ? iw.bitrate / 1000 : '?'); + + var ssid = document.getElementById(iw.id + '-ssid'); + if (ssid) + ssid.innerHTML = iw.ssid; + + var bssid = document.getElementById(iw.id + '-bssid'); + if (bssid) + bssid.innerHTML = iw.bssid; + + var channel = document.getElementById(iw.id + '-channel'); + if (channel) + channel.innerHTML = iw.channel; + + var mode = document.getElementById(iw.id + '-mode'); + if (mode) + mode.innerHTML = iw.mode; + } + + i = st.length - 1 + var u + + if (u = document.getElementById('dynuptime')) + u.innerHTML = st[i].uptime; + + if (u = document.getElementById('dynload')) + u.innerHTML = st[i].load; + + if (u = document.getElementById('dynmem')) + u.innerHTML = st[i].mem; + + if (u = document.getElementById('dyntime')) + u.innerHTML = st[i].time; + + if (st[i].defroutev4) + { + if (u = document.getElementById('v4dst')) + u.innerHTML = st[i].defroutev4.dest; + + if (u = document.getElementById('v4gw')) + u.innerHTML = st[i].defroutev4.gateway; + + if (u = document.getElementById('v4dev')) + u.innerHTML = st[i].defroutev4.dev; + + if (u = document.getElementById('v4metr')) + u.innerHTML = st[i].defroutev4.metr; + } + + if (st[i].defroutev6) + { + if (u = document.getElementById('v6dst')) + u.innerHTML = st[i].defroutev6.dest; + + if (u = document.getElementById('v6gw')) + u.innerHTML = st[i].defroutev6.gateway; + + if (u = document.getElementById('v6dev')) + u.innerHTML = st[i].defroutev6.dev; + + if (u = document.getElementById('v6metr')) + u.innerHTML = st[i].defroutev6.metr; + } + } + } + ); +//]]></script> + +<div class="cbi-map"> + <h2><%:System%></h2> + <div class="cbi-section-node"> + <div class="cbi-value"><label class="cbi-value-title"><%:System%></label><div class="cbi-value-field"><%=system%></div></div> + <div class="cbi-value"><label class="cbi-value-title"><%:Processor%></label><div class="cbi-value-field"><%=model%></div></div> + <div class="cbi-value"><label class="cbi-value-title"><%:Load%></label><div class="cbi-value-field" id="dynload"><%=load%></div></div> + <div class="cbi-value"><label class="cbi-value-title"><%:Memory%></label><div class="cbi-value-field" id="dynmem"><%=mem%></div></div> + <div class="cbi-value"><label class="cbi-value-title"><%:Local Time%></label><div class="cbi-value-field" id="dyntime"><%=time%></div></div> + <div class="cbi-value"><label class="cbi-value-title"><%:Uptime%></label><div class="cbi-value-field" id="dynuptime"><%=uptime%></div></div> + </div> +</div> + +<% if devices[1] then %> + +<div class="cbi-map"> + <h2><%:Wireless Overview%></h2> + + <% if not has_iwinfo then %> + <div class="errorbox"> + <strong><%:Package libiwinfo required!%></strong><br /> + <%_The <em>libiwinfo</em> package is not installed. You must install this component for working wireless configuration!%> + </div> + <% end %> + + <div class="cbi-section"> + <div class="cbi-section-node"> + <table class="cbi-section-table"> + <tr class="cbi-section-table-titles"> + <th class="cbi-section-table-cell"><%:Signal%></th> + <th class="cbi-section-table-cell"><%:Bitrate%></th> + <th class="cbi-section-table-cell"><%:SSID%></th> + <th class="cbi-section-table-cell"><%:BSSID%></th> + <th class="cbi-section-table-cell"><%:Channel%></th> + <th class="cbi-section-table-cell"><%:Mode%></th> + <th class="cbi-section-table-cell"><%:TX%>-<%:Power%></th> + <th class="cbi-section-table-cell"><%:Interface%></th> + </tr> + <% + for _, dev in ipairs(devices) do + local net + for _, net in ipairs(dev:get_wifinets()) do + netlist[#netlist+1] = net:ifname() + netdevs[net:ifname()] = dev:name() + + if net.iwdata.device then + local signal = net.iwinfo.signal or "N/A" + local noise = net.iwinfo.noise or "N/A" + local q = net.iwinfo.quality or "0" + local qmax = net.iwinfo.quality_max or "100" + local qperc = q / qmax * 100 + + if qperc == 0 then + icon = "signal-none.png" + elseif qperc < 26 then + icon = "signal-0-25.png" + elseif qperc < 51 then + icon = "signal-25-50.png" + elseif qperc < 76 then + icon = "signal-50-75.png" + elseif qperc < 100 then + icon = "signal-75-100.png" + else + icon = "signal-0.png" + end + + signal_string = "<img src='"..resource.."/icons/"..icon.."' title='Signal: "..signal.." db / Noise: "..noise.." db' alt='Signal Quality'></img>" + + local ssid = net.iwinfo.ssid or "N/A" + local bssid = net.iwinfo.bssid or "N/A" + local chan = net.iwinfo.channel or "N/A" + local mode = net.iwinfo.mode or "N/A" + local txpwr = net.iwinfo.txpower or "N/A" + if txpwr ~= "N/A" then + txpwr = txpwr.." dbm" + end + local bitrate = net.iwinfo.bitrate or "N/A" + if bitrate ~= "N/A" then + bitrate = ( bitrate / 1000 ).."Mb/s" + end + local interface = net.iwdata.ifname or "N/A" + %> + <tr class="cbi-section-table-row cbi-rowstyle-1"> + <td class="cbi-value-field" id="<%=net:ifname()%>-signal"><%=signal_string%></td> + <td class="cbi-value-field" id="<%=net:ifname()%>-bitrate"><%=bitrate%></td> + <td class="cbi-value-field" id="<%=net:ifname()%>-ssid"><%=ssid%></td> + <td class="cbi-value-field" id="<%=net:ifname()%>-bssid"><%=bssid%></td> + <td class="cbi-value-field" id="<%=net:ifname()%>-channel"><%=chan%></td> + <td class="cbi-value-field" id="<%=net:ifname()%>-mode"><%=mode%></td> + <td class="cbi-value-field" id="<%=net:ifname()%>-txpower"><%=txpwr%></td> + <td class="cbi-value-field"><%=interface%></td> + </tr> + <% end + end + end %> + </table> + </div> + </div> +</div> +<% end %> + +<div class="cbi-map"> + <h2><%:Default routes%></h2> + <div class="cbi-section"> + <div class="cbi-section-node"> + +<% if not defroutev4 and not defroutev6 then %> + <%:No default routes known.%> +<%else%> + <table class="cbi-section-table"> + <tr class="cbi-section-table-titles"> + <th class="cbi-section-table-cell"><%:Network%></th> + <th class="cbi-section-table-cell"><%:Interface%></th> + <th class="cbi-section-table-cell"><%:Gateway%></th> + <th class="cbi-section-table-cell"><%:Metric%></th> + </tr> + + <% if defroutev4 then %> + + <tr class="cbi-section-table-row cbi-rowstyle-1"> + <td class="cbi-value-field" id="v4dst"><%=defroutev4.dest%></td> + <td class="cbi-value-field" id="v4dev"><%=defroutev4.device%></td> + <td class="cbi-value-field" id="v4gw"><%=defroutev4.gateway%></td> + <td class="cbi-value-field" id="v4metr"><%=defroutev4.metric%></td> + </tr> + + <% end + if defroutev6 then %> + + <tr class="cbi-section-table-row cbi-rowstyle-2"> + <td class="cbi-value-field" id="v6dst"><%=defroutev6.dest%></td> + <td class="cbi-value-field" id="v6dev"><%=defroutev6.device%></td> + <td class="cbi-value-field" id="v6gw"><%=defroutev6.nexthop%></td> + <td class="cbi-value-field" id="v6metr"><%=defroutev6.metric%></td> + </tr> + + <% end %> + + </table> +<% end %> + </div> + </div> +</div> +<%+footer%> diff --git a/modules/luci-mod-freifunk/luasrc/view/freifunk/remote_update.htm b/modules/luci-mod-freifunk/luasrc/view/freifunk/remote_update.htm new file mode 100644 index 0000000000..092ec47143 --- /dev/null +++ b/modules/luci-mod-freifunk/luasrc/view/freifunk/remote_update.htm @@ -0,0 +1,59 @@ +<%# +LuCI - Lua Configuration Interface +Copyright 2008 Steven Barth <steven@midlink.org> +Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> + +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 + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id: contact.htm 3529 2008-10-07 13:10:24Z jow $ + +-%> +<%+header%> + +<h2><%:Freifunk Remote Update%></h2> + +<p><%:Check for new firmware versions and perform automatic updates.%></p> + +<% if update then %> + + <% if update.info then %> + <strong><%:Update available!%></strong> + <br /><br /> + <pre><%=update.info%></pre><br /> + <% else %> + <strong><%:The installed firmware is the most recent version.%></strong> + <br /><br /> + <% end %> + + <p> + <form method="post" action="" class="inline"> + <input type="hidden" name="flash" value="1" /> + <input type="submit" class="cbi-button cbi-button-apply" value="<%:Start Upgrade%>" /> + </form> + </p> + +<% elseif confirm then %> + + <strong><%:Update Settings%></strong> + <br /><br /> + + <p><form method="post" action="" class="inline"> + <input type="hidden" name="flash" value="1" /> + <input type="hidden" name="confirm" value="1" /> + + <input type="checkbox" class="cbi-input-checkbox" name="keepcfg" value="1" checked="checked" id="cb_keepcfg" /> + <label for="cb_keepcfg"><%:Keep configuration%></label><br /> + + <input type="checkbox" class="cbi-input-checkbox" name="verify" value="1" checked="checked" id="cb_verify" /> + <label for="cb_verify"><%:Verify downloaded images%></label><br /><br /> + + <input type="submit" class="cbi-button cbi-button-apply" value="<%:Confirm Upgrade%>" /> + </form></p> + +<% end %> + +<%+footer%> |