Mercurial > gemma
annotate client/src/components/systemconfiguration/PDFTemplates.vue @ 3474:a39795393c7c
legend
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Mon, 27 May 2019 12:16:45 +0200 |
parents | b3333311de42 |
children | 63322cd63a57 |
rev | line source |
---|---|
2213 | 1 <template> |
2290
92649a0537fa
client: admin: style adjustments
Markus Kottlaender <markus@intevation.de>
parents:
2289
diff
changeset
|
2 <div class="d-flex flex-column"> |
2213 | 3 <div class="d-flex flex-row justify-content-between"> |
4 <h5><translate>PDF-Templates</translate></h5> | |
5 <input | |
2384
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
6 @change="uploadTemplate" |
2257
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
7 id="uploadTemplate" |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
8 ref="uploadTemplate" |
2213 | 9 type="file" |
10 style="visibility:hidden" | |
11 /> | |
12 </div> | |
2290
92649a0537fa
client: admin: style adjustments
Markus Kottlaender <markus@intevation.de>
parents:
2289
diff
changeset
|
13 <div class="mt-1 border-bottom pb-4"> |
2462
9ae2a2f758bb
client: make use of new table header/body components
Markus Kottlaender <markus@intevation.de>
parents:
2459
diff
changeset
|
14 <UITableHeader |
9ae2a2f758bb
client: make use of new table header/body components
Markus Kottlaender <markus@intevation.de>
parents:
2459
diff
changeset
|
15 :columns="[ |
3232
86231e847762
client: add type field for pdf-templates configuration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3230
diff
changeset
|
16 { id: 'name', title: `${nameLabel}`, class: 'col-3' }, |
86231e847762
client: add type field for pdf-templates configuration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3230
diff
changeset
|
17 { id: 'time', title: `${dateLabel}`, class: 'col-3' }, |
86231e847762
client: add type field for pdf-templates configuration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3230
diff
changeset
|
18 { id: 'type', title: `${typeLabel}`, class: 'col-2' }, |
2782
615b0a9b8098
Client: correct strings marking for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2738
diff
changeset
|
19 { id: 'country', title: `${countryLabel}`, class: 'col-2' } |
2462
9ae2a2f758bb
client: make use of new table header/body components
Markus Kottlaender <markus@intevation.de>
parents:
2459
diff
changeset
|
20 ]" |
9ae2a2f758bb
client: make use of new table header/body components
Markus Kottlaender <markus@intevation.de>
parents:
2459
diff
changeset
|
21 /> |
2874
b9a6abef9f1c
client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents:
2802
diff
changeset
|
22 <UITableBody :data="templates | sortTable(sortColumn, sortDirection)"> |
b9a6abef9f1c
client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents:
2802
diff
changeset
|
23 <template v-slot:row="{ item: template }"> |
3232
86231e847762
client: add type field for pdf-templates configuration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3230
diff
changeset
|
24 <div class="py-1 col-3">{{ template.name }}</div> |
86231e847762
client: add type field for pdf-templates configuration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3230
diff
changeset
|
25 <div class="py-1 col-3">{{ template.time }}</div> |
86231e847762
client: add type field for pdf-templates configuration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3230
diff
changeset
|
26 <div class="py-1 col-2">{{ template.type }}</div> |
2874
b9a6abef9f1c
client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents:
2802
diff
changeset
|
27 <div class="py-1 col-2" v-if="template.country"> |
b9a6abef9f1c
client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents:
2802
diff
changeset
|
28 {{ template.country }} |
b9a6abef9f1c
client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents:
2802
diff
changeset
|
29 </div> |
b9a6abef9f1c
client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents:
2802
diff
changeset
|
30 <div class="py-1 col-2" v-else><i>global</i></div> |
b9a6abef9f1c
client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents:
2802
diff
changeset
|
31 <div class="col py-1 text-right"> |
b9a6abef9f1c
client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents:
2802
diff
changeset
|
32 <button |
b9a6abef9f1c
client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents:
2802
diff
changeset
|
33 class="btn btn-xs btn-info mr-1" |
b9a6abef9f1c
client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents:
2802
diff
changeset
|
34 ref="downloadTemplate" |
b9a6abef9f1c
client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents:
2802
diff
changeset
|
35 @click="downloadTemplate(template)" |
b9a6abef9f1c
client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents:
2802
diff
changeset
|
36 > |
b9a6abef9f1c
client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents:
2802
diff
changeset
|
37 <font-awesome-icon icon="download" fixed-width /> |
b9a6abef9f1c
client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents:
2802
diff
changeset
|
38 </button> |
b9a6abef9f1c
client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents:
2802
diff
changeset
|
39 <button |
b9a6abef9f1c
client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents:
2802
diff
changeset
|
40 class="btn btn-xs btn-dark" |
b9a6abef9f1c
client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents:
2802
diff
changeset
|
41 @click="deleteTemplate(template)" |
b9a6abef9f1c
client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents:
2802
diff
changeset
|
42 > |
b9a6abef9f1c
client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents:
2802
diff
changeset
|
43 <font-awesome-icon icon="trash" fixed-width /> |
b9a6abef9f1c
client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents:
2802
diff
changeset
|
44 </button> |
b9a6abef9f1c
client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents:
2802
diff
changeset
|
45 </div> |
b9a6abef9f1c
client: more unified table layout
Markus Kottlaender <markus@intevation.de>
parents:
2802
diff
changeset
|
46 </template> |
2462
9ae2a2f758bb
client: make use of new table header/body components
Markus Kottlaender <markus@intevation.de>
parents:
2459
diff
changeset
|
47 </UITableBody> |
3243
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
48 <div class="d-flex flex-column mt-2 w-25 mr-auto"> |
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
49 <select |
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
50 v-model="type" |
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
51 class="form-control d-block custom-select-sm w-75 h-25" |
3230
128d686c3950
client: improve styles of template-configuration elements
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3227
diff
changeset
|
52 > |
3243
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
53 <option :value="null"> |
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
54 Select template type |
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
55 </option> |
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
56 <option value="map"> |
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
57 Map-template |
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
58 </option> |
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
59 <option value="diagram"> |
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
60 Diagram-template |
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
61 </option> |
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
62 </select> |
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
63 <button class="btn btn-info btn-sm mt-1 w-75" @click="checkUpload"> |
3230
128d686c3950
client: improve styles of template-configuration elements
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3227
diff
changeset
|
64 <font-awesome-icon |
128d686c3950
client: improve styles of template-configuration elements
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3227
diff
changeset
|
65 icon="spinner" |
128d686c3950
client: improve styles of template-configuration elements
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3227
diff
changeset
|
66 class="fa-spin fa-fw" |
128d686c3950
client: improve styles of template-configuration elements
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3227
diff
changeset
|
67 v-if="uploading" |
128d686c3950
client: improve styles of template-configuration elements
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3227
diff
changeset
|
68 /> |
128d686c3950
client: improve styles of template-configuration elements
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3227
diff
changeset
|
69 <font-awesome-icon icon="upload" class="fa-fw" v-else /> |
128d686c3950
client: improve styles of template-configuration elements
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3227
diff
changeset
|
70 <translate>Upload new template</translate> |
128d686c3950
client: improve styles of template-configuration elements
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3227
diff
changeset
|
71 </button> |
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
|
72 </div> |
2213 | 73 </div> |
74 </div> | |
75 </template> | |
76 | |
2323
5b53be76080c
client: adjusted table and delete button styles
Markus Kottlaender <markus@intevation.de>
parents:
2290
diff
changeset
|
77 <style lang="scss" scoped> |
5b53be76080c
client: adjusted table and delete button styles
Markus Kottlaender <markus@intevation.de>
parents:
2290
diff
changeset
|
78 .table th, |
5b53be76080c
client: adjusted table and delete button styles
Markus Kottlaender <markus@intevation.de>
parents:
2290
diff
changeset
|
79 td { |
5b53be76080c
client: adjusted table and delete button styles
Markus Kottlaender <markus@intevation.de>
parents:
2290
diff
changeset
|
80 font-size: $smaller; |
5b53be76080c
client: adjusted table and delete button styles
Markus Kottlaender <markus@intevation.de>
parents:
2290
diff
changeset
|
81 border-top: 0px !important; |
5b53be76080c
client: adjusted table and delete button styles
Markus Kottlaender <markus@intevation.de>
parents:
2290
diff
changeset
|
82 text-align: left; |
5b53be76080c
client: adjusted table and delete button styles
Markus Kottlaender <markus@intevation.de>
parents:
2290
diff
changeset
|
83 padding: $small-offset !important; |
5b53be76080c
client: adjusted table and delete button styles
Markus Kottlaender <markus@intevation.de>
parents:
2290
diff
changeset
|
84 } |
5b53be76080c
client: adjusted table and delete button styles
Markus Kottlaender <markus@intevation.de>
parents:
2290
diff
changeset
|
85 </style> |
5b53be76080c
client: adjusted table and delete button styles
Markus Kottlaender <markus@intevation.de>
parents:
2290
diff
changeset
|
86 |
2213 | 87 <script> |
88 /* This is Free Software under GNU Affero General Public License v >= 3.0 | |
89 * without warranty, see README.md and license for details. | |
90 * | |
91 * SPDX-License-Identifier: AGPL-3.0-or-later | |
92 * License-Filename: LICENSES/AGPL-3.0.txt | |
93 * | |
2527
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
94 * Copyright (C) 2018, 2019 by via donau |
2213 | 95 * – Österreichische Wasserstraßen-Gesellschaft mbH |
96 * Software engineering by Intevation GmbH | |
97 * | |
98 * Author(s): | |
99 * Markus Kottländer <markus@intevation.de> | |
2527
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
100 * Fadi Abbud <fadi.abbud@intevation.de> |
2213 | 101 */ |
2257
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
102 import { HTTP } from "@/lib/http"; |
2738
add2d47c2567
client: tables: implemented simple default sorting
Markus Kottlaender <markus@intevation.de>
parents:
2640
diff
changeset
|
103 import { displayError, displayInfo } from "@/lib/errors"; |
add2d47c2567
client: tables: implemented simple default sorting
Markus Kottlaender <markus@intevation.de>
parents:
2640
diff
changeset
|
104 import { sortTable } from "@/lib/mixins"; |
2213 | 105 |
106 export default { | |
107 name: "pdftemplates", | |
2738
add2d47c2567
client: tables: implemented simple default sorting
Markus Kottlaender <markus@intevation.de>
parents:
2640
diff
changeset
|
108 mixins: [sortTable], |
2216
585373d33f8f
prepared pdf template administration
Markus Kottlaender <markus@intevation.de>
parents:
2213
diff
changeset
|
109 data() { |
585373d33f8f
prepared pdf template administration
Markus Kottlaender <markus@intevation.de>
parents:
2213
diff
changeset
|
110 return { |
2257
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
111 templates: [], |
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
|
112 uploading: false, |
3243
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
113 type: null |
2216
585373d33f8f
prepared pdf template administration
Markus Kottlaender <markus@intevation.de>
parents:
2213
diff
changeset
|
114 }; |
585373d33f8f
prepared pdf template administration
Markus Kottlaender <markus@intevation.de>
parents:
2213
diff
changeset
|
115 }, |
2782
615b0a9b8098
Client: correct strings marking for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2738
diff
changeset
|
116 computed: { |
615b0a9b8098
Client: correct strings marking for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2738
diff
changeset
|
117 nameLabel() { |
615b0a9b8098
Client: correct strings marking for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2738
diff
changeset
|
118 return this.$gettext("Name"); |
615b0a9b8098
Client: correct strings marking for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2738
diff
changeset
|
119 }, |
615b0a9b8098
Client: correct strings marking for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2738
diff
changeset
|
120 dateLabel() { |
615b0a9b8098
Client: correct strings marking for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2738
diff
changeset
|
121 return this.$gettext("Date"); |
615b0a9b8098
Client: correct strings marking for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2738
diff
changeset
|
122 }, |
615b0a9b8098
Client: correct strings marking for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2738
diff
changeset
|
123 countryLabel() { |
615b0a9b8098
Client: correct strings marking for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2738
diff
changeset
|
124 return this.$gettext("Country"); |
3232
86231e847762
client: add type field for pdf-templates configuration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3230
diff
changeset
|
125 }, |
86231e847762
client: add type field for pdf-templates configuration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3230
diff
changeset
|
126 typeLabel() { |
3234 | 127 return this.$gettext("Type"); |
2782
615b0a9b8098
Client: correct strings marking for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2738
diff
changeset
|
128 } |
615b0a9b8098
Client: correct strings marking for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2738
diff
changeset
|
129 }, |
2216
585373d33f8f
prepared pdf template administration
Markus Kottlaender <markus@intevation.de>
parents:
2213
diff
changeset
|
130 methods: { |
3243
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
131 // check if template type is selceted |
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
132 checkUpload() { |
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
133 if (this.type) { |
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
134 this.$refs.uploadTemplate.click(); |
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
135 } else { |
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
136 displayError({ |
3251
b3333311de42
client: pdf-template:(minor) add error title
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3243
diff
changeset
|
137 title: this.$gettext("Error"), |
3243
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
138 message: this.$gettext("Please select template type") |
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
139 }); |
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
140 } |
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
141 }, |
2527
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
142 downloadTemplate(template) { |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
143 if (template) { |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
144 var templateData = ""; |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
145 var element = document.createElement("a"); |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
146 element.style.display = "none"; |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
147 element.setAttribute("download", template.name + ".json"); |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
148 document.body.appendChild(element); |
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
|
149 HTTP.get(`/templates/${template.type}/${template.name}`, { |
2527
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
150 headers: { |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
151 "X-Gemma-Auth": localStorage.getItem("token"), |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
152 "Content-type": "text/xml; charset=UTF-8" |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
153 } |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
154 }) |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
155 .then(response => { |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
156 templateData = response.data.template_data; |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
157 element.setAttribute( |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
158 "href", |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
159 "data:text/json;charset=utf-8," + |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
160 encodeURIComponent( |
2531
47b9a4f9a05c
client:pdf-gen: change the formatting of the downloaded json file
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2527
diff
changeset
|
161 JSON.stringify( |
47b9a4f9a05c
client:pdf-gen: change the formatting of the downloaded json file
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2527
diff
changeset
|
162 { |
47b9a4f9a05c
client:pdf-gen: change the formatting of the downloaded json file
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2527
diff
changeset
|
163 name: templateData.name, |
47b9a4f9a05c
client:pdf-gen: change the formatting of the downloaded json file
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2527
diff
changeset
|
164 properties: templateData.properties, |
47b9a4f9a05c
client:pdf-gen: change the formatting of the downloaded json file
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2527
diff
changeset
|
165 elements: templateData.elements |
47b9a4f9a05c
client:pdf-gen: change the formatting of the downloaded json file
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2527
diff
changeset
|
166 }, |
47b9a4f9a05c
client:pdf-gen: change the formatting of the downloaded json file
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2527
diff
changeset
|
167 null, |
47b9a4f9a05c
client:pdf-gen: change the formatting of the downloaded json file
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2527
diff
changeset
|
168 2 |
47b9a4f9a05c
client:pdf-gen: change the formatting of the downloaded json file
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2527
diff
changeset
|
169 ) |
2527
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
170 ) |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
171 ); |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
172 element.click(); |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
173 }) |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
174 .catch(e => { |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
175 const { status, data } = e.response; |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
176 displayError({ |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
177 title: this.$gettext("Backend Error"), |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
178 message: `${status}: ${data.message || data}` |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
179 }); |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
180 }) |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
181 .finally(() => { |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
182 document.body.removeChild(element); |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
183 }); |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
184 } |
1a6553da9078
client:pdf-gen : add download-template functionality
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2522
diff
changeset
|
185 }, |
2384
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
186 uploadTemplate() { |
2257
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
187 const reader = new FileReader(); |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
188 reader.onload = event => { |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
189 let template; |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
190 try { |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
191 template = JSON.parse(event.target.result); |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
192 } catch (e) { |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
193 displayError({ |
2284
9f327f197ddd
client: translation: mark some strings for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2257
diff
changeset
|
194 title: this.$gettext("Format Error"), |
9f327f197ddd
client: translation: mark some strings for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2257
diff
changeset
|
195 message: this.$gettext( |
9f327f197ddd
client: translation: mark some strings for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2257
diff
changeset
|
196 "Uploaded file does not contain valid json data." |
9f327f197ddd
client: translation: mark some strings for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2257
diff
changeset
|
197 ) |
2257
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
198 }); |
3243
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
199 // allow the user to upload the same file |
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
200 // if user wants to upload the same file after edit it. |
2802
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
201 this.$refs.uploadTemplate.value = null; |
2257
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
202 } |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
203 if (template.name) { |
3243
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
204 // check if an element in the uploaded file does not match the predefind template-elements |
2802
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
205 let checkElement = false; |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
206 template.elements.forEach(e => { |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
207 if ( |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
208 [ |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
209 "text", |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
210 "box", |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
211 "textbox", |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
212 "image", |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
213 "bottleneck", |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
214 "legend", |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
215 "scalebar", |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
216 "scale", |
3138
106e1d011a5d
client: pdf-gen: include the diagram elements in the upload template constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2874
diff
changeset
|
217 "northarrow", |
106e1d011a5d
client: pdf-gen: include the diagram elements in the upload template constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2874
diff
changeset
|
218 "diagramlegend", |
3160
94935895e6d7
client: add diagram-element to template (waterlevel)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3138
diff
changeset
|
219 "diagramtitle", |
94935895e6d7
client: add diagram-element to template (waterlevel)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3138
diff
changeset
|
220 "diagram" |
2802
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
221 ].indexOf(e.type) === -1 |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
222 ) { |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
223 checkElement = true; |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
224 displayError({ |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
225 title: this.$gettext("Invalid element"), |
2459
408e0f4d4008
clinet:pdf-gen template:unifiy feedback messages for template
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2448
diff
changeset
|
226 message: |
2802
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
227 e.type + |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
228 this.$gettext(" does not match any template's element") |
2459
408e0f4d4008
clinet:pdf-gen template:unifiy feedback messages for template
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2448
diff
changeset
|
229 }); |
3243
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
230 // allow the user to upload the same file |
2802
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
231 this.$refs.uploadTemplate.value = null; |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
232 } |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
233 }); |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
234 |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
235 if (!checkElement) { |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
236 this.uploading = true; |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
237 HTTP.post( |
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
|
238 "/templates/" + this.type + "/" + template.name, |
2802
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
239 { |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
240 template_name: template.name, |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
241 template_data: template |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
242 }, |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
243 { |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
244 headers: { |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
245 "X-Gemma-Auth": localStorage.getItem("token"), |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
246 "Content-type": "text/xml; charset=UTF-8" |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
247 } |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
248 } |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
249 ) |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
250 .then(() => { |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
251 this.loadTemplates(); |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
252 displayInfo({ |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
253 message: |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
254 template.name + " " + this.$gettext("uploaded successfully") |
2522
24bab584f0a1
client: improved error message format for pdf-template uploads
Markus Kottlaender <markus@intevation.de>
parents:
2462
diff
changeset
|
255 }); |
2802
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
256 }) |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
257 .catch(e => { |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
258 const { status, data } = e.response; |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
259 if (status === 400) { |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
260 displayError({ |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
261 title: this.$gettext("Error"), |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
262 message: `${data.message || data}` |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
263 }); |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
264 } else { |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
265 displayError({ |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
266 title: this.$gettext("Backend Error"), |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
267 message: `${status}: ${data.message || data}` |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
268 }); |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
269 } |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
270 }) |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
271 .finally(() => { |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
272 this.uploading = false; |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
273 this.$refs.uploadTemplate.value = null; |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
274 }); |
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
275 } |
2257
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
276 } else { |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
277 displayError({ |
2284
9f327f197ddd
client: translation: mark some strings for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2257
diff
changeset
|
278 title: this.$gettext("Format Error"), |
9f327f197ddd
client: translation: mark some strings for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2257
diff
changeset
|
279 message: this.$gettext( |
9f327f197ddd
client: translation: mark some strings for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2257
diff
changeset
|
280 "The provided template has no name property." |
9f327f197ddd
client: translation: mark some strings for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2257
diff
changeset
|
281 ) |
2257
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
282 }); |
3243
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
283 // allow the user to upload the same file |
2802
9adbe0633bf9
client:pdf-gen: improve template upload constraint
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2782
diff
changeset
|
284 this.$refs.uploadTemplate.value = null; |
2257
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
285 } |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
286 }; |
3243
e9c143436432
client: diagram-template: improve Pdf-templates systemconfiguration
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3234
diff
changeset
|
287 |
2257
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
288 reader.onerror = error => console.log(error); |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
289 reader.readAsText(this.$refs.uploadTemplate.files[0]); |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
290 }, |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
291 loadTemplates() { |
3222
83e8e1ea0aff
print_templates: changed route /templates/print to /templates and /templates/print/... to /templates/
Thomas Junk <thomas.junk@intevation.de>
parents:
3160
diff
changeset
|
292 HTTP.get("/templates", { |
2257
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
293 headers: { |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
294 "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
|
295 "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
|
296 } |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
297 }) |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
298 .then(response => { |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
299 this.templates = response.data; |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
300 }) |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
301 .catch(e => { |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
302 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
|
303 displayError({ |
2284
9f327f197ddd
client: translation: mark some strings for translations
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2257
diff
changeset
|
304 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
|
305 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
|
306 }); |
2216
585373d33f8f
prepared pdf template administration
Markus Kottlaender <markus@intevation.de>
parents:
2213
diff
changeset
|
307 }); |
585373d33f8f
prepared pdf template administration
Markus Kottlaender <markus@intevation.de>
parents:
2213
diff
changeset
|
308 }, |
2384
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
309 deleteTemplate(template) { |
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
310 this.$store.commit("application/popup", { |
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
311 icon: "trash", |
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
312 title: this.$gettext("Delete Template"), |
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
313 content: |
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
314 this.$gettext( |
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
315 "Do you really want to delete the following template:" |
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
316 ) + |
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
317 `<br> |
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
318 <b>${template.name}</b>`, |
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
319 confirm: { |
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
320 label: this.$gettext("Delete"), |
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
321 icon: "trash", |
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
322 callback: () => { |
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
|
323 HTTP.delete(`/templates/${template.type}/${template.name}`, { |
2384
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
324 headers: { |
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
325 "X-Gemma-Auth": localStorage.getItem("token"), |
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
326 "Content-type": "text/xml; charset=UTF-8" |
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
327 } |
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
328 }).then(() => { |
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
329 let removeIndex = this.templates.findIndex( |
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
330 t => t.name === template.name |
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
331 ); |
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
332 if (removeIndex !== -1) { |
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
333 this.templates.splice(removeIndex, 1); |
2459
408e0f4d4008
clinet:pdf-gen template:unifiy feedback messages for template
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2448
diff
changeset
|
334 displayInfo({ |
408e0f4d4008
clinet:pdf-gen template:unifiy feedback messages for template
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2448
diff
changeset
|
335 message: |
408e0f4d4008
clinet:pdf-gen template:unifiy feedback messages for template
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2448
diff
changeset
|
336 template.name + " " + this.$gettext("deleted successfully") |
408e0f4d4008
clinet:pdf-gen template:unifiy feedback messages for template
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2448
diff
changeset
|
337 }); |
2384
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
338 } |
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
339 }); |
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
340 } |
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
341 }, |
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
342 cancel: { |
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
343 label: this.$gettext("Cancel"), |
c06b001dc26b
client: improved popup implementation
Markus Kottlaender <markus@intevation.de>
parents:
2357
diff
changeset
|
344 icon: "times" |
2257
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
345 } |
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
346 }); |
2216
585373d33f8f
prepared pdf template administration
Markus Kottlaender <markus@intevation.de>
parents:
2213
diff
changeset
|
347 } |
2247
e6fba449aa3c
merged pdf-export in default
Markus Kottlaender <markus@intevation.de>
parents:
2216
diff
changeset
|
348 }, |
e6fba449aa3c
merged pdf-export in default
Markus Kottlaender <markus@intevation.de>
parents:
2216
diff
changeset
|
349 mounted() { |
2257
ce6fd3d4a3a2
client: pdf-gen: moved template handling from store to components
Markus Kottlaender <markus@intevation.de>
parents:
2247
diff
changeset
|
350 this.loadTemplates(); |
2213 | 351 } |
352 }; | |
353 </script> |