From d24abe9636b26779edef53ea2a657326d49b9416 Mon Sep 17 00:00:00 2001 From: Jan-Tarek Butt Date: Wed, 18 Jul 2018 20:17:56 +0200 Subject: [PATCH] gluon-config-mode-geo-location: refactor lua code and fix interval uci request --- .../src/0400-geo-location.lua.in | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/package/gluon-config-mode-geo-location/src/0400-geo-location.lua.in b/package/gluon-config-mode-geo-location/src/0400-geo-location.lua.in index cfbb6b9e..f7e125da 100644 --- a/package/gluon-config-mode-geo-location/src/0400-geo-location.lua.in +++ b/package/gluon-config-mode-geo-location/src/0400-geo-location.lua.in @@ -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"