annotate client/src/components/map/contextbox/ImportSoundingresults.vue @ 1299:2738a6ae9ad8

fontawesome 4 -> 5 An icon was not displayed on a specific system/environment. No clue why... good moment to switch to version 5 of fontawesome
author Markus Kottlaender <markus@intevation.de>
date Fri, 23 Nov 2018 10:24:29 +0100
parents f674ce380de1
children 3c10c868cba7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1278
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
1 <template>
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
2 <div>
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
3 <h6 class="mb-0 py-2 px-3 border-bottom d-flex align-items-center">
1299
2738a6ae9ad8 fontawesome 4 -> 5
Markus Kottlaender <markus@intevation.de>
parents: 1285
diff changeset
4 <font-awesome-icon icon="upload" class="mr-2"></font-awesome-icon>
1279
60e15c2d26a2 licensing info updated
Thomas Junk <thomas.junk@intevation.de>
parents: 1278
diff changeset
5 Import Soundingresults
1278
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
6 </h6>
1285
f674ce380de1 layout soundingresults
Thomas Junk <thomas.junk@intevation.de>
parents: 1281
diff changeset
7 <div v-if="editState" class="ml-auto mr-auto mt-4 w-95">
1278
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
8 <div class="d-flex flex-row input-group mb-4">
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
9 <div class="offset-r">
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
10 <label for="bottleneck" class="label-text" id="bottlenecklabel">Bottleneck</label>
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
11 </div>
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
12 <input
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
13 id="bottleneck"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
14 type="text"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
15 class="form-control"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
16 placeholder="Name of Bottleneck"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
17 aria-label="bottleneck"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
18 aria-describedby="bottlenecklabel"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
19 v-model="bottleneck"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
20 >
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
21 </div>
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
22 <div class="d-flex flex-row input-group mb-4">
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
23 <div class="offset-r">
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
24 <label class="label-text" for="importdate" id="importdatelabel">Date</label>
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
25 </div>
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
26 <input
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
27 id="importdate"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
28 type="date"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
29 class="form-control"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
30 placeholder="Date of import"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
31 aria-label="bottleneck"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
32 aria-describedby="bottlenecklabel"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
33 v-model="importDate"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
34 >
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
35 <div class="offset-r">
1285
f674ce380de1 layout soundingresults
Thomas Junk <thomas.junk@intevation.de>
parents: 1281
diff changeset
36 <label
f674ce380de1 layout soundingresults
Thomas Junk <thomas.junk@intevation.de>
parents: 1281
diff changeset
37 class="label-text w-100 depthreferencelabel"
f674ce380de1 layout soundingresults
Thomas Junk <thomas.junk@intevation.de>
parents: 1281
diff changeset
38 for="depthreference"
f674ce380de1 layout soundingresults
Thomas Junk <thomas.junk@intevation.de>
parents: 1281
diff changeset
39 >Depthreference</label>
1278
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
40 </div>
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
41 <select v-model="depthReference" class="custom-select" id="depthreference">
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
42 <option
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
43 v-for="option in this.$options.depthReferenceOptions"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
44 :key="option"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
45 >{{option}}</option>
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
46 </select>
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
47 </div>
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
48 </div>
1285
f674ce380de1 layout soundingresults
Thomas Junk <thomas.junk@intevation.de>
parents: 1281
diff changeset
49 <div class="w-95 ml-auto mr-auto mt-4 mb-4">
1278
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
50 <div v-if="uploadState" class="d-flex flex-row input-group mb-4">
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
51 <div class="custom-file">
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
52 <input
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
53 type="file"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
54 @change="fileSelected"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
55 class="custom-file-input"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
56 id="uploadFile"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
57 >
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
58 <label class="custom-file-label" for="uploadFile">{{uploadLabel}}</label>
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
59 </div>
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
60 </div>
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
61 <div class="buttons text-right">
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
62 <a
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
63 v-if="editState"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
64 download="meta.json"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
65 :href="dataLink "
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
66 class="btn btn-outline-info pull-left"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
67 >Download Meta.json</a>
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
68 <button
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
69 v-if="editState"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
70 @click="deleteTempData"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
71 class="btn btn-danger"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
72 type="button"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
73 >Cancel Upload</button>
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
74 <button
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
75 :disabled="disableUpload"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
76 @click="submit"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
77 class="btn btn-info"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
78 type="button"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
79 >{{uploadState?"Upload":"Confirm"}}</button>
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
80 </div>
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
81 </div>
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
82 </div>
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
83 </template>
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
84
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
85 <script>
1279
60e15c2d26a2 licensing info updated
Thomas Junk <thomas.junk@intevation.de>
parents: 1278
diff changeset
86 /* This is Free Software under GNU Affero General Public License v >= 3.0
60e15c2d26a2 licensing info updated
Thomas Junk <thomas.junk@intevation.de>
parents: 1278
diff changeset
87 * without warranty, see README.md and license for details.
60e15c2d26a2 licensing info updated
Thomas Junk <thomas.junk@intevation.de>
parents: 1278
diff changeset
88 *
60e15c2d26a2 licensing info updated
Thomas Junk <thomas.junk@intevation.de>
parents: 1278
diff changeset
89 * SPDX-License-Identifier: AGPL-3.0-or-later
60e15c2d26a2 licensing info updated
Thomas Junk <thomas.junk@intevation.de>
parents: 1278
diff changeset
90 * License-Filename: LICENSES/AGPL-3.0.txt
60e15c2d26a2 licensing info updated
Thomas Junk <thomas.junk@intevation.de>
parents: 1278
diff changeset
91 *
60e15c2d26a2 licensing info updated
Thomas Junk <thomas.junk@intevation.de>
parents: 1278
diff changeset
92 * Copyright (C) 2018 by via donau
60e15c2d26a2 licensing info updated
Thomas Junk <thomas.junk@intevation.de>
parents: 1278
diff changeset
93 * – Österreichische Wasserstraßen-Gesellschaft mbH
60e15c2d26a2 licensing info updated
Thomas Junk <thomas.junk@intevation.de>
parents: 1278
diff changeset
94 * Software engineering by Intevation GmbH
60e15c2d26a2 licensing info updated
Thomas Junk <thomas.junk@intevation.de>
parents: 1278
diff changeset
95 *
60e15c2d26a2 licensing info updated
Thomas Junk <thomas.junk@intevation.de>
parents: 1278
diff changeset
96 * Author(s):
60e15c2d26a2 licensing info updated
Thomas Junk <thomas.junk@intevation.de>
parents: 1278
diff changeset
97 * Thomas Junk <thomas.junk@intevation.de>
60e15c2d26a2 licensing info updated
Thomas Junk <thomas.junk@intevation.de>
parents: 1278
diff changeset
98 * Markus Kottländer <markus.kottlaender@intevation.de>
60e15c2d26a2 licensing info updated
Thomas Junk <thomas.junk@intevation.de>
parents: 1278
diff changeset
99 */
1278
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
100 import { HTTP } from "../../../lib/http";
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
101 import { displayError, displayInfo } from "../../../lib/errors.js";
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
102
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
103 const defaultLabel = "Choose .zip-file";
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
104 const IMPORTSTATE = { UPLOAD: "UPLOAD", EDIT: "EDIT" };
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
105
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
106 export default {
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
107 name: "imports",
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
108 data() {
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
109 return {
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
110 importState: IMPORTSTATE.UPLOAD,
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
111 depthReference: "",
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
112 bottleneck: "",
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
113 importDate: "",
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
114 uploadLabel: defaultLabel,
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
115 uploadFile: null,
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
116 disableUpload: false,
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
117 token: null
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
118 };
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
119 },
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
120 methods: {
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
121 initialState() {
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
122 this.importState = IMPORTSTATE.UPLOAD;
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
123 this.depthReference = "";
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
124 this.bottleneck = "";
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
125 this.importDate = "";
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
126 this.uploadLabel = defaultLabel;
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
127 this.uploadFile = null;
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
128 this.disableUpload = false;
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
129 this.token = null;
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
130 },
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
131 fileSelected(e) {
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
132 const files = e.target.files || e.dataTransfer.files;
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
133 if (!files) return;
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
134 this.uploadLabel = files[0].name;
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
135 this.uploadFile = files[0];
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
136 },
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
137 deleteTempData() {
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
138 HTTP.delete("/imports/soundingresult-upload/" + this.token, {
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
139 headers: {
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
140 "X-Gemma-Auth": localStorage.getItem("token")
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
141 }
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
142 })
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
143 .then(() => {
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
144 this.initialState();
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
145 })
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
146 .catch(error => {
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
147 const { status, data } = error.response;
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
148 displayError({
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
149 title: "Backend Error",
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
150 message: `${status}: ${data.message || data}`
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
151 });
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
152 });
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
153 },
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
154 submit() {
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
155 if (!this.uploadFile || this.disableUpload) return;
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
156 if (this.importState === IMPORTSTATE.UPLOAD) {
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
157 this.upload();
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
158 } else {
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
159 this.confirm();
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
160 }
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
161 },
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
162 upload() {
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
163 let formData = new FormData();
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
164 formData.append("soundingresult", this.uploadFile);
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
165 HTTP.post("/imports/soundingresult-upload", formData, {
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
166 headers: {
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
167 "X-Gemma-Auth": localStorage.getItem("token"),
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
168 "Content-Type": "multipart/form-data"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
169 }
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
170 })
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
171 .then(response => {
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
172 const { bottleneck, date } = response.data.meta;
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
173 const depthReference = response.data.meta["depth-reference"];
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
174 this.importState = IMPORTSTATE.EDIT;
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
175 this.bottleneck = bottleneck;
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
176 this.depthReference = depthReference;
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
177 this.importDate = new Date(date).toISOString().split("T")[0];
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
178 this.token = response.data.token;
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
179 })
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
180 .catch(error => {
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
181 const { status, data } = error.response;
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
182 const messages = data.messages ? data.messages.join(", ") : "";
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
183 displayError({
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
184 title: "Backend Error",
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
185 message: `${status}: ${messages}`
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
186 });
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
187 });
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
188 },
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
189 confirm() {
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
190 let formData = new FormData();
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
191 formData.append("token", this.token);
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
192 ["bottleneck", "importDate", "depthReference"].forEach(x => {
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
193 if (this[x]) formData.append(x, this[x]);
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
194 });
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
195 HTTP.post("/imports/soundingresult", formData, {
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
196 headers: {
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
197 "X-Gemma-Auth": localStorage.getItem("token"),
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
198 "Content-Type": "multipart/form-data"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
199 }
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
200 })
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
201 .then(() => {
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
202 displayInfo({
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
203 title: "Import",
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
204 message: "Starting import for " + this.bottleneck
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
205 });
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
206 this.initialState();
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
207 })
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
208 .catch(error => {
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
209 const { status, data } = error.response;
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
210 displayError({
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
211 title: "Backend Error",
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
212 message: `${status}: ${data.message || data}`
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
213 });
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
214 });
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
215 }
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
216 },
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
217 computed: {
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
218 editState() {
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
219 return this.importState === IMPORTSTATE.EDIT;
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
220 },
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
221 uploadState() {
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
222 return this.importState === IMPORTSTATE.UPLOAD;
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
223 },
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
224 dataLink() {
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
225 return (
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
226 "data:text/json;charset=utf-8," +
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
227 encodeURIComponent(
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
228 JSON.stringify({
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
229 depthReference: this.depthReference,
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
230 bottleneck: this.bottleneck,
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
231 date: this.importDate
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
232 })
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
233 )
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
234 );
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
235 }
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
236 },
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
237 depthReferenceOptions: [
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
238 "",
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
239 "NAP",
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
240 "KP",
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
241 "FZP",
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
242 "ADR",
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
243 "TAW",
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
244 "PUL",
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
245 "NGM",
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
246 "ETRS",
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
247 "POT",
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
248 "LDC",
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
249 "HDC",
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
250 "ZPG",
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
251 "GLW",
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
252 "HSW",
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
253 "LNW",
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
254 "HNW",
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
255 "IGN",
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
256 "WGS",
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
257 "RN",
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
258 "HBO"
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
259 ]
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
260 };
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
261 </script>
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
262
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
263 <style lang="sass" scoped>
1285
f674ce380de1 layout soundingresults
Thomas Junk <thomas.junk@intevation.de>
parents: 1281
diff changeset
264 .depthreferencelabel
f674ce380de1 layout soundingresults
Thomas Junk <thomas.junk@intevation.de>
parents: 1281
diff changeset
265 margin-left: $small-offset
f674ce380de1 layout soundingresults
Thomas Junk <thomas.junk@intevation.de>
parents: 1281
diff changeset
266
1278
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
267 .offset-r
1285
f674ce380de1 layout soundingresults
Thomas Junk <thomas.junk@intevation.de>
parents: 1281
diff changeset
268 margin-right: $small-offset
1278
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
269
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
270 .buttons button
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
271 margin-left: $offset !important
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
272
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
273 .label-text
1285
f674ce380de1 layout soundingresults
Thomas Junk <thomas.junk@intevation.de>
parents: 1281
diff changeset
274 width: 5rem
1278
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
275 text-align: left
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
276 line-height: 2.25rem
8f4bf8576acd removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
277 </style>