changeset 4560:81b0f1cf2d41 iso-areas

Merged default into 'iso-areas' branch.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 02 Oct 2019 16:27:07 +0200
parents 92515c49c566 (current diff) e020e6e34ad7 (diff)
children f7b57136c800
files
diffstat 10 files changed, 121 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/README.md	Wed Oct 02 11:01:17 2019 +0200
+++ b/README.md	Wed Oct 02 16:27:07 2019 +0200
@@ -18,6 +18,9 @@
 
 - To only build the SPA-Client in demo mode you can use `make clientdemo`.
 
+Check [client/README](client/README.md) for details, especially
+if you want to do a production setup.
+
 For further details see [docs/DEVELOPMENT](docs/DEVELOPMENT.md).
 
 
--- a/client/README.md	Wed Oct 02 11:01:17 2019 +0200
+++ b/client/README.md	Wed Oct 02 16:27:07 2019 +0200
@@ -35,6 +35,11 @@
 * Build `yarn build`
 
   builds the production ready assets to `web` folder.
+  This is what the `../Makefile` will call, which you should use anyway.
+
+  For a real production use, edit the `title` tag in `public/index.html`
+  to something matching your installation.
+
 
 * Build `yarn build-demo`
   sets the hg revision as a node env var and builds the production ready assets to `web` folder.
--- a/client/src/components/fairway/BottleneckDialogue.vue	Wed Oct 02 11:01:17 2019 +0200
+++ b/client/src/components/fairway/BottleneckDialogue.vue	Wed Oct 02 16:27:07 2019 +0200
@@ -155,6 +155,32 @@
           </div>
           <hr class="w-100 mb-0" />
           <small class="text-muted d-block mt-2">
+            <translate>Custom Depth</translate>:
+          </small>
+          <div class="d-flex">
+            <input
+              class="form-control form-control-sm w-100 mt-1"
+              v-model.number="depth"
+              type="number"
+              step="0.1"
+              min="0"
+            />
+            <button
+              @click="useCustomDepth = !useCustomDepth"
+              :class="[
+                'btn',
+                'btn-xs',
+                'ml-2',
+                {
+                  'btn-info': useCustomDepth,
+                  'btn-secondary': !useCustomDepth
+                }
+              ]"
+            >
+              {{ useCustomDepth ? "disable" : "enable" }}
+            </button>
+          </div>
+          <small class="text-muted d-block mt-2">
             <translate>Saved cross profiles</translate>:
           </small>
           <div class="d-flex">
@@ -342,6 +368,22 @@
     profilesLable() {
       return this.$gettext("Bottleneck Surveys");
     },
+    useCustomDepth: {
+      get() {
+        return this.$store.state.fairwayprofile.useCustomDepth;
+      },
+      set(value) {
+        this.$store.commit("fairwayprofile/setUseCustomDepth", value);
+      }
+    },
+    depth: {
+      get() {
+        return this.$store.state.fairwayprofile.depth;
+      },
+      set(value) {
+        this.$store.commit("fairwayprofile/setDepth", value);
+      }
+    },
     selectedBottleneck: {
       get() {
         return this.$store.state.bottlenecks.selectedBottleneck;
@@ -476,6 +518,10 @@
     },
     selectedCut(cut) {
       if (cut) {
+        if (cut.depth) {
+          this.depth = cut.depth;
+          this.useCustomDepth = true;
+        }
         this.applyCoordinates(cut.coordinates);
       }
     }
@@ -618,7 +664,8 @@
         label: this.cutLabel,
         bottleneckName: this.selectedBottleneck,
         coordinates: [...this.startPoint, ...this.endPoint],
-        timestamp: new Date().getTime()
+        timestamp: new Date().getTime(),
+        depth: this.depth
       };
       const existingEntry = previousCuts.find(cut => {
         return JSON.stringify(cut) === JSON.stringify(newEntry);
--- a/client/src/components/fairway/Fairwayprofile.vue	Wed Oct 02 11:01:17 2019 +0200
+++ b/client/src/components/fairway/Fairwayprofile.vue	Wed Oct 02 16:27:07 2019 +0200
@@ -183,7 +183,9 @@
       "endPoint",
       "fairwayData",
       "maxAlt",
-      "selectedWaterLevel"
+      "selectedWaterLevel",
+      "depth",
+      "useCustomDepth"
     ]),
     ...mapState("bottlenecks", ["selectedSurvey", "selectedBottleneck"]),
     ...mapState("application", ["paneSetup"]),
