Skip to content
Snippets Groups Projects
Commit 6742584e authored by Tata's avatar Tata Committed by Andreas Ziegler
Browse files

gluon-config-mode-geo-location: allow to set location independently from sharing it (#1537)

also properly delete location data when a user disables
the location option after re-entering config-mode.
parent 6aee8e95
No related branches found
No related tags found
No related merge requests found
...@@ -26,6 +26,9 @@ msgstr "Breitengrad" ...@@ -26,6 +26,9 @@ msgstr "Breitengrad"
msgid "Longitude" msgid "Longitude"
msgstr "Längengrad" msgstr "Längengrad"
msgid "Set node position"
msgstr "Knotenposition setzen"
msgid "Advertise node position" msgid "Advertise node position"
msgstr "Knotenposition veröffentlichen" msgstr "Knotenposition veröffentlichen"
......
...@@ -24,6 +24,9 @@ msgstr "Latitude" ...@@ -24,6 +24,9 @@ msgstr "Latitude"
msgid "Longitude" msgid "Longitude"
msgstr "Longitude" msgstr "Longitude"
msgid "Set node position"
msgstr ""
msgid "Advertise node position" msgid "Advertise node position"
msgstr "" msgstr ""
......
...@@ -15,6 +15,9 @@ msgstr "" ...@@ -15,6 +15,9 @@ msgstr ""
msgid "Longitude" msgid "Longitude"
msgstr "" msgstr ""
msgid "Set node position"
msgstr ""
msgid "Advertise node position" msgid "Advertise node position"
msgstr "" msgstr ""
......
...@@ -32,26 +32,41 @@ return function(form, uci) ...@@ -32,26 +32,41 @@ return function(form, uci)
local o local o
local share_location = s:option(Flag, "location", pkg_i18n.translate("Advertise node position")) local own_latitude = uci:get("gluon-node-info", location, "latitude")
share_location.default = uci:get_bool("gluon-node-info", location, "share_location") local own_longitude = uci:get("gluon-node-info", location, "longitude")
function share_location:write(data)
uci:set("gluon-node-info", location, "share_location", data) local set_location = s:option(Flag, "location", pkg_i18n.translate("Set node position"))
set_location.default = own_latitude or own_longitude
-- Delete already saved coordinates
function set_location:write(data)
if not data then
uci:delete("gluon-node-info", location, "latitude")
uci:delete("gluon-node-info", location, "longitude")
uci:set("gluon-node-info", location, "share_location", false)
end
-- The config mode does not have a nicer place to put this at the moment... if not show_altitude or not data then
if not show_altitude then
uci:delete("gluon-node-info", location, "altitude") uci:delete("gluon-node-info", location, "altitude")
end end
end end
local share_location = s:option(Flag, "share_location", pkg_i18n.translate("Advertise node position"))
share_location.default = uci:get_bool("gluon-node-info", location, "share_location")
share_location:depends(set_location, true)
function share_location:write(data)
uci:set("gluon-node-info", location, "share_location", data)
end
local map local map
if osm then if osm then
map = s:option(osm.MapValue, "map", osm.options()) map = s:option(osm.MapValue, "map", osm.options())
map:depends(share_location, true) map:depends(set_location, true)
end end
o = s:option(Value, "latitude", pkg_i18n.translate("Latitude"), pkg_i18n.translatef("e.g. %s", "53.873621")) o = s:option(Value, "latitude", pkg_i18n.translate("Latitude"), pkg_i18n.translatef("e.g. %s", "53.873621"))
o.default = uci:get("gluon-node-info", location, "latitude") o.default = own_latitude
o:depends(share_location, true) o:depends(set_location, true)
o.datatype = "float" o.datatype = "float"
function o:write(data) function o:write(data)
uci:set("gluon-node-info", location, "latitude", data) uci:set("gluon-node-info", location, "latitude", data)
...@@ -61,8 +76,8 @@ return function(form, uci) ...@@ -61,8 +76,8 @@ return function(form, uci)
end end
o = s:option(Value, "longitude", pkg_i18n.translate("Longitude"), pkg_i18n.translatef("e.g. %s", "10.689901")) o = s:option(Value, "longitude", pkg_i18n.translate("Longitude"), pkg_i18n.translatef("e.g. %s", "10.689901"))
o.default = uci:get("gluon-node-info", location, "longitude") o.default = own_longitude
o:depends(share_location, true) o:depends(set_location, true)
o.datatype = "float" o.datatype = "float"
function o:write(data) function o:write(data)
uci:set("gluon-node-info", location, "longitude", data) uci:set("gluon-node-info", location, "longitude", data)
...@@ -77,7 +92,7 @@ return function(form, uci) ...@@ -77,7 +92,7 @@ return function(form, uci)
pkg_i18n.translatef("e.g. %s", "11.51") pkg_i18n.translatef("e.g. %s", "11.51")
) )
o.default = uci:get("gluon-node-info", location, "altitude") o.default = uci:get("gluon-node-info", location, "altitude")
o:depends(share_location, true) o:depends(set_location, true)
o.datatype = "float" o.datatype = "float"
o.optional = true o.optional = true
function o:write(data) function o:write(data)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment