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.
This commit is contained in:
parent
6aee8e95e8
commit
6742584e12
@ -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"
|
|||||||
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 ""
|
|||||||
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)
|
|||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
-- The config mode does not have a nicer place to put this at the moment...
|
local set_location = s:option(Flag, "location", pkg_i18n.translate("Set node position"))
|
||||||
if not show_altitude then
|
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
|
||||||
|
|
||||||
|
if not show_altitude or not data 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)
|
|||||||
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)
|
|||||||
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user