changeset 4458:0b99f03be707

merge
author Thomas Junk <thomas.junk@intevation.de>
date Mon, 23 Sep 2019 10:05:24 +0200
parents 8a8c08b54f67 (current diff) acb21e7362ce (diff)
children dc9c150243df
files
diffstat 4 files changed, 28 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/gauge/Gauges.vue	Mon Sep 23 10:05:15 2019 +0200
+++ b/client/src/components/gauge/Gauges.vue	Mon Sep 23 10:05:24 2019 +0200
@@ -109,11 +109,13 @@
  * Author(s):
  * Markus Kottländer <markus.kottlaender@intevation.de>
  */
-/*eslint no-unused-vars: ["error", { "varsIgnorePattern": "_" }]*/
+
 import { mapState, mapGetters } from "vuex";
 import { displayError } from "@/lib/errors";
+import { pdfgen } from "@/lib/mixins";
 
 export default {
+  mixins: [pdfgen],
   data() {
     return {
       loading: false
@@ -244,27 +246,6 @@
     },
     gaugeLabel(gauge) {
       return `${gauge.properties.objname} (${this.isrsInfo(gauge).orc})`;
-    },
-    isrsInfo(gauge) {
-      // See https://www.elwis.de/DE/Service/Daten-und-Fakten/RIS-Index/RIS-Index-node.html
-      const [
-        _,
-        countryCode,
-        loCode,
-        fairwaySection,
-        orc,
-        hectometre
-      ] = gauge.properties.isrs_code.match(
-        /(\w{2})(\w{3})(\w{5})(\w{5})(\w{5})/
-      );
-
-      return {
-        countryCode: countryCode,
-        loCode: loCode,
-        fairwaySection: fairwaySection,
-        orc: orc,
-        hectometre: hectometre
-      };
     }
   },
   mounted() {
--- a/client/src/components/gauge/HydrologicalConditions.vue	Mon Sep 23 10:05:15 2019 +0200
+++ b/client/src/components/gauge/HydrologicalConditions.vue	Mon Sep 23 10:05:24 2019 +0200
@@ -215,10 +215,9 @@
       );
     },
     downloadPDF() {
-      let diagramTitle =
-        this.gaugeInfo(this.selectedGaugeD) +
-        ": Hydrological Conditions " +
-        this.longtermIntervalD.join(" - ");
+      let diagramTitle = `${this.selectedGaugeD.properties.objname} (${
+        this.isrsInfo(this.selectedGaugeD).orc
+      }): Hydrological Conditions ${this.longtermIntervalD.join(" - ")}`;
 
       this.generatePDF({
         templateData: this.templateData,
--- a/client/src/components/gauge/Waterlevel.vue	Mon Sep 23 10:05:15 2019 +0200
+++ b/client/src/components/gauge/Waterlevel.vue	Mon Sep 23 10:05:24 2019 +0200
@@ -222,12 +222,9 @@
       saveAs(blog, filename);
     },
     downloadPDF() {
-      let diagramTitle =
-        this.gaugeInfo(this.selectedGauge) +
-        ": Waterlevel " +
-        this.dateFromD.toLocaleDateString() +
-        " - " +
-        this.dateToD.toLocaleDateString();
+      let diagramTitle = `${this.selectedGaugeD.properties.objname} (${
+        this.isrsInfo(this.selectedGaugeD).orc
+      }): Waterlevel ${this.dateFromD.toLocaleDateString()} - ${this.dateToD.toLocaleDateString()}`;
       this.generatePDF({
         templateData: this.templateData,
         diagramTitle: diagramTitle
--- a/client/src/lib/mixins.js	Mon Sep 23 10:05:15 2019 +0200
+++ b/client/src/lib/mixins.js	Mon Sep 23 10:05:24 2019 +0200
@@ -20,8 +20,7 @@
 import { HTTP } from "@/lib/http";
 import * as d3 from "d3";
 
-/*eslint no-unused-vars: ["error", { "varsIgnorePattern": "debugSVG" }]*/
-
+/*eslint no-unused-vars: ["error", { "varsIgnorePattern": "[debugSVG|_]" }]*/
 const debugSVG = ({ svg, svgWidth, svgHeight }) => {
   d3.select(svg)
     .append("rect")
@@ -216,17 +215,25 @@
     pixel2millimeter(pixels, dpi) {
       return (pixels * 25.4) / dpi;
     },
-    gaugeInfo(selectedGauge) {
-      // returns string with formatted gauge info
-      return (
-        selectedGauge.properties.objname +
-        " (" +
-        selectedGauge.id
-          .split(".")[1]
-          .replace(/[()]/g, "")
-          .split(",")[3] +
-        ")"
+    isrsInfo(gauge) {
+      // See https://www.elwis.de/DE/Service/Daten-und-Fakten/RIS-Index/RIS-Index-node.html
+      const [
+        _,
+        countryCode,
+        loCode,
+        fairwaySection,
+        orc,
+        hectometre
+      ] = gauge.properties.isrs_code.match(
+        /(\w{2})(\w{3})(\w{5})(\w{5})(\w{5})/
       );
+      return {
+        countryCode: countryCode,
+        loCode: loCode,
+        fairwaySection: fairwaySection,
+        orc: orc,
+        hectometre: hectometre
+      };
     },
     generatePDF(params) {
       // creates a new jsPDF object into this.pdf.doc