changeset 3756:c493e3be54ba infiniscroll

merge with default
author Thomas Junk <thomas.junk@intevation.de>
date Tue, 25 Jun 2019 12:05:10 +0200
parents 7ca3b288ac5e (current diff) 78ba9b2574ff (diff)
children dbd2531abc17
files
diffstat 3 files changed, 28 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/Search.vue	Tue Jun 25 12:04:45 2019 +0200
+++ b/client/src/components/Search.vue	Tue Jun 25 12:05:10 2019 +0200
@@ -317,11 +317,19 @@
           .setVisible(true);
       }
       if (resultEntry.type === "stretch") {
+        this.$store.commit(
+          "imports/selectedStretchId",
+          "stretches_geoserver." + resultEntry.id
+        );
         this.openLayersMap()
           .getLayer("STRETCHES")
           .setVisible(true);
       }
       if (resultEntry.type === "section") {
+        this.$store.commit(
+          "imports/selectedSectionId",
+          "sections_geoserver." + resultEntry.id
+        );
         this.openLayersMap()
           .getLayer("SECTIONS")
           .setVisible(true);
--- a/pkg/controllers/srimports.go	Tue Jun 25 12:04:45 2019 +0200
+++ b/pkg/controllers/srimports.go	Tue Jun 25 12:05:10 2019 +0200
@@ -193,17 +193,19 @@
 		return
 	}
 
+	var messages []string
+
 	srFile := filepath.Join(dir, "sr.zip")
 
 	var zr *zip.ReadCloser
-	if zr, err = zip.OpenReader(srFile); err != nil {
-		return
-	}
 	var once sync.Once
 	closeOnce := func() { zr.Close() }
-	defer once.Do(closeOnce)
 
-	var messages []string
+	if zr, err = zip.OpenReader(srFile); err != nil {
+		messages = append(messages, fmt.Sprintf("ZIP problem: %v", err))
+	} else {
+		defer once.Do(closeOnce)
+	}
 
 	var result struct {
 		Token    string      `json:"token,omitempty"`
@@ -213,7 +215,11 @@
 
 	find := func(ext string) *zip.File { return common.FindInZIP(zr, ext) }
 
-	noXYZ := find(".xyz") == nil && find(".txt") == nil
+	var noXYZ bool
+	if zr != nil {
+		noXYZ = find(".xyz") == nil && find(".txt") == nil
+	}
+
 	if noXYZ {
 		messages = append(messages, "no .xyz or .txt file found.")
 	}
@@ -233,7 +239,10 @@
 			result.Meta = meta
 		}
 	}
-	once.Do(closeOnce)
+
+	if zr != nil {
+		once.Do(closeOnce)
+	}
 
 	code := http.StatusCreated
 
--- a/schema/search_functions.sql	Tue Jun 25 12:04:45 2019 +0200
+++ b/schema/search_functions.sql	Tue Jun 25 12:05:10 2019 +0200
@@ -119,7 +119,8 @@
 BEGIN
   SELECT COALESCE(json_agg(r),'[]')
     INTO _result
-    FROM (SELECT objnam AS name,
+    FROM (SELECT id,
+                 objnam AS name,
                  ST_AsGeoJSON(ST_Envelope(area::geometry))::json AS geom,
                  'section' AS type
             FROM waterway.sections
@@ -138,7 +139,8 @@
 BEGIN
   SELECT COALESCE(json_agg(r),'[]')
     INTO _result
-    FROM (SELECT objnam AS name,
+    FROM (SELECT id,
+                 objnam AS name,
                  ST_AsGeoJSON(ST_Envelope(area::geometry))::json AS geom,
                  'stretch' AS type
             FROM waterway.stretches