annotate client/src/components/importconfiguration/Import.vue @ 3281:439e1865a2d2

client: define stretches/imports: code cleanup / style improvements
author Markus Kottlaender <markus@intevation.de>
date Thu, 16 May 2019 09:52:32 +0200
parents 5d06629a14df
children 4d7b481e1d39
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2968
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
1 <template>
2972
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
2 <div>
3023
5d06629a14df client: imports: added missing close button
Markus Kottlaender <markus@intevation.de>
parents: 2985
diff changeset
3 <UIBoxHeader icon="clock" :title="title" :closeCallback="$parent.close" />
3281
439e1865a2d2 client: define stretches/imports: code cleanup / style improvements
Markus Kottlaender <markus@intevation.de>
parents: 3023
diff changeset
4 <div v-if="mode === $options.MODES.LIST">
2972
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
5 <UISpinnerOverlay v-if="loading" />
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
6 <UITableHeader
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
7 :columns="[
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
8 { id: 'id', title: `${idLabel}`, class: 'col-1' },
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
9 { id: 'kind', title: `${typeLabel}`, class: 'col-2' },
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
10 { id: 'user', title: `${authorLabel}`, class: 'col-2' },
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
11 { id: 'config.cron', title: `${scheduleLabel}`, class: 'col-2' },
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
12 { id: 'config.send-email', title: `${emailLabel}`, class: 'col-2' }
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
13 ]"
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
14 />
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
15 <UITableBody
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
16 :data="filteredSchedules | sortTable(sortColumn, sortDirection)"
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
17 :isActive="item => currentSchedule && item.id === currentSchedule.id"
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
18 >
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
19 <template v-slot:row="{ item: schedule }">
3281
439e1865a2d2 client: define stretches/imports: code cleanup / style improvements
Markus Kottlaender <markus@intevation.de>
parents: 3023
diff changeset
20 <div class="table-cell py-1 col-1">{{ schedule.id }}</div>
439e1865a2d2 client: define stretches/imports: code cleanup / style improvements
Markus Kottlaender <markus@intevation.de>
parents: 3023
diff changeset
21 <div class="table-cell py-1 col-2">
2972
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
22 {{ schedule.kind.toUpperCase() }}
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
23 </div>
3281
439e1865a2d2 client: define stretches/imports: code cleanup / style improvements
Markus Kottlaender <markus@intevation.de>
parents: 3023
diff changeset
24 <div class="table-cell py-1 col-2">{{ schedule.user }}</div>
439e1865a2d2 client: define stretches/imports: code cleanup / style improvements
Markus Kottlaender <markus@intevation.de>
parents: 3023
diff changeset
25 <div class="table-cell py-1 col-2">{{ schedule.config.cron }}</div>
439e1865a2d2 client: define stretches/imports: code cleanup / style improvements
Markus Kottlaender <markus@intevation.de>
parents: 3023
diff changeset
26 <div class="table-cell py-1 col-2">
2972
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
27 <font-awesome-icon
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
28 v-if="schedule.config['send-email']"
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
29 class="fa-fw mr-2"
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
30 fixed-width
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
31 icon="check"
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
32 />
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
33 </div>
3281
439e1865a2d2 client: define stretches/imports: code cleanup / style improvements
Markus Kottlaender <markus@intevation.de>
parents: 3023
diff changeset
34 <div class="table-cell py-1 col justify-content-end">
2972
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
35 <button
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
36 @click="triggerManualImport(schedule.id)"
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
37 class="btn btn-xs btn-dark mr-1"
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
38 :disabled="importScheduleDetailVisible"
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
39 >
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
40 <font-awesome-icon icon="play" fixed-width />
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
41 </button>
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
42 <button
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
43 @click="editSchedule(schedule.id)"
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
44 class="btn btn-xs btn-dark mr-1"
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
45 :disabled="importScheduleDetailVisible"
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
46 >
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
47 <font-awesome-icon icon="pencil-alt" fixed-width />
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
48 </button>
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
49 <button
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
50 @click="deleteSchedule(schedule)"
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
51 class="btn btn-xs btn-dark"
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
52 :disabled="importScheduleDetailVisible"
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
53 >
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
54 <font-awesome-icon icon="trash" fixed-width />
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
55 </button>
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
56 </div>
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
57 </template>
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
58 </UITableBody>
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
59 </div>
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
60 <ImportDetails v-if="mode === $options.MODES.EDIT"></ImportDetails>
3281
439e1865a2d2 client: define stretches/imports: code cleanup / style improvements
Markus Kottlaender <markus@intevation.de>
parents: 3023
diff changeset
61 <div
439e1865a2d2 client: define stretches/imports: code cleanup / style improvements
Markus Kottlaender <markus@intevation.de>
parents: 3023
diff changeset
62 class="text-right border-top p-2"
439e1865a2d2 client: define stretches/imports: code cleanup / style improvements
Markus Kottlaender <markus@intevation.de>
parents: 3023
diff changeset
63 v-if="mode === $options.MODES.LIST && !isOnetime"
439e1865a2d2 client: define stretches/imports: code cleanup / style improvements
Markus Kottlaender <markus@intevation.de>
parents: 3023
diff changeset
64 >
439e1865a2d2 client: define stretches/imports: code cleanup / style improvements
Markus Kottlaender <markus@intevation.de>
parents: 3023
diff changeset
65 <button :key="3" @click="newConfiguration()" class="btn btn-sm btn-info">
2972
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
66 <translate>New import</translate>
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
67 </button>
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
68 </div>
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
69 </div>
2968
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
70 </template>
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
71
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
72 <script>
2972
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
73 /* This is Free Software under GNU Affero General Public License v >= 3.0
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
74 * without warranty, see README.md and license for details.
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
75 *
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
76 * SPDX-License-Identifier: AGPL-3.0-or-later
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
77 * License-Filename: LICENSES/AGPL-3.0.txt
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
78 *
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
79 * Copyright (C) 2018 by via donau
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
80 * – Österreichische Wasserstraßen-Gesellschaft mbH
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
81 * Software engineering by Intevation GmbH
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
82 *
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
83 * Author(s):
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
84 * Thomas Junk <thomas.junk@intevation.de>
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
85 * Markus Kottländer <markus.kottlaender@intevation.de>
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
86 */
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
87 import { mapState } from "vuex";
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
88 import { displayInfo, displayError } from "@/lib/errors";
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
89 import { HTTP } from "@/lib/http";
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
90 import {
2974
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2972
diff changeset
91 IMPORTTYPES,
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2972
diff changeset
92 MODES
2972
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
93 // IMPORTTYPEKIND,
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
94 // initializeCurrentSchedule
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
95 } from "@/store/importschedule";
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
96
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
97 export default {
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
98 components: {
2985
1b8bb4f89227 client: removed .js and .vue extention from imports
Markus Kottlaender <markus@intevation.de>
parents: 2980
diff changeset
99 ImportDetails: () => import("./ImportDetails")
2972
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
100 },
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
101 data() {
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
102 return {
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
103 loading: false,
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
104 sortColumn: "",
2974
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2972
diff changeset
105 sortDirection: ""
2972
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
106 };
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
107 },
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
108 methods: {
2974
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2972
diff changeset
109 back() {
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2972
diff changeset
110 this.$store.commit("importschedule/setListMode");
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2972
diff changeset
111 },
2972
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
112 newConfiguration() {
2974
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2972
diff changeset
113 this.$store.commit("importschedule/setEditMode");
2972
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
114 },
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
115 getSchedules() {
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
116 this.loading = true;
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
117 this.$store
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
118 .dispatch("importschedule/loadSchedules")
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
119 .catch(error => {
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
120 const { status, data } = error.response;
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
121 displayError({
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
122 title: this.$gettext("Backend Error"),
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
123 message: `${status}: ${data.message || data}`
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
124 });
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
125 })
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
126 .finally(() => {
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
127 this.loading = false;
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
128 });
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
129 },
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
130 editSchedule(id) {
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
131 this.$store
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
132 .dispatch("importschedule/loadSchedule", id)
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
133 .then(() => {
2980
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
134 this.$store.commit("importschedule/setEditMode");
2972
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
135 })
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
136 .catch(error => {
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
137 const { status, data } = error.response;
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
138 displayError({
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
139 title: this.$gettext("Backend Error"),
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
140 message: `${status}: ${data.message || data}`
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
141 });
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
142 });
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
143 },
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
144 triggerManualImport(id) {
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
145 HTTP.get("/imports/config/" + id + "/run", {
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
146 headers: { "X-Gemma-Auth": localStorage.getItem("token") }
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
147 })
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
148 .then(response => {
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
149 const { id } = response.data;
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
150 displayInfo({
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
151 title: this.$gettext("Imports"),
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
152 message: this.$gettext("Manually triggered import: #") + id
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
153 });
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
154 })
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
155 .catch(error => {
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
156 const { status, data } = error.response;
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
157 displayError({
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
158 title: this.$gettext("Backend Error"),
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
159 message: `${status}: ${data.message || data}`
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
160 });
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
161 });
2980
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
162 },
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
163 deleteSchedule(schedule) {
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
164 console.log(schedule);
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
165 this.$store.commit("application/popup", {
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
166 icon: "trash",
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
167 title: this.$gettext("Delete Import"),
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
168 content:
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
169 this.$gettext("Do you really want to delete the import with ID") +
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
170 `<b>${schedule.id}</b>` +
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
171 this.$gettext("of type") +
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
172 `<b>${schedule.kind.toUpperCase()}</b>?`,
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
173 confirm: {
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
174 label: this.$gettext("Delete"),
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
175 icon: "trash",
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
176 callback: () => {
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
177 this.$store
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
178 .dispatch("importschedule/deleteSchedule", schedule.id)
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
179 .then(() => {
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
180 this.getSchedules();
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
181 displayInfo({
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
182 title: this.$gettext("Imports"),
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
183 message: this.$gettext("Deleted import: #") + schedule.id
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
184 });
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
185 })
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
186 .catch(error => {
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
187 const { status, data } = error.response;
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
188 displayError({
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
189 title: this.$gettext("Backend Error"),
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
190 message: `${status}: ${data.message || data}`
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
191 });
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
192 });
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
193 }
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
194 },
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
195 cancel: {
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
196 label: this.$gettext("Cancel"),
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
197 icon: "times"
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
198 }
a9b61290fcc2 unified_imports: edit capabilities added
Thomas Junk <thomas.junk@intevation.de>
parents: 2979
diff changeset
199 });
2972
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
200 }
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
201 },
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
202 computed: {
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
203 ...mapState("application", ["searchQuery"]),
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
204 ...mapState("importschedule", [
2974
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2972
diff changeset
205 "mode",
2972
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
206 "schedules",
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
207 "currentSchedule",
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
208 "importScheduleDetailVisible"
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
209 ]),
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
210 isOnetime() {
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
211 for (let kind of [
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
212 this.$options.IMPORTTYPES.SOUNDINGRESULTS,
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
213 this.$options.IMPORTTYPES.APPROVEDGAUGEMEASUREMENTS,
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
214 this.$options.IMPORTTYPES.WATERWAYPROFILES
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
215 ]) {
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
216 if (kind === this.currentSchedule.importType) return true;
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
217 }
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
218 return false;
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
219 },
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
220 title() {
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
221 return this.$gettext("Imports");
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
222 },
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
223 filteredSchedules() {
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
224 return this.schedules.filter(s => {
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
225 return (s.id + s.kind)
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
226 .toLowerCase()
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
227 .includes(this.searchQuery.toLowerCase());
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
228 });
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
229 },
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
230 importScheduleLabel() {
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
231 return this.$gettext("Import Schedule");
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
232 },
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
233 idLabel() {
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
234 return this.$gettext("ID");
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
235 },
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
236 typeLabel() {
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
237 return this.$gettext("Type");
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
238 },
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
239 authorLabel() {
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
240 return this.$gettext("Author");
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
241 },
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
242 scheduleLabel() {
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
243 return this.$gettext("Schedule");
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
244 },
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
245 emailLabel() {
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
246 return this.$gettext("Email");
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
247 }
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
248 },
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
249 mounted() {
2974
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2972
diff changeset
250 this.$store.commit("importschedule/setListMode");
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2972
diff changeset
251 this.$store.commit("importschedule/clearCurrentSchedule");
2972
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
252 this.getSchedules();
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
253 },
2974
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2972
diff changeset
254 IMPORTTYPES: IMPORTTYPES,
e161e1ffb6b5 unified_imports: AGM moved to new interface
Thomas Junk <thomas.junk@intevation.de>
parents: 2972
diff changeset
255 MODES: MODES
2972
6f351e00e579 unified_imports: initial layout etd
Thomas Junk <thomas.junk@intevation.de>
parents: 2968
diff changeset
256 };
2968
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
257 </script>