annotate client/src/store/imports.js @ 2732:0ab7985ef008

import_review: fixed flakey display of logs
author Thomas Junk <thomas.junk@intevation.de>
date Tue, 19 Mar 2019 14:50:56 +0100
parents 501967471981
children 4ae3453fcf50
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1362
ca33ad696594 remove the first empyty lines
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1311
diff changeset
1 /* This is Free Software under GNU Affero General Public License v >= 3.0
1142
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
2 * without warranty, see README.md and license for details.
1173
3035ddd3d1a8 feat: importqueue
Thomas Junk <thomas.junk@intevation.de>
parents: 1142
diff changeset
3 *
1142
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
4 * SPDX-License-Identifier: AGPL-3.0-or-later
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
5 * License-Filename: LICENSES/AGPL-3.0.txt
1173
3035ddd3d1a8 feat: importqueue
Thomas Junk <thomas.junk@intevation.de>
parents: 1142
diff changeset
6 *
3035ddd3d1a8 feat: importqueue
Thomas Junk <thomas.junk@intevation.de>
parents: 1142
diff changeset
7 * Copyright (C) 2018 by via donau
1142
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
8 * – Österreichische Wasserstraßen-Gesellschaft mbH
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
9 * Software engineering by Intevation GmbH
1173
3035ddd3d1a8 feat: importqueue
Thomas Junk <thomas.junk@intevation.de>
parents: 1142
diff changeset
10 *
1142
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
11 * Author(s):
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
12 * Thomas Junk <thomas.junk@intevation.de>
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
13 */
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
14
1725
b24a54c684bd importschedule: UI improvements
Thomas Junk <thomas.junk@intevation.de>
parents: 1724
diff changeset
15 import { HTTP } from "@/lib/http";
1942
d1b7b1c70410 import stretch: listview with edit-function
Thomas Junk <thomas.junk@intevation.de>
parents: 1930
diff changeset
16 import { WFS } from "ol/format.js";
1980
c8e2f6838eaf define stretches: mark stretches in review
Thomas Junk <thomas.junk@intevation.de>
parents: 1946
diff changeset
17 import { equalTo as equalToFilter } from "ol/format/filter.js";
1142
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
18
1311
d5eda9f79610 staging: display visual feedback for now due missing backendcall
Thomas Junk <thomas.junk@intevation.de>
parents: 1310
diff changeset
19 /* eslint-disable no-unused-vars */
d5eda9f79610 staging: display visual feedback for now due missing backendcall
Thomas Junk <thomas.junk@intevation.de>
parents: 1310
diff changeset
20 /* eslint-disable no-unreachable */
d5eda9f79610 staging: display visual feedback for now due missing backendcall
Thomas Junk <thomas.junk@intevation.de>
parents: 1310
diff changeset
21 const STATES = {
1468
5e1218b5a123 proof of concept
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
22 NEEDSAPPROVAL: "pending",
5e1218b5a123 proof of concept
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
23 APPROVED: "accepted",
1475
2365acde39dc Staging area: Dealing with backend response.
Thomas Junk <thomas.junk@intevation.de>
parents: 1470
diff changeset
24 REJECTED: "declined"
1311
d5eda9f79610 staging: display visual feedback for now due missing backendcall
Thomas Junk <thomas.junk@intevation.de>
parents: 1310
diff changeset
25 };
d5eda9f79610 staging: display visual feedback for now due missing backendcall
Thomas Junk <thomas.junk@intevation.de>
parents: 1310
diff changeset
26
2578
3ad81357a57c overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2447
diff changeset
27 const NODETAILS = -1;
3ad81357a57c overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2447
diff changeset
28
1296
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
29 // initial state
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
30 const init = () => {
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
31 return {
2654
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
32 failed: false,
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
33 pending: false,
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
34 accepted: false,
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
35 declined: false,
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
36 warning: false,
1889
b6d0460b069d define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1867
diff changeset
37 stretches: [],
1310
d675e6439aa5 staging view: prepare retrieving list of pending imports for staging
Thomas Junk <thomas.junk@intevation.de>
parents: 1296
diff changeset
38 imports: [],
2600
6e6709bab5c4 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2594
diff changeset
39 reviewed: [],
2578
3ad81357a57c overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2447
diff changeset
40 show: NODETAILS,
3ad81357a57c overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2447
diff changeset
41 showAdditional: NODETAILS,
2732
0ab7985ef008 import_review: fixed flakey display of logs
Thomas Junk <thomas.junk@intevation.de>
parents: 2655
diff changeset
42 showLogs: NODETAILS,
0ab7985ef008 import_review: fixed flakey display of logs
Thomas Junk <thomas.junk@intevation.de>
parents: 2655
diff changeset
43 details: null
1429
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
44 };
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
45 };
f4b3fb43b311 automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents: 1365
diff changeset
46
2107
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
47 const getStretchFromWFS = filter => {
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
48 return new Promise((resolve, reject) => {
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
49 var stretchesFeatureCollectionRequest = new WFS().writeGetFeature({
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
50 srsName: "EPSG:4326",
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
51 featureNS: "gemma",
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
52 featurePrefix: "gemma",
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
53 featureTypes: ["stretches_geoserver"],
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
54 outputFormat: "application/json",
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
55 filter: filter
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
56 });
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
57 HTTP.post(
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
58 "/internal/wfs",
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
59 new XMLSerializer().serializeToString(stretchesFeatureCollectionRequest),
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
60 {
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
61 headers: {
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
62 "X-Gemma-Auth": localStorage.getItem("token"),
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
63 "Content-type": "text/xml; charset=UTF-8"
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
64 }
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
65 }
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
66 )
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
67 .then(response => {
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
68 resolve(response);
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
69 })
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
70 .catch(error => {
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
71 reject(error);
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
72 });
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
73 });
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
74 };
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
75
2654
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
76 const clearFilterCriteria = state => {
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
77 state.warning = false;
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
78 state.successful = false;
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
79 state.failed = false;
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
80 state.pending = false;
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
81 state.accepted = false;
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
82 state.declined = false;
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
83 };
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
84
1344
eda98694e678 staging: retrieve real data instead of displaying demodata
Thomas Junk <thomas.junk@intevation.de>
parents: 1311
diff changeset
85 const imports = {
1296
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
86 init,
1142
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
87 namespaced: true,
1296
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
88 state: init(),
2654
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
89 getters: {
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
90 filters: state => {
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
91 return ["failed", "pending", "accepted", "declined", "warning"].filter(
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
92 x => state[x]
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
93 );
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
94 }
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
95 },
1142
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
96 mutations: {
2732
0ab7985ef008 import_review: fixed flakey display of logs
Thomas Junk <thomas.junk@intevation.de>
parents: 2655
diff changeset
97 setCurrentDetails: (state, details) => {
0ab7985ef008 import_review: fixed flakey display of logs
Thomas Junk <thomas.junk@intevation.de>
parents: 2655
diff changeset
98 state.details = details;
0ab7985ef008 import_review: fixed flakey display of logs
Thomas Junk <thomas.junk@intevation.de>
parents: 2655
diff changeset
99 },
2654
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
100 toggleFilter: (state, name) => {
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
101 state[name] = !state[name];
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
102 const allSet =
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
103 state.failed &&
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
104 state.pending &&
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
105 state.accepted &&
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
106 state.declined &&
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
107 state.warning;
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
108 if (allSet) {
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
109 clearFilterCriteria(state);
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
110 }
2578
3ad81357a57c overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2447
diff changeset
111 },
3ad81357a57c overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2447
diff changeset
112 clearFilters: state => {
2654
3c04c8e46bd4 importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents: 2651
diff changeset
113 clearFilterCriteria(state);
2578
3ad81357a57c overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2447
diff changeset
114 },
1889
b6d0460b069d define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1867
diff changeset
115 setStretches: (state, stretches) => {
b6d0460b069d define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1867
diff changeset
116 state.stretches = stretches;
b6d0460b069d define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1867
diff changeset
117 },
2638
6c1730fc3dc1 client: importsoverview2: clear reviewed array after finishing review
Markus Kottlaender <markus@intevation.de>
parents: 2615
diff changeset
118 setReviewed: (state, reviewed) => {
6c1730fc3dc1 client: importsoverview2: clear reviewed array after finishing review
Markus Kottlaender <markus@intevation.de>
parents: 2615
diff changeset
119 state.reviewed = reviewed;
6c1730fc3dc1 client: importsoverview2: clear reviewed array after finishing review
Markus Kottlaender <markus@intevation.de>
parents: 2615
diff changeset
120 },
1142
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
121 setImports: (state, imports) => {
2600
6e6709bab5c4 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2594
diff changeset
122 const lookUp = state.reviewed.reduce((o, n) => {
6e6709bab5c4 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2594
diff changeset
123 const { id, status } = n;
6e6709bab5c4 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2594
diff changeset
124 o[id] = status;
6e6709bab5c4 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2594
diff changeset
125 return o;
6e6709bab5c4 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2594
diff changeset
126 }, {});
2578
3ad81357a57c overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2447
diff changeset
127 imports = imports.map(x => {
2600
6e6709bab5c4 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2594
diff changeset
128 if (x.state === "pending") {
6e6709bab5c4 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2594
diff changeset
129 const reviewState = lookUp[x.id];
6e6709bab5c4 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2594
diff changeset
130 if (reviewState) {
6e6709bab5c4 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2594
diff changeset
131 x.status = reviewState;
6e6709bab5c4 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2594
diff changeset
132 } else {
6e6709bab5c4 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2594
diff changeset
133 x.status = STATES.NEEDSAPPROVAL;
6e6709bab5c4 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2594
diff changeset
134 }
6e6709bab5c4 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2594
diff changeset
135 }
2578
3ad81357a57c overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2447
diff changeset
136 return x;
3ad81357a57c overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2447
diff changeset
137 });
1173
3035ddd3d1a8 feat: importqueue
Thomas Junk <thomas.junk@intevation.de>
parents: 1142
diff changeset
138 state.imports = imports;
1310
d675e6439aa5 staging view: prepare retrieving list of pending imports for staging
Thomas Junk <thomas.junk@intevation.de>
parents: 1296
diff changeset
139 },
2592
5472a5be09c2 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2578
diff changeset
140 showDetailsFor: (state, id) => {
5472a5be09c2 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2578
diff changeset
141 state.show = id;
5472a5be09c2 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2578
diff changeset
142 },
5472a5be09c2 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2578
diff changeset
143 hideDetails: state => {
5472a5be09c2 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2578
diff changeset
144 state.show = NODETAILS;
5472a5be09c2 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2578
diff changeset
145 },
2594
ecec6d5aae00 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2592
diff changeset
146 showAdditionalInfoFor: (state, id) => {
ecec6d5aae00 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2592
diff changeset
147 state.showAdditional = id;
ecec6d5aae00 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2592
diff changeset
148 },
ecec6d5aae00 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2592
diff changeset
149 hideAdditionalInfo: state => {
ecec6d5aae00 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2592
diff changeset
150 state.showAdditional = NODETAILS;
ecec6d5aae00 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2592
diff changeset
151 },
ecec6d5aae00 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2592
diff changeset
152 showAdditionalLogsFor: (state, id) => {
ecec6d5aae00 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2592
diff changeset
153 state.showLogs = id;
ecec6d5aae00 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2592
diff changeset
154 },
ecec6d5aae00 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2592
diff changeset
155 hideAdditionalLogs: state => {
ecec6d5aae00 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2592
diff changeset
156 state.showLogs = NODETAILS;
ecec6d5aae00 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2592
diff changeset
157 },
2592
5472a5be09c2 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2578
diff changeset
158 toggleApprove: (state, change) => {
5472a5be09c2 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2578
diff changeset
159 const { id, newStatus } = change;
5472a5be09c2 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2578
diff changeset
160 const stagedResult = state.imports.find(e => {
5472a5be09c2 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2578
diff changeset
161 return e.id === id;
5472a5be09c2 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2578
diff changeset
162 });
5472a5be09c2 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2578
diff changeset
163 if (stagedResult.status === newStatus) {
5472a5be09c2 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2578
diff changeset
164 stagedResult.status = STATES.NEEDSAPPROVAL;
2600
6e6709bab5c4 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2594
diff changeset
165 state.reviewed = state.reviewed.filter(x => x.id !== stagedResult.id);
2592
5472a5be09c2 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2578
diff changeset
166 } else {
5472a5be09c2 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2578
diff changeset
167 stagedResult.status = newStatus;
2615
7025d082c115 client: importoverview2: fixed counter in commit button
Markus Kottlaender <markus@intevation.de>
parents: 2608
diff changeset
168 let index = state.reviewed.findIndex(r => r.id === id);
7025d082c115 client: importoverview2: fixed counter in commit button
Markus Kottlaender <markus@intevation.de>
parents: 2608
diff changeset
169 if (index !== -1) {
7025d082c115 client: importoverview2: fixed counter in commit button
Markus Kottlaender <markus@intevation.de>
parents: 2608
diff changeset
170 state.reviewed[index].status = newStatus;
7025d082c115 client: importoverview2: fixed counter in commit button
Markus Kottlaender <markus@intevation.de>
parents: 2608
diff changeset
171 } else {
7025d082c115 client: importoverview2: fixed counter in commit button
Markus Kottlaender <markus@intevation.de>
parents: 2608
diff changeset
172 state.reviewed.push({ id: stagedResult.id, status: newStatus });
7025d082c115 client: importoverview2: fixed counter in commit button
Markus Kottlaender <markus@intevation.de>
parents: 2608
diff changeset
173 }
2592
5472a5be09c2 overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2578
diff changeset
174 }
1142
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
175 }
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
176 },
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
177 actions: {
2107
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
178 loadStretch({ commit }, name) {
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
179 return new Promise((resolve, reject) => {
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
180 getStretchFromWFS(equalToFilter("name", name))
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
181 .then(response => {
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
182 resolve(response);
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
183 })
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
184 .catch(error => {
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
185 reject(error);
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
186 });
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
187 });
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
188 },
1889
b6d0460b069d define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1867
diff changeset
189 loadStretches({ commit }) {
b6d0460b069d define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1867
diff changeset
190 return new Promise((resolve, reject) => {
2107
6747a4cf3639 staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2095
diff changeset
191 getStretchFromWFS(equalToFilter("staging_done", true))
1889
b6d0460b069d define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1867
diff changeset
192 .then(response => {
1945
f64bc12c1719 import stretches: minor fix
Thomas Junk <thomas.junk@intevation.de>
parents: 1942
diff changeset
193 if (response.data.features) {
f64bc12c1719 import stretches: minor fix
Thomas Junk <thomas.junk@intevation.de>
parents: 1942
diff changeset
194 commit("setStretches", response.data.features);
f64bc12c1719 import stretches: minor fix
Thomas Junk <thomas.junk@intevation.de>
parents: 1942
diff changeset
195 } else {
f64bc12c1719 import stretches: minor fix
Thomas Junk <thomas.junk@intevation.de>
parents: 1942
diff changeset
196 commit("setStretches", []);
f64bc12c1719 import stretches: minor fix
Thomas Junk <thomas.junk@intevation.de>
parents: 1942
diff changeset
197 }
1889
b6d0460b069d define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1867
diff changeset
198 resolve(response);
b6d0460b069d define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1867
diff changeset
199 })
b6d0460b069d define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1867
diff changeset
200 .catch(error => {
b6d0460b069d define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1867
diff changeset
201 reject(error);
b6d0460b069d define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1867
diff changeset
202 });
b6d0460b069d define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1867
diff changeset
203 });
b6d0460b069d define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1867
diff changeset
204 },
b6d0460b069d define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1867
diff changeset
205 saveStretch({ commit }, stretch) {
b6d0460b069d define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1867
diff changeset
206 return new Promise((resolve, reject) => {
2095
98f0c7956128 Fixed api url used in front end for stretches.
Sascha Wilde <wilde@intevation.de>
parents: 2033
diff changeset
207 HTTP.post("/imports/st", stretch, {
1889
b6d0460b069d define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1867
diff changeset
208 headers: { "X-Gemma-Auth": localStorage.getItem("token") }
b6d0460b069d define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1867
diff changeset
209 })
b6d0460b069d define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1867
diff changeset
210 .then(response => {
b6d0460b069d define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1867
diff changeset
211 resolve(response);
b6d0460b069d define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1867
diff changeset
212 })
b6d0460b069d define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1867
diff changeset
213 .catch(error => {
b6d0460b069d define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1867
diff changeset
214 reject(error);
b6d0460b069d define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1867
diff changeset
215 });
b6d0460b069d define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1867
diff changeset
216 });
b6d0460b069d define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents: 1867
diff changeset
217 },
2415
Thomas Junk <thomas.junk@intevation.de>
parents: 2402
diff changeset
218 getImports({ commit }, filter) {
Thomas Junk <thomas.junk@intevation.de>
parents: 2402
diff changeset
219 let queryParams = "";
2655
501967471981 overview: warning filter implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2654
diff changeset
220 const hasWarning = filter.includes("warning");
501967471981 overview: warning filter implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2654
diff changeset
221 filter = filter.filter(x => x != "warning");
501967471981 overview: warning filter implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2654
diff changeset
222 if (filter && filter.length > 0) {
2447
522024fa06eb staging: filter logs on server
Thomas Junk <thomas.junk@intevation.de>
parents: 2415
diff changeset
223 queryParams = "?states=" + filter.join(",");
2655
501967471981 overview: warning filter implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2654
diff changeset
224 if (hasWarning) queryParams += "&warnings=true";
501967471981 overview: warning filter implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2654
diff changeset
225 } else {
501967471981 overview: warning filter implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2654
diff changeset
226 if (hasWarning) queryParams += "?warnings=true";
501967471981 overview: warning filter implemented
Thomas Junk <thomas.junk@intevation.de>
parents: 2654
diff changeset
227 }
1142
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
228 return new Promise((resolve, reject) => {
2415
Thomas Junk <thomas.junk@intevation.de>
parents: 2402
diff changeset
229 HTTP.get("/imports" + queryParams, {
1142
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
230 headers: { "X-Gemma-Auth": localStorage.getItem("token") }
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
231 })
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
232 .then(response => {
2578
3ad81357a57c overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2447
diff changeset
233 const { imports } = response.data;
3ad81357a57c overview2 WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2447
diff changeset
234 commit("setImports", imports);
1142
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
235 resolve(response);
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
236 })
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
237 .catch(error => {
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
238 reject(error);
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
239 });
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
240 });
1310
d675e6439aa5 staging view: prepare retrieving list of pending imports for staging
Thomas Junk <thomas.junk@intevation.de>
parents: 1296
diff changeset
241 },
2402
Thomas Junk <thomas.junk@intevation.de>
parents: 2399
diff changeset
242 confirmReview({ state }, reviewResults) {
2399
Thomas Junk <thomas.junk@intevation.de>
parents: 2107
diff changeset
243 return new Promise((resolve, reject) => {
Thomas Junk <thomas.junk@intevation.de>
parents: 2107
diff changeset
244 HTTP.patch("/imports", reviewResults, {
Thomas Junk <thomas.junk@intevation.de>
parents: 2107
diff changeset
245 headers: {
Thomas Junk <thomas.junk@intevation.de>
parents: 2107
diff changeset
246 "X-Gemma-Auth": localStorage.getItem("token"),
Thomas Junk <thomas.junk@intevation.de>
parents: 2107
diff changeset
247 "Content-type": "application/json"
Thomas Junk <thomas.junk@intevation.de>
parents: 2107
diff changeset
248 }
Thomas Junk <thomas.junk@intevation.de>
parents: 2107
diff changeset
249 })
Thomas Junk <thomas.junk@intevation.de>
parents: 2107
diff changeset
250 .then(response => {
Thomas Junk <thomas.junk@intevation.de>
parents: 2107
diff changeset
251 resolve(response);
Thomas Junk <thomas.junk@intevation.de>
parents: 2107
diff changeset
252 })
Thomas Junk <thomas.junk@intevation.de>
parents: 2107
diff changeset
253 .catch(error => {
Thomas Junk <thomas.junk@intevation.de>
parents: 2107
diff changeset
254 reject(error);
Thomas Junk <thomas.junk@intevation.de>
parents: 2107
diff changeset
255 });
Thomas Junk <thomas.junk@intevation.de>
parents: 2107
diff changeset
256 });
1142
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
257 }
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
258 }
dc3f0277628a feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
259 };
1344
eda98694e678 staging: retrieve real data instead of displaying demodata
Thomas Junk <thomas.junk@intevation.de>
parents: 1311
diff changeset
260
2033
431f97fd873b importschedule: extracted to separate store
Thomas Junk <thomas.junk@intevation.de>
parents: 1996
diff changeset
261 export { imports, STATES };