diff --git a/docs/index.rst b/docs/index.rst index 07777460be0c44e041ff304292bec5b337c9a5e6..1b68d02756dda9cae17f5edf17f4e691bffdcdea 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -51,6 +51,7 @@ Packages :maxdepth: 1 package/gluon-client-bridge + package/gluon-config-mode-geo-location package/gluon-ebtables-filter-multicast package/gluon-ebtables-filter-ra-dhcp diff --git a/docs/package/gluon-config-mode-geo-location.rst b/docs/package/gluon-config-mode-geo-location.rst new file mode 100644 index 0000000000000000000000000000000000000000..83ca238bf1dc8884e8a010eb4b1b6a0d73c1dd38 --- /dev/null +++ b/docs/package/gluon-config-mode-geo-location.rst @@ -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`` diff --git a/docs/site-example/site.conf b/docs/site-example/site.conf index acabadb225ef377d331e8a017c11d5aeda369cfb..45719b940e4dd4b262b010ce9ab573e2069e0873 100644 --- a/docs/site-example/site.conf +++ b/docs/site-example/site.conf @@ -183,4 +183,11 @@ -- setup_mode = { -- skip = true, -- }, + + -- Show/hide the altitude field + -- config_mode = { + -- geo_location = { + -- show_altitude = false, + -- }, + -- }, } diff --git a/package/gluon-config-mode-geo-location/Makefile b/package/gluon-config-mode-geo-location/Makefile index 28d347643e54bb9a3fc94e8d340b3a3043c0bd50..03812e54ad662a0febb72e8c2759de50a1391f19 100644 --- a/package/gluon-config-mode-geo-location/Makefile +++ b/package/gluon-config-mode-geo-location/Makefile @@ -33,4 +33,9 @@ define Package/gluon-config-mode-geo-location/install $(call GluonInstallI18N,gluon-config-mode-geo-location,$(1)) 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)) diff --git a/package/gluon-config-mode-geo-location/check_site.lua b/package/gluon-config-mode-geo-location/check_site.lua new file mode 100644 index 0000000000000000000000000000000000000000..509226feb24548af470b3441098dd2aea9b6f5fd --- /dev/null +++ b/package/gluon-config-mode-geo-location/check_site.lua @@ -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 diff --git a/package/gluon-config-mode-geo-location/files/lib/gluon/config-mode/wizard/0400-geo-location.lua b/package/gluon-config-mode-geo-location/files/lib/gluon/config-mode/wizard/0400-geo-location.lua index e8c9976d5bf4270769a9c4a395ffab5b563aeae9..9bc703014e6850d44e629e4a315ec30510fd6286 100644 --- a/package/gluon-config-mode-geo-location/files/lib/gluon/config-mode/wizard/0400-geo-location.lua +++ b/package/gluon-config-mode-geo-location/files/lib/gluon/config-mode/wizard/0400-geo-location.lua @@ -1,14 +1,28 @@ local cbi = require "luci.cbi" local i18n = require "luci.i18n" local uci = luci.model.uci.cursor() +local site = require 'gluon.site_config' 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) - local s = form:section(cbi.SimpleSection, nil, i18n.translate( - '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 only be done if a proper value is known.')) + local text = i18n.translate('If you want the location of your node to ' + .. 'be displayed on the map, you can enter its coordinates here.') + if show_altitude() then + 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 @@ -31,12 +45,14 @@ function M.section(form) o.datatype = "float" o.description = i18n.translatef("e.g. %s", "10.689901") - o = s:option(cbi.Value, "_altitude", i18n.translate("Altitude")) - o.default = uci:get_first("gluon-node-info", "location", "altitude") - o:depends("_location", "1") - o.rmempty = true - o.datatype = "float" - o.description = i18n.translatef("e.g. %s", "11.51") + if show_altitude() then + o = s:option(cbi.Value, "_altitude", i18n.translate("Altitude")) + o.default = uci:get_first("gluon-node-info", "location", "altitude") + o:depends("_location", "1") + o.rmempty = true + o.datatype = "float" + o.description = i18n.translatef("e.g. %s", "11.51") + end end diff --git a/package/gluon-config-mode-geo-location/i18n/de.po b/package/gluon-config-mode-geo-location/i18n/de.po index a2850d5b831de0801a541b26e3ab27a784cdfdb6..3580732b1f3313e3fc624544e494568230c240fc 100644 --- a/package/gluon-config-mode-geo-location/i18n/de.po +++ b/package/gluon-config-mode-geo-location/i18n/de.po @@ -12,13 +12,17 @@ msgstr "" msgid "" "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 " -"only be done if a proper value is known." +"enter its coordinates here." msgstr "" "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 " -"Höhenangabe ist optional und sollte nur gesetzt werden, wenn ein exakter " -"Wert bekannt ist." +"Koordinaten. Hier hast du die Möglichkeit, diese zu hinterlegen." + +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" msgstr "Breitengrad" diff --git a/package/gluon-config-mode-geo-location/i18n/fr.po b/package/gluon-config-mode-geo-location/i18n/fr.po index 15d79e2bdd77945f6b4c903750d04f1aad266eb3..b239c84c9b41e690b14196a0cdab36381cf716cb 100644 --- a/package/gluon-config-mode-geo-location/i18n/fr.po +++ b/package/gluon-config-mode-geo-location/i18n/fr.po @@ -12,12 +12,17 @@ msgstr "" msgid "" "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 " -"only be done if a proper value is known." +"enter its coordinates here." msgstr "" "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 " -"et ne devrait que être ajoutée si la valeur exacte est connue. " +"Ici vous pouvez entrer sa position." + +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" msgstr "Latitude" diff --git a/package/gluon-config-mode-geo-location/i18n/gluon-config-mode-geo-location.pot b/package/gluon-config-mode-geo-location/i18n/gluon-config-mode-geo-location.pot index a2be4fdf776708f28064bc8bf450ffb6a7c5b6d0..48f26f7046beff070120f4d3ff65db47740e44c5 100644 --- a/package/gluon-config-mode-geo-location/i18n/gluon-config-mode-geo-location.pot +++ b/package/gluon-config-mode-geo-location/i18n/gluon-config-mode-geo-location.pot @@ -3,8 +3,12 @@ msgstr "Content-Type: text/plain; charset=UTF-8" msgid "" "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 " -"only be done if a proper value is known." +"enter its coordinates here." +msgstr "" + +msgid "" +"Specifying the altitude is optional and should only be done if a proper " +"value is known." msgstr "" msgid "Latitude"