Mercurial > gemma
annotate client/src/components/map/contextbox/ImportSoundingresults.vue @ 1281:f1b096e1ee69
renamed imports
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Thu, 22 Nov 2018 10:02:20 +0100 |
parents | client/src/components/map/contextbox/Import_soundingresults.vue@f9e4c494e4c5 |
children | f674ce380de1 |
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"> |
1279
60e15c2d26a2
licensing info updated
Thomas Junk <thomas.junk@intevation.de>
parents:
1278
diff
changeset
|
4 <i class="fa fa-upload mr-2"></i> |
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> |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
7 <div v-if="editState" class="ml-auto mr-auto mt-4 w-90"> |
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> |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
36 <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
|
37 <div class="offset-r"> |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
38 <label class="label-text" for="depthreference">Depth reference</label> |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
39 </div> |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
40 <select v-model="depthReference" class="custom-select" id="depthreference"> |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
41 <option |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
42 v-for="option in this.$options.depthReferenceOptions" |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
43 :key="option" |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
44 >{{option}}</option> |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
45 </select> |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
46 </div> |
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 class="w-90 ml-auto mr-auto mt-4 mb-4"> |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
49 <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
|
50 <div class="custom-file"> |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
51 <input |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
52 type="file" |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
53 @change="fileSelected" |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
54 class="custom-file-input" |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
55 id="uploadFile" |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
56 > |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
57 <label class="custom-file-label" for="uploadFile">{{uploadLabel}}</label> |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
58 </div> |
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 class="buttons text-right"> |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
61 <a |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
62 v-if="editState" |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
63 download="meta.json" |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
64 :href="dataLink " |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
65 class="btn btn-outline-info pull-left" |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
66 >Download Meta.json</a> |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
67 <button |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
68 v-if="editState" |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
69 @click="deleteTempData" |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
70 class="btn btn-danger" |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
71 type="button" |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
72 >Cancel Upload</button> |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
73 <button |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
74 :disabled="disableUpload" |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
75 @click="submit" |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
76 class="btn btn-info" |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
77 type="button" |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
78 >{{uploadState?"Upload":"Confirm"}}</button> |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
79 </div> |
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 </template> |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
83 |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
84 <script> |
1279
60e15c2d26a2
licensing info updated
Thomas Junk <thomas.junk@intevation.de>
parents:
1278
diff
changeset
|
85 /* 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
|
86 * without warranty, see README.md and license for details. |
60e15c2d26a2
licensing info updated
Thomas Junk <thomas.junk@intevation.de>
parents:
1278
diff
changeset
|
87 * |
60e15c2d26a2
licensing info updated
Thomas Junk <thomas.junk@intevation.de>
parents:
1278
diff
changeset
|
88 * SPDX-License-Identifier: AGPL-3.0-or-later |
60e15c2d26a2
licensing info updated
Thomas Junk <thomas.junk@intevation.de>
parents:
1278
diff
changeset
|
89 * License-Filename: LICENSES/AGPL-3.0.txt |
60e15c2d26a2
licensing info updated
Thomas Junk <thomas.junk@intevation.de>
parents:
1278
diff
changeset
|
90 * |
60e15c2d26a2
licensing info updated
Thomas Junk <thomas.junk@intevation.de>
parents:
1278
diff
changeset
|
91 * Copyright (C) 2018 by via donau |
60e15c2d26a2
licensing info updated
Thomas Junk <thomas.junk@intevation.de>
parents:
1278
diff
changeset
|
92 * – Österreichische Wasserstraßen-Gesellschaft mbH |
60e15c2d26a2
licensing info updated
Thomas Junk <thomas.junk@intevation.de>
parents:
1278
diff
changeset
|
93 * Software engineering by Intevation GmbH |
60e15c2d26a2
licensing info updated
Thomas Junk <thomas.junk@intevation.de>
parents:
1278
diff
changeset
|
94 * |
60e15c2d26a2
licensing info updated
Thomas Junk <thomas.junk@intevation.de>
parents:
1278
diff
changeset
|
95 * Author(s): |
60e15c2d26a2
licensing info updated
Thomas Junk <thomas.junk@intevation.de>
parents:
1278
diff
changeset
|
96 * Thomas Junk <thomas.junk@intevation.de> |
60e15c2d26a2
licensing info updated
Thomas Junk <thomas.junk@intevation.de>
parents:
1278
diff
changeset
|
97 * Markus Kottländer <markus.kottlaender@intevation.de> |
60e15c2d26a2
licensing info updated
Thomas Junk <thomas.junk@intevation.de>
parents:
1278
diff
changeset
|
98 */ |
1278
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
99 import { HTTP } from "../../../lib/http"; |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
100 import { displayError, displayInfo } from "../../../lib/errors.js"; |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
101 |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
102 const defaultLabel = "Choose .zip-file"; |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
103 const IMPORTSTATE = { UPLOAD: "UPLOAD", EDIT: "EDIT" }; |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
104 |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
105 export default { |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
106 name: "imports", |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
107 data() { |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
108 return { |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
109 importState: IMPORTSTATE.UPLOAD, |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
110 depthReference: "", |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
111 bottleneck: "", |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
112 importDate: "", |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
113 uploadLabel: defaultLabel, |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
114 uploadFile: null, |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
115 disableUpload: false, |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
116 token: null |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
117 }; |
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 methods: { |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
120 initialState() { |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
121 this.importState = IMPORTSTATE.UPLOAD; |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
122 this.depthReference = ""; |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
123 this.bottleneck = ""; |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
124 this.importDate = ""; |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
125 this.uploadLabel = defaultLabel; |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
126 this.uploadFile = null; |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
127 this.disableUpload = false; |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
128 this.token = null; |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
129 }, |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
130 fileSelected(e) { |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
131 const files = e.target.files || e.dataTransfer.files; |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
132 if (!files) return; |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
133 this.uploadLabel = files[0].name; |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
134 this.uploadFile = files[0]; |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
135 }, |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
136 deleteTempData() { |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
137 HTTP.delete("/imports/soundingresult-upload/" + this.token, { |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
138 headers: { |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
139 "X-Gemma-Auth": localStorage.getItem("token") |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
140 } |
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 .then(() => { |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
143 this.initialState(); |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
144 }) |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
145 .catch(error => { |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
146 const { status, data } = error.response; |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
147 displayError({ |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
148 title: "Backend Error", |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
149 message: `${status}: ${data.message || data}` |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
150 }); |
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 submit() { |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
154 if (!this.uploadFile || this.disableUpload) return; |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
155 if (this.importState === IMPORTSTATE.UPLOAD) { |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
156 this.upload(); |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
157 } else { |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
158 this.confirm(); |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
159 } |
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 upload() { |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
162 let formData = new FormData(); |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
163 formData.append("soundingresult", this.uploadFile); |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
164 HTTP.post("/imports/soundingresult-upload", formData, { |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
165 headers: { |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
166 "X-Gemma-Auth": localStorage.getItem("token"), |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
167 "Content-Type": "multipart/form-data" |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
168 } |
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 .then(response => { |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
171 const { bottleneck, date } = response.data.meta; |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
172 const depthReference = response.data.meta["depth-reference"]; |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
173 this.importState = IMPORTSTATE.EDIT; |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
174 this.bottleneck = bottleneck; |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
175 this.depthReference = depthReference; |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
176 this.importDate = new Date(date).toISOString().split("T")[0]; |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
177 this.token = response.data.token; |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
178 }) |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
179 .catch(error => { |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
180 const { status, data } = error.response; |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
181 const messages = data.messages ? data.messages.join(", ") : ""; |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
182 displayError({ |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
183 title: "Backend Error", |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
184 message: `${status}: ${messages}` |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
185 }); |
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 confirm() { |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
189 let formData = new FormData(); |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
190 formData.append("token", this.token); |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
191 ["bottleneck", "importDate", "depthReference"].forEach(x => { |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
192 if (this[x]) formData.append(x, this[x]); |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
193 }); |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
194 HTTP.post("/imports/soundingresult", formData, { |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
195 headers: { |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
196 "X-Gemma-Auth": localStorage.getItem("token"), |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
197 "Content-Type": "multipart/form-data" |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
198 } |
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 .then(() => { |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
201 displayInfo({ |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
202 title: "Import", |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
203 message: "Starting import for " + this.bottleneck |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
204 }); |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
205 this.initialState(); |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
206 }) |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
207 .catch(error => { |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
208 const { status, data } = error.response; |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
209 displayError({ |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
210 title: "Backend Error", |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
211 message: `${status}: ${data.message || data}` |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
212 }); |
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 computed: { |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
217 editState() { |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
218 return this.importState === IMPORTSTATE.EDIT; |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
219 }, |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
220 uploadState() { |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
221 return this.importState === IMPORTSTATE.UPLOAD; |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
222 }, |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
223 dataLink() { |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
224 return ( |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
225 "data:text/json;charset=utf-8," + |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
226 encodeURIComponent( |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
227 JSON.stringify({ |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
228 depthReference: this.depthReference, |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
229 bottleneck: this.bottleneck, |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
230 date: this.importDate |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
231 }) |
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 depthReferenceOptions: [ |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
237 "", |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
238 "NAP", |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
239 "KP", |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
240 "FZP", |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
241 "ADR", |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
242 "TAW", |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
243 "PUL", |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
244 "NGM", |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
245 "ETRS", |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
246 "POT", |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
247 "LDC", |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
248 "HDC", |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
249 "ZPG", |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
250 "GLW", |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
251 "HSW", |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
252 "LNW", |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
253 "HNW", |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
254 "IGN", |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
255 "WGS", |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
256 "RN", |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
257 "HBO" |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
258 ] |
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 </script> |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
261 |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
262 <style lang="sass" scoped> |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
263 .offset-r |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
264 margin-right: $large-offset |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
265 |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
266 .buttons button |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
267 margin-left: $offset !important |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
268 |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
269 .label-text |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
270 width: 10rem |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
271 text-align: left |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
272 line-height: 2.25rem |
8f4bf8576acd
removed directory with only one file
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
273 </style> |