Mercurial > gemma
comparison client/src/components/fairway/AvailableFairwayDepthLNWL.vue @ 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 | 26325370ba18 |
children | ff8ca2d80ce9 |
comparison
equal
deleted
inserted
replaced
3805:36add6adf09b | 3806:cc80a37173f8 |
---|---|
71 * * Fadi Abbud <fadi.abbud@intevation.de> | 71 * * Fadi Abbud <fadi.abbud@intevation.de> |
72 */ | 72 */ |
73 import * as d3 from "d3"; | 73 import * as d3 from "d3"; |
74 import app from "@/main"; | 74 import app from "@/main"; |
75 import debounce from "debounce"; | 75 import debounce from "debounce"; |
76 import { diagram } from "@/lib/mixins"; | |
77 import { mapState } from "vuex"; | 76 import { mapState } from "vuex"; |
78 import filters from "@/lib/filters.js"; | 77 import filters from "@/lib/filters.js"; |
79 import canvg from "canvg"; | 78 import canvg from "canvg"; |
80 import { pdfgen } from "@/lib/mixins"; | 79 import { diagram, pdfgen, templateLoader } from "@/lib/mixins"; |
81 import { HTTP } from "@/lib/http"; | 80 import { HTTP } from "@/lib/http"; |
82 import { displayError } from "@/lib/errors"; | 81 import { displayError } from "@/lib/errors"; |
83 | 82 |
84 export default { | 83 export default { |
85 mixins: [diagram, pdfgen], | 84 mixins: [diagram, pdfgen, templateLoader], |
86 components: { | 85 components: { |
87 DiagramLegend: () => import("@/components/DiagramLegend") | 86 DiagramLegend: () => import("@/components/DiagramLegend") |
88 }, | 87 }, |
89 data() { | 88 data() { |
90 return { | 89 return { |
265 if (this.form.template.hasOwnProperty("properties")) { | 264 if (this.form.template.hasOwnProperty("properties")) { |
266 this.templateData = this.defaultTemplate; | 265 this.templateData = this.defaultTemplate; |
267 return; | 266 return; |
268 } | 267 } |
269 if (this.form.template) { | 268 if (this.form.template) { |
270 HTTP.get("/templates/diagram/" + this.form.template.name, { | 269 this.loadTemplates("/templates/diagram/" + this.form.template.name) |
271 headers: { | |
272 "X-Gemma-Auth": localStorage.getItem("token"), | |
273 "Content-type": "text/xml; charset=UTF-8" | |
274 } | |
275 }) | |
276 .then(response => { | 270 .then(response => { |
277 this.templateData = response.data.template_data; | 271 this.prepareImages(response.data.template_data.elements).then( |
272 values => { | |
273 values.forEach(v => { | |
274 response.data.template_data.elements[v.index].url = v.url; | |
275 }); | |
276 this.templateData = response.data.template_data; | |
277 } | |
278 ); | |
278 }) | 279 }) |
279 .catch(e => { | 280 .catch(e => { |
280 const { status, data } = e.response; | 281 const { status, data } = e.response; |
281 displayError({ | 282 displayError({ |
282 title: this.$gettext("Backend Error"), | 283 title: this.$gettext("Backend Error"), |