gluon-config-mode-geo-location-with-map: integrate a location picker map into the config-mode.

Signed-off-by: Jan-Tarek Butt <tarek@ring0.de>
This commit is contained in:
Jan-Tarek Butt 2018-07-18 06:38:25 +02:00
parent a304814c80
commit 4d2a17e0dc
11 changed files with 343 additions and 144 deletions

View File

@ -6,8 +6,62 @@ PKG_VERSION:=1
include ../gluon.mk include ../gluon.mk
define Package/gluon-config-mode-geo-location define Package/gluon-config-mode-geo-location
TITLE:=Set geographic location of a node TITLE:=Set geographic location of a node manualy and share it.
CONFLICTS:=+gluon-config-mode-geo-location-with-map
DEPENDS:=+gluon-config-mode-core +gluon-node-info DEPENDS:=+gluon-config-mode-core +gluon-node-info
endef endef
define Package/gluon-config-mode-geo-location-with-map
TITLE:=Set geographic location of a node manualy and share it, optionally show a map if internet available.
CONFLICTS:=+gluon-config-mode-geo-location
DEPENDS:=+gluon-config-mode-core +gluon-node-info +gluon-web-osm
endef
define Build/Configure
$(CP) ./src/* $(PKG_BUILD_DIR)/
$(INSTALL_DIR) $(PKG_BUILD_DIR)/gluon-config-mode-geo-location{,-with-map}/{luasrc/lib/gluon/config-mode/wizard/,i18n/}
endef
define Build/Compile
$(CC) -E -x c -P $(PKG_BUILD_DIR)/0400-geo-location.lua.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua
$(CC) -E -x c -P $(PKG_BUILD_DIR)/gluon-config-mode-geo-location.pot.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location/i18n/gluon-config-mode-geo-location.pot
$(CC) -E -x c -P $(PKG_BUILD_DIR)/check_site.lua.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location/check_site.lua
$(CC) -E -x c -P $(PKG_BUILD_DIR)/de.po.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location/i18n/de.po
$(CC) -E -x c -P $(PKG_BUILD_DIR)/fr.po.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location/i18n/fr.po
$(call GluonBuildI18N,gluon-config-mode-geo-location,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location/i18n)
$(call GluonSrcDiet,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location/luasrc,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location/luadest/)
$(CC) -DWITHMAP -E -x c -P $(PKG_BUILD_DIR)/0400-geo-location.lua.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua
$(CC) -DWITHMAP -E -x c -P $(PKG_BUILD_DIR)/gluon-config-mode-geo-location.pot.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/i18n/gluon-config-mode-geo-location-with-map.pot
$(CC) -DWITHMAP -E -x c -P $(PKG_BUILD_DIR)/check_site.lua.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/check_site.lua
$(CC) -DWITHMAP -E -x c -P $(PKG_BUILD_DIR)/de.po.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/i18n/de.po
$(CC) -DWITHMAP -E -x c -P $(PKG_BUILD_DIR)/fr.po.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/i18n/fr.po
$(call GluonBuildI18N,gluon-config-mode-geo-location-with-map,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/i18n)
$(call GluonSrcDiet,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/luasrc,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/luadest/)
endef
define Package/gluon-config-mode-geo-location/install
$(CP) $(PKG_BUILD_DIR)/gluon-config-mode-geo-location/luadest/* $(1)/
$(call GluonInstallI18N,gluon-config-mode-geo-location,$(1))
endef
define Package/gluon-config-mode-geo-location-with-map/install
$(CP) $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/luadest/* $(1)/
$(INSTALL_DIR) $(1)/lib/gluon/config-mode/www/static/
$(LN) /lib/gluon/web/www/static/osm.js $(1)/lib/gluon/config-mode/www/static/osm.js
$(call GluonInstallI18N,gluon-config-mode-geo-location-with-map,$(1))
endef
define Package/gluon-config-mode-geo-location/postinst
#!/bin/sh
$(call GluonCheckSite,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location/check_site.lua)
endef
define Package/gluon-config-mode-geo-location-with-map/postinst
#!/bin/sh
$(call GluonCheckSite,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-map/check_site.lua)
endef
$(eval $(call BuildPackageGluon,gluon-config-mode-geo-location)) $(eval $(call BuildPackageGluon,gluon-config-mode-geo-location))
$(eval $(call BuildPackageGluon,gluon-config-mode-geo-location-with-map))

View File

@ -1 +0,0 @@
need_boolean(in_site({'config_mode', 'geo_location', 'show_altitude'}), false)

View File

@ -1,30 +0,0 @@
msgid ""
msgstr ""
"Project-Id-Version: gluon-config-mode-geo-location\n"
"PO-Revision-Date: 2015-03-23 02:18+0100\n"
"Last-Translator: Martin Weinelt <martin@darmstadt.freifunk.net>\n"
"Language-Team: German\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
msgid ""
"If you want the location of your node to be displayed on the map, 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."
msgid "Latitude"
msgstr "Breitengrad"
msgid "Longitude"
msgstr "Längengrad"
msgid "Show node on the map"
msgstr "Knoten auf der Karte anzeigen"
msgid "e.g. %s"
msgstr "z.B. %s"

View File

@ -1,30 +0,0 @@
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Project-Id-Version: PACKAGE VERSION\n"
"PO-Revision-Date: 2015-08-12 23:30+0100\n"
"Last-Translator:Tobias Bernot <tqbs@airmail.cc>\n"
"Language-Team: French\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
msgid ""
"If you want the location of your node to be displayed on the map, 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"
msgid "Longitude"
msgstr "Longitude"
msgid "Show node on the map"
msgstr "Afficher le nœud sur la carte"
msgid "e.g. %s"
msgstr "Ex: %s"

View File

@ -1,19 +0,0 @@
msgid ""
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."
msgstr ""
msgid "Latitude"
msgstr ""
msgid "Longitude"
msgstr ""
msgid "Show node on the map"
msgstr ""
msgid "e.g. %s"
msgstr ""

View File

@ -1,63 +0,0 @@
return function(form, uci)
local pkg_i18n = i18n 'gluon-config-mode-geo-location'
local site_i18n = i18n 'gluon-site'
local site = require 'gluon.site'
local location = uci:get_first("gluon-node-info", "location")
local function show_altitude()
if site.config_mode.geo_location.show_altitude(true) then
return true
end
return uci:get_bool("gluon-node-info", location, "altitude")
end
local text = site_i18n._translate("gluon-config-mode:geo-location-help") or pkg_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 .. ' ' .. site_i18n.translate("gluon-config-mode:altitude-help")
end
local s = form:section(Section, nil, text)
local o
local share_location = s:option(Flag, "location", pkg_i18n.translate("Show node on the map"))
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)
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)
o.datatype = "float"
function o:write(data)
uci:set("gluon-node-info", location, "latitude", data)
end
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:depends(share_location, true)
o.datatype = "float"
function o:write(data)
uci:set("gluon-node-info", location, "longitude", data)
end
if show_altitude() then
o = s:option(Value, "altitude", site_i18n.translate("gluon-config-mode:altitude-label"), pkg_i18n.translatef("e.g. %s", "11.51"))
o.default = uci:get("gluon-node-info", location, "altitude")
o:depends(share_location, true)
o.datatype = "float"
o.optional = true
function o:write(data)
uci:set("gluon-node-info", location, "altitude", data)
end
end
return {'gluon-node-info'}
end

View File

@ -0,0 +1,145 @@
return function(form, uci)
local pkg_i18n = i18n 'gluon-config-mode-geo-location'
local site_i18n = i18n 'gluon-site'
local site = require 'gluon.site'
local location = uci:get_first("gluon-node-info", "location")
local uci_latitude = uci:get("gluon-node-info", location, "latitude")
local uci_longitude = uci:get("gluon-node-info", location, "longitude")
#ifdef WITHMAP
local function show_lon()
if uci_longitude ~= nil then
return uci_longitude
end
if site.config_mode.geo_location.map_lon(false) then
return site.config_mode.geo_location.map_lon()
end
return 0.0
end
local function show_lat()
if uci_latitude ~= nil then
return uci_latitude
end
if site.config_mode.geo_location.map_lat(false) then
return site.config_mode.geo_location.map_lat()
end
return 0.0
end
local function show_olurl()
if site.config_mode.geo_location.olurl(false) then
return site.config_mode.geo_location.olurl()
end
return 'http://dev.openlayers.org/OpenLayers.js'
end
#endif
local function show_altitude()
if site.config_mode.geo_location.show_altitude(true) then
return true
end
return uci:get_bool("gluon-node-info", location, "altitude")
end
local text = site_i18n._translate("gluon-config-mode:geo-location-help") or pkg_i18n.translate(
'If you want the location of your node to be displayed on the map, you can ' ..
'enter its coordinates here. ' ..
#ifdef WITHMAP
'If your PC is connected to the internet you can also click on the map displayed below. ' ..
#endif
'Please keep in mind setting a location can also enhance the network quality.'
)
if show_altitude() then
text = text .. ' ' .. site_i18n.translate("gluon-config-mode:altitude-help")
end
#ifdef WITHMAP
text = text .. [[
<div id="locationPickerMap" style="width:100%; height:300px; display: none;"></div>
<script type="text/javascript" src="]] .. show_olurl() .. [["></script>
<script type="text/javascript" src="/static/osm.js"></script>
<script type="text/javascript">
var latitude=]] .. show_lon() .. ",longitude=" .. show_lat() .. [[;
document.addEventListener("DOMContentLoaded", showMap, false);
setInterval(function() {
if(false !== findObj("longitude")) {
document.getElementById("locationPickerMap").style.display="block";
}else{
document.getElementById("locationPickerMap").style.display="none";
}
}, 1000);
</script>
]]
#endif
local s = form:section(Section, nil, text)
local uci_share_location = uci:get_bool("gluon-node-info", location, "share_location")
local geolocation = s:option(ListValue, "geolocation", pkg_i18n.translate("Geo-Location"))
geolocation:value("static", pkg_i18n.translate("Static location"))
geolocation:value("none", pkg_i18n.translate("Disabled"))
if uci_latitude == nil and uci_longitude == nil and uci_share_location == false then
geolocation.default = "none"
else
geolocation.default = "static"
end
local share_location = s:option(Flag, "sharelocation", pkg_i18n.translate("Share your location to see your router on the map"))
share_location.default = uci_share_location
share_location:depends(geolocation, "static")
local latitude = s:option(Value, "latitude", pkg_i18n.translate("Latitude"), pkg_i18n.translatef("e.g. %s", "50.364931"))
latitude.default = uci_latitude
latitude:depends(geolocation, "static")
latitude.datatype = "float"
local longitude = s:option(Value, "longitude", pkg_i18n.translate("Longitude"), pkg_i18n.translatef("e.g. %s", "7.606417"))
longitude.default = uci_longitude
longitude:depends(geolocation, "static")
longitude.datatype = "float"
local altitude;
if show_altitude() then
altitude = s:option(Value, "altitude", site_i18n.translate("gluon-config-mode:altitude-label"), pkg_i18n.translatef("e.g. %s", "11.51"))
altitude.default = uci:get("gluon-node-info", location, "altitude")
altitude:depends(geolocation, "static")
altitude.datatype = "float"
altitude.optional = true
end
function geolocation:write(data)
if data == "static" then
uci:set("gluon-node-info", location, "latitude", latitude.data)
uci:set("gluon-node-info", location, "longitude", longitude.data)
if show_altitude() then
if altitude.data then
uci:set("gluon-node-info", location, "altitude", altitude.data)
else
uci:delete("gluon-node-info", location, "altitude")
end
end
end
if data == "none" then
uci:delete("gluon-node-info", location, "altitude")
uci:delete("gluon-node-info", location, "latitude")
uci:delete("gluon-node-info", location, "longitude")
uci:set("gluon-node-info", location, "share_location", 0)
else
uci:set("gluon-node-info", location, "share_location", share_location.data)
end
end
return {'gluon-node-info'}
end

View File

@ -0,0 +1,6 @@
need_boolean(in_site({'config_mode', 'geo_location', 'show_altitude'}), false)
#ifdef WITHMAP
need_string(in_site({'config_mode', 'geo_location', 'olurl'}), false)
need_number(in_site({'config_mode', 'geo_location', 'map_lon'}), false)
need_number(in_site({'config_mode', 'geo_location', 'map_lat'}), false)
#endif

View File

@ -0,0 +1,54 @@
msgid ""
msgstr ""
#ifdef WITHMAP
"Project-Id-Version: gluon-config-mode-geo-location-with-map\n"
#else
"Project-Id-Version: gluon-config-mode-geo-location\n"
#endif
"PO-Revision-Date: 2017-08-22 12:14+0100\n"
"Last-Translator: Jan-Tarek Butt <tarek@ring0.de>\n"
"Language-Team: German\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
msgid ""
"If you want the location of your node to be displayed on the map, you can "
"enter its coordinates here. "
#ifdef WITHMAP
"If your PC is connected to the internet you can also click on the map displayed below. "
#endif
"Please keep in mind setting a location can also enhance the network quality."
msgstr ""
"Um Deinen Router auf der Karte anzeigen zu können, benötigen wir seine "
"Koordinaten. Hier hast Du die Möglichkeit, "
"die Koordinaten händisch zu hinterlegen."
#ifdef WITHMAP
"Wenn dein Computer mit dem du den Router einrichtes am Internet angeschlossen ist, "
"hast du die Möglichkeit auf der unten angezeigten Karte an die stelle zu klicken wo "
"der Router Stehen wird."
#endif
"Bitte berücksichtige das, das setzen einer Position die Netzwerk Qualität verbessern kann."
msgid "Geo-Location"
msgstr "Geo-Position"
msgid "Static location"
msgstr "Manuelle Position"
msgid "Disabled"
msgstr "Deaktiviert"
msgid "Share your location to see your router on the map"
msgstr "Position für die Karte freigeben"
msgid "Latitude"
msgstr "Breitengrad"
msgid "Longitude"
msgstr "Längengrad"
msgid "e.g. %s"
msgstr "z.B. %s"

View File

@ -0,0 +1,51 @@
msgid ""
msgstr ""
#ifdef WITHMAP
"Project-Id-Version: gluon-config-mode-geo-location-with-map\n"
#else
"Project-Id-Version: gluon-config-mode-geo-location\n"
#endif
"PO-Revision-Date: 2017-08-22 12:14+0100\n"
"Last-Translator: Jan-Tarek Butt <tarek@ring0.de>\n"
"Language-Team: French\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
msgid ""
"If you want the location of your node to be displayed on the map, you can "
"enter its coordinates here. "
#ifdef WITHMAP
"If your PC is connected to the internet you can also click on the map displayed below. "
#endif
"Please keep in mind setting a location can also enhance the network quality."
msgstr ""
"Si vous souhaitez que l'emplacement de votre nœud soit affiché sur la carte, vous pouvez "
"entrer ses coordonnées ici."
#ifdef WITHMAP
"Si votre PC est connecté à Internet, vous pouvez également cliquer sur la carte ci-dessous."
#endif
"Gardez à l'esprit que la définition d'un emplacement peut également améliorer la qualité du réseau."
msgid "Geo-Location"
msgstr "Géolocalisation"
msgid "Static location"
msgstr "position manuelle"
msgid "Disabled"
msgstr "Désactivé"
msgid "Share your location to see your router on the map"
msgstr "Partagez votre emplacement pour voir votre routeur sur la carte"
msgid "Latitude"
msgstr "Latitude"
msgid "Longitude"
msgstr "Longitude"
msgid "e.g. %s"
msgstr "Ex: %s"

View File

@ -0,0 +1,32 @@
msgid ""
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. "
#ifdef WITHMAP
"If your PC is connected to the internet you can also click on the map displayed below. "
#endif
"Please keep in mind setting a location can also enhance the network quality."
msgstr ""
msgid "Geo-Location"
msgstr ""
msgid "Static location"
msgstr ""
msgid "Disabled"
msgstr ""
msgid "Share your location to see your router on the map"
msgstr ""
msgid "Latitude"
msgstr ""
msgid "Longitude"
msgstr ""
msgid "e.g. %s"
msgstr ""