gluon-config-mode-geo-location: refactor lua code and fix interval uci request

This commit is contained in:
Jan-Tarek Butt 2018-07-18 20:17:56 +02:00
parent 908efde194
commit d24abe9636

View File

@ -14,36 +14,24 @@ return function(form, uci)
if uci_longitude ~= nil then
return uci_longitude
end
if site.config_mode.geo_location.map_lon(false) then
return site.config_mode.geo_location.map_lon()
end
return 0.0
return site.config_mode.geo_location.map_lon(0.0)
end
local function show_lat()
if uci_latitude ~= nil then
return uci_latitude
end
if site.config_mode.geo_location.map_lat(false) then
return site.config_mode.geo_location.map_lat()
end
return 0.0
return site.config_mode.geo_location.map_lat(0.0)
end
local function show_olurl()
if site.config_mode.geo_location.olurl(false) then
return site.config_mode.geo_location.olurl()
end
return 'http://dev.openlayers.org/OpenLayers.js'
return site.config_mode.geo_location.olurl('http://dev.openlayers.org/OpenLayers.js')
end
#endif
-- show altitude if site.json retruns true or nil and uci an value. Dont show if site.json retruns false or uci nil!
local function show_altitude()
if site.config_mode.geo_location.show_altitude(true) then
return true
end
return uci:get_bool("gluon-node-info", location, "altitude")
return site.config_mode.geo_location.show_altitude(uci:get("gluon-node-info", location, "altitude") ~= nil)
end
local text = site_i18n._translate("gluon-config-mode:geo-location-help") or pkg_i18n.translate(
@ -137,7 +125,7 @@ return function(form, uci)
--]]
local interval = s:option(Value, "interval", pkg_i18n.translate("Interval in minutes"), pkg_i18n.translatef("Set refresh interval"))
interval.default = uci:get_first("geolocator", "settings", "refresh_interval")
interval.default = uci:get("geolocator", "settings", "refresh_interval")
interval:depends(geolocation, "automatic")
interval:depends(geolocation, "auto_static")
interval.datatype = "uinteger"