changeset 5669:6bf942f486e9

Merging with clickable-links
author Thomas Junk <thomas.junk@intevation.de>
date Thu, 07 Dec 2023 16:56:24 +0100
parents daa39433bef1 (current diff) 296569ad839b (diff)
children b75d0b303328
files
diffstat 3 files changed, 96 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/identify/Identify.vue	Mon Dec 04 12:44:04 2023 +0100
+++ b/client/src/components/identify/Identify.vue	Thu Dec 07 16:56:24 2023 +0100
@@ -162,13 +162,13 @@
               v-if="prop.val"
               class="d-flex justify-content-between px-2"
             >
-              <template v-if="prop.key != 'gauge_objname'">
+              <template v-if="prop.key != 'gauge objname'">
                 <b>{{ prop.key }}</b>
                 <span>{{ prop.val }}</span>
               </template>
               <template v-else>
                 <b><translate>Reference Gauge</translate></b>
-                <a>{{ prop.val }}</a>
+                <a @click="selectGauge(prop.val)" href="#">{{ prop.val }}</a>
               </template>
             </small>
           </div>
@@ -324,9 +324,18 @@
     ...mapState("application", ["showIdentify", "userManualUrl", "config"]),
     ...mapGetters("map", ["filteredIdentifiedFeatures"]),
     ...mapState("map", ["currentMeasurement"]),
+    ...mapGetters("map", ["openLayersMap"]),
     ...mapState("gauges", ["gauges"]),
     ...mapGetters("user", ["isWaterwayAdmin", "isSysAdmin"]),
     ...mapState("importschedule", ["availableReports"]),
+    gaugesLookUp: {
+      get() {
+        return this.gauges.reduce((o, gauge) => {
+          o[gauge.properties.objname] = gauge;
+          return o;
+        }, {});
+      }
+    },
     DQLDownloadAllowed() {
       if (this.loadingDQL) return false;
       return this.isWaterwayAdmin || this.isSysAdmin;
@@ -439,6 +448,22 @@
     }
   },
   methods: {
+    selectGauge(gauge_name) {
+      const gauge = this.gaugesLookUp[gauge_name];
+      const zoom = 16;
+      this.openLayersMap()
+        .getLayer("GAUGES")
+        .setVisible(true);
+      this.$store.dispatch(
+        "gauges/setSelectedGaugeISRS",
+        gauge.properties.isrs_code
+      );
+      this.$store.dispatch("map/moveMap", {
+        coordinates: gauge.geometry.coordinates,
+        zoom,
+        preventZoomOut: true
+      });
+    },
     downloadDataQualityReport(reportName) {
       this.loadingDQL = true;
       HTTP.get(`/data/report/${reportName}`, {
--- a/client/src/components/importconfiguration/ImportDetails.vue	Mon Dec 04 12:44:04 2023 +0100
+++ b/client/src/components/importconfiguration/ImportDetails.vue	Thu Dec 07 16:56:24 2023 +0100
@@ -152,7 +152,7 @@
     }
   },
   mounted() {
-    this.updateImport = !!this.Import
+    this.updateImport = !!this.Import;
   },
   methods: {
     back() {
--- a/client/src/components/importoverview/LogItem.vue	Mon Dec 04 12:44:04 2023 +0100
+++ b/client/src/components/importoverview/LogItem.vue	Thu Dec 07 16:56:24 2023 +0100
@@ -31,15 +31,81 @@
           'font-weight-bold': /warn|error/.test(line.kind)
         }
       ]"
-      >{{ line.message }}
+      ><template v-for="part in line_message">
+        <template
+          v-if="/\w+_Bottleneck_?\d+/.test(part) && bottlenecksLookup[part]"
+        >
+          <a @click="showBottleneck(part)" href="#" :key="part">{{ part }}</a>
+        </template>
+        <template v-else>
+          {{ part }}
+        </template>
+      </template>
     </span>
   </div>
 </template>
 
 <script>
+/* This is Free Software under GNU Affero General Public License v >= 3.0
+ * without warranty, see README.md and license for details.
+ *
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ * License-Filename: LICENSES/AGPL-3.0.txt
+ *
+ * Copyright (C) 2018 by via donau
+ *   – Österreichische Wasserstraßen-Gesellschaft mbH
+ * Software engineering by Intevation GmbH
+ *
+ * Author(s):
+ * Thomas Junk <thomas.junk@intevation.de>
+ */
+import { mapGetters } from "vuex";
+
 export default {
   name: "Item",
-  props: ["height", "line", "index"]
+  props: ["height", "line", "index"],
+  computed: {
+    ...mapGetters("bottlenecks", ["bottlenecksForDisplay"]),
+    ...mapGetters("map", ["openLayersMap"]),
+    bottlenecksLookup: {
+      get() {
+        return this.bottlenecksForDisplay.reduce((o, bn) => {
+          o[bn.properties.bottleneck_id] = bn;
+          return o;
+        }, {});
+      }
+    },
+    line_message: {
+      get() {
+        const search = /(\w+_Bottleneck_?\d+)/g;
+        return this.line.message.replace(search, "||$1||").split("||");
+      }
+    }
+  },
+  methods: {
+    showBottleneck(bottleneck_id) {
+      const bottleneck = this.bottlenecksLookup[bottleneck_id];
+      this.openLayersMap()
+        .getLayer("BOTTLENECKS")
+        .setVisible(true);
+      this.$store
+        .dispatch(
+          "bottlenecks/setSelectedBottleneck",
+          bottleneck.properties.bottleneck_id
+        )
+        .then(() => {
+          this.$store.dispatch("map/moveToFeauture", {
+            feature: bottleneck,
+            zoom: 16,
+            preventZoomOut: true
+          });
+        });
+      this.$store.commit(
+        "bottlenecks/setBottleneckForPrint",
+        bottleneck.properties.name
+      );
+    }
+  }
 };
 </script>