comparison client/src/components/ImportApprovedGaugeMeasurement.vue @ 1784:724758455a4e v2-preview20190111

Submit Approved Gaugemeasurements data to backend.
author Sascha Wilde <wilde@intevation.de>
date Fri, 11 Jan 2019 19:46:21 +0100
parents 68bd990dd8e5
children 535a1a40f1df
comparison
equal deleted inserted replaced
1783:8fd132b9cdbd 1784:724758455a4e
15 <div class="w-95 ml-auto mr-auto mt-4 mb-4"> 15 <div class="w-95 ml-auto mr-auto mt-4 mb-4">
16 <div class="d-flex flex-row input-group mb-4"> 16 <div class="d-flex flex-row input-group mb-4">
17 <div class="flex-column w-100"> 17 <div class="flex-column w-100">
18 <div class="custom-file"> 18 <div class="custom-file">
19 <input 19 <input
20 accept=".zip" 20 accept=".csv"
21 type="file" 21 type="file"
22 @change="fileSelected" 22 @change="fileSelected"
23 class="custom-file-input" 23 class="custom-file-input"
24 id="uploadFile" 24 id="uploadFile"
25 /> 25 />
63 * 63 *
64 * Author(s): 64 * Author(s):
65 * Thomas Junk <thomas.junk@intevation.de> 65 * Thomas Junk <thomas.junk@intevation.de>
66 */ 66 */
67 67
68 import { displayInfo } from "@/lib/errors.js"; 68 import { HTTP } from "@/lib/http";
69 import { displayError, displayInfo } from "@/lib/errors.js";
69 70
70 export default { 71 export default {
71 name: "importapprovedgaugemeasurements", 72 name: "importapprovedgaugemeasurements",
72 data() { 73 data() {
73 return { 74 return {
82 if (!files) return; 83 if (!files) return;
83 this.uploadLabel = files[0].name; 84 this.uploadLabel = files[0].name;
84 this.uploadFile = files[0]; 85 this.uploadFile = files[0];
85 }, 86 },
86 submit() { 87 submit() {
87 displayInfo({ 88 if (!this.uploadFile) return;
88 title: this.$gettext("Import"), 89 let formData = new FormData();
89 message: this.$gettext("under construction") 90 formData.append("approvedgm", this.uploadFile);
90 }); 91 HTTP.post("/imports/approvedgm", formData, {
92 headers: {
93 "X-Gemma-Auth": localStorage.getItem("token"),
94 "Content-Type": "multipart/form-data"
95 }
96 })
97 .then(() => {
98 displayInfo({
99 title: this.$gettext("Import"),
100 message: this.$gettext("Starting import of Approved Gauge Measurements")
101 });
102 this.initialState();
103 })
104 .catch(error => {
105 const { status, data } = error.response;
106 displayError({
107 title: this.$gettext("Backend Error"),
108 message: `${status}: ${data.message || data}`
109 });
110 });
91 } 111 }
92 }, 112 },
93 components: { 113 components: {
94 Spacer: () => import("./Spacer") 114 Spacer: () => import("./Spacer")
95 } 115 }