2011-01-25 21:04:57 +00:00
--[[
LuCI - Lua Configuration Interface
Copyright 2008 Steven Barth < steven @ midlink.org >
2011-03-12 17:13:36 +00:00
Copyright 2011 Manuel Munz < freifunk at somakoma de >
2011-01-25 21:04:57 +00:00
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
2011-01-28 23:31:10 +00:00
] ]
2011-01-25 21:04:57 +00:00
2015-01-15 14:11:57 +00:00
local fs = require " nixio.fs "
2011-01-25 21:04:57 +00:00
local util = require " luci.util "
local uci = require " luci.model.uci " . cursor ( )
local profiles = " /etc/config/profile_ "
2011-03-12 17:13:36 +00:00
2011-01-28 23:31:10 +00:00
m = Map ( " freifunk " , translate ( " Community " ) )
2011-02-14 18:01:20 +00:00
c = m : section ( NamedSection , " community " , " public " , nil , translate ( " These are the basic settings for your local wireless community. These settings define the default values for the wizard and DO NOT affect the actual configuration of the router. " ) )
2011-01-25 21:04:57 +00:00
2011-01-28 23:31:10 +00:00
community = c : option ( ListValue , " name " , translate ( " Community " ) )
2011-01-25 21:04:57 +00:00
community.rmempty = false
2015-01-15 14:11:57 +00:00
local profile
for profile in fs.dir ( profiles ) do
local name = uci : get_first ( profile , " community " , " name " ) or " ? "
community : value ( profile , name )
2011-01-25 21:04:57 +00:00
end
2011-03-12 17:13:36 +00:00
2011-01-25 21:04:57 +00:00
n = Map ( " system " , translate ( " Basic system settings " ) )
2011-03-12 17:13:36 +00:00
function n . on_after_commit ( self )
luci.http . redirect ( luci.dispatcher . build_url ( " admin " , " freifunk " , " basics " ) )
end
2011-01-28 23:31:10 +00:00
b = n : section ( TypedSection , " system " )
2011-01-25 21:04:57 +00:00
b.anonymous = true
2011-02-02 10:55:38 +00:00
hn = b : option ( Value , " hostname " , translate ( " Hostname " ) )
2011-01-25 21:04:57 +00:00
hn.rmempty = false
2011-02-12 11:09:13 +00:00
hn.datatype = " hostname "
2011-01-25 21:04:57 +00:00
2011-02-02 10:55:38 +00:00
loc = b : option ( Value , " location " , translate ( " Location " ) )
2011-01-25 21:04:57 +00:00
loc.rmempty = false
2012-06-25 10:02:53 +00:00
loc.datatype = " minlength(1) "
2011-01-25 21:04:57 +00:00
2011-02-02 10:55:38 +00:00
lat = b : option ( Value , " latitude " , translate ( " Latitude " ) , translate ( " e.g. " ) .. " 48.12345 " )
2011-03-12 17:13:36 +00:00
lat.datatype = " float "
2011-01-25 21:04:57 +00:00
lat.rmempty = false
2011-02-02 10:55:38 +00:00
lon = b : option ( Value , " longitude " , translate ( " Longitude " ) , translate ( " e.g. " ) .. " 10.12345 " )
2011-03-12 17:13:36 +00:00
lon.datatype = " float "
2011-01-25 21:04:57 +00:00
lon.rmempty = false
--[[
Opens an OpenStreetMap iframe or popup
Makes use of resources / OSMLatLon.htm and htdocs / resources / osm.js
] ] --
local class = util.class
2011-03-12 17:13:36 +00:00
local ff = uci : get ( " freifunk " , " community " , " name " ) or " "
local co = " profile_ " .. ff
local deflat = uci : get_first ( " system " , " system " , " latitude " ) or uci : get_first ( co , " community " , " latitude " ) or 52
local deflon = uci : get_first ( " system " , " system " , " longitude " ) or uci : get_first ( co , " community " , " longitude " ) or 10
local zoom = 12
if ( deflat == 52 and deflon == 10 ) then
zoom = 4
end
2011-01-25 21:04:57 +00:00
2011-03-12 17:13:36 +00:00
OpenStreetMapLonLat = luci.util . class ( AbstractValue )
2011-01-25 21:04:57 +00:00
function OpenStreetMapLonLat . __init__ ( self , ... )
AbstractValue.__init__ ( self , ... )
self.template = " cbi/osmll_value "
self.latfield = nil
self.lonfield = nil
self.centerlat = " "
self.centerlon = " "
self.zoom = " 0 "
self.width = " 100% " --popups will ignore the %-symbol, "100%" is interpreted as "100"
self.height = " 600 "
self.popup = false
self.displaytext = " OpenStreetMap " --text on button, that loads and displays the OSMap
self.hidetext = " X " -- text on button, that hides OSMap
end
2011-03-12 17:13:36 +00:00
osm = b : option ( OpenStreetMapLonLat , " latlon " , translate ( " Find your coordinates with OpenStreetMap " ) , translate ( " Select your location with a mouse click on the map. The map will only show up if you are connected to the Internet. " ) )
osm.latfield = " latitude "
osm.lonfield = " longitude "
osm.centerlat = uci : get_first ( " system " , " system " , " latitude " ) or deflat
osm.centerlon = uci : get_first ( " system " , " system " , " longitude " ) or deflon
osm.zoom = zoom
osm.width = " 100% "
osm.height = " 600 "
osm.popup = false
osm.displaytext = translate ( " Show OpenStreetMap " )
osm.hidetext = translate ( " Hide OpenStreetMap " )
2011-01-25 21:04:57 +00:00
return m , n