Mercurial > gemma
changeset 1747:90178f4ce255
import waterway axis
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Thu, 10 Jan 2019 14:33:10 +0100 |
parents | 09f51f2b3b0d |
children | c11807dc6940 |
files | client/src/components/importschedule/Importscheduledetail.vue client/src/store/imports.js |
diffstat | 2 files changed, 136 insertions(+), 61 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/importschedule/Importscheduledetail.vue Thu Jan 10 14:27:03 2019 +0100 +++ b/client/src/components/importschedule/Importscheduledetail.vue Thu Jan 10 14:33:10 2019 +0100 @@ -14,7 +14,7 @@ </h6> <div class="card-body"> <form @submit.prevent="save" class="ml-2 mr-2"> - <div class="d-flex flex-row w-100"> + <div class="d-flex flex-row"> <div class="flex-column w-50 mr-3"> <div class="flex-row text-left"> <small class="text-muted"> @@ -25,24 +25,30 @@ <option :value="$options.IMPORTTYPES.BOTTLENECK" ><translate>Bottlenecks</translate></option > + <option :value="$options.IMPORTTYPES.WATERWAYAXIS" + ><translate>Waterway axis</translate></option + > </select> </div> - <div v-if="import_" class="flex-column w-50"> + <div class="flex-column ml-4"> <div class="flex-row text-left"> <small class="text-muted"> - <translate>Importtype</translate> + <translate>Email Notification</translate> </small> </div> - <select - :disabled="fixedSource" - v-model="importSource" - class="custom-select" - id="importsource" - > - <option :value="this.$options.IMPORTSOURCES.SOAP" - ><translate>SOAP</translate></option - > - </select> + <div class="flex-flex-row text-left"> + <toggle-button + v-model="eMailNotification" + class="mt-2" + :speed="100" + :labels="{ + checked: this.$options.on, + unchecked: this.$options.off + }" + :width="60" + :height="30" + /> + </div> </div> </div> <div v-if="isURLRequired"> @@ -55,7 +61,7 @@ <input v-model="url" class="form-control" type="url" /> </div> </div> - <div class="flex-column mt-3 text-left"> + <div v-if="false" class="flex-column mt-3 text-left"> <div class="d-flex flex-row"> <small class="text-muted mr-2" ><translate>Insecure</translate> @@ -89,24 +95,46 @@ > </div> </div> - <div class="flex-column mt-3 w-100 mr-2"> - <div class="flex-row text-left"> - <small class="text-muted"> - <translate>Email Notification</translate> - </small> - </div> - <div class="flex-flex-row text-left"> - <toggle-button - v-model="eMailNotification" - class="mt-2" - :speed="100" - :labels="{ - checked: this.$options.on, - unchecked: this.$options.off - }" - :width="60" - :height="30" - /> + <div v-if="isFeatureTypeRequired"> + <div class="d-flex flex-row"> + <div class="flex-column mt-3 mr-3 w-50"> + <div class="flex-row text-left"> + <small class="text-muted"> + <translate>Featuretype</translate> + </small> + </div> + <div class="w-100"> + <input + v-model="featureType" + class="form-control" + type="text" + /> + </div> + <div v-if="!featureType" class="d-flex flex-row"> + <small + ><translate class="text-danger" + >Please enter a Featuretype</translate + ></small + > + </div> + </div> + <div class="flex-column mt-3 w-50"> + <div class="flex-row text-left"> + <small class="text-muted"> + <translate>SortBy</translate> + </small> + </div> + <div class="w-100"> + <input v-model="sortBy" class="form-control" type="text" /> + </div> + <div v-if="!sortBy" class="d-flex flex-row"> + <small + ><translate class="text-danger" + >Please enter SortBy</translate + ></small + > + </div> + </div> </div> </div> <div class="d-flex flex-row"> @@ -373,13 +401,12 @@ url: null, insecure: false, triggerActive: true, - cronString: "* * * * " + cronString: "* * * * ", + featureType: null, + sortBy: null }; }, IMPORTTYPES: IMPORTTYPES, - IMPORTSOURCES: { - SOAP: "SOAP" - }, EVERY: app.$gettext("Every"), MINUTESPAST: app.$gettext("minutes past"), ON: app.$gettext("on"), @@ -449,18 +476,34 @@ if (this.isMonthly(this.cronString)) { this.simple = "monthly"; } - }, - import_() { - if (this.import_ === this.$options.IMPORTTYPES.BOTTLENECK) { - this.importSource = this.$options.IMPORTSOURCES.SOAP; - } } }, computed: { ...mapState("imports", ["importScheduleDetailVisible", "currentSchedule"]), isURLRequired() { - if (this.import_ === this.$options.IMPORTTYPES.BOTTLENECK) return true; - return false; + switch (this.import_) { + case this.$options.IMPORTTYPES.BOTTLENECK: + case this.$options.IMPORTTYPES.WATERWAYAXIS: + return true; + default: + return false; + } + }, + isFeatureTypeRequired() { + switch (this.import_) { + case this.$options.IMPORTTYPES.WATERWAYAXIS: + return true; + default: + return false; + } + }, + isSortbyRequired() { + switch (this.import_) { + case this.$options.IMPORTTYPES.WATERWAYAXIS: + return true; + default: + return false; + } }, fixedSource() { if (this.import_ === this.$options.IMPORTTYPES.BOTTLENECK) return true; @@ -502,6 +545,8 @@ this.url = this.currentSchedule.url; this.insecure = this.currentSchedule.insecure; this.cronString = this.currentSchedule.cronString; + this.featureType = this.currentSchedule.featureType; + this.sortBy = this.currentSchedule.sortBy; }, isWeekly(cron) { return /0 \d{1,2} \d{1,2} \* \* \d{1}/.test(cron); @@ -520,11 +565,19 @@ if (!this.triggerActive) return; if (!this.import_) return; let data = {}; - if (this.import_ === this.$options.IMPORTTYPES.BOTTLENECK) { + if (this.isURLRequired) { if (!this.url) return; data["url"] = this.url; data["insecure"] = this.insecure; } + if (this.isFeatureTypeRequired) { + if (!this.featureType) return; + data["feature-type"] = this.featureType; + } + if (this.isSortbyRequired) { + if (!this.sortBy) return; + data["sort-by"] = this.sortBy; + } this.triggerActive = false; this.$store .dispatch("imports/triggerImport", { type: this.import_, data }) @@ -547,27 +600,39 @@ }); }, save() { - let data = {}; + const addAttribute = (data, attribute) => { + if (!data["attributes"]) data.attributes = {}; + data["attributes"] = { ...data["attributes"], ...attribute }; + }; if (!this.import_) return; let cron = this.cronString; if (this.easyCron) { if (this.simple === "weekly") cron = "0 0 0 * * 0"; if (this.simple === "monthly") cron = "0 0 0 1 * *"; } - switch (this.import_) { - case this.$options.IMPORTTYPES.BOTTLENECK: - if (!this.validateBottleneckfields()) return; - data["url"] = this.url; - data["kind"] = IMPORTTYPEKIND[this.import_]; - data["send-email"] = this.eMailNotification; - data["attributes"] = { - insecure: this.insecure + "" - }; - if (this.scheduled) data["cron"] = cron; - break; - default: - break; + let data = {}; + if (this.isURLRequired) { + if (!this.url) return; + data["url"] = this.url; + addAttribute(data, { + insecure: this.insecure + "" + }); } + if (this.isSortbyRequired) { + if (!this.sortBy) return; + addAttribute(data, { + sortBy: this.sortBy + }); + } + if (this.isFeatureTypeRequired) { + if (!this.featureType) return; + addAttribute(data, { + "feature-type": this.featureType + }); + } + if (this.scheduled) data["cron"] = cron; + data["kind"] = IMPORTTYPEKIND[this.import_]; + data["send-email"] = this.eMailNotification; if (!this.id) { this.$store .dispatch("imports/saveCurrentSchedule", data)
--- a/client/src/store/imports.js Thu Jan 10 14:27:03 2019 +0100 +++ b/client/src/store/imports.js Thu Jan 10 14:33:10 2019 +0100 @@ -24,7 +24,8 @@ }; const IMPORTTYPES = { - BOTTLENECK: "bottleneck" + BOTTLENECK: "bottleneck", + WATERWAYAXIS: "waterwayaxis" }; const SCHEDULES = { @@ -65,7 +66,9 @@ dayOfMonth: null, simple: null, url: null, - insecure: false + insecure: false, + featureType: null, + sortBy: null }; }; @@ -140,11 +143,18 @@ Vue.set(state.currentSchedule, "url", url); } if (attributes) { - let { insecure } = attributes; + let { insecure, sortBy } = attributes; + const featureType = attributes["feature-type"]; insecure = insecure == "true"; if (insecure) { Vue.set(state.currentSchedule, "insecure", insecure); } + if (featureType) { + Vue.set(state.currentSchedule, "featureType", featureType); + } + if (sortBy) { + Vue.set(state.currentSchedule, "sortBy", sortBy); + } } } },