@@ -236,6 +238,13 @@
     }
   },
   watch: {
+    depth() {
+      if (!this.useCustomDepth) return;
+      this.drawDiagram();
+    },
+    useCustomDepth() {
+      this.drawDiagram();
+    },
     currentData() {
       this.drawDiagram();
     },
@@ -465,7 +474,10 @@
             });
           graph
             .append("path")
-            .datum([{ x: startPoint, y: depth }, { x: endPoint, y: depth }])
+            .datum([
+              { x: startPoint, y: this.useCustomDepth ? this.depth : depth },
+              { x: endPoint, y: this.useCustomDepth ? this.depth : depth }
+            ])
             .attr("fill", `${this.getLayerStyle(data.los).fillColor}`)
             .attr("fill-opacity", this.getLayerStyle(data.los).fillOpacity)
             .attr("stroke", `${this.getLayerStyle(data.los).strokeColor}`)
--- a/client/src/store/fairwayprofile.js	Wed Oct 02 11:01:17 2019 +0200
+++ b/client/src/store/fairwayprofile.js	Wed Oct 02 16:27:07 2019 +0200
@@ -35,7 +35,9 @@
     previousCuts: [],
     profileLoading: false,
     selectedCut: null,
-    differencesLoading: false
+    differencesLoading: false,
+    depth: 2.5,
+    useCustomDepth: true
   };
 };
 
@@ -55,6 +57,12 @@
     }
   },
   mutations: {
+    setDepth: (state, value) => {
+      state.depth = value;
+    },
+    setUseCustomDepth: (state, flag) => {
+      state.useCustomDepth = flag;
+    },
     additionalSurvey: (state, additionalSurvey) => {
       state.additionalSurvey = additionalSurvey;
     },
--- a/pkg/controllers/search.go	Wed Oct 02 11:01:17 2019 +0200
+++ b/pkg/controllers/search.go	Wed Oct 02 16:27:07 2019 +0200
@@ -45,8 +45,10 @@
 	s := mw.JSONInput(req).(*models.SearchRequest)
 
 	if len(s.SearchString) == 0 {
-		err = mw.JSONError{http.StatusBadRequest,
-			"error: empty search string"}
+		err = mw.JSONError{
+			Code:    http.StatusBadRequest,
+			Message: "error: empty search string",
+		}
 		return
 	}
 
--- a/pkg/controllers/system.go	Wed Oct 02 11:01:17 2019 +0200
+++ b/pkg/controllers/system.go	Wed Oct 02 16:27:07 2019 +0200
@@ -68,8 +68,10 @@
 	// able to inject a verbatim '/' via the middleware, but better be on
 	// the safe site...
 	if strings.Contains(fileName, "/") {
-		err = mw.JSONError{http.StatusBadRequest,
-			"error: no slashes allowed in file name"}
+		err = mw.JSONError{
+			Code:    http.StatusBadRequest,
+			Message: "error: no slashes allowed in file name",
+		}
 		return
 	}
 
@@ -79,8 +81,10 @@
 	case "apache2", "postgresql":
 		path = "/var/log/" + serviceName + "/" + fileName
 	default:
-		err = mw.JSONError{http.StatusBadRequest,
-			"error: invalid service: " + serviceName}
+		err = mw.JSONError{
+			Code:    http.StatusBadRequest,
+			Message: "error: invalid service: " + serviceName,
+		}
 		return
 	}
 
