changeset 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 d84c64c0f510
children 607a158fe8f5
files client/src/components/Pdftool.vue client/src/components/systemconfiguration/PDFTemplates.vue
diffstat 2 files changed, 36 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/Pdftool.vue	Thu May 09 16:16:37 2019 +0200
+++ b/client/src/components/Pdftool.vue	Thu May 09 16:40:33 2019 +0200
@@ -211,12 +211,18 @@
     // applied to the rest of the form.
     applyTemplateToForm() {
       if (this.form.template) {
-        HTTP.get("/templates/" + this.form.template.name, {
-          headers: {
-            "X-Gemma-Auth": localStorage.getItem("token"),
-            "Content-type": "text/xml; charset=UTF-8"
+        HTTP.get(
+          "/templates/" +
+            this.form.template.type +
+            "/" +
+            this.form.template.name,
+          {
+            headers: {
+              "X-Gemma-Auth": localStorage.getItem("token"),
+              "Content-type": "text/xml; charset=UTF-8"
+            }
           }
-        })
+        )
           .then(response => {
             this.templateData = response.data.template_data;
             this.form.format = this.templateData.properties.format;
@@ -941,7 +947,7 @@
   mounted() {
     this.form.template = this.templates[0];
     this.templateData = this.form.template;
-    HTTP.get("/templates", {
+    HTTP.get("/templates/map", {
       headers: {
         "X-Gemma-Auth": localStorage.getItem("token"),
         "Content-type": "text/xml; charset=UTF-8"
--- a/client/src/components/systemconfiguration/PDFTemplates.vue	Thu May 09 16:16:37 2019 +0200
+++ b/client/src/components/systemconfiguration/PDFTemplates.vue	Thu May 09 16:40:33 2019 +0200
@@ -43,6 +43,25 @@
           </div>
         </template>
       </UITableBody>
+      <div class="form-check form-check-inline">
+        <input
+          class="form-check-input"
+          type="radio"
+          name="type"
+          v-model="type"
+          value="map"
+        />
+        <label class="form-check-label">Map-template</label>
+      </div>
+      <div class="form-check form-check-inline">
+        <input
+          class="form-check-input"
+          type="radio"
+          v-model="type"
+          value="diagram"
+        />
+        <label class="form-check-label">Diagram-template</label>
+      </div>
       <button class="btn btn-info mt-2" @click="$refs.uploadTemplate.click()">
         <font-awesome-icon
           icon="spinner"
@@ -91,7 +110,8 @@
   data() {
     return {
       templates: [],
-      uploading: false
+      uploading: false,
+      type: "map"
     };
   },
   computed: {
@@ -113,7 +133,7 @@
         element.style.display = "none";
         element.setAttribute("download", template.name + ".json");
         document.body.appendChild(element);
-        HTTP.get("/templates/" + template.name, {
+        HTTP.get(`/templates/${template.type}/${template.name}`, {
           headers: {
             "X-Gemma-Auth": localStorage.getItem("token"),
             "Content-type": "text/xml; charset=UTF-8"
@@ -202,7 +222,7 @@
           if (!checkElement) {
             this.uploading = true;
             HTTP.post(
-              "/templates/print/" + template.name,
+              "/templates/" + this.type + "/" + template.name,
               {
                 template_name: template.name,
                 template_data: template
@@ -286,7 +306,7 @@
           label: this.$gettext("Delete"),
           icon: "trash",
           callback: () => {
-            HTTP.delete("/templates/print/" + template.name, {
+            HTTP.delete(`/templates/${template.type}/${template.name}`, {
               headers: {
                 "X-Gemma-Auth": localStorage.getItem("token"),
                 "Content-type": "text/xml; charset=UTF-8"