Przeglądaj źródła

ffho-config-mode-geo-location: update to be like the patch submitted upstream

for details see https://github.com/freifunk-gluon/gluon/pull/693
Karsten Böddeker 8 lat temu
rodzic
commit
e5fb2f8419

+ 5 - 0
ffho/ffho-config-mode-geo-location/Makefile

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

+ 3 - 0
ffho/ffho-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

+ 32 - 3
ffho/ffho-config-mode-geo-location/files/lib/gluon/config-mode/wizard/0400-geo-location.lua

@@ -1,13 +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.'))
+  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
@@ -30,6 +45,15 @@ function M.section(form)
   o.datatype = "float"
   o.description = i18n.translatef("e.g. %s", "10.689901")
 
+  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
 
 function M.handle(data)
@@ -39,6 +63,11 @@ function M.handle(data)
   if data._location and data._latitude ~= nil and data._longitude ~= nil then
     uci:set("gluon-node-info", sname, "latitude", data._latitude:trim())
     uci:set("gluon-node-info", sname, "longitude", data._longitude:trim())
+    if data._altitude ~= nil then
+      uci:set("gluon-node-info", sname, "altitude", data._altitude:trim())
+    else
+      uci:delete("gluon-node-info", sname, "altitude")
+    end
   end
   uci:save("gluon-node-info")
   uci:commit("gluon-node-info")

+ 13 - 3
ffho/ffho-config-mode-geo-location/i18n/de.po

@@ -1,8 +1,8 @@
 msgid ""
 msgstr ""
-"Project-Id-Version: ffho-config-mode-geo-location\n"
-"PO-Revision-Date: 2015-10-23 14:45+0200\n"
-"Last-Translator: Karsten Böddeker <freifunk@kb-light.de>\n"
+"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"
@@ -17,12 +17,22 @@ 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 ""
+"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"
 
 msgid "Longitude"
 msgstr "Längengrad"
 
+msgid "Altitude"
+msgstr "Höhe"
+
 msgid "Show node on the map"
 msgstr "Knoten auf der Karte anzeigen"
 

+ 8 - 0
ffho/ffho-config-mode-geo-location/i18n/ffho-config-mode-geo-location.pot

@@ -6,12 +6,20 @@ msgid ""
 "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"
 msgstr ""
 
 msgid "Longitude"
 msgstr ""
 
+msgid "Altitude"
+msgstr ""
+
 msgid "Show node on the map"
 msgstr ""
 

+ 10 - 0
ffho/ffho-config-mode-geo-location/i18n/fr.po

@@ -17,12 +17,22 @@ msgstr ""
 "Pour Afficher votre nœud sur la Carte nous avons besoin de ses coordonnées. "
 "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"
 
 msgid "Longitude"
 msgstr "Longitude"
 
+msgid "Altitude"
+msgstr "Hauteur"
+
 msgid "Show node on the map"
 msgstr "Afficher le nœud sur la carte"