# HG changeset patch # User Thomas Junk # Date 1569225924 -7200 # Node ID 0b99f03be7073716d7076132824b44a83367a108 # Parent 8a8c08b54f67b646714b4d9b22a04a7a2e8df899# Parent acb21e7362ce3c229d0721a6d2bececa13dadd2d merge diff -r 8a8c08b54f67 -r 0b99f03be707 client/src/components/gauge/Gauges.vue --- 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 */ -/*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() { diff -r 8a8c08b54f67 -r 0b99f03be707 client/src/components/gauge/HydrologicalConditions.vue --- 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, diff -r 8a8c08b54f67 -r 0b99f03be707 client/src/components/gauge/Waterlevel.vue --- 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 diff -r 8a8c08b54f67 -r 0b99f03be707 client/src/lib/mixins.js --- 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