Mercurial > gemma
annotate client/src/store/bottlenecks.js @ 1096:aa1f5daf6fc9
refac: centralized stores
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Tue, 30 Oct 2018 16:55:29 +0100 |
parents | |
children | f106aee673e7 |
rev | line source |
---|---|
1096
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
1 /* |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
2 * This is Free Software under GNU Affero General Public License v >= 3.0 |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
3 * without warranty, see README.md and license for details. |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
4 * |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
5 * SPDX-License-Identifier: AGPL-3.0-or-later |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
6 * License-Filename: LICENSES/AGPL-3.0.txt |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
7 * |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
8 * Copyright (C) 2018 by via donau |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
9 * – Österreichische Wasserstraßen-Gesellschaft mbH |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
10 * Software engineering by Intevation GmbH |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
11 * |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
12 * Author(s): |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
13 * Markus Kottländer <markuks.kottlaender@intevation.de> |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
14 */ |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
15 import { HTTP } from "../application/lib/http"; |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
16 import { WFS } from "ol/format.js"; |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
17 |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
18 const Bottlenecks = { |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
19 namespaced: true, |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
20 state: { |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
21 bottlenecks: [] |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
22 }, |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
23 mutations: { |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
24 setBottlenecks: (state, bottlenecks) => { |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
25 state.bottlenecks = bottlenecks; |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
26 } |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
27 }, |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
28 actions: { |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
29 loadBottlenecks({ commit }) { |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
30 var bottleneckFeatureCollectionRequest = new WFS().writeGetFeature({ |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
31 srsName: "EPSG:4326", |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
32 featureNS: "gemma", |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
33 featurePrefix: "gemma", |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
34 featureTypes: ["bottleneck_overview"], |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
35 outputFormat: "application/json" |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
36 }); |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
37 |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
38 HTTP.post( |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
39 "/internal/wfs", |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
40 new XMLSerializer().serializeToString( |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
41 bottleneckFeatureCollectionRequest |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
42 ), |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
43 { |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
44 headers: { |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
45 "X-Gemma-Auth": localStorage.getItem("token"), |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
46 "Content-type": "text/xml; charset=UTF-8" |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
47 } |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
48 } |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
49 ).then(response => { |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
50 commit("setBottlenecks", response.data.features); |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
51 }); |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
52 } |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
53 } |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
54 }; |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
55 |
aa1f5daf6fc9
refac: centralized stores
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
56 export default Bottlenecks; |