Mercurial > gemma
changeset 2199:b1735b09df6f
UBN: WIP
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Tue, 12 Feb 2019 16:54:48 +0100 |
parents | 4db1fa4f049c |
children | 64147a137e0a |
files | client/src/components/importschedule/Importscheduledetail.vue |
diffstat | 1 files changed, 36 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/importschedule/Importscheduledetail.vue Tue Feb 12 14:55:09 2019 +0100 +++ b/client/src/components/importschedule/Importscheduledetail.vue Tue Feb 12 16:54:48 2019 +0100 @@ -377,7 +377,7 @@ <div class="mt-3 mb-3 flex-column w-100"> <div class="custom-file"> <input - accept=".csv" + accept=".xml" type="file" @change="fileSelected" class="custom-file-input" @@ -437,6 +437,7 @@ import { mapState } from "vuex"; import { displayInfo, displayError } from "@/lib/errors.js"; import app from "@/main.js"; +import { HTTP } from "@/lib/http"; export default { name: "importscheduledetail", @@ -662,15 +663,45 @@ this.day = null; this.dayOfMonth = null; }, + triggerBottleneckFileUpload() { + if (!this.uploadFile) return; + let formData = new FormData(); + formData.append("ubn", this.uploadFile); + HTTP.post("/imports/ubn", { + headers: { + "X-Gemma-Auth": localStorage.getItem("token"), + "Content-type": "text/xml; charset=UTF-8" + } + }) + .then(response => { + const { id } = response.data; + displayInfo({ + title: this.$gettext("File Import"), + message: this.$gettext("Import import: #") + id + }); + this.closeDetailview(); + this.$store.dispatch("importschedule/loadSchedules").catch(error => { + const { status, data } = error.response; + displayError({ + title: this.gettext("Backend Error"), + message: `${status}: ${data.message || data}` + }); + }); + }) + .catch(error => { + const { status, data } = error.response; + displayError({ + title: this.$gettext("Backend Error"), + message: `${status}: ${data.message || data}` + }); + }); + }, triggerManualImport() { if (!this.triggerActive) return; if (!this.import_) return; if (this.directImport) { if (!this.uploadFile) return; - displayInfo({ - title: this.$gettext("Direct Import"), - message: this.$gettext("Not Implemented") - }); + this.triggerBottleneckFileUpload(); return; } let data = {};