# HG changeset patch # User Sascha Wilde # Date 1562856931 -7200 # Node ID 03f37e64701c7b9f8f6eb5d162f88c2142f45d4c # Parent 3ebde6dd336faa4afc6924b783162d518bec2cc8 Factored out default template for diagrams in a single file. diff -r 3ebde6dd336f -r 03f37e64701c client/src/components/fairway/AvailableFairwayDepth.vue --- 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() { diff -r 3ebde6dd336f -r 03f37e64701c client/src/components/fairway/AvailableFairwayDepthLNWL.vue --- 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() { diff -r 3ebde6dd336f -r 03f37e64701c client/src/components/gauge/HydrologicalConditions.vue --- 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, diff -r 3ebde6dd336f -r 03f37e64701c client/src/components/gauge/Waterlevel.vue --- 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, diff -r 3ebde6dd336f -r 03f37e64701c client/src/lib/DefaultDiagramTemplate.js --- /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 };