--- a/pkg/controllers/user.go	Wed Oct 02 11:01:17 2019 +0200
+++ b/pkg/controllers/user.go	Wed Oct 02 16:27:07 2019 +0200
@@ -103,13 +103,19 @@
 
 	user := mux.Vars(req)["user"]
 	if !models.UserName(user).IsValid() {
-		err = mw.JSONError{http.StatusBadRequest, "error: user invalid"}
+		err = mw.JSONError{
+			Code:    http.StatusBadRequest,
+			Message: "error: user invalid",
+		}
 		return
 	}
 
 	session, _ := auth.GetSession(req)
 	if session.User == user {
-		err = mw.JSONError{http.StatusBadRequest, "error: cannot delete yourself"}
+		err = mw.JSONError{
+			Code:    http.StatusBadRequest,
+			Message: "error: cannot delete yourself",
+		}
 		return
 	}
 
@@ -152,7 +158,10 @@
 
 	user := models.UserName(mux.Vars(req)["user"])
 	if !user.IsValid() {
-		err = mw.JSONError{http.StatusBadRequest, "error: user invalid"}
+		err = mw.JSONError{
+			Code:    http.StatusBadRequest,
+			Message: "error: user invalid",
+		}
 		return
 	}
 
@@ -189,7 +198,10 @@
 		}
 	} else {
 		if newUser.Extent == nil {
-			err = mw.JSONError{http.StatusBadRequest, "extent is mandatory"}
+			err = mw.JSONError{
+				Code:    http.StatusBadRequest,
+				Message: "extent is mandatory",
+			}
 			return
 		}
 		res, err = db.ExecContext(
@@ -313,7 +325,10 @@
 
 	user := models.UserName(mux.Vars(req)["user"])
 	if !user.IsValid() {
-		err = mw.JSONError{http.StatusBadRequest, "error: user invalid"}
+		err = mw.JSONError{
+			Code:    http.StatusBadRequest,
+			Message: "error: user invalid",
+		}
 		return
 	}
 
@@ -349,7 +364,10 @@
 
 	user := models.UserName(mux.Vars(req)["user"])
 	if !user.IsValid() {
-		err = mw.JSONError{http.StatusBadRequest, "error: user invalid"}
+		err = mw.JSONError{
+			Code:    http.StatusBadRequest,
+			Message: "error: user invalid",
+		}
 		return
 	}
 
--- a/pkg/imports/gm.go	Wed Oct 02 11:01:17 2019 +0200
+++ b/pkg/imports/gm.go	Wed Oct 02 16:27:07 2019 +0200
@@ -161,11 +161,11 @@
 		client := nts.NewINtSMessageService(gm.URL, gm.Insecure, nil)
 
 		mt := nts.Message_type_typeWRM
-		var dis []*nts.Date_pair
-		dis = append(dis, &nts.Date_pair{
-			Date_start: nts.Date{Time: time.Now().Add(time.Duration(-24) * time.Hour)},
-			Date_end:   nts.Date{Time: time.Now()},
-		})
+		now := time.Now()
+		dis := []*nts.Date_pair{{
+			Date_start: nts.Date{Time: now.AddDate(0, 0, -1)},
+			Date_end:   nts.Date{Time: now.AddDate(0, 0, +1)},
+		}}
 
 		req := &nts.Get_messages_query{
 			Message_type: &mt,
--- a/pkg/imports/stsh.go	Wed Oct 02 11:01:17 2019 +0200
+++ b/pkg/imports/stsh.go	Wed Oct 02 16:27:07 2019 +0200
@@ -341,7 +341,7 @@
 			From:      lower,
 			To:        upper,
 			ObjNam:    objnam,
-			Date:      models.Date{date},
+			Date:      models.Date{Time: date},
 			Countries: countries,
 		}