Mercurial > gemma
changeset 3806:cc80a37173f8 yworks-svg2pdf
Available-fairway-depth(both): use mixin for template loading and image processing
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Thu, 04 Jul 2019 11:43:06 +0200 |
parents | 36add6adf09b |
children | 876dc90c2825 |
files | client/src/components/fairway/AvailableFairwayDepth.vue client/src/components/fairway/AvailableFairwayDepthLNWL.vue |
diffstat | 2 files changed, 22 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/fairway/AvailableFairwayDepth.vue Thu Jul 04 11:25:25 2019 +0200 +++ b/client/src/components/fairway/AvailableFairwayDepth.vue Thu Jul 04 11:43:06 2019 +0200 @@ -73,11 +73,10 @@ import * as d3 from "d3"; import app from "@/main"; import debounce from "debounce"; -import { diagram } from "@/lib/mixins"; import { mapState } from "vuex"; import filters from "@/lib/filters.js"; import canvg from "canvg"; -import { pdfgen } from "@/lib/mixins"; +import { diagram, pdfgen, templateLoader } from "@/lib/mixins"; import { HTTP } from "@/lib/http"; import { displayError } from "@/lib/errors"; import { FREQUENCIES } from "@/store/fairwayavailability"; @@ -85,7 +84,7 @@ const hoursInDays = x => x / 24; export default { - mixins: [diagram, pdfgen], + mixins: [diagram, pdfgen, templateLoader], components: { DiagramLegend: () => import("@/components/DiagramLegend") }, @@ -267,14 +266,16 @@ return; } if (this.form.template) { - HTTP.get("/templates/diagram/" + this.form.template.name, { - headers: { - "X-Gemma-Auth": localStorage.getItem("token"), - "Content-type": "text/xml; charset=UTF-8" - } - }) + this.loadTemplates("/templates/diagram/" + this.form.template.name) .then(response => { - this.templateData = response.data.template_data; + this.prepareImages(response.data.template_data.elements).then( + values => { + values.forEach(v => { + response.data.template_data.elements[v.index].url = v.url; + }); + this.templateData = response.data.template_data; + } + ); }) .catch(e => { const { status, data } = e.response;
--- a/client/src/components/fairway/AvailableFairwayDepthLNWL.vue Thu Jul 04 11:25:25 2019 +0200 +++ b/client/src/components/fairway/AvailableFairwayDepthLNWL.vue Thu Jul 04 11:43:06 2019 +0200 @@ -73,16 +73,15 @@ import * as d3 from "d3"; import app from "@/main"; import debounce from "debounce"; -import { diagram } from "@/lib/mixins"; import { mapState } from "vuex"; import filters from "@/lib/filters.js"; import canvg from "canvg"; -import { pdfgen } from "@/lib/mixins"; +import { diagram, pdfgen, templateLoader } from "@/lib/mixins"; import { HTTP } from "@/lib/http"; import { displayError } from "@/lib/errors"; export default { - mixins: [diagram, pdfgen], + mixins: [diagram, pdfgen, templateLoader], components: { DiagramLegend: () => import("@/components/DiagramLegend") }, @@ -267,14 +266,16 @@ return; } if (this.form.template) { - HTTP.get("/templates/diagram/" + this.form.template.name, { - headers: { - "X-Gemma-Auth": localStorage.getItem("token"), - "Content-type": "text/xml; charset=UTF-8" - } - }) + this.loadTemplates("/templates/diagram/" + this.form.template.name) .then(response => { - this.templateData = response.data.template_data; + this.prepareImages(response.data.template_data.elements).then( + values => { + values.forEach(v => { + response.data.template_data.elements[v.index].url = v.url; + }); + this.templateData = response.data.template_data; + } + ); }) .catch(e => { const { status, data } = e.response;