diff client/src/components/fairway/Profiles.vue @ 2848:b6886706b325

profiles: display sounding_differences
author Thomas Junk <thomas.junk@intevation.de>
date Thu, 28 Mar 2019 16:38:15 +0100
parents 77cef49d93ca
children a7e31594959d
line wrap: on
line diff
--- a/client/src/components/fairway/Profiles.vue	Thu Mar 28 15:43:32 2019 +0100
+++ b/client/src/components/fairway/Profiles.vue	Thu Mar 28 16:38:15 2019 +0100
@@ -92,6 +92,15 @@
               </select>
             </div>
           </div>
+          <div class="mt-3">
+            <button
+              :disabled="!additionalSurvey"
+              class="btn btn-info btn-sm w-100"
+              @click="showSurveyDiffences"
+            >
+              <translate>Show differences</translate>
+            </button>
+          </div>
           <hr class="w-100 mb-0" />
           <small class="text-muted d-block mt-2">
             <translate>Saved cross profiles</translate>:
@@ -241,6 +250,7 @@
 import LineString from "ol/geom/LineString";
 import { displayError, displayInfo } from "@/lib/errors.js";
 import { LAYERS } from "@/store/map.js";
+import { HTTP } from "@/lib/http";
 
 export default {
   name: "profiles",
@@ -252,7 +262,7 @@
     };
   },
   computed: {
-    ...mapGetters("map", ["getVSourceByName"]),
+    ...mapGetters("map", ["getVSourceByName", "getLayerByName"]),
     ...mapState("application", ["showProfiles"]),
     ...mapState("map", ["lineTool", "polygonTool", "cutTool"]),
     ...mapState("bottlenecks", [
@@ -382,6 +392,44 @@
     }
   },
   methods: {
+    showSurveyDiffences() {
+      HTTP.post(
+        "/diff",
+        {
+          bottleneck: this.selectedSurvey.bottleneck_id,
+          minuend: this.selectedSurvey.date_info,
+          subtrahend: this.additionalSurvey.date_info
+        },
+        {
+          headers: {
+            "X-Gemma-Auth": localStorage.getItem("token")
+          }
+        }
+      )
+        .then(() => {
+          const layer = this.getLayerByName(LAYERS.DIFFERENCES);
+          const wmsSrc = layer.data.getSource();
+          wmsSrc.updateParams({
+            cql_filter:
+              "objnam='" +
+              this.selectedBottleneck +
+              "' AND " +
+              "minuend='" +
+              this.selectedSurvey.date_info +
+              "' AND subtrahend='" +
+              this.additionalSurvey.date_info +
+              "'"
+          });
+          this.$store.commit("map/setLayerVisible", LAYERS.DIFFERENCES);
+        })
+        .catch(error => {
+          const { status, data } = error.response;
+          displayError({
+            title: this.$gettext("Backend Error"),
+            message: `${status}: ${data.message || data}`
+          });
+        });
+    },
     close() {
       this.$store.commit("application/showProfiles", false);
     },