Mercurial > gemma
changeset 1791:0f98ef2531a5
importschedule: frontend for waterway gauges etd
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Mon, 14 Jan 2019 12:09:34 +0100 |
parents | fe1aa62195c2 |
children | 2c71012fee5e |
files | client/src/components/importschedule/Importscheduledetail.vue client/src/store/imports.js |
diffstat | 2 files changed, 94 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/importschedule/Importscheduledetail.vue Mon Jan 14 11:09:10 2019 +0100 +++ b/client/src/components/importschedule/Importscheduledetail.vue Mon Jan 14 12:09:34 2019 +0100 @@ -40,6 +40,9 @@ <option :value="$options.IMPORTTYPES.FAIRWAYDIMENSIONS" ><translate>Fairwaydimensions</translate></option > + <option :value="$options.IMPORTTYPES.WATERWAYGAUGES" + ><translate>Waterway gauges</translate></option + > </select> </div> <div class="flex-column ml-4"> @@ -107,6 +110,44 @@ > </div> </div> + <div v-if="isCredentialsRequired"> + <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>Username</translate> + </small> + </div> + <div class="w-100"> + <input v-model="username" class="form-control" type="text" /> + </div> + <div v-if="!username" class="d-flex flex-row"> + <small + ><translate class="text-danger" + >Please enter a Username</translate + ></small + > + </div> + </div> + <div class="flex-column mt-3 w-50"> + <div class="flex-row text-left"> + <small class="text-muted"> + <translate>Password</translate> + </small> + </div> + <div class="w-100"> + <input v-model="password" class="form-control" type="text" /> + </div> + <div v-if="!password" class="d-flex flex-row"> + <small + ><translate class="text-danger" + >Please enter a Password</translate + ></small + > + </div> + </div> + </div> + </div> <div v-if="isFeatureTypeRequired"> <div class="d-flex flex-row"> <div class="flex-column mt-3 mr-3 w-50"> @@ -386,7 +427,11 @@ * Author(s): * Thomas Junk <thomas.junk@intevation.de> */ -import { IMPORTTYPES, IMPORTTYPEKIND } from "@/store/imports.js"; +import { + IMPORTTYPES, + IMPORTTYPEKIND, + initializeCurrentSchedule +} from "@/store/imports.js"; import { mapState } from "vuex"; import { displayInfo, displayError } from "@/lib/errors.js"; import app from "@/main.js"; @@ -394,29 +439,7 @@ export default { name: "importscheduledetail", data() { - return { - id: null, - importType: null, - schedule: null, - import_: null, - importSource: null, - eMailNotification: false, - scheduled: false, - easyCron: true, - cronMode: "", - minutes: null, - month: null, - hour: null, - day: null, - dayOfMonth: null, - simple: null, - url: null, - insecure: false, - triggerActive: true, - cronString: "* * * * ", - featureType: null, - sortBy: null - }; + return initializeCurrentSchedule(); }, IMPORTTYPES: IMPORTTYPES, EVERY: app.$gettext("Every"), @@ -496,6 +519,14 @@ if (this.id) return this.$gettext("Import") + " " + this.id; return this.$gettext("New Import"); }, + isCredentialsRequired() { + switch (this.import_) { + case this.$options.IMPORTTYPES.WATERWAYGAUGES: + return true; + default: + return false; + } + }, isURLRequired() { switch (this.import_) { case this.$options.IMPORTTYPES.BOTTLENECK: @@ -504,6 +535,7 @@ case this.$options.IMPORTTYPES.FAIRWAYAVAILABILITY: case this.$options.IMPORTTYPES.WATERWAYAREA: case this.$options.IMPORTTYPES.FAIRWAYDIMENSIONS: + case this.$options.IMPORTTYPES.WATERWAYGAUGES: return true; default: return false; @@ -523,7 +555,6 @@ switch (this.import_) { case this.$options.IMPORTTYPES.WATERWAYAXIS: case this.$options.IMPORTTYPES.WATERWAYAREA: - case this.$options.IMPORTTYPES.FAIRWAYDIMENSIONS: return true; default: return false; @@ -571,6 +602,8 @@ this.cronString = this.currentSchedule.cronString; this.featureType = this.currentSchedule.featureType; this.sortBy = this.currentSchedule.sortBy; + this.username = this.currentSchedule.username; + this.password = this.currentSchedule.password; }, isWeekly(cron) { return /0 \d{1,2} \d{1,2} \* \* \d{1}/.test(cron); @@ -602,6 +635,11 @@ if (!this.sortBy) return; data["sort-by"] = this.sortBy; } + if (this.isCredentialsRequired) { + if (!this.username || !this.password) return; + data["username"] = this.username; + data["password"] = this.password; + } this.triggerActive = false; this.$store .dispatch("imports/triggerImport", { type: this.import_, data }) @@ -654,6 +692,11 @@ "feature-type": this.featureType }); } + if (this.isCredentialsRequired) { + if (!this.username || !this.password) return; + addAttribute(data, { username: this.username }); + addAttribute(data, { password: this.password }); + } if (this.scheduled) data["cron"] = cron; data["kind"] = IMPORTTYPEKIND[this.import_]; data["send-email"] = this.eMailNotification;
--- a/client/src/store/imports.js Mon Jan 14 11:09:10 2019 +0100 +++ b/client/src/store/imports.js Mon Jan 14 12:09:34 2019 +0100 @@ -29,7 +29,8 @@ GAUGEMEASUREMENT: "gaugemeasurement", FAIRWAYAVAILABILITY: "fairwayavailability", WATERWAYAREA: "waterwayarea", - FAIRWAYDIMENSIONS: "fd" + FAIRWAYDIMENSIONS: "fd", + WATERWAYGAUGES: "wg" }; const SCHEDULES = { @@ -43,7 +44,8 @@ gaugemeasurement: "gm", waterwayaxis: "wx", waterwayarea: "wa", - fairwaydimensions: "fd" + fairwaydimensions: "fd", + waterwaygauges: "wg" }; const KINDIMPORTTYPE = { @@ -52,7 +54,8 @@ gm: "gaugemeasurement", wx: "waterwayaxis", wa: "waterwayarea", - fd: "fairwaydimensions" + fd: "fairwaydimensions", + wg: "waterwaygauges" }; const initializeCurrentSchedule = () => { @@ -65,7 +68,7 @@ eMailNotification: false, scheduled: false, easyCron: true, - cronString: null, + cronString: "* * * * ", cronMode: "", minutes: null, month: null, @@ -75,8 +78,11 @@ simple: null, url: null, insecure: false, + triggerActive: true, featureType: null, - sortBy: null + sortBy: null, + username: "", + password: "" }; }; @@ -151,7 +157,7 @@ Vue.set(state.currentSchedule, "url", url); } if (attributes) { - let { insecure } = attributes; + let { insecure, username, password } = attributes; let sortBy = attributes["sort-by"]; const featureType = attributes["feature-type"]; insecure = insecure == "true"; @@ -164,6 +170,12 @@ if (sortBy) { Vue.set(state.currentSchedule, "sortBy", sortBy); } + if (username) { + Vue.set(state.currentSchedule, "username", username); + } + if (password) { + Vue.set(state.currentSchedule, "password", password); + } } } }, @@ -288,4 +300,11 @@ } }; -export { imports, STATES, SCHEDULES, IMPORTTYPES, IMPORTTYPEKIND }; +export { + imports, + STATES, + SCHEDULES, + IMPORTTYPES, + IMPORTTYPEKIND, + initializeCurrentSchedule +};