comparison client/src/components/systemconfiguration/PDFTemplates.vue @ 3227:6d4d8e7ef881

client: adjust route for pdftemplate,pdftool and add check type to uploaded templates
author Fadi Abbud <fadi.abbud@intevation.de>
date Thu, 09 May 2019 16:40:33 +0200
parents 83e8e1ea0aff
children 128d686c3950
comparison
equal deleted inserted replaced
3226:d84c64c0f510 3227:6d4d8e7ef881
41 <font-awesome-icon icon="trash" fixed-width /> 41 <font-awesome-icon icon="trash" fixed-width />
42 </button> 42 </button>
43 </div> 43 </div>
44 </template> 44 </template>
45 </UITableBody> 45 </UITableBody>
46 <div class="form-check form-check-inline">
47 <input
48 class="form-check-input"
49 type="radio"
50 name="type"
51 v-model="type"
52 value="map"
53 />
54 <label class="form-check-label">Map-template</label>
55 </div>
56 <div class="form-check form-check-inline">
57 <input
58 class="form-check-input"
59 type="radio"
60 v-model="type"
61 value="diagram"
62 />
63 <label class="form-check-label">Diagram-template</label>
64 </div>
46 <button class="btn btn-info mt-2" @click="$refs.uploadTemplate.click()"> 65 <button class="btn btn-info mt-2" @click="$refs.uploadTemplate.click()">
47 <font-awesome-icon 66 <font-awesome-icon
48 icon="spinner" 67 icon="spinner"
49 class="fa-spin fa-fw" 68 class="fa-spin fa-fw"
50 v-if="uploading" 69 v-if="uploading"
89 name: "pdftemplates", 108 name: "pdftemplates",
90 mixins: [sortTable], 109 mixins: [sortTable],
91 data() { 110 data() {
92 return { 111 return {
93 templates: [], 112 templates: [],
94 uploading: false 113 uploading: false,
114 type: "map"
95 }; 115 };
96 }, 116 },
97 computed: { 117 computed: {
98 nameLabel() { 118 nameLabel() {
99 return this.$gettext("Name"); 119 return this.$gettext("Name");
111 var templateData = ""; 131 var templateData = "";
112 var element = document.createElement("a"); 132 var element = document.createElement("a");
113 element.style.display = "none"; 133 element.style.display = "none";
114 element.setAttribute("download", template.name + ".json"); 134 element.setAttribute("download", template.name + ".json");
115 document.body.appendChild(element); 135 document.body.appendChild(element);
116 HTTP.get("/templates/" + template.name, { 136 HTTP.get(`/templates/${template.type}/${template.name}`, {
117 headers: { 137 headers: {
118 "X-Gemma-Auth": localStorage.getItem("token"), 138 "X-Gemma-Auth": localStorage.getItem("token"),
119 "Content-type": "text/xml; charset=UTF-8" 139 "Content-type": "text/xml; charset=UTF-8"
120 } 140 }
121 }) 141 })
200 }); 220 });
201 221
202 if (!checkElement) { 222 if (!checkElement) {
203 this.uploading = true; 223 this.uploading = true;
204 HTTP.post( 224 HTTP.post(
205 "/templates/print/" + template.name, 225 "/templates/" + this.type + "/" + template.name,
206 { 226 {
207 template_name: template.name, 227 template_name: template.name,
208 template_data: template 228 template_data: template
209 }, 229 },
210 { 230 {
284 <b>${template.name}</b>`, 304 <b>${template.name}</b>`,
285 confirm: { 305 confirm: {
286 label: this.$gettext("Delete"), 306 label: this.$gettext("Delete"),
287 icon: "trash", 307 icon: "trash",
288 callback: () => { 308 callback: () => {
289 HTTP.delete("/templates/print/" + template.name, { 309 HTTP.delete(`/templates/${template.type}/${template.name}`, {
290 headers: { 310 headers: {
291 "X-Gemma-Auth": localStorage.getItem("token"), 311 "X-Gemma-Auth": localStorage.getItem("token"),
292 "Content-type": "text/xml; charset=UTF-8" 312 "Content-type": "text/xml; charset=UTF-8"
293 } 313 }
294 }).then(() => { 314 }).then(() => {