Mercurial > gemma
annotate client/src/components/Pdftool.vue @ 4086:23f88a6c1e88 timezone
importoverview, fairwayavailability, gauges: handle timezones
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Thu, 25 Jul 2019 17:11:30 +0200 |
parents | 6672b780722f |
children | 917c72e8360d |
rev | line source |
---|---|
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
1 <template> |
1480 | 2 <div |
3 :class="[ | |
4 'box ui-element rounded bg-white text-nowrap', | |
5 { expanded: showPdfTool } | |
6 ]" | |
7 > | |
2260
531e776cb81d
client: reduced width of pdf-, profile- and identify-box
Markus Kottlaender <markus@intevation.de>
parents:
2259
diff
changeset
|
8 <div style="width: 18rem"> |
2387
f185503ef35a
client: unified box's header styles by creating a reusable component
Markus Kottlaender <markus@intevation.de>
parents:
2376
diff
changeset
|
9 <UIBoxHeader |
f185503ef35a
client: unified box's header styles by creating a reusable component
Markus Kottlaender <markus@intevation.de>
parents:
2376
diff
changeset
|
10 icon="file-pdf" |
2754
d0f6c222f4f9
client:correct a set of strings marking
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2737
diff
changeset
|
11 :title="generatePdfLable" |
2387
f185503ef35a
client: unified box's header styles by creating a reusable component
Markus Kottlaender <markus@intevation.de>
parents:
2376
diff
changeset
|
12 :closeCallback="close" |
f185503ef35a
client: unified box's header styles by creating a reusable component
Markus Kottlaender <markus@intevation.de>
parents:
2376
diff
changeset
|
13 /> |
2534
bb5286acfee2
client: reduced spacings between and inside boxes and more compact main menu
Markus Kottlaender <markus@intevation.de>
parents:
2387
diff
changeset
|
14 <div class="box-body"> |
2114 | 15 <select |
16 @change="applyTemplateToForm" | |
17 v-model="form.template" | |
18 class="form-control d-block mb-2 w-100 font-weight-bold" | |
19 > | |
2124 | 20 <option |
2257
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
21 v-for="template in templates" |
2214
5a4b0c85e7a8
values in template select are now the actual objects
Markus Kottlaender <markus@intevation.de>
parents:
2212
diff
changeset
|
22 :value="template" |
2124 | 23 :key="template.name" |
2114 | 24 > |
2754
d0f6c222f4f9
client:correct a set of strings marking
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2737
diff
changeset
|
25 {{ template.name }} |
2124 | 26 </option> |
2112
8c0a0f237c2d
improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents:
2111
diff
changeset
|
27 </select> |
2114 | 28 <select |
29 v-model="form.format" | |
30 class="form-control form-control-sm d-block mb-2 w-100" | |
31 > | |
1635
ca48145dba9c
client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents:
1613
diff
changeset
|
32 <option value="landscape"><translate>landscape</translate></option> |
ca48145dba9c
client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents:
1613
diff
changeset
|
33 <option value="portrait"><translate>portrait</translate></option> |
ca48145dba9c
client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents:
1613
diff
changeset
|
34 </select> |
2112
8c0a0f237c2d
improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents:
2111
diff
changeset
|
35 <div class="d-flex"> |
8c0a0f237c2d
improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents:
2111
diff
changeset
|
36 <div class="flex-fill mr-2"> |
2114 | 37 <select |
38 v-model="form.resolution" | |
39 class="form-control form-control-sm mb-2 d-block w-100" | |
40 > | |
2225
bc1780dd7cd1
PDF generation: changed option names in resolution select
Markus Kottlaender <markus@intevation.de>
parents:
2224
diff
changeset
|
41 <option value="80"><translate>80 dpi</translate></option> |
bc1780dd7cd1
PDF generation: changed option names in resolution select
Markus Kottlaender <markus@intevation.de>
parents:
2224
diff
changeset
|
42 <option value="120"><translate>120 dpi</translate></option> |
bc1780dd7cd1
PDF generation: changed option names in resolution select
Markus Kottlaender <markus@intevation.de>
parents:
2224
diff
changeset
|
43 <option value="200"><translate>200 dpi</translate></option> |
2112
8c0a0f237c2d
improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents:
2111
diff
changeset
|
44 </select> |
8c0a0f237c2d
improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents:
2111
diff
changeset
|
45 </div> |
8c0a0f237c2d
improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents:
2111
diff
changeset
|
46 <div class="flex-fill ml-2"> |
2114 | 47 <select |
48 v-model="form.paperSize" | |
49 class="form-control form-control-sm mb-2 d-block w-100" | |
50 > | |
2220
d926292d81b6
PDF generation: changed form labels/option texts
Markus Kottlaender <markus@intevation.de>
parents:
2219
diff
changeset
|
51 <option value="a4"><translate>A4</translate></option> |
d926292d81b6
PDF generation: changed form labels/option texts
Markus Kottlaender <markus@intevation.de>
parents:
2219
diff
changeset
|
52 <option value="a3"><translate>A3</translate></option> |
2112
8c0a0f237c2d
improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents:
2111
diff
changeset
|
53 </select> |
8c0a0f237c2d
improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents:
2111
diff
changeset
|
54 </div> |
8c0a0f237c2d
improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents:
2111
diff
changeset
|
55 </div> |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1299
diff
changeset
|
56 <button |
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1299
diff
changeset
|
57 @click="download" |
2275
a6cfa06c5983
client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents:
2265
diff
changeset
|
58 :key="'downloadBtn'" |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1299
diff
changeset
|
59 type="button" |
2275
a6cfa06c5983
client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents:
2265
diff
changeset
|
60 v-if="readyToGenerate" |
2112
8c0a0f237c2d
improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents:
2111
diff
changeset
|
61 class="btn btn-sm btn-info d-block w-100 mt-2" |
1480 | 62 > |
63 <translate>Generate PDF</translate> | |
64 </button> | |
2275
a6cfa06c5983
client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents:
2265
diff
changeset
|
65 <button |
a6cfa06c5983
client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents:
2265
diff
changeset
|
66 @click="cancel" |
a6cfa06c5983
client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents:
2265
diff
changeset
|
67 :key="'cancelBtn'" |
a6cfa06c5983
client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents:
2265
diff
changeset
|
68 type="button" |
a6cfa06c5983
client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents:
2265
diff
changeset
|
69 v-else |
a6cfa06c5983
client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents:
2265
diff
changeset
|
70 class="btn btn-sm btn-danger d-block w-100 mt-2" |
a6cfa06c5983
client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents:
2265
diff
changeset
|
71 > |
a6cfa06c5983
client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents:
2265
diff
changeset
|
72 <font-awesome-icon class="mr-1" icon="spinner" spin /> |
a6cfa06c5983
client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents:
2265
diff
changeset
|
73 <translate>Cancel</translate> |
a6cfa06c5983
client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents:
2265
diff
changeset
|
74 </button> |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1299
diff
changeset
|
75 </div> |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
76 </div> |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1299
diff
changeset
|
77 </div> |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
78 </template> |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
79 |
3202 | 80 <style lang="scss" scoped> |
81 input, | |
82 select { | |
83 font-size: 0.8em; | |
84 } | |
85 </style> | |
86 | |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
87 <script> |
1362
ca33ad696594
remove the first empyty lines
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1361
diff
changeset
|
88 /* This is Free Software under GNU Affero General Public License v >= 3.0 |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
89 * without warranty, see README.md and license for details. |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1299
diff
changeset
|
90 * |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
91 * SPDX-License-Identifier: AGPL-3.0-or-later |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
92 * License-Filename: LICENSES/AGPL-3.0.txt |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1299
diff
changeset
|
93 * |
1878
f030182f82f1
client: fix style warning for pdfexport
Bernhard Reiter <bernhard@intevation.de>
parents:
1876
diff
changeset
|
94 * Copyright (C) 2018, 2019 by via donau |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
95 * – Österreichische Wasserstraßen-Gesellschaft mbH |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
96 * Software engineering by Intevation GmbH |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1299
diff
changeset
|
97 * |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
98 * Author(s): |
1635
ca48145dba9c
client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents:
1613
diff
changeset
|
99 * * Markus Kottländer <markus.kottlaender@intevation.de> |
ca48145dba9c
client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents:
1613
diff
changeset
|
100 * * Bernhard E. Reiter <bernhard@intevation.de> |
1878
f030182f82f1
client: fix style warning for pdfexport
Bernhard Reiter <bernhard@intevation.de>
parents:
1876
diff
changeset
|
101 * * Fadi Abbud <fadi.abbud@intevation.de> |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
102 */ |
3044
c71373594719
client: map: prepared store to hold multiple map objects
Markus Kottlaender <markus@intevation.de>
parents:
3006
diff
changeset
|
103 import { mapState, mapGetters } from "vuex"; |
3780
2b6734a6730a
include svg2pdf. substitute upstream jsdpf with yworks-fork
Thomas Junk <thomas.junk@intevation.de>
parents:
3408
diff
changeset
|
104 import jsPDF from "jspdf-yworks"; |
2985
1b8bb4f89227
client: removed .js and .vue extention from imports
Markus Kottlaender <markus@intevation.de>
parents:
2959
diff
changeset
|
105 import "@/lib/font-linbiolinum"; |
1b8bb4f89227
client: removed .js and .vue extention from imports
Markus Kottlaender <markus@intevation.de>
parents:
2959
diff
changeset
|
106 import { getPointResolution } from "ol/proj"; |
2947
a6eea3002e6e
client: cleanup import paths
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2767
diff
changeset
|
107 import { HTTP } from "@/lib/http"; |
2985
1b8bb4f89227
client: removed .js and .vue extention from imports
Markus Kottlaender <markus@intevation.de>
parents:
2959
diff
changeset
|
108 import { displayError } from "@/lib/errors"; |
3802
e8a950cf6c02
Move Template loading and Imageprocessing to mixin
Thomas Junk <thomas.junk@intevation.de>
parents:
3790
diff
changeset
|
109 import { pdfgen, templateLoader } from "@/lib/mixins"; |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
110 |
3840
387f239018c7
pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents:
3802
diff
changeset
|
111 const paperSizes = { |
1635
ca48145dba9c
client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents:
1613
diff
changeset
|
112 // in millimeter, landscape [width, height] |
ca48145dba9c
client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents:
1613
diff
changeset
|
113 a3: [420, 297], |
ca48145dba9c
client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents:
1613
diff
changeset
|
114 a4: [297, 210] |
ca48145dba9c
client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents:
1613
diff
changeset
|
115 }; |
ca48145dba9c
client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents:
1613
diff
changeset
|
116 |
3840
387f239018c7
pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents:
3802
diff
changeset
|
117 const DEFAULT_TEMPLATE = "Default"; |
387f239018c7
pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents:
3802
diff
changeset
|
118 |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
119 export default { |
3802
e8a950cf6c02
Move Template loading and Imageprocessing to mixin
Thomas Junk <thomas.junk@intevation.de>
parents:
3790
diff
changeset
|
120 mixins: [pdfgen, templateLoader], |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
121 name: "pdftool", |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
122 data() { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
123 return { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
124 form: { |
2112
8c0a0f237c2d
improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents:
2111
diff
changeset
|
125 template: null, |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
126 format: "landscape", |
1635
ca48145dba9c
client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents:
1613
diff
changeset
|
127 paperSize: "a4", |
1881
f512cfb63e53
pdf-generation: add select box to pdf tool to choose the resolutions
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1879
diff
changeset
|
128 downloadType: "download", |
2220
d926292d81b6
PDF generation: changed form labels/option texts
Markus Kottlaender <markus@intevation.de>
parents:
2219
diff
changeset
|
129 resolution: "80" |
1947
4235fa8f59d7
clien: pdf-gen: load logo externally; add prepare step
Bernhard Reiter <bernhard@intevation.de>
parents:
1936
diff
changeset
|
130 }, |
2265
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
131 templates: [ |
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
132 { |
3840
387f239018c7
pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents:
3802
diff
changeset
|
133 name: DEFAULT_TEMPLATE, |
2265
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
134 properties: { |
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
135 format: "landscape", |
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
136 paperSize: "a4", |
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
137 resolution: "80" |
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
138 }, |
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
139 elements: [ |
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
140 { |
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
141 type: "scalebar", |
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
142 position: "bottomright", |
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
143 offset: { x: 2, y: 2 } |
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
144 }, |
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
145 { |
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
146 type: "textbox", |
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
147 position: "bottomleft", |
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
148 offset: { x: 2, y: 2 }, |
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
149 width: 60, |
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
150 fontSize: 8, |
2284
9f327f197ddd
client: translation: mark some strings for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2275
diff
changeset
|
151 text: this.$gettext("Generated by") + " " + "{user}, {date}" |
2265
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
152 }, |
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
153 { |
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
154 type: "northarrow", |
3840
387f239018c7
pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents:
3802
diff
changeset
|
155 position: "topleft", |
2265
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
156 offset: { x: 6, y: 4 }, |
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
157 size: 2 |
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
158 } |
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
159 ] |
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
160 } |
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
161 ], |
2247
e6fba449aa3c
merged pdf-export in default
Markus Kottlaender <markus@intevation.de>
parents:
2240
diff
changeset
|
162 templateData: null, |
2218
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
163 pdf: { |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
164 doc: null, |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
165 width: null, |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
166 height: null |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
167 }, |
1947
4235fa8f59d7
clien: pdf-gen: load logo externally; add prepare step
Bernhard Reiter <bernhard@intevation.de>
parents:
1936
diff
changeset
|
168 logoImageForPDF: null, // a HTMLImageElement instance |
2275
a6cfa06c5983
client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents:
2265
diff
changeset
|
169 readyToGenerate: true, // if the user is allowed to press the button |
a6cfa06c5983
client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents:
2265
diff
changeset
|
170 rendercompleteListener: null, |
a6cfa06c5983
client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents:
2265
diff
changeset
|
171 mapSize: null, |
3980 | 172 resolution: null |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
173 }; |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
174 }, |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
175 computed: { |
2257
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
176 ...mapState("application", ["showPdfTool", "logoForPDF"]), |
2137
a31c9fa47ab8
client: pdf-gen: add bottleneck details
Bernhard Reiter <bernhard@intevation.de>
parents:
2124
diff
changeset
|
177 ...mapState("bottlenecks", ["selectedBottleneck", "selectedSurvey"]), |
3044
c71373594719
client: map: prepared store to hold multiple map objects
Markus Kottlaender <markus@intevation.de>
parents:
3006
diff
changeset
|
178 ...mapState("map", ["isolinesLegendImgDataURL"]), |
c71373594719
client: map: prepared store to hold multiple map objects
Markus Kottlaender <markus@intevation.de>
parents:
3006
diff
changeset
|
179 ...mapGetters("map", ["openLayersMap"]), |
2754
d0f6c222f4f9
client:correct a set of strings marking
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2737
diff
changeset
|
180 generatePdfLable() { |
d0f6c222f4f9
client:correct a set of strings marking
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2737
diff
changeset
|
181 return this.$gettext("Generate PDF"); |
d0f6c222f4f9
client:correct a set of strings marking
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2737
diff
changeset
|
182 }, |
2376
6efd7ecd3a7d
client: pdf-gen: generate more expressive filename
Markus Kottlaender <markus@intevation.de>
parents:
2325
diff
changeset
|
183 filename() { |
6efd7ecd3a7d
client: pdf-gen: generate more expressive filename
Markus Kottlaender <markus@intevation.de>
parents:
2325
diff
changeset
|
184 let date = new Date() |
6efd7ecd3a7d
client: pdf-gen: generate more expressive filename
Markus Kottlaender <markus@intevation.de>
parents:
2325
diff
changeset
|
185 .toISOString() |
6efd7ecd3a7d
client: pdf-gen: generate more expressive filename
Markus Kottlaender <markus@intevation.de>
parents:
2325
diff
changeset
|
186 .slice(0, 10) |
6efd7ecd3a7d
client: pdf-gen: generate more expressive filename
Markus Kottlaender <markus@intevation.de>
parents:
2325
diff
changeset
|
187 .replace(/-/g, ""); |
6efd7ecd3a7d
client: pdf-gen: generate more expressive filename
Markus Kottlaender <markus@intevation.de>
parents:
2325
diff
changeset
|
188 let filename = "map"; |
6efd7ecd3a7d
client: pdf-gen: generate more expressive filename
Markus Kottlaender <markus@intevation.de>
parents:
2325
diff
changeset
|
189 |
6efd7ecd3a7d
client: pdf-gen: generate more expressive filename
Markus Kottlaender <markus@intevation.de>
parents:
2325
diff
changeset
|
190 if (this.selectedBottleneck) { |
6efd7ecd3a7d
client: pdf-gen: generate more expressive filename
Markus Kottlaender <markus@intevation.de>
parents:
2325
diff
changeset
|
191 filename = this.selectedBottleneck; |
6efd7ecd3a7d
client: pdf-gen: generate more expressive filename
Markus Kottlaender <markus@intevation.de>
parents:
2325
diff
changeset
|
192 if (this.selectedSurvey) { |
6efd7ecd3a7d
client: pdf-gen: generate more expressive filename
Markus Kottlaender <markus@intevation.de>
parents:
2325
diff
changeset
|
193 filename += "-sr" + this.selectedSurvey.date_info.replace(/-/g, ""); |
6efd7ecd3a7d
client: pdf-gen: generate more expressive filename
Markus Kottlaender <markus@intevation.de>
parents:
2325
diff
changeset
|
194 } |
6efd7ecd3a7d
client: pdf-gen: generate more expressive filename
Markus Kottlaender <markus@intevation.de>
parents:
2325
diff
changeset
|
195 } |
6efd7ecd3a7d
client: pdf-gen: generate more expressive filename
Markus Kottlaender <markus@intevation.de>
parents:
2325
diff
changeset
|
196 |
6efd7ecd3a7d
client: pdf-gen: generate more expressive filename
Markus Kottlaender <markus@intevation.de>
parents:
2325
diff
changeset
|
197 filename = |
6efd7ecd3a7d
client: pdf-gen: generate more expressive filename
Markus Kottlaender <markus@intevation.de>
parents:
2325
diff
changeset
|
198 filename |
6efd7ecd3a7d
client: pdf-gen: generate more expressive filename
Markus Kottlaender <markus@intevation.de>
parents:
2325
diff
changeset
|
199 .replace(/[^\w-]/gi, "") // remove everything but wordchars and dash |
6efd7ecd3a7d
client: pdf-gen: generate more expressive filename
Markus Kottlaender <markus@intevation.de>
parents:
2325
diff
changeset
|
200 .toLowerCase() + |
6efd7ecd3a7d
client: pdf-gen: generate more expressive filename
Markus Kottlaender <markus@intevation.de>
parents:
2325
diff
changeset
|
201 "-exported" + |
6efd7ecd3a7d
client: pdf-gen: generate more expressive filename
Markus Kottlaender <markus@intevation.de>
parents:
2325
diff
changeset
|
202 date + |
6efd7ecd3a7d
client: pdf-gen: generate more expressive filename
Markus Kottlaender <markus@intevation.de>
parents:
2325
diff
changeset
|
203 ".pdf"; |
6efd7ecd3a7d
client: pdf-gen: generate more expressive filename
Markus Kottlaender <markus@intevation.de>
parents:
2325
diff
changeset
|
204 |
6efd7ecd3a7d
client: pdf-gen: generate more expressive filename
Markus Kottlaender <markus@intevation.de>
parents:
2325
diff
changeset
|
205 return filename; |
6efd7ecd3a7d
client: pdf-gen: generate more expressive filename
Markus Kottlaender <markus@intevation.de>
parents:
2325
diff
changeset
|
206 } |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
207 }, |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
208 methods: { |
2387
f185503ef35a
client: unified box's header styles by creating a reusable component
Markus Kottlaender <markus@intevation.de>
parents:
2376
diff
changeset
|
209 close() { |
f185503ef35a
client: unified box's header styles by creating a reusable component
Markus Kottlaender <markus@intevation.de>
parents:
2376
diff
changeset
|
210 this.$store.commit("application/showPdfTool", false); |
f185503ef35a
client: unified box's header styles by creating a reusable component
Markus Kottlaender <markus@intevation.de>
parents:
2376
diff
changeset
|
211 }, |
2112
8c0a0f237c2d
improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents:
2111
diff
changeset
|
212 // When a template is chosen from the dropdown, its propoerties are |
8c0a0f237c2d
improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents:
2111
diff
changeset
|
213 // applied to the rest of the form. |
8c0a0f237c2d
improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents:
2111
diff
changeset
|
214 applyTemplateToForm() { |
3840
387f239018c7
pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents:
3802
diff
changeset
|
215 if (this.form.template && this.form.template.name !== DEFAULT_TEMPLATE) { |
3802
e8a950cf6c02
Move Template loading and Imageprocessing to mixin
Thomas Junk <thomas.junk@intevation.de>
parents:
3790
diff
changeset
|
216 this.loadTemplates( |
e8a950cf6c02
Move Template loading and Imageprocessing to mixin
Thomas Junk <thomas.junk@intevation.de>
parents:
3790
diff
changeset
|
217 `/templates/${this.form.template.type}/${this.form.template.name}` |
3227
6d4d8e7ef881
client: adjust route for pdftemplate,pdftool and add check type to uploaded templates
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3222
diff
changeset
|
218 ) |
2247
e6fba449aa3c
merged pdf-export in default
Markus Kottlaender <markus@intevation.de>
parents:
2240
diff
changeset
|
219 .then(response => { |
3802
e8a950cf6c02
Move Template loading and Imageprocessing to mixin
Thomas Junk <thomas.junk@intevation.de>
parents:
3790
diff
changeset
|
220 this.prepareImages(response.data.template_data.elements).then( |
e8a950cf6c02
Move Template loading and Imageprocessing to mixin
Thomas Junk <thomas.junk@intevation.de>
parents:
3790
diff
changeset
|
221 values => { |
e8a950cf6c02
Move Template loading and Imageprocessing to mixin
Thomas Junk <thomas.junk@intevation.de>
parents:
3790
diff
changeset
|
222 values.forEach(v => { |
e8a950cf6c02
Move Template loading and Imageprocessing to mixin
Thomas Junk <thomas.junk@intevation.de>
parents:
3790
diff
changeset
|
223 response.data.template_data.elements[v.index].url = v.url; |
e8a950cf6c02
Move Template loading and Imageprocessing to mixin
Thomas Junk <thomas.junk@intevation.de>
parents:
3790
diff
changeset
|
224 }); |
3840
387f239018c7
pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents:
3802
diff
changeset
|
225 this.setTemplate(response.data.template_data); |
3802
e8a950cf6c02
Move Template loading and Imageprocessing to mixin
Thomas Junk <thomas.junk@intevation.de>
parents:
3790
diff
changeset
|
226 } |
3786
a2da2328bb86
PDFTool: prefetch images of template and convert to dataURI
Thomas Junk <thomas.junk@intevation.de>
parents:
3781
diff
changeset
|
227 ); |
2247
e6fba449aa3c
merged pdf-export in default
Markus Kottlaender <markus@intevation.de>
parents:
2240
diff
changeset
|
228 }) |
e6fba449aa3c
merged pdf-export in default
Markus Kottlaender <markus@intevation.de>
parents:
2240
diff
changeset
|
229 .catch(e => { |
e6fba449aa3c
merged pdf-export in default
Markus Kottlaender <markus@intevation.de>
parents:
2240
diff
changeset
|
230 const { status, data } = e.response; |
e6fba449aa3c
merged pdf-export in default
Markus Kottlaender <markus@intevation.de>
parents:
2240
diff
changeset
|
231 displayError({ |
2284
9f327f197ddd
client: translation: mark some strings for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2275
diff
changeset
|
232 title: this.$gettext("Backend Error"), |
2247
e6fba449aa3c
merged pdf-export in default
Markus Kottlaender <markus@intevation.de>
parents:
2240
diff
changeset
|
233 message: `${status}: ${data.message || data}` |
e6fba449aa3c
merged pdf-export in default
Markus Kottlaender <markus@intevation.de>
parents:
2240
diff
changeset
|
234 }); |
e6fba449aa3c
merged pdf-export in default
Markus Kottlaender <markus@intevation.de>
parents:
2240
diff
changeset
|
235 }); |
3840
387f239018c7
pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents:
3802
diff
changeset
|
236 } else { |
387f239018c7
pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents:
3802
diff
changeset
|
237 this.setTemplate(this.templates[0]); |
2112
8c0a0f237c2d
improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents:
2111
diff
changeset
|
238 } |
8c0a0f237c2d
improved behavior of pdf generation form
Markus Kottlaender <markus@intevation.de>
parents:
2111
diff
changeset
|
239 }, |
3840
387f239018c7
pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents:
3802
diff
changeset
|
240 setTemplate(template) { |
387f239018c7
pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents:
3802
diff
changeset
|
241 this.templateData = template; |
387f239018c7
pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents:
3802
diff
changeset
|
242 this.form.format = this.templateData.properties.format; |
387f239018c7
pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents:
3802
diff
changeset
|
243 this.form.paperSize = this.templateData.properties.paperSize; |
387f239018c7
pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents:
3802
diff
changeset
|
244 this.form.resolution = this.templateData.properties.resolution; |
387f239018c7
pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents:
3802
diff
changeset
|
245 }, |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
246 download() { |
3981
8ec8d9bc5468
document algorithm
Thomas Junk <thomas.junk@intevation.de>
parents:
3980
diff
changeset
|
247 /** |
8ec8d9bc5468
document algorithm
Thomas Junk <thomas.junk@intevation.de>
parents:
3980
diff
changeset
|
248 * In order to generate the image with the appropriate resolution |
8ec8d9bc5468
document algorithm
Thomas Junk <thomas.junk@intevation.de>
parents:
3980
diff
changeset
|
249 * we have to temporaily scale the visible part of the map. |
8ec8d9bc5468
document algorithm
Thomas Junk <thomas.junk@intevation.de>
parents:
3980
diff
changeset
|
250 * The newly rendered canvas is converted to Base64 DataURL. |
8ec8d9bc5468
document algorithm
Thomas Junk <thomas.junk@intevation.de>
parents:
3980
diff
changeset
|
251 * After that is done, the resolution is resetted to its previous state. |
8ec8d9bc5468
document algorithm
Thomas Junk <thomas.junk@intevation.de>
parents:
3980
diff
changeset
|
252 * |
8ec8d9bc5468
document algorithm
Thomas Junk <thomas.junk@intevation.de>
parents:
3980
diff
changeset
|
253 * calculateExtent() and fit() do not give the desired result |
8ec8d9bc5468
document algorithm
Thomas Junk <thomas.junk@intevation.de>
parents:
3980
diff
changeset
|
254 * when the view is rotated so we replace them completely by setting resolution |
8ec8d9bc5468
document algorithm
Thomas Junk <thomas.junk@intevation.de>
parents:
3980
diff
changeset
|
255 * |
8ec8d9bc5468
document algorithm
Thomas Junk <thomas.junk@intevation.de>
parents:
3980
diff
changeset
|
256 * Details: https://gis.stackexchange.com/questions/328933/openlayers-generating-clientside-pdfs |
8ec8d9bc5468
document algorithm
Thomas Junk <thomas.junk@intevation.de>
parents:
3980
diff
changeset
|
257 * |
8ec8d9bc5468
document algorithm
Thomas Junk <thomas.junk@intevation.de>
parents:
3980
diff
changeset
|
258 */ |
1947
4235fa8f59d7
clien: pdf-gen: load logo externally; add prepare step
Bernhard Reiter <bernhard@intevation.de>
parents:
1936
diff
changeset
|
259 this.readyToGenerate = false; |
4235fa8f59d7
clien: pdf-gen: load logo externally; add prepare step
Bernhard Reiter <bernhard@intevation.de>
parents:
1936
diff
changeset
|
260 |
1635
ca48145dba9c
client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents:
1613
diff
changeset
|
261 console.log( |
ca48145dba9c
client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents:
1613
diff
changeset
|
262 "will generate pdf with", |
ca48145dba9c
client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents:
1613
diff
changeset
|
263 this.form.paperSize, |
1884
59ef76d83de7
client: pdf-gen: make scalebar dynamic
Bernhard Reiter <bernhard@intevation.de>
parents:
1883
diff
changeset
|
264 this.form.format, |
59ef76d83de7
client: pdf-gen: make scalebar dynamic
Bernhard Reiter <bernhard@intevation.de>
parents:
1883
diff
changeset
|
265 this.form.resolution |
1635
ca48145dba9c
client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents:
1613
diff
changeset
|
266 ); |
1883
76a6d334e681
Client: pdf-gen: refactor addScaleBar
Bernhard Reiter <bernhard@intevation.de>
parents:
1882
diff
changeset
|
267 |
1635
ca48145dba9c
client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents:
1613
diff
changeset
|
268 if (this.form.format !== "portrait") { |
2218
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
269 this.pdf.width = paperSizes[this.form.paperSize][0]; |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
270 this.pdf.height = paperSizes[this.form.paperSize][1]; |
1635
ca48145dba9c
client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents:
1613
diff
changeset
|
271 } else { |
2218
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
272 this.pdf.width = paperSizes[this.form.paperSize][1]; |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
273 this.pdf.height = paperSizes[this.form.paperSize][0]; |
1635
ca48145dba9c
client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents:
1613
diff
changeset
|
274 } |
1874
bad32adafef2
client: add real pdf generation with jspdf
Bernhard Reiter <bernhard@intevation.de>
parents:
1635
diff
changeset
|
275 |
bad32adafef2
client: add real pdf generation with jspdf
Bernhard Reiter <bernhard@intevation.de>
parents:
1635
diff
changeset
|
276 // FUTURE: consider margins |
1635
ca48145dba9c
client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents:
1613
diff
changeset
|
277 |
1884
59ef76d83de7
client: pdf-gen: make scalebar dynamic
Bernhard Reiter <bernhard@intevation.de>
parents:
1883
diff
changeset
|
278 var pixelsPerMapMillimeter = this.form.resolution / 25.4; |
59ef76d83de7
client: pdf-gen: make scalebar dynamic
Bernhard Reiter <bernhard@intevation.de>
parents:
1883
diff
changeset
|
279 var mapSizeForPrint = [ |
2218
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
280 Math.round(this.pdf.width * pixelsPerMapMillimeter), |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
281 Math.round(this.pdf.height * pixelsPerMapMillimeter) |
1884
59ef76d83de7
client: pdf-gen: make scalebar dynamic
Bernhard Reiter <bernhard@intevation.de>
parents:
1883
diff
changeset
|
282 ]; |
3127
0374197c384f
client: fix openLayersMap getter calls
Markus Kottlaender <markus@intevation.de>
parents:
3044
diff
changeset
|
283 var map = this.openLayersMap(); |
3981
8ec8d9bc5468
document algorithm
Thomas Junk <thomas.junk@intevation.de>
parents:
3980
diff
changeset
|
284 this.mapSize = map.getSize(); |
3980 | 285 this.resolution = map.getView().getResolution(); |
1883
76a6d334e681
Client: pdf-gen: refactor addScaleBar
Bernhard Reiter <bernhard@intevation.de>
parents:
1882
diff
changeset
|
286 |
2218
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
287 this.pdf.doc = new jsPDF(this.form.format, "mm", this.form.paperSize); |
2275
a6cfa06c5983
client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents:
2265
diff
changeset
|
288 this.rendercompleteListener = map.once("rendercomplete", event => { |
1874
bad32adafef2
client: add real pdf generation with jspdf
Bernhard Reiter <bernhard@intevation.de>
parents:
1635
diff
changeset
|
289 let canvas = event.context.canvas; |
1884
59ef76d83de7
client: pdf-gen: make scalebar dynamic
Bernhard Reiter <bernhard@intevation.de>
parents:
1883
diff
changeset
|
290 let view = map.getView(); |
1887
3ed036adc80f
client: pdf-gen: fix scale calculation
Bernhard Reiter <bernhard@intevation.de>
parents:
1886
diff
changeset
|
291 let proj = view.getProjection(); |
3ed036adc80f
client: pdf-gen: fix scale calculation
Bernhard Reiter <bernhard@intevation.de>
parents:
1886
diff
changeset
|
292 let metersPerPixel = // average meters (reality) per pixel (map) |
3ed036adc80f
client: pdf-gen: fix scale calculation
Bernhard Reiter <bernhard@intevation.de>
parents:
1886
diff
changeset
|
293 getPointResolution(proj, view.getResolution(), view.getCenter()) * |
3ed036adc80f
client: pdf-gen: fix scale calculation
Bernhard Reiter <bernhard@intevation.de>
parents:
1886
diff
changeset
|
294 proj.getMetersPerUnit(); |
2767 | 295 let scaleDenominator = Math.round( |
1897
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
296 1000 * pixelsPerMapMillimeter * metersPerPixel |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
297 ); |
2767 | 298 console.log("scaleDenominator = ", scaleDenominator); |
3980 | 299 var snapshot = canvas.toDataURL("image/jpeg"); |
300 this.pdf.doc.addImage( | |
301 snapshot, | |
302 "JPEG", | |
303 0, | |
304 0, | |
2227
9b545e470b94
PDF generation: logo image, adjusted templates
Markus Kottlaender <markus@intevation.de>
parents:
2226
diff
changeset
|
305 this.pdf.width, |
3980 | 306 this.pdf.height |
2227
9b545e470b94
PDF generation: logo image, adjusted templates
Markus Kottlaender <markus@intevation.de>
parents:
2226
diff
changeset
|
307 ); |
1903
7247ac316cb7
client: pdf-gen: improve layout and ui
Bernhard Reiter <bernhard@intevation.de>
parents:
1897
diff
changeset
|
308 |
3980 | 309 if (this.templateData) { |
310 this.pdf.doc.setFont("linbiolinum", "normal"); | |
311 let defaultFontSize = 11, | |
312 defaultRounding = 2, | |
313 defaultTextColor = "black", | |
314 defaultBgColor = "white", | |
315 defaultPadding = 3, | |
316 defaultOffset = { x: 0, y: 0 }, | |
3993
6672b780722f
client: pdf-gen: improve addtext for pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3981
diff
changeset
|
317 defaultBorderColor = "white"; |
3980 | 318 this.templateData.elements.forEach(e => { |
319 switch (e.type) { | |
320 case "text": { | |
321 this.addText( | |
322 e.position, | |
323 e.offset || defaultOffset, | |
3993
6672b780722f
client: pdf-gen: improve addtext for pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3981
diff
changeset
|
324 e.width, |
3980 | 325 e.fontSize || defaultFontSize, |
326 e.color || defaultTextColor, | |
327 e.text | |
328 ); | |
329 break; | |
330 } | |
331 case "box": { | |
332 this.addBox( | |
333 e.position, | |
334 e.offset || defaultOffset, | |
335 e.width, | |
336 e.height, | |
337 e.rounding === 0 || e.rounding ? e.rounding : defaultRounding, | |
338 e.color || defaultBgColor, | |
339 e.brcolor || defaultBorderColor | |
340 ); | |
341 break; | |
342 } | |
343 case "textbox": { | |
344 this.addTextBox( | |
345 e.position, | |
346 e.offset || defaultOffset, | |
347 e.width, | |
348 e.height, | |
349 e.rounding === 0 || e.rounding ? e.rounding : defaultRounding, | |
350 e.padding || defaultPadding, | |
351 e.fontSize || defaultFontSize, | |
352 e.color || defaultTextColor, | |
353 e.background || defaultBgColor, | |
354 e.text, | |
355 e.brcolor || defaultBorderColor | |
356 ); | |
357 break; | |
2223
85142493096c
PDF generation: improved positioning, prepared demo templates
Markus Kottlaender <markus@intevation.de>
parents:
2222
diff
changeset
|
358 } |
3980 | 359 case "image": { |
360 this.addImage( | |
361 e.url, | |
362 e.format, | |
363 e.position, | |
364 e.offset || defaultOffset, | |
365 e.width, | |
366 e.height | |
367 ); | |
368 break; | |
369 } | |
370 case "bottleneck": { | |
371 this.addBottleneckInfo( | |
372 e.position, | |
373 e.offset || defaultOffset, | |
374 e.rounding === 0 || e.rounding ? e.rounding : defaultRounding, | |
375 e.color || defaultTextColor, | |
376 e.brcolor || defaultBorderColor | |
377 ); | |
378 break; | |
379 } | |
380 case "legend": { | |
381 this.addLegend( | |
382 e.position, | |
383 e.offset || defaultOffset, | |
384 e.rounding === 0 || e.rounding ? e.rounding : defaultRounding, | |
385 e.brcolor || defaultBorderColor | |
386 ); | |
387 break; | |
388 } | |
389 case "scalebar": { | |
390 this.addScaleBar( | |
391 scaleDenominator, | |
392 e.position, | |
393 e.offset || defaultOffset, | |
394 e.rounding === 0 || e.rounding ? e.rounding : defaultRounding, | |
395 e.brcolor || defaultBorderColor | |
396 ); | |
397 break; | |
398 } | |
399 case "scale": { | |
400 this.addScale( | |
401 scaleDenominator, | |
402 e.position, | |
403 e.width, | |
404 e.offset || defaultOffset, | |
405 e.fontSize || defaultFontSize, | |
406 e.color || defaultTextColor | |
407 ); | |
408 break; | |
409 } | |
410 case "northarrow": { | |
411 this.addNorthArrow( | |
412 e.position, | |
413 e.offset || defaultOffset, | |
414 e.size | |
415 ); | |
416 break; | |
417 } | |
418 } | |
2205
59c21dee6315
pdf-gen: improve pdftool to use value from template
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2124
diff
changeset
|
419 }); |
1928
76ca071cb006
client: pdf-gen: add legend graphic
Bernhard Reiter <bernhard@intevation.de>
parents:
1914
diff
changeset
|
420 |
3980 | 421 this.pdf.doc.save(this.filename); |
422 } | |
423 map.setSize(this.mapSize); | |
424 map.getView().setResolution(this.resolution); | |
425 this.readyToGenerate = true; | |
1874
bad32adafef2
client: add real pdf generation with jspdf
Bernhard Reiter <bernhard@intevation.de>
parents:
1635
diff
changeset
|
426 }); |
3980 | 427 const size = map.getSize(); |
428 const [width, height] = mapSizeForPrint; | |
2227
9b545e470b94
PDF generation: logo image, adjusted templates
Markus Kottlaender <markus@intevation.de>
parents:
2226
diff
changeset
|
429 map.setSize(mapSizeForPrint); |
3980 | 430 const scaling = Math.min(width / size[0], height / size[1]); |
431 map.getView().setResolution(this.resolution / scaling); | |
2275
a6cfa06c5983
client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents:
2265
diff
changeset
|
432 }, |
a6cfa06c5983
client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents:
2265
diff
changeset
|
433 cancel() { |
3127
0374197c384f
client: fix openLayersMap getter calls
Markus Kottlaender <markus@intevation.de>
parents:
3044
diff
changeset
|
434 this.openLayersMap().un( |
2275
a6cfa06c5983
client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents:
2265
diff
changeset
|
435 this.rendercompleteListener.type, |
a6cfa06c5983
client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents:
2265
diff
changeset
|
436 this.rendercompleteListener.listener |
a6cfa06c5983
client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents:
2265
diff
changeset
|
437 ); |
3127
0374197c384f
client: fix openLayersMap getter calls
Markus Kottlaender <markus@intevation.de>
parents:
3044
diff
changeset
|
438 this.openLayersMap().setSize(this.mapSize); |
0374197c384f
client: fix openLayersMap getter calls
Markus Kottlaender <markus@intevation.de>
parents:
3044
diff
changeset
|
439 this.openLayersMap() |
0374197c384f
client: fix openLayersMap getter calls
Markus Kottlaender <markus@intevation.de>
parents:
3044
diff
changeset
|
440 .getView() |
3980 | 441 .fit(this.resolution, { size: this.mapSize }); |
2275
a6cfa06c5983
client: pdf-gen: added cancel button
Markus Kottlaender <markus@intevation.de>
parents:
2265
diff
changeset
|
442 this.readyToGenerate = true; |
1876
e53924abb4a2
client: export some elements to pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1874
diff
changeset
|
443 }, |
2737
4a5c0e7cb75b
client:pdf-gen: add template element
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2714
diff
changeset
|
444 // add the used map scale and papersize |
2767 | 445 addScale(scaleDenominator, position, width, offset, fontSize, color) { |
2737
4a5c0e7cb75b
client:pdf-gen: add template element
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2714
diff
changeset
|
446 //TODO: check the correctence of the scalnominator value here. |
4a5c0e7cb75b
client:pdf-gen: add template element
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2714
diff
changeset
|
447 let str = |
4a5c0e7cb75b
client:pdf-gen: add template element
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2714
diff
changeset
|
448 this.$gettext("Scale") + |
4a5c0e7cb75b
client:pdf-gen: add template element
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2714
diff
changeset
|
449 " 1 : " + |
2767 | 450 scaleDenominator + |
2737
4a5c0e7cb75b
client:pdf-gen: add template element
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2714
diff
changeset
|
451 " " + |
4a5c0e7cb75b
client:pdf-gen: add template element
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2714
diff
changeset
|
452 "(DIN" + |
4a5c0e7cb75b
client:pdf-gen: add template element
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2714
diff
changeset
|
453 " " + |
4a5c0e7cb75b
client:pdf-gen: add template element
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2714
diff
changeset
|
454 this.form.paperSize.toUpperCase() + |
4a5c0e7cb75b
client:pdf-gen: add template element
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2714
diff
changeset
|
455 ")"; |
4a5c0e7cb75b
client:pdf-gen: add template element
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2714
diff
changeset
|
456 this.addText(position, offset, width, fontSize, color, str); |
4a5c0e7cb75b
client:pdf-gen: add template element
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2714
diff
changeset
|
457 }, |
2767 | 458 addScaleBar(scaleDenominator, position, offset, rounding, brcolor) { |
459 // scaleDenominator is the x in 1:x of the map scale | |
1897
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
460 |
2218
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
461 // hardcode maximal width for now |
1933
1aa2921d8832
client: pdf-gen: make scalebar box size dynamic
Bernhard Reiter <bernhard@intevation.de>
parents:
1931
diff
changeset
|
462 let maxWidth = 80; // in mm |
1aa2921d8832
client: pdf-gen: make scalebar box size dynamic
Bernhard Reiter <bernhard@intevation.de>
parents:
1931
diff
changeset
|
463 |
1897
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
464 // reduce width until we'll find a nice number for printing |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
465 // strategy: |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
466 // 1. check which unit prefix we shall use to get [10:10000[ |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
467 // 2. using a mapping for the leading digit to get [1:10[ |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
468 // 3. select a smaller number which is nicely dividable |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
469 // 4. scale up again to get length in paper mm and to be shown |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
470 |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
471 // from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log10#Polyfill |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
472 let log10 = |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
473 Math.log10 || // more precise, but unsupported by IE |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
474 function(x) { |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
475 return Math.log(x) * Math.LOG10E; |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
476 }; |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
477 |
2767 | 478 let maxLength = maxWidth * scaleDenominator; |
1897
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
479 |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
480 let unit = "mm"; |
1914
3d2b55d2d8a6
client: pdf-gen: fix scale bar calculation
Bernhard Reiter <bernhard@intevation.de>
parents:
1903
diff
changeset
|
481 let unitConversionFactor = 1; |
3d2b55d2d8a6
client: pdf-gen: fix scale bar calculation
Bernhard Reiter <bernhard@intevation.de>
parents:
1903
diff
changeset
|
482 if (maxLength >= 1e7) { |
3d2b55d2d8a6
client: pdf-gen: fix scale bar calculation
Bernhard Reiter <bernhard@intevation.de>
parents:
1903
diff
changeset
|
483 // >= 10 km |
1897
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
484 unit = "km"; |
1914
3d2b55d2d8a6
client: pdf-gen: fix scale bar calculation
Bernhard Reiter <bernhard@intevation.de>
parents:
1903
diff
changeset
|
485 unitConversionFactor = 1e6; |
3d2b55d2d8a6
client: pdf-gen: fix scale bar calculation
Bernhard Reiter <bernhard@intevation.de>
parents:
1903
diff
changeset
|
486 } else if (maxLength >= 1e4) { |
3d2b55d2d8a6
client: pdf-gen: fix scale bar calculation
Bernhard Reiter <bernhard@intevation.de>
parents:
1903
diff
changeset
|
487 // >= 10 m |
1897
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
488 unit = "m"; |
1914
3d2b55d2d8a6
client: pdf-gen: fix scale bar calculation
Bernhard Reiter <bernhard@intevation.de>
parents:
1903
diff
changeset
|
489 unitConversionFactor = 1e3; |
1897
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
490 } |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
491 |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
492 maxLength /= unitConversionFactor; |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
493 |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
494 // DEBUG console.log(maxLength, unit); |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
495 let unroundedLength = maxLength; |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
496 let numberOfDigits = Math.floor(log10(unroundedLength)); |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
497 let factor = Math.pow(10, numberOfDigits); |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
498 let mapped = unroundedLength / factor; |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
499 // DEBUG console.log(mapped); |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
500 |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
501 var length = Math.floor(maxLength); // just to have an upper limit |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
502 |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
503 // manually only use numbers that are very nice to devide by 4 |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
504 // note that this is taken into account for rounding later |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
505 if (mapped > 8) { |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
506 length = 8 * factor; |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
507 } else if (mapped > 4) { |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
508 length = 4 * factor; |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
509 } else if (mapped > 2) { |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
510 length = 2 * factor; |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
511 } else { |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
512 length = factor; |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
513 } |
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
514 |
2767 | 515 let size = (length * unitConversionFactor) / scaleDenominator / 4; |
2218
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
516 let fullSize = size * 4; |
1933
1aa2921d8832
client: pdf-gen: make scalebar box size dynamic
Bernhard Reiter <bernhard@intevation.de>
parents:
1931
diff
changeset
|
517 |
2218
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
518 // x/y defaults to offset for topleft corner (normal x/y coordinates) |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
519 let x = offset.x; |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
520 let y = offset.y; |
1933
1aa2921d8832
client: pdf-gen: make scalebar box size dynamic
Bernhard Reiter <bernhard@intevation.de>
parents:
1931
diff
changeset
|
521 |
2218
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
522 // if position is on the right, x needs to be calculate with pdf width and |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
523 // the size of the element |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
524 if (["topright", "bottomright"].indexOf(position) !== -1) { |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
525 x = this.pdf.width - offset.x - fullSize - 8; |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
526 } |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
527 if (["bottomright", "bottomleft"].indexOf(position) !== -1) { |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
528 y = this.pdf.height - offset.y - 10; |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
529 } |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
530 |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
531 // to give the outer white box 4mm padding |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
532 let scaleBarX = x + 4; |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
533 let scaleBarY = y + 5; // 5 because above the scalebar will be the numbers |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
534 |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
535 // draw outer white box |
2714
4dd38840d74b
client:pdf-gen:imporve some template elements
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2561
diff
changeset
|
536 this.addRoundedBox(x, y, fullSize + 8, 10, "white", rounding, brcolor); |
1897
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
537 |
2218
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
538 // draw first part of scalebar |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
539 this.pdf.doc.setDrawColor(0, 0, 0); |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
540 this.pdf.doc.setFillColor(0, 0, 0); |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
541 this.pdf.doc.rect(scaleBarX, scaleBarY, size, 1, "FD"); |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
542 |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
543 // draw second part of scalebar |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
544 this.pdf.doc.setDrawColor(0, 0, 0); |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
545 this.pdf.doc.setFillColor(255, 255, 255); |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
546 this.pdf.doc.rect(scaleBarX + size, scaleBarY, size, 1, "FD"); |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
547 |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
548 // draw third part of scalebar |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
549 this.pdf.doc.setDrawColor(0, 0, 0); |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
550 this.pdf.doc.setFillColor(0, 0, 0); |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
551 this.pdf.doc.rect(scaleBarX + size * 2, scaleBarY, size * 2, 1, "FD"); |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
552 |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
553 // draw numeric labels above scalebar |
2223
85142493096c
PDF generation: improved positioning, prepared demo templates
Markus Kottlaender <markus@intevation.de>
parents:
2222
diff
changeset
|
554 this.pdf.doc.setTextColor("black"); |
2240
c3cc21dee75d
client: pdf-gen add multi-language font
Bernhard Reiter <bernhard@intevation.de>
parents:
2227
diff
changeset
|
555 this.pdf.doc.setFontSize(6); |
2218
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
556 this.pdf.doc.text(scaleBarX, scaleBarY - 1, "0"); |
1897
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
557 // /4 and could give 2.5. We still round, because of floating point arith |
2218
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
558 this.pdf.doc.text( |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
559 scaleBarX + size - 1, |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
560 scaleBarY - 1, |
1897
c78efb1ddb02
client: pdf-gen: improve scalebar to show nice values
Bernhard Reiter <bernhard@intevation.de>
parents:
1887
diff
changeset
|
561 (Math.round((length * 10) / 4) / 10).toString() |
1884
59ef76d83de7
client: pdf-gen: make scalebar dynamic
Bernhard Reiter <bernhard@intevation.de>
parents:
1883
diff
changeset
|
562 ); |
2218
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
563 this.pdf.doc.text( |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
564 scaleBarX + size * 2 - 2, |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
565 scaleBarY - 1, |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
566 Math.round(length / 2).toString() |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
567 ); |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
568 this.pdf.doc.text( |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
569 scaleBarX + size * 4 - 4, |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
570 scaleBarY - 1, |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
571 Math.round(length).toString() + " " + unit |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
572 ); |
1876
e53924abb4a2
client: export some elements to pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1874
diff
changeset
|
573 }, |
2218
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
574 addNorthArrow(position, offset, size) { |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
575 // TODO: fix positioning |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
576 // x/y defaults to offset for topleft corner (normal x/y coordinates) |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
577 let x1 = offset.x; |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
578 let y1 = offset.y; |
1876
e53924abb4a2
client: export some elements to pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1874
diff
changeset
|
579 |
2218
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
580 // if position is on the right, x needs to be calculate with pdf width and |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
581 // the size of the element |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
582 if (["topright", "bottomright"].indexOf(position) !== -1) { |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
583 x1 = this.pdf.width - offset.x - size; |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
584 } |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
585 if (["bottomright", "bottomleft"].indexOf(position) !== -1) { |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
586 y1 = this.pdf.height - offset.y - size; |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
587 } |
2220
d926292d81b6
PDF generation: changed form labels/option texts
Markus Kottlaender <markus@intevation.de>
parents:
2219
diff
changeset
|
588 |
1876
e53924abb4a2
client: export some elements to pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1874
diff
changeset
|
589 var y2 = y1 + size * 3; |
e53924abb4a2
client: export some elements to pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1874
diff
changeset
|
590 var x3 = x1 - size * 2; |
e53924abb4a2
client: export some elements to pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1874
diff
changeset
|
591 var y3 = y1 + size * 5; |
e53924abb4a2
client: export some elements to pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1874
diff
changeset
|
592 var x4 = x1 + size * 2; |
2218
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
593 // white triangle |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
594 this.pdf.doc.setFillColor(255, 255, 255); |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
595 this.pdf.doc.setDrawColor(255, 255, 255); |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
596 this.pdf.doc.triangle( |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
597 x3 - 0.8, |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
598 y3 + 1.2, |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
599 x1, |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
600 y1 - 1.2, |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
601 x1, |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
602 y2 + 0.6, |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
603 "F" |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
604 ); |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
605 this.pdf.doc.triangle( |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
606 x1, |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
607 y1 - 1.2, |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
608 x1, |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
609 y2 + 0.6, |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
610 x4 + 0.8, |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
611 y3 + 1.2, |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
612 "F" |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
613 ); |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
614 |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
615 // north arrow |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
616 this.pdf.doc.setDrawColor(0, 0, 0); |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
617 this.pdf.doc.setFillColor(255, 255, 255); |
2539
ad2a1d02ad1c
client:pdf-gen: improve north arrow drawing
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2534
diff
changeset
|
618 this.pdf.doc.triangle(x3, y3, x1 - 0.1, y1 + 0.2, x1 - 0.1, y2, "FD"); |
2218
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
619 this.pdf.doc.setFillColor(0, 0, 0); |
2539
ad2a1d02ad1c
client:pdf-gen: improve north arrow drawing
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2534
diff
changeset
|
620 this.pdf.doc.triangle(x1 + 0.1, y1 + 0.2, x1 + 0.1, y2, x4, y3, "FD"); |
2218
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
621 this.pdf.doc.setFontSize(size * 3.1); |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
622 this.pdf.doc.setTextColor(255, 255, 255); |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
623 this.pdf.doc.setFontStyle("bold"); |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
624 this.pdf.doc.text(size < 3 ? x1 - 0.5 : x1 - 1.3, y3 + 1, "N"); |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
625 this.pdf.doc.setFontSize(size * 3); |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
626 this.pdf.doc.setTextColor(0, 0, 0); |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
627 this.pdf.doc.setFontStyle("normal"); |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
628 this.pdf.doc.text(size < 3 ? x1 - 0.5 : x1 - 1.3, y3 + 1, "N"); |
1876
e53924abb4a2
client: export some elements to pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1874
diff
changeset
|
629 }, |
2714
4dd38840d74b
client:pdf-gen:imporve some template elements
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2561
diff
changeset
|
630 addLegend(position, offset, rounding, brcolor) { |
2220
d926292d81b6
PDF generation: changed form labels/option texts
Markus Kottlaender <markus@intevation.de>
parents:
2219
diff
changeset
|
631 if ( |
d926292d81b6
PDF generation: changed form labels/option texts
Markus Kottlaender <markus@intevation.de>
parents:
2219
diff
changeset
|
632 this.selectedBottleneck && |
2259
7e378b38d302
client: pdf-gen: made selectedSurvey mandatory for displaying the bottleneck info box and iso line legend.
Markus Kottlaender <markus@intevation.de>
parents:
2258
diff
changeset
|
633 this.selectedSurvey && |
3127
0374197c384f
client: fix openLayersMap getter calls
Markus Kottlaender <markus@intevation.de>
parents:
3044
diff
changeset
|
634 this.openLayersMap() |
0374197c384f
client: fix openLayersMap getter calls
Markus Kottlaender <markus@intevation.de>
parents:
3044
diff
changeset
|
635 .getLayer("BOTTLENECKISOLINE") |
0374197c384f
client: fix openLayersMap getter calls
Markus Kottlaender <markus@intevation.de>
parents:
3044
diff
changeset
|
636 .getVisible() |
2220
d926292d81b6
PDF generation: changed form labels/option texts
Markus Kottlaender <markus@intevation.de>
parents:
2219
diff
changeset
|
637 ) { |
2218
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
638 // transforming into an HTMLImageElement only to find out |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
639 // the width x height of the legend image |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
640 // FUTURE: find a better way to get the width and height |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
641 let legendImage = new Image(); |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
642 legendImage.src = this.isolinesLegendImgDataURL; |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
643 let aspectRatio = legendImage.width / legendImage.height; |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
644 let width = 54; |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
645 let height = width / aspectRatio; |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
646 let padding = 2; |
2220
d926292d81b6
PDF generation: changed form labels/option texts
Markus Kottlaender <markus@intevation.de>
parents:
2219
diff
changeset
|
647 |
2218
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
648 // x/y defaults to offset for topleft corner (normal x/y coordinates) |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
649 let x = offset.x; |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
650 let y = offset.y; |
1947
4235fa8f59d7
clien: pdf-gen: load logo externally; add prepare step
Bernhard Reiter <bernhard@intevation.de>
parents:
1936
diff
changeset
|
651 |
2218
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
652 // if position is on the right, x needs to be calculate with pdf width and |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
653 // the size of the element |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
654 if (["topright", "bottomright"].indexOf(position) !== -1) { |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
655 x = this.pdf.width - offset.x - width; |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
656 } |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
657 if (["bottomright", "bottomleft"].indexOf(position) !== -1) { |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
658 y = this.pdf.height - offset.y - height; |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
659 } |
1947
4235fa8f59d7
clien: pdf-gen: load logo externally; add prepare step
Bernhard Reiter <bernhard@intevation.de>
parents:
1936
diff
changeset
|
660 |
2714
4dd38840d74b
client:pdf-gen:imporve some template elements
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2561
diff
changeset
|
661 this.addRoundedBox(x, y, width, height, "white", rounding, brcolor); |
2218
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
662 this.pdf.doc.addImage( |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
663 legendImage, |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
664 x + padding, |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
665 y + padding, |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
666 width - 2 * padding, |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
667 height - 2 * padding |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
668 ); |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
669 } |
1931
8fb1b1a8ea85
client: pdf-gen: improve legend behaviour
Bernhard Reiter <bernhard@intevation.de>
parents:
1928
diff
changeset
|
670 }, |
2714
4dd38840d74b
client:pdf-gen:imporve some template elements
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2561
diff
changeset
|
671 addBottleneckInfo(position, offset, rounding, color, brcolor) { |
2220
d926292d81b6
PDF generation: changed form labels/option texts
Markus Kottlaender <markus@intevation.de>
parents:
2219
diff
changeset
|
672 if ( |
d926292d81b6
PDF generation: changed form labels/option texts
Markus Kottlaender <markus@intevation.de>
parents:
2219
diff
changeset
|
673 this.selectedBottleneck && |
2259
7e378b38d302
client: pdf-gen: made selectedSurvey mandatory for displaying the bottleneck info box and iso line legend.
Markus Kottlaender <markus@intevation.de>
parents:
2258
diff
changeset
|
674 this.selectedSurvey && |
3127
0374197c384f
client: fix openLayersMap getter calls
Markus Kottlaender <markus@intevation.de>
parents:
3044
diff
changeset
|
675 this.openLayersMap() |
0374197c384f
client: fix openLayersMap getter calls
Markus Kottlaender <markus@intevation.de>
parents:
3044
diff
changeset
|
676 .getLayer("BOTTLENECKISOLINE") |
0374197c384f
client: fix openLayersMap getter calls
Markus Kottlaender <markus@intevation.de>
parents:
3044
diff
changeset
|
677 .getVisible() |
2220
d926292d81b6
PDF generation: changed form labels/option texts
Markus Kottlaender <markus@intevation.de>
parents:
2219
diff
changeset
|
678 ) { |
2258
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
679 let survey = this.selectedSurvey; |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
680 |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
681 // determine text dimensions |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
682 // this is a little bit cumbersome but we need to separate width |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
683 // calculations and writing |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
684 this.pdf.doc.setFontSize(10); |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
685 this.pdf.doc.setTextColor(color); |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
686 let textOptions = { baseline: "hanging" }; |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
687 let str1_1 = this.$gettext("Bottleneck") + ": "; |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
688 let str1_2 = this.selectedBottleneck; |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
689 let str2_1 = this.$gettext("Survey date") + ": "; |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
690 let str2_2 = survey.date_info; |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
691 let str3_1 = this.$gettext("Ref gauge") + ": "; |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
692 let str3_2 = survey.gauge_objname; |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
693 let str4_1 = this.$gettext("Depth relativ to") + ": "; |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
694 let str4_2 = |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
695 survey.depth_reference + |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
696 " = " + |
2291
60af456d01f0
client:pdf-gen:(minor) fix bottleneckinfo function
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2288
diff
changeset
|
697 (survey.hasOwnProperty("waterlevel_value") |
2258
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
698 ? survey.waterlevel_value + " cm" |
2291
60af456d01f0
client:pdf-gen:(minor) fix bottleneckinfo function
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2288
diff
changeset
|
699 : "?"); |
2258
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
700 |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
701 this.pdf.doc.setFontStyle("italic"); |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
702 let w1_1 = this.pdf.doc.getTextWidth(str1_1); |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
703 this.pdf.doc.setFontStyle("bold"); |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
704 let w1_2 = this.pdf.doc.getTextWidth(str1_2); |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
705 this.pdf.doc.setFontStyle("italic"); |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
706 let w2_1 = this.pdf.doc.getTextWidth(str2_1); |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
707 this.pdf.doc.setFontStyle("normal"); |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
708 let w2_2 = this.pdf.doc.getTextWidth(str2_2); |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
709 this.pdf.doc.setFontStyle("italic"); |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
710 let w3_1 = this.pdf.doc.getTextWidth(str3_1); |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
711 this.pdf.doc.setFontStyle("normal"); |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
712 let w3_2 = this.pdf.doc.getTextWidth(str3_2); |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
713 this.pdf.doc.setFontStyle("italic"); |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
714 let w4_1 = this.pdf.doc.getTextWidth(str4_1); |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
715 this.pdf.doc.setFontStyle("normal"); |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
716 let w4_2 = this.pdf.doc.getTextWidth(str4_2); |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
717 |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
718 let height = 21; |
2240
c3cc21dee75d
client: pdf-gen add multi-language font
Bernhard Reiter <bernhard@intevation.de>
parents:
2227
diff
changeset
|
719 let padding = 3; |
2258
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
720 let width = |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
721 Math.max(w1_1 + w1_2, w2_1 + w2_2, w3_1 + w3_2, w4_1 + w4_2) + |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
722 2 * padding; |
2220
d926292d81b6
PDF generation: changed form labels/option texts
Markus Kottlaender <markus@intevation.de>
parents:
2219
diff
changeset
|
723 |
2218
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
724 // x/y defaults to offset for topleft corner (normal x/y coordinates) |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
725 let x = offset.x; |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
726 let y = offset.y; |
1931
8fb1b1a8ea85
client: pdf-gen: improve legend behaviour
Bernhard Reiter <bernhard@intevation.de>
parents:
1928
diff
changeset
|
727 |
2218
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
728 // if position is on the right, x needs to be calculate with pdf width and |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
729 // the size of the element |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
730 if (["topright", "bottomright"].indexOf(position) !== -1) { |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
731 x = this.pdf.width - offset.x - width; |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
732 } |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
733 if (["bottomright", "bottomleft"].indexOf(position) !== -1) { |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
734 y = this.pdf.height - offset.y - height; |
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
735 } |
2137
a31c9fa47ab8
client: pdf-gen: add bottleneck details
Bernhard Reiter <bernhard@intevation.de>
parents:
2124
diff
changeset
|
736 |
2258
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
737 // white background box |
2714
4dd38840d74b
client:pdf-gen:imporve some template elements
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2561
diff
changeset
|
738 this.addRoundedBox(x, y, width, height, "white", rounding, brcolor); |
2138
4a903d382901
client: pdf-gen: make bottleneck infos more fancy
Bernhard Reiter <bernhard@intevation.de>
parents:
2137
diff
changeset
|
739 |
2258
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
740 // bottleneck |
2218
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
741 this.pdf.doc.setFontStyle("italic"); |
2258
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
742 this.pdf.doc.text(x + padding, y + padding, str1_1, textOptions); |
2218
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
743 this.pdf.doc.setFontStyle("bold"); |
2258
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
744 this.pdf.doc.text(x + padding + w1_1, y + padding, str1_2, textOptions); |
2137
a31c9fa47ab8
client: pdf-gen: add bottleneck details
Bernhard Reiter <bernhard@intevation.de>
parents:
2124
diff
changeset
|
745 |
2258
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
746 // survey date |
2218
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
747 this.pdf.doc.setFontStyle("italic"); |
2258
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
748 this.pdf.doc.text(x + padding, y + padding + 4, str2_1, textOptions); |
2218
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
749 this.pdf.doc.setFontStyle("normal"); |
2258
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
750 this.pdf.doc.text( |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
751 x + padding + w2_1, |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
752 y + padding + 4, |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
753 str2_2, |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
754 textOptions |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
755 ); |
2247
e6fba449aa3c
merged pdf-export in default
Markus Kottlaender <markus@intevation.de>
parents:
2240
diff
changeset
|
756 |
2258
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
757 // ref gauge |
2247
e6fba449aa3c
merged pdf-export in default
Markus Kottlaender <markus@intevation.de>
parents:
2240
diff
changeset
|
758 this.pdf.doc.setFontStyle("italic"); |
2258
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
759 this.pdf.doc.text(x + padding, y + padding + 8, str3_1, textOptions); |
2247
e6fba449aa3c
merged pdf-export in default
Markus Kottlaender <markus@intevation.de>
parents:
2240
diff
changeset
|
760 this.pdf.doc.setFontStyle("normal"); |
2258
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
761 this.pdf.doc.text( |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
762 x + padding + w3_1, |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
763 y + padding + 8, |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
764 str3_2, |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
765 textOptions |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
766 ); |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
767 |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
768 // depth relative to |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
769 this.pdf.doc.setFontStyle("italic"); |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
770 this.pdf.doc.text(x + padding, y + padding + 12, str4_1, textOptions); |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
771 this.pdf.doc.setFontStyle("normal"); |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
772 this.pdf.doc.text( |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
773 x + padding + w4_1, |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
774 y + padding + 12, |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
775 str4_2, |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
776 textOptions |
24cafd6b1a55
client: pdf-gen: width of bottleneck info box is calculated based on its content now
Markus Kottlaender <markus@intevation.de>
parents:
2257
diff
changeset
|
777 ); |
2218
631ca0412db9
adjusted positioning of pdf elements
Markus Kottlaender <markus@intevation.de>
parents:
2215
diff
changeset
|
778 } |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
779 } |
2212
733cfc3db48a
started pdf template administration
Markus Kottlaender <markus@intevation.de>
parents:
2207
diff
changeset
|
780 }, |
733cfc3db48a
started pdf template administration
Markus Kottlaender <markus@intevation.de>
parents:
2207
diff
changeset
|
781 mounted() { |
3227
6d4d8e7ef881
client: adjust route for pdftemplate,pdftool and add check type to uploaded templates
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3222
diff
changeset
|
782 HTTP.get("/templates/map", { |
2257
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
783 headers: { |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
784 "X-Gemma-Auth": localStorage.getItem("token"), |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
785 "Content-type": "text/xml; charset=UTF-8" |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
786 } |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
787 }) |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
788 .then(response => { |
2265
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
789 if (response.data.length) { |
3840
387f239018c7
pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents:
3802
diff
changeset
|
790 this.templates = [...this.templates, ...response.data]; |
387f239018c7
pdf_tool: retain default template, when custom template is uploaded
Thomas Junk <thomas.junk@intevation.de>
parents:
3802
diff
changeset
|
791 this.form.template = this.templates[1]; |
2265
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
792 this.applyTemplateToForm(); |
3786
a2da2328bb86
PDFTool: prefetch images of template and convert to dataURI
Thomas Junk <thomas.junk@intevation.de>
parents:
3781
diff
changeset
|
793 } else { |
a2da2328bb86
PDFTool: prefetch images of template and convert to dataURI
Thomas Junk <thomas.junk@intevation.de>
parents:
3781
diff
changeset
|
794 this.form.template = this.templates[0]; |
a2da2328bb86
PDFTool: prefetch images of template and convert to dataURI
Thomas Junk <thomas.junk@intevation.de>
parents:
3781
diff
changeset
|
795 this.templateData = this.form.template; |
2265
940ae7c20326
client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents:
2260
diff
changeset
|
796 } |
2257
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
797 }) |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
798 .catch(e => { |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
799 const { status, data } = e.response; |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
800 displayError({ |
2284
9f327f197ddd
client: translation: mark some strings for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2275
diff
changeset
|
801 title: this.$gettext("Backend Error"), |
2257
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
802 message: `${status}: ${data.message || data}` |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
803 }); |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
804 }); |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
805 } |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
806 }; |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
807 </script> |