changeset 3927:03f37e64701c

Factored out default template for diagrams in a single file.
author Sascha Wilde <wilde@intevation.de>
date Thu, 11 Jul 2019 16:55:31 +0200
parents 3ebde6dd336f
children 90496300311d
files client/src/components/fairway/AvailableFairwayDepth.vue client/src/components/fairway/AvailableFairwayDepthLNWL.vue client/src/components/gauge/HydrologicalConditions.vue client/src/components/gauge/Waterlevel.vue client/src/lib/DefaultDiagramTemplate.js
diffstat 5 files changed, 38 insertions(+), 121 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/fairway/AvailableFairwayDepth.vue	Thu Jul 11 16:25:56 2019 +0200
+++ b/client/src/components/fairway/AvailableFairwayDepth.vue	Thu Jul 11 16:55:31 2019 +0200
@@ -80,6 +80,7 @@
 import { HTTP } from "@/lib/http";
 import { displayError } from "@/lib/errors";
 import { FREQUENCIES } from "@/store/fairwayavailability";
+import { defaultDiagramTemplate } from "@/lib/DefaultDiagramTemplate";
 
 const hoursInDays = x => x / 24;
 
@@ -106,34 +107,7 @@
       },
       templateData: null,
       templates: [],
-      defaultTemplate: {
-        name: "Default",
-        properties: {
-          paperSize: "a4"
-        },
-        elements: [
-          {
-            type: "diagram",
-            position: "topleft",
-            offset: { x: 20, y: 30 },
-            width: 200,
-            height: 60
-          },
-          {
-            type: "diagramtitle",
-            position: "topleft",
-            offset: { x: 70, y: 20 },
-            fontsize: 20,
-            color: "steelblue"
-          },
-          {
-            type: "diagramlegend",
-            position: "topleft",
-            offset: { x: 30, y: 170 },
-            color: "black"
-          }
-        ]
-      }
+      defaultTemplate: defaultDiagramTemplate
     };
   },
   created() {
--- a/client/src/components/fairway/AvailableFairwayDepthLNWL.vue	Thu Jul 11 16:25:56 2019 +0200
+++ b/client/src/components/fairway/AvailableFairwayDepthLNWL.vue	Thu Jul 11 16:55:31 2019 +0200
@@ -79,6 +79,7 @@
 import { pdfgen, templateLoader } from "@/lib/mixins";
 import { HTTP } from "@/lib/http";
 import { displayError } from "@/lib/errors";
+import { defaultDiagramTemplate } from "@/lib/DefaultDiagramTemplate";
 
 export default {
   mixins: [pdfgen, templateLoader],
@@ -103,34 +104,7 @@
       },
       templateData: null,
       templates: [],
-      defaultTemplate: {
-        name: "Default",
-        properties: {
-          paperSize: "a4"
-        },
-        elements: [
-          {
-            type: "diagram",
-            position: "topleft",
-            offset: { x: 20, y: 30 },
-            width: 200,
-            height: 60
-          },
-          {
-            type: "diagramtitle",
-            position: "topleft",
-            offset: { x: 70, y: 20 },
-            fontsize: 20,
-            color: "steelblue"
-          },
-          {
-            type: "diagramlegend",
-            position: "topleft",
-            offset: { x: 30, y: 170 },
-            color: "black"
-          }
-        ]
-      }
+      defaultTemplate: defaultDiagramTemplate
     };
   },
   created() {
--- a/client/src/components/gauge/HydrologicalConditions.vue	Thu Jul 11 16:25:56 2019 +0200
+++ b/client/src/components/gauge/HydrologicalConditions.vue	Thu Jul 11 16:55:31 2019 +0200
@@ -108,6 +108,7 @@
 import { pdfgen, templateLoader } from "@/lib/mixins";
 import { HTTP } from "@/lib/http";
 import { displayError } from "@/lib/errors";
+import { defaultDiagramTemplate } from "@/lib/DefaultDiagramTemplate";
 
 export default {
   mixins: [pdfgen, templateLoader],
@@ -124,34 +125,7 @@
         form: null
       },
       templates: [],
-      defaultTemplate: {
-        name: "Default",
-        properties: {
-          paperSize: "a4"
-        },
-        elements: [
-          {
-            type: "diagram",
-            position: "topleft",
-            offset: { x: 15, y: 50 },
-            width: 240,
-            height: 100
-          },
-          {
-            type: "diagramlegend",
-            position: "topleft",
-            offset: { x: 42, y: 172 },
-            colot: "black"
-          },
-          {
-            type: "diagramtitle",
-            position: "topleft",
-            offset: { x: 50, y: 26 },
-            fontsize: 22,
-            color: "steelblue"
-          }
-        ]
-      },
+      defaultTemplate: defaultDiagramTemplate,
       pdf: {
         doc: null,
         width: 420,
--- a/client/src/components/gauge/Waterlevel.vue	Thu Jul 11 16:25:56 2019 +0200
+++ b/client/src/components/gauge/Waterlevel.vue	Thu Jul 11 16:55:31 2019 +0200
@@ -114,6 +114,7 @@
 import { pdfgen, templateLoader } from "@/lib/mixins";
 import { HTTP } from "@/lib/http";
 import { displayError } from "@/lib/errors";
+import { defaultDiagramTemplate } from "@/lib/DefaultDiagramTemplate";
 // we should load only d3 modules we need but for now we'll go with the lazy way
 // https://www.giacomodebidda.com/how-to-import-d3-plugins-with-webpack/
 // d3-line-chunked plugin: https://github.com/pbeshai/d3-line-chunked
@@ -132,43 +133,7 @@
         template: null
       },
       templates: [],
-      defaultTemplate: {
-        name: "Default",
-        properties: {
-          paperSize: "a4"
-        },
-        elements: [
-          {
-            type: "diagram",
-            position: "topleft",
-            offset: { x: 15, y: 50 },
-            width: 240,
-            height: 100
-          },
-          {
-            type: "diagramlegend",
-            position: "topleft",
-            offset: { x: 42, y: 172 },
-            color: "black"
-          },
-          {
-            type: "diagramtitle",
-            position: "topleft",
-            offset: { x: 50, y: 26 },
-            fontsize: 22,
-            color: "steelblue"
-          },
-          {
-            type: "text",
-            position: "topleft",
-            offset: { x: 3, y: 3 },
-            fontsize: 8,
-            width: 90,
-            color: "gray",
-            text: this.$gettext("Generated by") + " " + "{user}, {date}"
-          }
-        ]
-      },
+      defaultTemplate: defaultDiagramTemplate,
       pdf: {
         doc: null,
         width: 420,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/client/src/lib/DefaultDiagramTemplate.js	Thu Jul 11 16:55:31 2019 +0200
@@ -0,0 +1,30 @@
+const defaultDiagramTemplate = {
+  name: "Default",
+  properties: {
+    paperSize: "a4"
+  },
+  elements: [
+    {
+      type: "diagramtitle",
+      position: "topleft",
+      offset: { x: 25, y: 25 },
+      fontsize: 20,
+      color: "steelblue"
+    },
+    {
+      type: "diagram",
+      position: "topleft",
+      offset: { x: 25, y: 35 },
+      width: 240,
+      height: 120
+    },
+    {
+      type: "diagramlegend",
+      position: "topleft",
+      offset: { x: 25, y: 165 },
+      color: "black"
+    }
+  ]
+};
+
+export { defaultDiagramTemplate };