annotate client/src/components/importconfiguration/types/ApprovedGaugeMeasurement.vue @ 2978:d6dd158b8071 unified_import

unified_import: reorganizing files
author Thomas Junk <thomas.junk@intevation.de>
date Tue, 09 Apr 2019 13:42:44 +0200
parents client/src/components/importconfiguration/ImportApprovedGaugeMeasurement.vue@2a29bf8776d0
children 1b8bb4f89227
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1753
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
1 <template>
2974
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
2 <div>
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
3 <div class="d-flex flex-column text-left w-25">
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
4 <label class="text-nowrap" for="originator">
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
5 <small class="text-muted"
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
6 >{{ $options.ORIGINATOR }} / {{ $options.FROM }}</small
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
7 >
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
8 </label>
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
9 <input
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
10 type="text"
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
11 v-model="originator"
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
12 class="form-control"
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
13 id="originator"
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
14 />
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
15 <span class="text-left text-danger">
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
16 <small v-if="!originator">
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
17 <translate>Please enter an originator</translate>
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
18 </small>
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
19 </span>
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
20 </div>
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
21 <div class="mt-4 flex-column w-100">
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
22 <div class="custom-file">
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
23 <input
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
24 accept=".csv"
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
25 type="file"
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
26 @change="fileSelected"
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
27 class="custom-file-input"
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
28 id="uploadFile"
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
29 />
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
30 <label class="pointer custom-file-label" for="uploadFile">
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
31 {{ uploadLabel }}
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
32 </label>
1753
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
33 </div>
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
34 </div>
2974
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
35 <div class="d-flex flex-row-reverse w-100 mt-3">
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
36 <button :key="1" @click="back()" class="btn btn-warning">
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
37 Back
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
38 </button>
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
39 <button
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
40 :key="2"
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
41 type="submit"
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
42 @click="submit"
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
43 class="shadow-sm btn btn-info submit-button mr-3"
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
44 >
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
45 <translate>Submit</translate>
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
46 </button>
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
47 </div>
1753
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
48 </div>
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
49 </template>
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
50
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
51 <script>
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
52 /* This is Free Software under GNU Affero General Public License v >= 3.0
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
53 * without warranty, see README.md and license for details.
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
54 *
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
55 * SPDX-License-Identifier: AGPL-3.0-or-later
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
56 * License-Filename: LICENSES/AGPL-3.0.txt
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
57 *
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
58 * Copyright (C) 2018 by via donau
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
59 * – Österreichische Wasserstraßen-Gesellschaft mbH
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
60 * Software engineering by Intevation GmbH
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
61 *
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
62 * Author(s):
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
63 * Thomas Junk <thomas.junk@intevation.de>
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
64 */
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
65
1784
724758455a4e Submit Approved Gaugemeasurements data to backend.
Sascha Wilde <wilde@intevation.de>
parents: 1753
diff changeset
66 import { HTTP } from "@/lib/http";
724758455a4e Submit Approved Gaugemeasurements data to backend.
Sascha Wilde <wilde@intevation.de>
parents: 1753
diff changeset
67 import { displayError, displayInfo } from "@/lib/errors.js";
2366
ff1e4f1b54c6 agm_import: originator field added
Thomas Junk <thomas.junk@intevation.de>
parents: 2255
diff changeset
68 import app from "@/main";
1753
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
69
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
70 export default {
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
71 name: "importapprovedgaugemeasurements",
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
72 data() {
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
73 return {
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
74 disableUploadButton: false,
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
75 uploadLabel: this.$gettext("choose file to upload"),
2366
ff1e4f1b54c6 agm_import: originator field added
Thomas Junk <thomas.junk@intevation.de>
parents: 2255
diff changeset
76 uploadFile: null,
ff1e4f1b54c6 agm_import: originator field added
Thomas Junk <thomas.junk@intevation.de>
parents: 2255
diff changeset
77 originator: "viadonau"
1753
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
78 };
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
79 },
2760
c6fba10926cc client:correct a set of strings marking
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2534
diff changeset
80 computed: {
c6fba10926cc client:correct a set of strings marking
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2534
diff changeset
81 importGaugmeasurmentLabel() {
c6fba10926cc client:correct a set of strings marking
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2534
diff changeset
82 return this.$gettext("Import approved gaugemeasurements");
c6fba10926cc client:correct a set of strings marking
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2534
diff changeset
83 }
c6fba10926cc client:correct a set of strings marking
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2534
diff changeset
84 },
1753
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
85 methods: {
2974
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
86 back() {
2975
2a29bf8776d0 unified_imports: waterway profiles moved to new UI
Thomas Junk <thomas.junk@intevation.de>
parents: 2974
diff changeset
87 this.uploadLabel = this.$gettext("choose file to upload");
2a29bf8776d0 unified_imports: waterway profiles moved to new UI
Thomas Junk <thomas.junk@intevation.de>
parents: 2974
diff changeset
88 this.uploadFile = null;
2a29bf8776d0 unified_imports: waterway profiles moved to new UI
Thomas Junk <thomas.junk@intevation.de>
parents: 2974
diff changeset
89 this.originator = "viadonau";
2974
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
90 this.$store.commit("importschedule/setListMode");
2366
ff1e4f1b54c6 agm_import: originator field added
Thomas Junk <thomas.junk@intevation.de>
parents: 2255
diff changeset
91 },
1753
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
92 fileSelected(e) {
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
93 const files = e.target.files || e.dataTransfer.files;
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
94 if (!files) return;
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
95 this.uploadLabel = files[0].name;
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
96 this.uploadFile = files[0];
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
97 },
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
98 submit() {
2366
ff1e4f1b54c6 agm_import: originator field added
Thomas Junk <thomas.junk@intevation.de>
parents: 2255
diff changeset
99 if (!this.originator || !this.uploadFile) return;
1784
724758455a4e Submit Approved Gaugemeasurements data to backend.
Sascha Wilde <wilde@intevation.de>
parents: 1753
diff changeset
100 let formData = new FormData();
2255
33af355047e1 Approved gauge meassurement import: Unified file upload parameter to 'agm'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2154
diff changeset
101 formData.append("agm", this.uploadFile);
2366
ff1e4f1b54c6 agm_import: originator field added
Thomas Junk <thomas.junk@intevation.de>
parents: 2255
diff changeset
102 formData.append("originator", this.originator);
2144
e22a354a2312 approved_gauge_measurements: url adjusted
Thomas Junk <thomas.junk@intevation.de>
parents: 2123
diff changeset
103 HTTP.post("/imports/agm", formData, {
1784
724758455a4e Submit Approved Gaugemeasurements data to backend.
Sascha Wilde <wilde@intevation.de>
parents: 1753
diff changeset
104 headers: {
724758455a4e Submit Approved Gaugemeasurements data to backend.
Sascha Wilde <wilde@intevation.de>
parents: 1753
diff changeset
105 "X-Gemma-Auth": localStorage.getItem("token"),
724758455a4e Submit Approved Gaugemeasurements data to backend.
Sascha Wilde <wilde@intevation.de>
parents: 1753
diff changeset
106 "Content-Type": "multipart/form-data"
724758455a4e Submit Approved Gaugemeasurements data to backend.
Sascha Wilde <wilde@intevation.de>
parents: 1753
diff changeset
107 }
724758455a4e Submit Approved Gaugemeasurements data to backend.
Sascha Wilde <wilde@intevation.de>
parents: 1753
diff changeset
108 })
724758455a4e Submit Approved Gaugemeasurements data to backend.
Sascha Wilde <wilde@intevation.de>
parents: 1753
diff changeset
109 .then(() => {
724758455a4e Submit Approved Gaugemeasurements data to backend.
Sascha Wilde <wilde@intevation.de>
parents: 1753
diff changeset
110 displayInfo({
724758455a4e Submit Approved Gaugemeasurements data to backend.
Sascha Wilde <wilde@intevation.de>
parents: 1753
diff changeset
111 title: this.$gettext("Import"),
1804
535a1a40f1df yarn lint
Thomas Junk <thomas.junk@intevation.de>
parents: 1784
diff changeset
112 message: this.$gettext(
535a1a40f1df yarn lint
Thomas Junk <thomas.junk@intevation.de>
parents: 1784
diff changeset
113 "Starting import of Approved Gauge Measurements"
535a1a40f1df yarn lint
Thomas Junk <thomas.junk@intevation.de>
parents: 1784
diff changeset
114 )
1784
724758455a4e Submit Approved Gaugemeasurements data to backend.
Sascha Wilde <wilde@intevation.de>
parents: 1753
diff changeset
115 });
2974
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2919
diff changeset
116 this.back();
1784
724758455a4e Submit Approved Gaugemeasurements data to backend.
Sascha Wilde <wilde@intevation.de>
parents: 1753
diff changeset
117 })
724758455a4e Submit Approved Gaugemeasurements data to backend.
Sascha Wilde <wilde@intevation.de>
parents: 1753
diff changeset
118 .catch(error => {
724758455a4e Submit Approved Gaugemeasurements data to backend.
Sascha Wilde <wilde@intevation.de>
parents: 1753
diff changeset
119 const { status, data } = error.response;
724758455a4e Submit Approved Gaugemeasurements data to backend.
Sascha Wilde <wilde@intevation.de>
parents: 1753
diff changeset
120 displayError({
724758455a4e Submit Approved Gaugemeasurements data to backend.
Sascha Wilde <wilde@intevation.de>
parents: 1753
diff changeset
121 title: this.$gettext("Backend Error"),
724758455a4e Submit Approved Gaugemeasurements data to backend.
Sascha Wilde <wilde@intevation.de>
parents: 1753
diff changeset
122 message: `${status}: ${data.message || data}`
724758455a4e Submit Approved Gaugemeasurements data to backend.
Sascha Wilde <wilde@intevation.de>
parents: 1753
diff changeset
123 });
724758455a4e Submit Approved Gaugemeasurements data to backend.
Sascha Wilde <wilde@intevation.de>
parents: 1753
diff changeset
124 });
1753
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
125 }
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
126 },
2366
ff1e4f1b54c6 agm_import: originator field added
Thomas Junk <thomas.junk@intevation.de>
parents: 2255
diff changeset
127 ORIGINATOR: app.$gettext("originator"),
ff1e4f1b54c6 agm_import: originator field added
Thomas Junk <thomas.junk@intevation.de>
parents: 2255
diff changeset
128 FROM: app.$gettext("from")
1753
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
129 };
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
130 </script>
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
131
68bd990dd8e5 feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
132 <style lang="scss" scoped></style>