Mercurial > gemma
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/src/store/bottlenecks.js Tue Oct 30 16:55:29 2018 +0100 @@ -0,0 +1,56 @@ +/* + * This is Free Software under GNU Affero General Public License v >= 3.0 + * without warranty, see README.md and license for details. + * + * SPDX-License-Identifier: AGPL-3.0-or-later + * License-Filename: LICENSES/AGPL-3.0.txt + * + * Copyright (C) 2018 by via donau + * – Österreichische Wasserstraßen-Gesellschaft mbH + * Software engineering by Intevation GmbH + * + * Author(s): + * Markus Kottländer <markuks.kottlaender@intevation.de> + */ +import { HTTP } from "../application/lib/http"; +import { WFS } from "ol/format.js"; + +const Bottlenecks = { + namespaced: true, + state: { + bottlenecks: [] + }, + mutations: { + setBottlenecks: (state, bottlenecks) => { + state.bottlenecks = bottlenecks; + } + }, + actions: { + loadBottlenecks({ commit }) { + var bottleneckFeatureCollectionRequest = new WFS().writeGetFeature({ + srsName: "EPSG:4326", + featureNS: "gemma", + featurePrefix: "gemma", + featureTypes: ["bottleneck_overview"], + outputFormat: "application/json" + }); + + HTTP.post( + "/internal/wfs", + new XMLSerializer().serializeToString( + bottleneckFeatureCollectionRequest + ), + { + headers: { + "X-Gemma-Auth": localStorage.getItem("token"), + "Content-type": "text/xml; charset=UTF-8" + } + } + ).then(response => { + commit("setBottlenecks", response.data.features); + }); + } + } +}; + +export default Bottlenecks;