Mercurial > gemma
changeset 2061:4a0d4e50768d unify_imports
frontend adapted to new backend
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Tue, 29 Jan 2019 14:46:57 +0100 |
parents | f9d13ce57893 |
children | a47943348865 |
files | client/src/components/importschedule/Importscheduledetail.vue client/src/store/importschedule.js |
diffstat | 2 files changed, 75 insertions(+), 83 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/importschedule/Importscheduledetail.vue Tue Jan 29 14:15:34 2019 +0100 +++ b/client/src/components/importschedule/Importscheduledetail.vue Tue Jan 29 14:46:57 2019 +0100 @@ -630,7 +630,10 @@ } this.triggerActive = false; this.$store - .dispatch("importschedule/triggerImport", { type: this.import_, data }) + .dispatch("importschedule/triggerImport", { + type: IMPORTTYPEKIND[this.import_], + data + }) .then(response => { const { id } = response.data; displayInfo({ @@ -650,10 +653,6 @@ }); }, save() { - 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) { @@ -661,31 +660,29 @@ if (this.simple === "monthly") cron = "0 0 0 1 * *"; } let data = {}; + let config = {}; + data["kind"] = IMPORTTYPEKIND[this.import_]; + if (this.isURLRequired) { if (!this.url) return; - data["url"] = this.url; - addAttribute(data, { - insecure: this.insecure + "" - }); + config["url"] = this.url; + config["insecure"] = this.insecure; } if (this.isSortbyRequired) { if (!this.sortBy) return; - addAttribute(data, { - "sort-by": this.sortBy - }); + config["sort-by"] = this.sortBy; } if (this.isFeatureTypeRequired) { if (!this.featureType) return; - addAttribute(data, { - "feature-type": this.featureType - }); + config["feature-type"] = this.featureType; } if (this.isCredentialsRequired) { if (!this.username || !this.password) return; - addAttribute(data, { + config = { + ...config, username: this.username, password: this.password - }); + }; } if (this.import_ == this.$options.IMPORTTYPES.FAIRWAYDIMENSION) { if ( @@ -696,18 +693,14 @@ !this.sourceOrganization ) return; - const values = { - los: this.LOS + "", - depth: this.depth + "" - }; - values["min-width"] = this.minWidth + ""; - values["max-width"] = this.maxWidth + ""; - values["source-organization"] = this.sourceOrganization; - addAttribute(data, values); + config = { ...config, los: this.LOS, depth: this.depth }; + config["min-width"] = this.minWidth; + config["max-width"] = this.maxWidth; + config["source-organization"] = this.sourceOrganization; } - if (this.scheduled) data["cron"] = cron; - data["kind"] = IMPORTTYPEKIND[this.import_]; - data["send-email"] = this.eMailNotification; + if (this.scheduled) config["cron"] = cron; + config["send-email"] = this.eMailNotification; + data["config"] = config; if (!this.id) { this.$store .dispatch("importschedule/saveCurrentSchedule", data)
--- a/client/src/store/importschedule.js Tue Jan 29 14:15:34 2019 +0100 +++ b/client/src/store/importschedule.js Tue Jan 29 14:46:57 2019 +0100 @@ -29,6 +29,17 @@ DISTANCEMARKSVIRTUAL: "distancemarksvirtual" }; +const KINDIMPORTTYPE = { + bn: "bottleneck", + fa: "fairwayavailability", + gm: "gaugemeasurement", + wx: "waterwayaxis", + wa: "waterwayarea", + fd: "fairwaydimension", + wg: "waterwaygauge", + dmv: "distancemarksvirtual" +}; + const IMPORTTYPEKIND = { bottleneck: "bn", fairwayavailability: "fa", @@ -40,17 +51,6 @@ distancemarksvirtual: "dmv" }; -const KINDIMPORTTYPE = { - bn: "bottleneck", - fa: "fairwayavailability", - gm: "gaugemeasurement", - wx: "waterwayaxis", - wa: "waterwayarea", - fd: "fairwaydimension", - wg: "waterwaygauge", - dmv: "distancemarksvirtual" -}; - const initializeCurrentSchedule = () => { return { id: null, @@ -111,8 +111,9 @@ state.schedules = schedules; }, unmarshallCurrentSchedule: (state, payload) => { - const { kind, id, cron, url, attributes } = payload; - const eMailNotification = payload["send-email"]; + const { kind, config, id } = payload; + const eMailNotification = config["send-email"]; + const { cron, url } = config; Vue.set(state.currentSchedule, "import_", KINDIMPORTTYPE[kind]); Vue.set(state.currentSchedule, "id", id); if (cron) { @@ -126,48 +127,46 @@ if (url) { Vue.set(state.currentSchedule, "url", url); } - if (attributes) { - let { insecure, username, password, los, depth } = attributes; - let sortBy = attributes["sort-by"]; - let minWidth = attributes["min-width"]; - let maxWidth = attributes["max-width"]; - let sourceOrganization = attributes["source-organization"]; - 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); - } - if (username) { - Vue.set(state.currentSchedule, "username", username); - } - if (password) { - Vue.set(state.currentSchedule, "password", password); - } - if (los) { - Vue.set(state.currentSchedule, "LOS", los); - } - if (minWidth) { - Vue.set(state.currentSchedule, "minWidth", minWidth); - } - if (maxWidth) { - Vue.set(state.currentSchedule, "maxWidth", maxWidth); - } - if (depth) { - Vue.set(state.currentSchedule, "depth", depth); - } - if (sourceOrganization) { - Vue.set( - state.currentSchedule, - "sourceOrganization", - sourceOrganization - ); - } + let { insecure, username, password, los, depth } = config; + let sortBy = config["sort-by"]; + let minWidth = config["min-width"]; + let maxWidth = config["max-width"]; + let sourceOrganization = config["source-organization"]; + const featureType = config["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); + } + if (username) { + Vue.set(state.currentSchedule, "username", username); + } + if (password) { + Vue.set(state.currentSchedule, "password", password); + } + if (los) { + Vue.set(state.currentSchedule, "LOS", los); + } + if (minWidth) { + Vue.set(state.currentSchedule, "minWidth", minWidth); + } + if (maxWidth) { + Vue.set(state.currentSchedule, "maxWidth", maxWidth); + } + if (depth) { + Vue.set(state.currentSchedule, "depth", depth); + } + if (sourceOrganization) { + Vue.set( + state.currentSchedule, + "sourceOrganization", + sourceOrganization + ); } } },