Mercurial > gemma
annotate client/src/store/importschedule.js @ 2384:c06b001dc26b
client: improved popup implementation
For deleting users and templates there was a more or less quick n' dirty implementation of
a confirmation dialog/popup. Since we need this kind of dialog in several more places I
generalized the implementation a bit and made it more robust.
author | Markus Kottlaender <markus@intevation.de> |
---|---|
date | Mon, 25 Feb 2019 13:11:30 +0100 |
parents | fdec7a652f34 |
children | dc4fae4bdb8f |
rev | line source |
---|---|
2034
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
1 /* This is Free Software under GNU Affero General Public License v >= 3.0 |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
2 * without warranty, see README.md and license for details. |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
3 * |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
4 * SPDX-License-Identifier: AGPL-3.0-or-later |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
5 * License-Filename: LICENSES/AGPL-3.0.txt |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
6 * |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
7 * Copyright (C) 2018 by via donau |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
8 * – Österreichische Wasserstraßen-Gesellschaft mbH |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
9 * Software engineering by Intevation GmbH |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
10 * |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
11 * Author(s): |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
12 * Thomas Junk <thomas.junk@intevation.de> |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
13 */ |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
14 |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
15 import Vue from "vue"; |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
16 import { HTTP } from "@/lib/http"; |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
17 |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
18 /* eslint-disable no-unused-vars */ |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
19 /* eslint-disable no-unreachable */ |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
20 |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
21 const IMPORTTYPES = { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
22 BOTTLENECK: "bottleneck", |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
23 WATERWAYAXIS: "waterwayaxis", |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
24 GAUGEMEASUREMENT: "gaugemeasurement", |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
25 FAIRWAYAVAILABILITY: "fairwayavailability", |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
26 WATERWAYAREA: "waterwayarea", |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
27 FAIRWAYDIMENSION: "fairwaydimension", |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
28 WATERWAYGAUGES: "waterwaygauges", |
2068 | 29 DISTANCEMARKSVIRTUAL: "distancemarksvirtual", |
30 DISTANCEMARKSASHORE: "distancemarksashore" | |
2034
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
31 }; |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
32 |
2061
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
33 const KINDIMPORTTYPE = { |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
34 bn: "bottleneck", |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
35 fa: "fairwayavailability", |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
36 gm: "gaugemeasurement", |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
37 wx: "waterwayaxis", |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
38 wa: "waterwayarea", |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
39 fd: "fairwaydimension", |
2311
716c0eba89a2
import_schedule: fixed typo. edit waterway gauges should preselect waterway gauges
Thomas Junk <thomas.junk@intevation.de>
parents:
2295
diff
changeset
|
40 wg: "waterwaygauges", |
2068 | 41 dmv: "distancemarksvirtual", |
42 dma: "distancemarksashore" | |
2061
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
43 }; |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
44 |
2034
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
45 const IMPORTTYPEKIND = { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
46 bottleneck: "bn", |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
47 fairwayavailability: "fa", |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
48 gaugemeasurement: "gm", |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
49 waterwayaxis: "wx", |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
50 waterwayarea: "wa", |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
51 fairwaydimension: "fd", |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
52 waterwaygauges: "wg", |
2068 | 53 distancemarksvirtual: "dmv", |
54 distancemarksashore: "dma" | |
2034
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
55 }; |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
56 |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
57 const initializeCurrentSchedule = () => { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
58 return { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
59 id: null, |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
60 importType: null, |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
61 schedule: null, |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
62 import_: null, |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
63 importSource: null, |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
64 eMailNotification: false, |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
65 scheduled: false, |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
66 easyCron: true, |
2344
a5b87a695469
client: imports: fixed cron string
Markus Kottlaender <markus@intevation.de>
parents:
2312
diff
changeset
|
67 cronString: "0 */15 * * * *", |
a5b87a695469
client: imports: fixed cron string
Markus Kottlaender <markus@intevation.de>
parents:
2312
diff
changeset
|
68 cronMode: "15minutes", |
a5b87a695469
client: imports: fixed cron string
Markus Kottlaender <markus@intevation.de>
parents:
2312
diff
changeset
|
69 minutes: 0, |
a5b87a695469
client: imports: fixed cron string
Markus Kottlaender <markus@intevation.de>
parents:
2312
diff
changeset
|
70 month: 1, |
a5b87a695469
client: imports: fixed cron string
Markus Kottlaender <markus@intevation.de>
parents:
2312
diff
changeset
|
71 hour: 0, |
a5b87a695469
client: imports: fixed cron string
Markus Kottlaender <markus@intevation.de>
parents:
2312
diff
changeset
|
72 day: 0, |
a5b87a695469
client: imports: fixed cron string
Markus Kottlaender <markus@intevation.de>
parents:
2312
diff
changeset
|
73 dayOfMonth: 1, |
2034
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
74 simple: null, |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
75 url: null, |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
76 insecure: false, |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
77 triggerActive: true, |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
78 featureType: null, |
2295
b6cd295bf75d
import_schedule: default for sort-by: 'hydro_scamin'
Thomas Junk <thomas.junk@intevation.de>
parents:
2099
diff
changeset
|
79 sortBy: "hydro_scamin", |
2034
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
80 username: "", |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
81 password: "", |
2099
1baae9d31b3d
importschedule: LOS fixed, default level=3
Thomas Junk <thomas.junk@intevation.de>
parents:
2068
diff
changeset
|
82 LOS: 3, |
2034
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
83 minWidth: null, |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
84 maxWidth: null, |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
85 depth: null, |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
86 sourceOrganization: null |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
87 }; |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
88 }; |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
89 |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
90 // initial state |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
91 const init = () => { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
92 return { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
93 schedules: [], |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
94 importScheduleDetailVisible: false, |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
95 currentSchedule: initializeCurrentSchedule() |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
96 }; |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
97 }; |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
98 |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
99 const importschedule = { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
100 init, |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
101 namespaced: true, |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
102 state: init(), |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
103 mutations: { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
104 clearCurrentSchedule: state => { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
105 state.currentSchedule = initializeCurrentSchedule(); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
106 }, |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
107 setImportScheduleDetailInvisible: state => { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
108 state.importScheduleDetailVisible = false; |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
109 }, |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
110 setImportScheduleDetailVisible: state => { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
111 state.importScheduleDetailVisible = true; |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
112 }, |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
113 setSchedules: (state, schedules) => { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
114 state.schedules = schedules; |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
115 }, |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
116 unmarshallCurrentSchedule: (state, payload) => { |
2061
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
117 const { kind, config, id } = payload; |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
118 const eMailNotification = config["send-email"]; |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
119 const { cron, url } = config; |
2034
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
120 Vue.set(state.currentSchedule, "import_", KINDIMPORTTYPE[kind]); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
121 Vue.set(state.currentSchedule, "id", id); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
122 if (cron) { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
123 Vue.set(state.currentSchedule, "scheduled", true); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
124 Vue.set(state.currentSchedule, "cronString", cron); |
2344
a5b87a695469
client: imports: fixed cron string
Markus Kottlaender <markus@intevation.de>
parents:
2312
diff
changeset
|
125 |
a5b87a695469
client: imports: fixed cron string
Markus Kottlaender <markus@intevation.de>
parents:
2312
diff
changeset
|
126 // simple weekly or monthly? |
a5b87a695469
client: imports: fixed cron string
Markus Kottlaender <markus@intevation.de>
parents:
2312
diff
changeset
|
127 if (cron === "0 0 0 * * 0") { |
a5b87a695469
client: imports: fixed cron string
Markus Kottlaender <markus@intevation.de>
parents:
2312
diff
changeset
|
128 Vue.set(state.currentSchedule, "simple", "weekly"); |
a5b87a695469
client: imports: fixed cron string
Markus Kottlaender <markus@intevation.de>
parents:
2312
diff
changeset
|
129 Vue.set(state.currentSchedule, "easyCron", true); |
a5b87a695469
client: imports: fixed cron string
Markus Kottlaender <markus@intevation.de>
parents:
2312
diff
changeset
|
130 } else if (cron === "0 0 0 1 * *") { |
a5b87a695469
client: imports: fixed cron string
Markus Kottlaender <markus@intevation.de>
parents:
2312
diff
changeset
|
131 Vue.set(state.currentSchedule, "simple", "monthly"); |
a5b87a695469
client: imports: fixed cron string
Markus Kottlaender <markus@intevation.de>
parents:
2312
diff
changeset
|
132 Vue.set(state.currentSchedule, "easyCron", true); |
a5b87a695469
client: imports: fixed cron string
Markus Kottlaender <markus@intevation.de>
parents:
2312
diff
changeset
|
133 } else { |
a5b87a695469
client: imports: fixed cron string
Markus Kottlaender <markus@intevation.de>
parents:
2312
diff
changeset
|
134 Vue.set(state.currentSchedule, "easyCron", false); |
a5b87a695469
client: imports: fixed cron string
Markus Kottlaender <markus@intevation.de>
parents:
2312
diff
changeset
|
135 } |
a5b87a695469
client: imports: fixed cron string
Markus Kottlaender <markus@intevation.de>
parents:
2312
diff
changeset
|
136 |
a5b87a695469
client: imports: fixed cron string
Markus Kottlaender <markus@intevation.de>
parents:
2312
diff
changeset
|
137 // set cronMode from cronString |
2377
fdec7a652f34
client: imports: avoid error when cron string cannot be parsed when trying to edit imports
Markus Kottlaender <markus@intevation.de>
parents:
2344
diff
changeset
|
138 Vue.set(state.currentSchedule, "cronMode", null); |
fdec7a652f34
client: imports: avoid error when cron string cannot be parsed when trying to edit imports
Markus Kottlaender <markus@intevation.de>
parents:
2344
diff
changeset
|
139 if (cron === "0 */15 * * * *") |
fdec7a652f34
client: imports: avoid error when cron string cannot be parsed when trying to edit imports
Markus Kottlaender <markus@intevation.de>
parents:
2344
diff
changeset
|
140 Vue.set(state.currentSchedule, "cronMode", "15minutes"); |
fdec7a652f34
client: imports: avoid error when cron string cannot be parsed when trying to edit imports
Markus Kottlaender <markus@intevation.de>
parents:
2344
diff
changeset
|
141 else if (/^0 \d{1,2} \* \* \* \*$/.test(cron)) |
2344
a5b87a695469
client: imports: fixed cron string
Markus Kottlaender <markus@intevation.de>
parents:
2312
diff
changeset
|
142 Vue.set(state.currentSchedule, "cronMode", "hour"); |
2377
fdec7a652f34
client: imports: avoid error when cron string cannot be parsed when trying to edit imports
Markus Kottlaender <markus@intevation.de>
parents:
2344
diff
changeset
|
143 else if (/^0 \d{1,2} \d{1,2} \* \* \*$/.test(cron)) |
2344
a5b87a695469
client: imports: fixed cron string
Markus Kottlaender <markus@intevation.de>
parents:
2312
diff
changeset
|
144 Vue.set(state.currentSchedule, "cronMode", "day"); |
2377
fdec7a652f34
client: imports: avoid error when cron string cannot be parsed when trying to edit imports
Markus Kottlaender <markus@intevation.de>
parents:
2344
diff
changeset
|
145 else if (/^0 \d{1,2} \d{1,2} \* \* \d{1}$/.test(cron)) |
2344
a5b87a695469
client: imports: fixed cron string
Markus Kottlaender <markus@intevation.de>
parents:
2312
diff
changeset
|
146 Vue.set(state.currentSchedule, "cronMode", "week"); |
2377
fdec7a652f34
client: imports: avoid error when cron string cannot be parsed when trying to edit imports
Markus Kottlaender <markus@intevation.de>
parents:
2344
diff
changeset
|
147 else if (/^0 \d{1,2} \d{1,2} \d{1,2} \* \*$/.test(cron)) |
2344
a5b87a695469
client: imports: fixed cron string
Markus Kottlaender <markus@intevation.de>
parents:
2312
diff
changeset
|
148 Vue.set(state.currentSchedule, "cronMode", "month"); |
2377
fdec7a652f34
client: imports: avoid error when cron string cannot be parsed when trying to edit imports
Markus Kottlaender <markus@intevation.de>
parents:
2344
diff
changeset
|
149 else if (/^0 \d{1,2} \d{1,2} \d{1,2} \d{1,2} \*$/.test(cron)) |
2344
a5b87a695469
client: imports: fixed cron string
Markus Kottlaender <markus@intevation.de>
parents:
2312
diff
changeset
|
150 Vue.set(state.currentSchedule, "cronMode", "year"); |
a5b87a695469
client: imports: fixed cron string
Markus Kottlaender <markus@intevation.de>
parents:
2312
diff
changeset
|
151 |
a5b87a695469
client: imports: fixed cron string
Markus Kottlaender <markus@intevation.de>
parents:
2312
diff
changeset
|
152 // set minute, hour, etc from cronString |
a5b87a695469
client: imports: fixed cron string
Markus Kottlaender <markus@intevation.de>
parents:
2312
diff
changeset
|
153 let cronConf = cron.match( |
a5b87a695469
client: imports: fixed cron string
Markus Kottlaender <markus@intevation.de>
parents:
2312
diff
changeset
|
154 /0 (\d{1,2}|\*) (\d{1,2}|\*) (\d{1,2}|\*) (\d{1,2}|\*) (\d{1}|\*)/ |
a5b87a695469
client: imports: fixed cron string
Markus Kottlaender <markus@intevation.de>
parents:
2312
diff
changeset
|
155 ); |
2377
fdec7a652f34
client: imports: avoid error when cron string cannot be parsed when trying to edit imports
Markus Kottlaender <markus@intevation.de>
parents:
2344
diff
changeset
|
156 |
fdec7a652f34
client: imports: avoid error when cron string cannot be parsed when trying to edit imports
Markus Kottlaender <markus@intevation.de>
parents:
2344
diff
changeset
|
157 // if cronString could not be parsed/matched (cronConf is null), |
fdec7a652f34
client: imports: avoid error when cron string cannot be parsed when trying to edit imports
Markus Kottlaender <markus@intevation.de>
parents:
2344
diff
changeset
|
158 // skip prefilling those values |
fdec7a652f34
client: imports: avoid error when cron string cannot be parsed when trying to edit imports
Markus Kottlaender <markus@intevation.de>
parents:
2344
diff
changeset
|
159 if (cronConf) { |
fdec7a652f34
client: imports: avoid error when cron string cannot be parsed when trying to edit imports
Markus Kottlaender <markus@intevation.de>
parents:
2344
diff
changeset
|
160 // remove first element which is the whole matched string |
fdec7a652f34
client: imports: avoid error when cron string cannot be parsed when trying to edit imports
Markus Kottlaender <markus@intevation.de>
parents:
2344
diff
changeset
|
161 cronConf.shift(); |
fdec7a652f34
client: imports: avoid error when cron string cannot be parsed when trying to edit imports
Markus Kottlaender <markus@intevation.de>
parents:
2344
diff
changeset
|
162 cronConf = cronConf.map(field => |
fdec7a652f34
client: imports: avoid error when cron string cannot be parsed when trying to edit imports
Markus Kottlaender <markus@intevation.de>
parents:
2344
diff
changeset
|
163 field === "*" ? null : Number(field) |
fdec7a652f34
client: imports: avoid error when cron string cannot be parsed when trying to edit imports
Markus Kottlaender <markus@intevation.de>
parents:
2344
diff
changeset
|
164 ); |
fdec7a652f34
client: imports: avoid error when cron string cannot be parsed when trying to edit imports
Markus Kottlaender <markus@intevation.de>
parents:
2344
diff
changeset
|
165 Vue.set(state.currentSchedule, "minutes", cronConf[0]); |
fdec7a652f34
client: imports: avoid error when cron string cannot be parsed when trying to edit imports
Markus Kottlaender <markus@intevation.de>
parents:
2344
diff
changeset
|
166 Vue.set(state.currentSchedule, "hour", cronConf[1]); |
fdec7a652f34
client: imports: avoid error when cron string cannot be parsed when trying to edit imports
Markus Kottlaender <markus@intevation.de>
parents:
2344
diff
changeset
|
167 Vue.set(state.currentSchedule, "dayOfMonth", cronConf[2]); |
fdec7a652f34
client: imports: avoid error when cron string cannot be parsed when trying to edit imports
Markus Kottlaender <markus@intevation.de>
parents:
2344
diff
changeset
|
168 Vue.set(state.currentSchedule, "month", cronConf[3]); |
fdec7a652f34
client: imports: avoid error when cron string cannot be parsed when trying to edit imports
Markus Kottlaender <markus@intevation.de>
parents:
2344
diff
changeset
|
169 Vue.set(state.currentSchedule, "day", cronConf[4]); |
fdec7a652f34
client: imports: avoid error when cron string cannot be parsed when trying to edit imports
Markus Kottlaender <markus@intevation.de>
parents:
2344
diff
changeset
|
170 } |
2034
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
171 } |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
172 if (eMailNotification) { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
173 Vue.set(state.currentSchedule, "eMailNotification", eMailNotification); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
174 } |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
175 if (url) { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
176 Vue.set(state.currentSchedule, "url", url); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
177 } |
2312
b87211f595ae
import-schedule: fix edit waterway gauge import. transmitting cedentials correctly
Thomas Junk <thomas.junk@intevation.de>
parents:
2311
diff
changeset
|
178 let { insecure, user, password, los, depth } = config; |
2061
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
179 let sortBy = config["sort-by"]; |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
180 let minWidth = config["min-width"]; |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
181 let maxWidth = config["max-width"]; |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
182 let sourceOrganization = config["source-organization"]; |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
183 const featureType = config["feature-type"]; |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
184 insecure = insecure == "true"; |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
185 if (insecure) { |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
186 Vue.set(state.currentSchedule, "insecure", insecure); |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
187 } |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
188 if (featureType) { |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
189 Vue.set(state.currentSchedule, "featureType", featureType); |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
190 } |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
191 if (sortBy) { |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
192 Vue.set(state.currentSchedule, "sortBy", sortBy); |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
193 } |
2312
b87211f595ae
import-schedule: fix edit waterway gauge import. transmitting cedentials correctly
Thomas Junk <thomas.junk@intevation.de>
parents:
2311
diff
changeset
|
194 if (user) { |
b87211f595ae
import-schedule: fix edit waterway gauge import. transmitting cedentials correctly
Thomas Junk <thomas.junk@intevation.de>
parents:
2311
diff
changeset
|
195 Vue.set(state.currentSchedule, "username", user); |
2061
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
196 } |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
197 if (password) { |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
198 Vue.set(state.currentSchedule, "password", password); |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
199 } |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
200 if (los) { |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
201 Vue.set(state.currentSchedule, "LOS", los); |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
202 } |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
203 if (minWidth) { |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
204 Vue.set(state.currentSchedule, "minWidth", minWidth); |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
205 } |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
206 if (maxWidth) { |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
207 Vue.set(state.currentSchedule, "maxWidth", maxWidth); |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
208 } |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
209 if (depth) { |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
210 Vue.set(state.currentSchedule, "depth", depth); |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
211 } |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
212 if (sourceOrganization) { |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
213 Vue.set( |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
214 state.currentSchedule, |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
215 "sourceOrganization", |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
216 sourceOrganization |
4a0d4e50768d
frontend adapted to new backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2034
diff
changeset
|
217 ); |
2034
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
218 } |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
219 } |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
220 }, |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
221 actions: { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
222 loadSchedule({ commit }, id) { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
223 return new Promise((resolve, reject) => { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
224 HTTP.get("/imports/config/" + id, { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
225 headers: { "X-Gemma-Auth": localStorage.getItem("token") } |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
226 }) |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
227 .then(response => { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
228 commit("unmarshallCurrentSchedule", response.data); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
229 resolve(response); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
230 }) |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
231 .catch(error => { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
232 reject(error); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
233 }); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
234 }); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
235 }, |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
236 updateCurrentSchedule({ commit }, payload) { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
237 const { data, id } = payload; |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
238 return new Promise((resolve, reject) => { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
239 HTTP.patch("imports/config/" + id, data, { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
240 headers: { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
241 "X-Gemma-Auth": localStorage.getItem("token") |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
242 } |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
243 }) |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
244 .then(response => { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
245 resolve(response); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
246 }) |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
247 .catch(error => { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
248 reject(error); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
249 }); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
250 }); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
251 }, |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
252 saveCurrentSchedule({ commit }, data) { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
253 return new Promise((resolve, reject) => { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
254 HTTP.post("imports/config", data, { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
255 headers: { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
256 "X-Gemma-Auth": localStorage.getItem("token") |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
257 } |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
258 }) |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
259 .then(response => { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
260 resolve(response); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
261 }) |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
262 .catch(error => { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
263 reject(error); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
264 }); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
265 }); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
266 }, |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
267 loadSchedules({ commit }) { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
268 return new Promise((resolve, reject) => { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
269 HTTP.get("/imports/config", { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
270 headers: { "X-Gemma-Auth": localStorage.getItem("token") } |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
271 }) |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
272 .then(response => { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
273 commit("setSchedules", response.data); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
274 resolve(response); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
275 }) |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
276 .catch(error => { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
277 reject(error); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
278 }); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
279 }); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
280 }, |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
281 deleteSchedule({ commit }, id) { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
282 return new Promise((resolve, reject) => { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
283 HTTP.delete("imports/config/" + id, { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
284 headers: { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
285 "X-Gemma-Auth": localStorage.getItem("token") |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
286 } |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
287 }) |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
288 .then(response => { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
289 resolve(response); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
290 }) |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
291 .catch(error => { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
292 reject(error); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
293 }); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
294 }); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
295 }, |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
296 triggerImport({ commit }, { type, data }) { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
297 return new Promise((resolve, reject) => { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
298 HTTP.post("imports/" + type, data, { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
299 headers: { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
300 "X-Gemma-Auth": localStorage.getItem("token") |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
301 } |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
302 }) |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
303 .then(response => { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
304 resolve(response); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
305 }) |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
306 .catch(error => { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
307 reject(error); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
308 }); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
309 }); |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
310 } |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
311 } |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
312 }; |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
313 |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
314 export { |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
315 importschedule, |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
316 initializeCurrentSchedule, |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
317 IMPORTTYPES, |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
318 IMPORTTYPEKIND |
cc3ad4aa9b2f
importschedule: add store
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
319 }; |