gluon-config-mode-geo-location: add ability to hide the altitude field (#693)

This commit is contained in:
kb-light 2016-04-27 12:37:30 +02:00 committed by Matthias Schiffer
parent 937fe715c7
commit 269a8fbdd4
9 changed files with 80 additions and 21 deletions

View File

@ -51,6 +51,7 @@ Packages
:maxdepth: 1 :maxdepth: 1
package/gluon-client-bridge package/gluon-client-bridge
package/gluon-config-mode-geo-location
package/gluon-ebtables-filter-multicast package/gluon-ebtables-filter-multicast
package/gluon-ebtables-filter-ra-dhcp package/gluon-ebtables-filter-ra-dhcp

View File

@ -0,0 +1,14 @@
gluon-config-mode-geo-location
==============================
This package enables the user to set latitude, longitude and altitude of their
node within config mode. As the usage of the altitude is not well defined the
corresponding field can be disabled.
site.conf
---------
config_mode.geo_location.show_altitude : optional
- ``true`` enables the altitude field
- ``false`` disables the altitude field if altitude has not yet been set
- defaults to ``true``

View File

@ -183,4 +183,11 @@
-- setup_mode = { -- setup_mode = {
-- skip = true, -- skip = true,
-- }, -- },
-- Show/hide the altitude field
-- config_mode = {
-- geo_location = {
-- show_altitude = false,
-- },
-- },
} }

View File

@ -33,4 +33,9 @@ define Package/gluon-config-mode-geo-location/install
$(call GluonInstallI18N,gluon-config-mode-geo-location,$(1)) $(call GluonInstallI18N,gluon-config-mode-geo-location,$(1))
endef endef
define Package/gluon-config-mode-geo-location/postinst
#!/bin/sh
$(call GluonCheckSite,check_site.lua)
endef
$(eval $(call BuildPackage,gluon-config-mode-geo-location)) $(eval $(call BuildPackage,gluon-config-mode-geo-location))

View File

@ -0,0 +1,3 @@
if need_table('config_mode', nil, false) and need_table('config_mode.geo_location', nil, false) then
need_boolean('config_mode.geo_location.show_altitude', false)
end

View File

@ -1,14 +1,28 @@
local cbi = require "luci.cbi" local cbi = require "luci.cbi"
local i18n = require "luci.i18n" local i18n = require "luci.i18n"
local uci = luci.model.uci.cursor() local uci = luci.model.uci.cursor()
local site = require 'gluon.site_config'
local M = {} local M = {}
local function show_altitude()
if ((site.config_mode or {}).geo_location or {}).show_altitude ~= false then
return true
end
if uci:get_first("gluon-node-info", "location", "altitude") then
return true
end
return false
end
function M.section(form) function M.section(form)
local s = form:section(cbi.SimpleSection, nil, i18n.translate( local text = i18n.translate('If you want the location of your node to '
'If you want the location of your node to be displayed on the map, ' .. 'be displayed on the map, you can enter its coordinates here.')
.. 'you can enter its coordinates here. Specifying the altitude ' if show_altitude() then
.. 'is optional and should only be done if a proper value is known.')) text = text .. ' ' .. i18n.translate('Specifying the altitude is '
.. 'optional and should only be done if a proper value is known.')
end
local s = form:section(cbi.SimpleSection, nil, text)
local o local o
@ -31,12 +45,14 @@ function M.section(form)
o.datatype = "float" o.datatype = "float"
o.description = i18n.translatef("e.g. %s", "10.689901") o.description = i18n.translatef("e.g. %s", "10.689901")
if show_altitude() then
o = s:option(cbi.Value, "_altitude", i18n.translate("Altitude")) o = s:option(cbi.Value, "_altitude", i18n.translate("Altitude"))
o.default = uci:get_first("gluon-node-info", "location", "altitude") o.default = uci:get_first("gluon-node-info", "location", "altitude")
o:depends("_location", "1") o:depends("_location", "1")
o.rmempty = true o.rmempty = true
o.datatype = "float" o.datatype = "float"
o.description = i18n.translatef("e.g. %s", "11.51") o.description = i18n.translatef("e.g. %s", "11.51")
end
end end

View File

@ -12,13 +12,17 @@ msgstr ""
msgid "" msgid ""
"If you want the location of your node to be displayed on the map, you can " "If you want the location of your node to be displayed on the map, you can "
"enter its coordinates here. Specifying the altitude is optional and should " "enter its coordinates here."
"only be done if a proper value is known."
msgstr "" msgstr ""
"Um deinen Knoten auf der Karte anzeigen zu können, benötigen wir seine " "Um deinen Knoten auf der Karte anzeigen zu können, benötigen wir seine "
"Koordinaten. Hier hast du die Möglichkeit, diese zu hinterlegen. Die " "Koordinaten. Hier hast du die Möglichkeit, diese zu hinterlegen."
"Höhenangabe ist optional und sollte nur gesetzt werden, wenn ein exakter "
"Wert bekannt ist." msgid ""
"Specifying the altitude is optional and should only be done if a proper "
"value is known."
msgstr ""
"Die Höhenangabe ist optional und sollte nur gesetzt werden, wenn ein "
"exakter Wert bekannt ist."
msgid "Latitude" msgid "Latitude"
msgstr "Breitengrad" msgstr "Breitengrad"

View File

@ -12,12 +12,17 @@ msgstr ""
msgid "" msgid ""
"If you want the location of your node to be displayed on the map, you can " "If you want the location of your node to be displayed on the map, you can "
"enter its coordinates here. Specifying the altitude is optional and should " "enter its coordinates here."
"only be done if a proper value is known."
msgstr "" msgstr ""
"Pour Afficher votre nœud sur la Carte nous avons besoin de ses coordonnées. " "Pour Afficher votre nœud sur la Carte nous avons besoin de ses coordonnées. "
"Ici vous pouvez entrer sa position. La altitude est optionelle " "Ici vous pouvez entrer sa position."
"et ne devrait que être ajoutée si la valeur exacte est connue. "
msgid ""
"Specifying the altitude is optional and should only be done if a proper "
"value is known."
msgstr ""
"La altitude est optionelle et ne devrait que être ajoutée si la valeur "
"exacte est connue."
msgid "Latitude" msgid "Latitude"
msgstr "Latitude" msgstr "Latitude"

View File

@ -3,8 +3,12 @@ msgstr "Content-Type: text/plain; charset=UTF-8"
msgid "" msgid ""
"If you want the location of your node to be displayed on the map, you can " "If you want the location of your node to be displayed on the map, you can "
"enter its coordinates here. Specifying the altitude is optional and should " "enter its coordinates here."
"only be done if a proper value is known." msgstr ""
msgid ""
"Specifying the altitude is optional and should only be done if a proper "
"value is known."
msgstr "" msgstr ""
msgid "Latitude" msgid "Latitude"