Commit a8d736ac authored by Matthias Schiffer's avatar Matthias Schiffer

gluon-config-mode-geo-location-osm: add OSM-based location picker

gluon-config-mode-geo-location-osm extends the
gluon-config-mode-geo-location with a location picker based on
OpenStreetMaps.
Based-on-patch-by: default avatarJan-Tarek Butt <tarek@ring0.de>
parent 0d4188d4
......@@ -407,6 +407,13 @@ config_mode \: optional
package. Set *geo_location.show_altitude* to *true* if you want the altitude
field to be visible.
The *geo_location.osm* section is only relevant when the *gluon-config-mode-geo-location-osm*
package is used. The *center.lon* and *center.lat* values are mandatory in this case and
define the default center of the map when no position has been picked yet. The *zoom* level
defaults to 12 in this case. *openlayers_url* allows to override the base URL of the
*build/ol.js* and *css/ol.css* files (the default is
``https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.2.0``).
The remote login page only shows SSH key configuration by default. A
password form can be displayed by setting *remote_login.show_password_form*
to true; in this case, *remote_login.min_password_length* defines the
......@@ -419,6 +426,14 @@ config_mode \: optional
},
geo_location = {
show_altitude = true,
osm = {
center = {
lon = 52.951947558,
lat = 7.844238281,
},
zoom = 13,
openlayers_url = 'http://ffac/ol',
},
},
remote_login = {
show_password_form = true,
......
include $(TOPDIR)/rules.mk
PKG_NAME:=gluon-config-mode-geo-location-osm
PKG_VERSION:=1
include ../gluon.mk
define Package/gluon-config-mode-geo-location-osm
TITLE:=Set geographic location of a node (map support)
DEPENDS:=+gluon-config-mode-geo-location +gluon-web-osm
endef
define Package/gluon-config-mode-geo-location-osm/install
$(Gluon/Build/Install)
$(INSTALL_DIR) $(1)/lib/gluon/config-mode/www/static/
$(LN) /lib/gluon/web/www/static/gluon-web-osm.js $(1)/lib/gluon/config-mode/www/static/
endef
$(eval $(call BuildPackageGluon,gluon-config-mode-geo-location-osm))
need_number(in_site({'config_mode', 'geo_location', 'osm', 'center', 'lon'}))
need_number(in_site({'config_mode', 'geo_location', 'osm', 'center', 'lat'}))
need_number(in_site({'config_mode', 'geo_location', 'osm', 'zoom'}), false)
need_string(in_site({'config_mode', 'geo_location', 'osm', 'openlayers_url'}), false)
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Project-Id-Version: gluon-config-mode-geo-location\n"
"Last-Translator: Matthias Schiffer <mschiffer@universe-factory.net>\n"
"Language-Team: German\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
msgid ""
"You may also select the position on the map displayed below if your computer "
"is connected to the internet at the moment."
msgstr ""
"Wenn dein Computer aktuell mit dem Internet verbunden ist, kann die Position "
"auch auf der hier angezeigten Karte ausgewählt werden."
msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8"
msgid ""
"You may also select the position on the map displayed below if your computer "
"is connected to the internet at the moment."
msgstr ""
local osm = require 'gluon.web.model.osm'
local site = require 'gluon.site'
local tonumber = tonumber
module 'gluon.config-mode.geo-location-osm'
MapValue = osm.MapValue
function help(i18n)
local pkg_i18n = i18n 'gluon-config-mode-geo-location-osm'
return pkg_i18n.translate(
'You may also select the position on the map displayed below if your computer is connected to the internet at the moment.'
)
end
function options()
local config = site.config_mode.geo_location.osm
return {
openlayers_url = config.openlayers_url(),
zoom = config.zoom(12),
pos = config.center(),
}
end
......@@ -14,11 +14,11 @@ msgid "Altitude"
msgstr "Höhe"
msgid ""
"If you want the location of your node to be displayed on the map, you can "
"enter its coordinates here."
"If you want the location of your node to be displayed on public maps, you "
"can 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."
"Um deinen Knoten auf öffentlichen Karten anzeigen zu können, benötigen wir "
"seine Koordinaten. Hier hast du die Möglichkeit, diese zu hinterlegen."
msgid "Latitude"
msgstr "Breitengrad"
......@@ -26,8 +26,8 @@ msgstr "Breitengrad"
msgid "Longitude"
msgstr "Längengrad"
msgid "Show node on the map"
msgstr "Knoten auf der Karte anzeigen"
msgid "Advertise node position"
msgstr "Knotenposition veröffentlichen"
msgid ""
"Specifying the altitude is optional; it should only be filled in if an "
......
......@@ -14,11 +14,9 @@ msgid "Altitude"
msgstr "Hauteur"
msgid ""
"If you want the location of your node to be displayed on the map, you can "
"enter its coordinates here."
"If you want the location of your node to be displayed on public maps, you "
"can 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."
msgid "Latitude"
msgstr "Latitude"
......@@ -26,8 +24,8 @@ msgstr "Latitude"
msgid "Longitude"
msgstr "Longitude"
msgid "Show node on the map"
msgstr "Afficher le nœud sur la carte"
msgid "Advertise node position"
msgstr ""
msgid ""
"Specifying the altitude is optional; it should only be filled in if an "
......
......@@ -5,8 +5,8 @@ msgid "Altitude"
msgstr ""
msgid ""
"If you want the location of your node to be displayed on the map, you can "
"enter its coordinates here."
"If you want the location of your node to be displayed on public maps, you "
"can enter its coordinates here."
msgstr ""
msgid "Latitude"
......@@ -15,7 +15,7 @@ msgstr ""
msgid "Longitude"
msgstr ""
msgid "Show node on the map"
msgid "Advertise node position"
msgstr ""
msgid ""
......
......@@ -4,6 +4,9 @@ return function(form, uci)
local site = require 'gluon.site'
local osm
pcall(function() osm = require 'gluon.config-mode.geo-location-osm' end)
local location = uci:get_first("gluon-node-info", "location")
local show_altitude = site.config_mode.geo_location.show_altitude(false)
......@@ -14,6 +17,9 @@ return function(form, uci)
'If you want the location of your node to ' ..
'be displayed on the map, you can enter its coordinates here.'
)
if osm then
text = text .. ' ' .. osm.help(i18n)
end
if show_altitude then
text = text .. ' ' .. pkg_i18n.translate(
'Specifying the altitude is optional; it should only be filled in if an accurate ' ..
......@@ -26,7 +32,7 @@ return function(form, uci)
local o
local share_location = s:option(Flag, "location", pkg_i18n.translate("Show node on the map"))
local share_location = s:option(Flag, "location", pkg_i18n.translate("Advertise node position"))
share_location.default = uci:get_bool("gluon-node-info", location, "share_location")
function share_location:write(data)
uci:set("gluon-node-info", location, "share_location", data)
......@@ -37,6 +43,12 @@ return function(form, uci)
end
end
local map = {}
if osm then
map = s:option(osm.MapValue, "map", osm.options())
map:depends(share_location, true)
end
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:depends(share_location, true)
......@@ -44,6 +56,7 @@ return function(form, uci)
function o:write(data)
uci:set("gluon-node-info", location, "latitude", data)
end
map.lat = o
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")
......@@ -52,6 +65,7 @@ return function(form, uci)
function o:write(data)
uci:set("gluon-node-info", location, "longitude", data)
end
map.lon = o
if show_altitude then
o = s:option(Value, "altitude",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment