# HG changeset patch # User Thomas Junk # Date 1562232325 -7200 # Node ID 36add6adf09bce73e0a523ace75708a90f4dea9c # Parent 7f2c5576ec0a92f812da99d2502a881d8db4b9a1 x-cuts_diagram: use mixin for template loading and image processing diff -r 7f2c5576ec0a -r 36add6adf09b client/src/components/fairway/Fairwayprofile.vue --- a/client/src/components/fairway/Fairwayprofile.vue Thu Jul 04 11:21:59 2019 +0200 +++ b/client/src/components/fairway/Fairwayprofile.vue Thu Jul 04 11:25:25 2019 +0200 @@ -149,7 +149,7 @@ import { mapState, mapGetters } from "vuex"; import debounce from "debounce"; import canvg from "canvg"; -import { pdfgen } from "@/lib/mixins"; +import { pdfgen, templateLoader } from "@/lib/mixins"; import { HTTP } from "@/lib/http"; import { displayError } from "@/lib/errors"; @@ -157,7 +157,7 @@ const WATER_COLOR = "#005DFF"; export default { - mixins: [pdfgen], + mixins: [pdfgen, templateLoader], name: "fairwayprofile", components: { DiagramLegend: () => import("@/components/DiagramLegend") @@ -331,14 +331,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;