Mercurial > gemma
annotate client/src/store/imports.js @ 2909:5105f6ad0176
client: stretches: fixed highlighting of selected stretch
The vectorloader for each layer can now take a callback to postprocess the returned features.
For the stretches layer the selectedStretch (which is now stored in the vuex store) now gets
a 'highlighted' flag. The layer respects that flag to alter the styles.
A watcher on selectedStretch resets the styles when selectedStretch changes and sets the highlighted
flag for the new selectedStretch, if present, otherwise the vectorloader does this job.
author | Markus Kottlaender <markus@intevation.de> |
---|---|
date | Tue, 02 Apr 2019 18:19:43 +0200 |
parents | c40540889b53 |
children | c8c7122047a2 |
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 | 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 | 6 * |
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 | 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"; |
2789
c1e832f77726
import_overview: setting a sane default window in case of reload
Thomas Junk <thomas.junk@intevation.de>
parents:
2759
diff
changeset
|
18 import { startOfHour, endOfHour } from "date-fns"; |
1142
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
19 |
1311
d5eda9f79610
staging: display visual feedback for now due missing backendcall
Thomas Junk <thomas.junk@intevation.de>
parents:
1310
diff
changeset
|
20 const STATES = { |
1468 | 21 NEEDSAPPROVAL: "pending", |
22 APPROVED: "accepted", | |
1475
2365acde39dc
Staging area: Dealing with backend response.
Thomas Junk <thomas.junk@intevation.de>
parents:
1470
diff
changeset
|
23 REJECTED: "declined" |
1311
d5eda9f79610
staging: display visual feedback for now due missing backendcall
Thomas Junk <thomas.junk@intevation.de>
parents:
1310
diff
changeset
|
24 }; |
d5eda9f79610
staging: display visual feedback for now due missing backendcall
Thomas Junk <thomas.junk@intevation.de>
parents:
1310
diff
changeset
|
25 |
1296
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
26 // initial state |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
27 const init = () => { |
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
28 return { |
2654
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
29 failed: false, |
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
30 pending: false, |
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
31 accepted: false, |
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
32 declined: false, |
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
33 warning: false, |
1889
b6d0460b069d
define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1867
diff
changeset
|
34 stretches: [], |
2909
5105f6ad0176
client: stretches: fixed highlighting of selected stretch
Markus Kottlaender <markus@intevation.de>
parents:
2880
diff
changeset
|
35 selectedStretch: null, |
1310
d675e6439aa5
staging view: prepare retrieving list of pending imports for staging
Thomas Junk <thomas.junk@intevation.de>
parents:
1296
diff
changeset
|
36 imports: [], |
2600 | 37 reviewed: [], |
2880
c40540889b53
client: code cleanup, slight style improvements
Markus Kottlaender <markus@intevation.de>
parents:
2789
diff
changeset
|
38 show: null, |
c40540889b53
client: code cleanup, slight style improvements
Markus Kottlaender <markus@intevation.de>
parents:
2789
diff
changeset
|
39 showAdditional: null, |
c40540889b53
client: code cleanup, slight style improvements
Markus Kottlaender <markus@intevation.de>
parents:
2789
diff
changeset
|
40 showLogs: null, |
2753
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2749
diff
changeset
|
41 details: [], |
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2749
diff
changeset
|
42 startDate: startOfHour(new Date()), |
2789
c1e832f77726
import_overview: setting a sane default window in case of reload
Thomas Junk <thomas.junk@intevation.de>
parents:
2759
diff
changeset
|
43 endDate: endOfHour(new Date()), |
2759
7badd99c9315
import_overview: sprinkled fairydust into the app to make magical timewarp possible for log_overview
Thomas Junk <thomas.junk@intevation.de>
parents:
2753
diff
changeset
|
44 prev: null, |
7badd99c9315
import_overview: sprinkled fairydust into the app to make magical timewarp possible for log_overview
Thomas Junk <thomas.junk@intevation.de>
parents:
2753
diff
changeset
|
45 next: null |
1429
f4b3fb43b311
automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents:
1365
diff
changeset
|
46 }; |
f4b3fb43b311
automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents:
1365
diff
changeset
|
47 }; |
f4b3fb43b311
automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents:
1365
diff
changeset
|
48 |
2107
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
49 const getStretchFromWFS = filter => { |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
50 return new Promise((resolve, reject) => { |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
51 var stretchesFeatureCollectionRequest = new WFS().writeGetFeature({ |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
52 srsName: "EPSG:4326", |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
53 featureNS: "gemma", |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
54 featurePrefix: "gemma", |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
55 featureTypes: ["stretches_geoserver"], |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
56 outputFormat: "application/json", |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
57 filter: filter |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
58 }); |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
59 HTTP.post( |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
60 "/internal/wfs", |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
61 new XMLSerializer().serializeToString(stretchesFeatureCollectionRequest), |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
62 { |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
63 headers: { |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
64 "X-Gemma-Auth": localStorage.getItem("token"), |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
65 "Content-type": "text/xml; charset=UTF-8" |
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 } |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
68 ) |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
69 .then(response => { |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
70 resolve(response); |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
71 }) |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
72 .catch(error => { |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
73 reject(error); |
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 }); |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
76 }; |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
77 |
2654
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
78 const clearFilterCriteria = state => { |
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
79 state.warning = false; |
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
80 state.successful = false; |
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
81 state.failed = false; |
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
82 state.pending = false; |
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
83 state.accepted = false; |
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
84 state.declined = false; |
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
85 }; |
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
86 |
1344
eda98694e678
staging: retrieve real data instead of displaying demodata
Thomas Junk <thomas.junk@intevation.de>
parents:
1311
diff
changeset
|
87 const imports = { |
1296
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
88 init, |
1142
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
89 namespaced: true, |
1296
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1272
diff
changeset
|
90 state: init(), |
2654
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
91 getters: { |
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
92 filters: state => { |
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
93 return ["failed", "pending", "accepted", "declined", "warning"].filter( |
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
94 x => state[x] |
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
95 ); |
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
96 } |
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
97 }, |
1142
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
98 mutations: { |
2759
7badd99c9315
import_overview: sprinkled fairydust into the app to make magical timewarp possible for log_overview
Thomas Junk <thomas.junk@intevation.de>
parents:
2753
diff
changeset
|
99 setPrev: (state, prev) => { |
7badd99c9315
import_overview: sprinkled fairydust into the app to make magical timewarp possible for log_overview
Thomas Junk <thomas.junk@intevation.de>
parents:
2753
diff
changeset
|
100 state.prev = prev; |
7badd99c9315
import_overview: sprinkled fairydust into the app to make magical timewarp possible for log_overview
Thomas Junk <thomas.junk@intevation.de>
parents:
2753
diff
changeset
|
101 }, |
7badd99c9315
import_overview: sprinkled fairydust into the app to make magical timewarp possible for log_overview
Thomas Junk <thomas.junk@intevation.de>
parents:
2753
diff
changeset
|
102 setNext: (state, next) => { |
7badd99c9315
import_overview: sprinkled fairydust into the app to make magical timewarp possible for log_overview
Thomas Junk <thomas.junk@intevation.de>
parents:
2753
diff
changeset
|
103 state.next = next; |
7badd99c9315
import_overview: sprinkled fairydust into the app to make magical timewarp possible for log_overview
Thomas Junk <thomas.junk@intevation.de>
parents:
2753
diff
changeset
|
104 }, |
2753
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2749
diff
changeset
|
105 setStartDate: (state, start) => { |
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2749
diff
changeset
|
106 state.startDate = start; |
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2749
diff
changeset
|
107 }, |
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2749
diff
changeset
|
108 setEndDate: (state, end) => { |
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2749
diff
changeset
|
109 state.endDate = end; |
2aa1620ffd9e
search: in context of importoverview pressing enter triggers a request for and updated dataset
Thomas Junk <thomas.junk@intevation.de>
parents:
2749
diff
changeset
|
110 }, |
2732
0ab7985ef008
import_review: fixed flakey display of logs
Thomas Junk <thomas.junk@intevation.de>
parents:
2655
diff
changeset
|
111 setCurrentDetails: (state, details) => { |
0ab7985ef008
import_review: fixed flakey display of logs
Thomas Junk <thomas.junk@intevation.de>
parents:
2655
diff
changeset
|
112 state.details = details; |
0ab7985ef008
import_review: fixed flakey display of logs
Thomas Junk <thomas.junk@intevation.de>
parents:
2655
diff
changeset
|
113 }, |
2654
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
114 toggleFilter: (state, name) => { |
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
115 state[name] = !state[name]; |
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
116 const allSet = |
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
117 state.failed && |
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
118 state.pending && |
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
119 state.accepted && |
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
120 state.declined && |
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
121 state.warning; |
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
122 if (allSet) { |
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
123 clearFilterCriteria(state); |
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
124 } |
2578 | 125 }, |
126 clearFilters: state => { | |
2654
3c04c8e46bd4
importoverview: reload reloads current selection
Thomas Junk <thomas.junk@intevation.de>
parents:
2651
diff
changeset
|
127 clearFilterCriteria(state); |
2578 | 128 }, |
1889
b6d0460b069d
define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1867
diff
changeset
|
129 setStretches: (state, stretches) => { |
b6d0460b069d
define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1867
diff
changeset
|
130 state.stretches = stretches; |
b6d0460b069d
define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1867
diff
changeset
|
131 }, |
2909
5105f6ad0176
client: stretches: fixed highlighting of selected stretch
Markus Kottlaender <markus@intevation.de>
parents:
2880
diff
changeset
|
132 selectedStretch: (state, stretch) => { |
5105f6ad0176
client: stretches: fixed highlighting of selected stretch
Markus Kottlaender <markus@intevation.de>
parents:
2880
diff
changeset
|
133 state.selectedStretch = stretch; |
5105f6ad0176
client: stretches: fixed highlighting of selected stretch
Markus Kottlaender <markus@intevation.de>
parents:
2880
diff
changeset
|
134 }, |
2638
6c1730fc3dc1
client: importsoverview2: clear reviewed array after finishing review
Markus Kottlaender <markus@intevation.de>
parents:
2615
diff
changeset
|
135 setReviewed: (state, reviewed) => { |
6c1730fc3dc1
client: importsoverview2: clear reviewed array after finishing review
Markus Kottlaender <markus@intevation.de>
parents:
2615
diff
changeset
|
136 state.reviewed = reviewed; |
6c1730fc3dc1
client: importsoverview2: clear reviewed array after finishing review
Markus Kottlaender <markus@intevation.de>
parents:
2615
diff
changeset
|
137 }, |
1142
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
138 setImports: (state, imports) => { |
2600 | 139 const lookUp = state.reviewed.reduce((o, n) => { |
140 const { id, status } = n; | |
141 o[id] = status; | |
142 return o; | |
143 }, {}); | |
2578 | 144 imports = imports.map(x => { |
2600 | 145 if (x.state === "pending") { |
146 const reviewState = lookUp[x.id]; | |
147 if (reviewState) { | |
148 x.status = reviewState; | |
149 } else { | |
150 x.status = STATES.NEEDSAPPROVAL; | |
151 } | |
152 } | |
2578 | 153 return x; |
154 }); | |
1173 | 155 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
|
156 }, |
2592 | 157 showDetailsFor: (state, id) => { |
158 state.show = id; | |
159 }, | |
160 hideDetails: state => { | |
2880
c40540889b53
client: code cleanup, slight style improvements
Markus Kottlaender <markus@intevation.de>
parents:
2789
diff
changeset
|
161 state.show = null; |
2592 | 162 }, |
2594 | 163 showAdditionalInfoFor: (state, id) => { |
164 state.showAdditional = id; | |
165 }, | |
166 hideAdditionalInfo: state => { | |
2880
c40540889b53
client: code cleanup, slight style improvements
Markus Kottlaender <markus@intevation.de>
parents:
2789
diff
changeset
|
167 state.showAdditional = false; |
2594 | 168 }, |
169 showAdditionalLogsFor: (state, id) => { | |
170 state.showLogs = id; | |
171 }, | |
172 hideAdditionalLogs: state => { | |
2880
c40540889b53
client: code cleanup, slight style improvements
Markus Kottlaender <markus@intevation.de>
parents:
2789
diff
changeset
|
173 state.showLogs = false; |
2594 | 174 }, |
2592 | 175 toggleApprove: (state, change) => { |
176 const { id, newStatus } = change; | |
177 const stagedResult = state.imports.find(e => { | |
178 return e.id === id; | |
179 }); | |
180 if (stagedResult.status === newStatus) { | |
181 stagedResult.status = STATES.NEEDSAPPROVAL; | |
2600 | 182 state.reviewed = state.reviewed.filter(x => x.id !== stagedResult.id); |
2592 | 183 } else { |
184 stagedResult.status = newStatus; | |
2615
7025d082c115
client: importoverview2: fixed counter in commit button
Markus Kottlaender <markus@intevation.de>
parents:
2608
diff
changeset
|
185 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
|
186 if (index !== -1) { |
7025d082c115
client: importoverview2: fixed counter in commit button
Markus Kottlaender <markus@intevation.de>
parents:
2608
diff
changeset
|
187 state.reviewed[index].status = newStatus; |
7025d082c115
client: importoverview2: fixed counter in commit button
Markus Kottlaender <markus@intevation.de>
parents:
2608
diff
changeset
|
188 } else { |
7025d082c115
client: importoverview2: fixed counter in commit button
Markus Kottlaender <markus@intevation.de>
parents:
2608
diff
changeset
|
189 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
|
190 } |
2592 | 191 } |
1142
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
192 } |
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
193 }, |
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
194 actions: { |
2880
c40540889b53
client: code cleanup, slight style improvements
Markus Kottlaender <markus@intevation.de>
parents:
2789
diff
changeset
|
195 loadStretch(context, name) { |
2107
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
196 return new Promise((resolve, reject) => { |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
197 getStretchFromWFS(equalToFilter("name", name)) |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
198 .then(response => { |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
199 resolve(response); |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
200 }) |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
201 .catch(error => { |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
202 reject(error); |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
203 }); |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
204 }); |
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
205 }, |
1889
b6d0460b069d
define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1867
diff
changeset
|
206 loadStretches({ commit }) { |
b6d0460b069d
define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1867
diff
changeset
|
207 return new Promise((resolve, reject) => { |
2107
6747a4cf3639
staging: zoom to Stretch implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2095
diff
changeset
|
208 getStretchFromWFS(equalToFilter("staging_done", true)) |
1889
b6d0460b069d
define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1867
diff
changeset
|
209 .then(response => { |
1945
f64bc12c1719
import stretches: minor fix
Thomas Junk <thomas.junk@intevation.de>
parents:
1942
diff
changeset
|
210 if (response.data.features) { |
f64bc12c1719
import stretches: minor fix
Thomas Junk <thomas.junk@intevation.de>
parents:
1942
diff
changeset
|
211 commit("setStretches", response.data.features); |
f64bc12c1719
import stretches: minor fix
Thomas Junk <thomas.junk@intevation.de>
parents:
1942
diff
changeset
|
212 } else { |
f64bc12c1719
import stretches: minor fix
Thomas Junk <thomas.junk@intevation.de>
parents:
1942
diff
changeset
|
213 commit("setStretches", []); |
f64bc12c1719
import stretches: minor fix
Thomas Junk <thomas.junk@intevation.de>
parents:
1942
diff
changeset
|
214 } |
1889
b6d0460b069d
define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1867
diff
changeset
|
215 resolve(response); |
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 .catch(error => { |
b6d0460b069d
define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1867
diff
changeset
|
218 reject(error); |
b6d0460b069d
define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1867
diff
changeset
|
219 }); |
b6d0460b069d
define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1867
diff
changeset
|
220 }); |
b6d0460b069d
define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1867
diff
changeset
|
221 }, |
2880
c40540889b53
client: code cleanup, slight style improvements
Markus Kottlaender <markus@intevation.de>
parents:
2789
diff
changeset
|
222 saveStretch(context, stretch) { |
1889
b6d0460b069d
define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1867
diff
changeset
|
223 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
|
224 HTTP.post("/imports/st", stretch, { |
1889
b6d0460b069d
define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1867
diff
changeset
|
225 headers: { "X-Gemma-Auth": localStorage.getItem("token") } |
b6d0460b069d
define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1867
diff
changeset
|
226 }) |
b6d0460b069d
define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1867
diff
changeset
|
227 .then(response => { |
b6d0460b069d
define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1867
diff
changeset
|
228 resolve(response); |
b6d0460b069d
define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1867
diff
changeset
|
229 }) |
b6d0460b069d
define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1867
diff
changeset
|
230 .catch(error => { |
b6d0460b069d
define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1867
diff
changeset
|
231 reject(error); |
b6d0460b069d
define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1867
diff
changeset
|
232 }); |
b6d0460b069d
define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1867
diff
changeset
|
233 }); |
b6d0460b069d
define stretches: Now with store-backend
Thomas Junk <thomas.junk@intevation.de>
parents:
1867
diff
changeset
|
234 }, |
2748
c6695d6e9334
import_overview: filtering date interval via backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2733
diff
changeset
|
235 getImports({ commit }, options) { |
2749
cd789302b3e2
import_overview: start is initially always beginning of current hour
Thomas Junk <thomas.junk@intevation.de>
parents:
2748
diff
changeset
|
236 let { filter, from, to, query } = options; |
2415 | 237 let queryParams = ""; |
2655
501967471981
overview: warning filter implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2654
diff
changeset
|
238 const hasWarning = filter.includes("warning"); |
501967471981
overview: warning filter implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2654
diff
changeset
|
239 filter = filter.filter(x => x != "warning"); |
501967471981
overview: warning filter implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2654
diff
changeset
|
240 if (filter && filter.length > 0) { |
2447
522024fa06eb
staging: filter logs on server
Thomas Junk <thomas.junk@intevation.de>
parents:
2415
diff
changeset
|
241 queryParams = "?states=" + filter.join(","); |
2655
501967471981
overview: warning filter implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2654
diff
changeset
|
242 if (hasWarning) queryParams += "&warnings=true"; |
2748
c6695d6e9334
import_overview: filtering date interval via backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2733
diff
changeset
|
243 queryParams += "&from=" + from; |
c6695d6e9334
import_overview: filtering date interval via backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2733
diff
changeset
|
244 queryParams += "&to=" + to; |
2749
cd789302b3e2
import_overview: start is initially always beginning of current hour
Thomas Junk <thomas.junk@intevation.de>
parents:
2748
diff
changeset
|
245 queryParams += "&query=" + query; |
2655
501967471981
overview: warning filter implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2654
diff
changeset
|
246 } else { |
2748
c6695d6e9334
import_overview: filtering date interval via backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2733
diff
changeset
|
247 if (hasWarning) { |
c6695d6e9334
import_overview: filtering date interval via backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2733
diff
changeset
|
248 queryParams += "?warnings=true"; |
c6695d6e9334
import_overview: filtering date interval via backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2733
diff
changeset
|
249 queryParams += "&from=" + from; |
c6695d6e9334
import_overview: filtering date interval via backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2733
diff
changeset
|
250 queryParams += "&to=" + to; |
2749
cd789302b3e2
import_overview: start is initially always beginning of current hour
Thomas Junk <thomas.junk@intevation.de>
parents:
2748
diff
changeset
|
251 queryParams += "&query=" + query; |
2748
c6695d6e9334
import_overview: filtering date interval via backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2733
diff
changeset
|
252 } else { |
c6695d6e9334
import_overview: filtering date interval via backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2733
diff
changeset
|
253 queryParams += "?from=" + from; |
c6695d6e9334
import_overview: filtering date interval via backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2733
diff
changeset
|
254 queryParams += "&to=" + to; |
2749
cd789302b3e2
import_overview: start is initially always beginning of current hour
Thomas Junk <thomas.junk@intevation.de>
parents:
2748
diff
changeset
|
255 queryParams += "&query=" + query; |
2748
c6695d6e9334
import_overview: filtering date interval via backend
Thomas Junk <thomas.junk@intevation.de>
parents:
2733
diff
changeset
|
256 } |
2655
501967471981
overview: warning filter implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2654
diff
changeset
|
257 } |
1142
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
258 return new Promise((resolve, reject) => { |
2415 | 259 HTTP.get("/imports" + queryParams, { |
1142
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
260 headers: { "X-Gemma-Auth": localStorage.getItem("token") } |
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
261 }) |
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
262 .then(response => { |
2759
7badd99c9315
import_overview: sprinkled fairydust into the app to make magical timewarp possible for log_overview
Thomas Junk <thomas.junk@intevation.de>
parents:
2753
diff
changeset
|
263 const { imports, prev, next } = response.data; |
7badd99c9315
import_overview: sprinkled fairydust into the app to make magical timewarp possible for log_overview
Thomas Junk <thomas.junk@intevation.de>
parents:
2753
diff
changeset
|
264 commit("setPrev", prev); |
7badd99c9315
import_overview: sprinkled fairydust into the app to make magical timewarp possible for log_overview
Thomas Junk <thomas.junk@intevation.de>
parents:
2753
diff
changeset
|
265 commit("setNext", next); |
2578 | 266 commit("setImports", imports); |
1142
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
267 resolve(response); |
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
268 }) |
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
269 .catch(error => { |
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
270 reject(error); |
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
271 }); |
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
272 }); |
1310
d675e6439aa5
staging view: prepare retrieving list of pending imports for staging
Thomas Junk <thomas.junk@intevation.de>
parents:
1296
diff
changeset
|
273 }, |
2880
c40540889b53
client: code cleanup, slight style improvements
Markus Kottlaender <markus@intevation.de>
parents:
2789
diff
changeset
|
274 confirmReview(context, reviewResults) { |
2399 | 275 return new Promise((resolve, reject) => { |
276 HTTP.patch("/imports", reviewResults, { | |
277 headers: { | |
278 "X-Gemma-Auth": localStorage.getItem("token"), | |
279 "Content-type": "application/json" | |
280 } | |
281 }) | |
282 .then(response => { | |
283 resolve(response); | |
284 }) | |
285 .catch(error => { | |
286 reject(error); | |
287 }); | |
288 }); | |
1142
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
289 } |
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
290 } |
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
291 }; |
1344
eda98694e678
staging: retrieve real data instead of displaying demodata
Thomas Junk <thomas.junk@intevation.de>
parents:
1311
diff
changeset
|
292 |
2033
431f97fd873b
importschedule: extracted to separate store
Thomas Junk <thomas.junk@intevation.de>
parents:
1996
diff
changeset
|
293 export { imports, STATES }; |