# HG changeset patch # User Sascha Wilde # Date 1547839581 -3600 # Node ID 0059aa870a396e2112efae43f822c0c133454d7a # Parent 3dca0ee97da65a32238ab37e31cb2d78e36ec348 Hotfixed stretch import. diff -r 3dca0ee97da6 -r 0059aa870a39 client/src/components/ImportStretches.vue --- a/client/src/components/ImportStretches.vue Fri Jan 18 20:02:55 2019 +0100 +++ b/client/src/components/ImportStretches.vue Fri Jan 18 20:26:21 2019 +0100 @@ -225,7 +225,8 @@ * Thomas Junk */ import { mapState, mapGetters } from "vuex"; -import { displayInfo } from "@/lib/errors.js"; +import { HTTP } from "@/lib/http"; +import { displayError, displayInfo } from "@/lib/errors.js"; export default { name: "importstretches", @@ -256,14 +257,13 @@ }, mounted() { this.edit = false; - // uncomment when backend is there - // this.$store.dispatch("imports/loadStretches").catch(error => { - // const { status, data } = error.response; - // displayError({ - // title: this.$gettext("Backend Error"), - // message: `${status}: ${data.message || data}` - // }); - // }); + this.$store.dispatch("imports/loadStretches").catch(error => { + const { status, data } = error.response; + displayError({ + title: this.$gettext("Backend Error"), + message: `${status}: ${data.message || data}` + }); + }); }, methods: { clean() { @@ -308,7 +308,6 @@ "startrhm", "endrhm", "objbn", - "nobjbn", "date_info", "source" ]; @@ -333,8 +332,9 @@ date_info: this.date_info, source: this.source }; - this.$store.commit("imports/addStretch", stretch); - // uncomment when backend is there + //-- The following code does not work... [sw] + // this.$store.commit("imports/addStretch", stretch); + // this.$store.dispatch("imports/addStretch", stretch).catch(error => { // const { status, data } = error.response; // displayError({ @@ -342,11 +342,40 @@ // message: `${status}: ${data.message || data}` // }); // }); - this.edit = false; - displayInfo({ - title: this.$gettext("Sections"), - message: this.$gettext("Not implemented!") - }); + + // so here the quick dirty and working version: [sw] + const data = { + name: stretch.id, + from: stretch.startrhm, + to: stretch.endrhm, + source_organization: stretch.source, + date_info: stretch.date_info, + objnam: stretch.objnam, + nobjnam: stretch.nobjnam, + countries: stretch.countryCode.split() + }; + HTTP.post("/imports/stretch", data, { + headers: { + "X-Gemma-Auth": localStorage.getItem("token"), + "Content-Type": "multipart/form-data" + } + }) + .then(() => { + displayInfo({ + title: this.$gettext("Import"), + message: this.$gettext( + "Starting import of stretch" + ) + }); + this.initialState(); + }) + .catch(error => { + const { status, data } = error.response; + displayError({ + title: this.$gettext("Backend Error"), + message: `${status}: ${data.message || data}` + }); + }); } }, watch: { diff -r 3dca0ee97da6 -r 0059aa870a39 client/yarn.lock --- a/client/yarn.lock Fri Jan 18 20:02:55 2019 +0100 +++ b/client/yarn.lock Fri Jan 18 20:26:21 2019 +0100 @@ -4530,7 +4530,7 @@ loader-utils "^1.0.2" schema-utils "^1.0.0" -"file-saver@github:eligrey/FileSaver.js#1.3.8": +file-saver@eligrey/FileSaver.js#1.3.8: version "1.3.8" resolved "https://codeload.github.com/eligrey/FileSaver.js/tar.gz/e865e37af9f9947ddcced76b549e27dc45c1cb2e"