gluon-config-mode-geo-location: rebase on master

This commit is contained in:
Jan-Tarek Butt 2018-07-18 06:14:17 +02:00
parent 3569f12944
commit 908efde194
7 changed files with 132 additions and 165 deletions

View File

@ -6,8 +6,114 @@ PKG_VERSION:=1
include ../gluon.mk
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-geloc-map +gluon-config-mode-geo-location-with-geloc +gluon-config-mode-geo-location-with-map
DEPENDS:=+gluon-config-mode-core +gluon-node-info
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 +gluon-config-mode-geo-location-with-geloc-map +gluon-config-mode-geo-location-with-geloc
DEPENDS:=+gluon-config-mode-core +gluon-node-info +gluon-web-osm
endef
define Package/gluon-config-mode-geo-location-with-geloc
TITLE:=Set geographic location of a node manualy or automatically recive geo locations via surrunding wifis and share it.
CONFLICTS:=+gluon-config-mode-geo-location +gluon-config-mode-geo-location-with-geloc-map +gluon-config-mode-geo-location-with-map
DEPENDS:=+gluon-config-mode-core +gluon-node-info +gluon-geolocator
endef
define Package/gluon-config-mode-geo-location-with-geloc-map
TITLE:=Set geographic location of a node manualy or automatically recive geo locations via surrunding wifis and share it, optionally show a map if internet available.
CONFLICTS:=+gluon-config-mode-geo-location +gluon-config-mode-geo-location-with-geloc +gluon-config-mode-geo-location-with-map
DEPENDS:=+gluon-config-mode-core +gluon-node-info +gluon-geolocator +gluon-web-osm
endef
define Build/Configure
$(CP) ./src/* $(PKG_BUILD_DIR)/
$(INSTALL_DIR) $(PKG_BUILD_DIR)/gluon-config-mode-geo-location{,-with-map,-with-geloc,-with-geloc-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/)
$(CC) -DWITHGELOC -E -x c -P $(PKG_BUILD_DIR)/0400-geo-location.lua.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua
$(CC) -DWITHGELOC -E -x c -P $(PKG_BUILD_DIR)/gluon-config-mode-geo-location.pot.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/i18n/gluon-config-mode-geo-location-with-geloc.pot
$(CC) -DWITHGELOC -E -x c -P $(PKG_BUILD_DIR)/check_site.lua.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/check_site.lua
$(CC) -DWITHGELOC -E -x c -P $(PKG_BUILD_DIR)/de.po.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/i18n/de.po
$(CC) -DWITHGELOC -E -x c -P $(PKG_BUILD_DIR)/fr.po.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/i18n/fr.po
$(call GluonBuildI18N,gluon-config-mode-geo-location-with-geloc,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/i18n)
$(call GluonSrcDiet,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/luasrc,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/luadest/)
$(CC) -DWITHMAP -DWITHGELOC -E -x c -P $(PKG_BUILD_DIR)/0400-geo-location.lua.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-map/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua
$(CC) -DWITHMAP -DWITHGELOC -E -x c -P $(PKG_BUILD_DIR)/gluon-config-mode-geo-location.pot.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-map/i18n/gluon-config-mode-geo-location-with-geloc-map.pot
$(CC) -DWITHMAP -DWITHGELOC -E -x c -P $(PKG_BUILD_DIR)/check_site.lua.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-map/check_site.lua
$(CC) -DWITHMAP -DWITHGELOC -E -x c -P $(PKG_BUILD_DIR)/de.po.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-map/i18n/de.po
$(CC) -DWITHMAP -DWITHGELOC -E -x c -P $(PKG_BUILD_DIR)/fr.po.in -o $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-map/i18n/fr.po
$(call GluonBuildI18N,gluon-config-mode-geo-location-with-geloc-map,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-map/i18n)
$(call GluonSrcDiet,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-map/luasrc,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-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-with-geloc/install
$(CP) $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/luadest/* $(1)/
$(call GluonInstallI18N,gluon-config-mode-geo-location-with-geloc,$(1))
endef
define Package/gluon-config-mode-geo-location-with-geloc-map/install
$(CP) $(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-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-geloc-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
define Package/gluon-config-mode-geo-location-with-geloc/postinst
#!/bin/sh
$(call GluonCheckSite,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc/check_site.lua)
endef
define Package/gluon-config-mode-geo-location-with-geloc-map/postinst
#!/bin/sh
$(call GluonCheckSite,$(PKG_BUILD_DIR)/gluon-config-mode-geo-location-with-geloc-map/check_site.lua)
endef
$(eval $(call BuildPackageGluon,gluon-config-mode-geo-location))
$(eval $(call BuildPackageGluon,gluon-config-mode-geo-location-with-map))
$(eval $(call BuildPackageGluon,gluon-config-mode-geo-location-with-geloc))
$(eval $(call BuildPackageGluon,gluon-config-mode-geo-location-with-geloc-map))

View File

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

View File

@ -1,6 +0,0 @@
({
baseUrl: "src",
include: "osm.js",
optimize: "uglify2",
out: "osm.js",
})

View File

@ -1,70 +0,0 @@
function findObj(name) {
list = document.getElementsByClassName("gluon-input-text");
for(i = 0; i < list.length; i++) {
item = list.item(i);
if(item.id.indexOf(name) >= 0) return item;
}
return false;
}
function showMap() {
if ("object" == typeof OpenLayers && false !== findObj("longitude")) {
document.getElementById("locationPickerMap").style.display = "block";
var e = new OpenLayers.Projection("EPSG:4326"),
a = new OpenLayers.Projection("EPSG:900913"),
t = 12,
n = new OpenLayers.Layer.Markers("Markers");
OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
defaultHandlerOptions: {
single: !0,
"double": !1,
pixelTolerance: 0,
stopSingle: !1,
stopDouble: !1
},
initialize: function() {
this.handlerOptions = OpenLayers.Util.extend({}, this.defaultHandlerOptions), OpenLayers.Control.prototype.initialize.apply(this, arguments), this.handler = new OpenLayers.Handler.Click(this, {
click: this.trigger
}, this.handlerOptions)
},
trigger: function(t) {
var i = osmMap.getLonLatFromPixel(t.xy);
oLon = findObj("longitude");
oLat = findObj("latitude");
lonlat1 = new OpenLayers.LonLat(i.lon, i.lat).transform(a, e),
oLon.value = lonlat1.lon,
oLat.value = lonlat1.lat,
n.clearMarkers(),
n.addMarker(new OpenLayers.Marker(i)),
oLon.className = oLon.className.replace(/ gluon-input-invalid/g, ""),
oLat.className = oLat.className.replace(/ gluon-input-invalid/g, "");
//Anyone knows how to trigger the change event?
//oLon.onChange()
//oLat.onChange()
}
}), osmMap = new OpenLayers.Map("locationPickerMap", {
controls: [new OpenLayers.Control.Navigation, new OpenLayers.Control.PanZoomBar, new OpenLayers.Control.MousePosition],
maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34),
numZoomLevels: 18,
maxResolution: 156543,
units: "m",
projection: a,
displayProjection: e
});
var i = new OpenLayers.Layer.OSM("OpenStreetMap");
osmMap.addLayer(i), osmMap.addLayer(n);
var o = longitude,
r = latitude;
oLon = findObj("longitude");
oLat = findObj("latitude");
"" != oLon.value && (o = oLon.value),
"" != oLat.value && (r = oLat.value),
n.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(o, r).transform(e, a)));
var l = new OpenLayers.LonLat(o, r),
d = l.transform(e, a);
osmMap.setCenter(d, t);
var s = new OpenLayers.Control.Click;
osmMap.addControl(s), s.activate()
} else setTimeout(showMap, 1e3)
}

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

@ -1,4 +1,7 @@
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")
@ -43,7 +46,7 @@ return function(form, uci)
return uci:get_bool("gluon-node-info", location, "altitude")
end
local text = translate(
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 ' ..
#ifdef WITHGELOC
'set an automatically localization of your router or ' ..
@ -60,16 +63,16 @@ return function(form, uci)
)
if show_altitude() then
text = text .. ' ' .. translate("gluon-config-mode:altitude-help")
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 src="]] .. show_olurl() .. [["></script>
<script src="/static/gluon/osm.js"></script>
<script>
<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() {
@ -89,13 +92,13 @@ return function(form, uci)
local uci_share_location = uci:get_bool("gluon-node-info", location, "share_location")
local geolocation = s:option(ListValue, "geolocation", translate("Geo-Location"))
local geolocation = s:option(ListValue, "geolocation", pkg_i18n.translate("Geo-Location"))
#ifdef WITHGELOC
geolocation:value("automatic", translate("Automatic (geolocator)"))
geolocation:value("auto_static", translate("Automatic & Static"))
geolocation:value("automatic", pkg_i18n.translate("Automatic (geolocator)"))
geolocation:value("auto_static", pkg_i18n.translate("Automatic & Static"))
#endif
geolocation:value("static", translate("Static location"))
geolocation:value("none", translate("Disabled"))
geolocation:value("static", pkg_i18n.translate("Static location"))
geolocation:value("none", pkg_i18n.translate("Disabled"))
#ifdef WITHGELOC
local auto_location = uci:get_bool("geolocator", "settings", "auto_location")
local static_location = uci:get_bool("geolocator", "settings", "static_location")
@ -118,7 +121,7 @@ return function(form, uci)
end
#endif
local share_location = s:option(Flag, "sharelocation", translate("Share your location to see your router on the map"))
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
#ifdef WITHGELOC
share_location:depends(geolocation, "automatic")
@ -128,19 +131,19 @@ return function(form, uci)
#ifdef WITHGELOC
--[[ -- Currently not available
o = s:option(DummyValue, "automatic_disc", " ", translatef("Automaticaly location service over wifi."))
o = s:option(DummyValue, "automatic_disc", " ", pkg_i18n.translatef("Automaticaly location service over wifi."))
o:depends(geolocation, "automatic")
o.description = translatef("Automaticaly location service over wifi.")
o.description = pkg_i18n.translatef("Automaticaly location service over wifi.")
--]]
local interval = s:option(Value, "interval", translate("Interval in minutes"), translatef("Set refresh interval"))
local interval = s:option(Value, "interval", pkg_i18n.translate("Interval in minutes"), pkg_i18n.translatef("Set refresh interval"))
interval.default = uci:get_first("geolocator", "settings", "refresh_interval")
interval:depends(geolocation, "automatic")
interval:depends(geolocation, "auto_static")
interval.datatype = "uinteger"
#endif
local latitude = s:option(Value, "latitude", translate("Latitude"), translatef("e.g. %s", "50.364931"))
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")
#ifdef WITHGELOC
@ -148,7 +151,7 @@ return function(form, uci)
#endif
latitude.datatype = "float"
local longitude = s:option(Value, "longitude", translate("Longitude"), translatef("e.g. %s", "7.606417"))
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")
#ifdef WITHGELOC
@ -158,7 +161,7 @@ return function(form, uci)
local altitude;
if show_altitude() then
altitude = s:option(Value, "altitude", translate("gluon-config-mode:altitude-label"), translatef("e.g. %s", "11.51"))
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")
#ifdef WITHGELOC

View File

@ -1,8 +1,6 @@
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)
need_boolean(in_site({'config_mode', 'geo_location', 'show_altitude'}), false)
#ifdef WITHMAP
need_string('config_mode.geo_location.olurl', false)
need_number('config_mode.geo_location.map_lon', false)
need_number('config_mode.geo_location.map_lat', false)
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
end