comparison client/src/store/gauges.js @ 2590:1686ec185155

client: added gauge waterlevel example diagram
author Markus Kottlaender <markus@intevation.de>
date Tue, 12 Mar 2019 08:37:09 +0100
parents
children 8774054959a7
comparison
equal deleted inserted replaced
2589:f4c399a496cb 2590:1686ec185155
1 /* This is Free Software under GNU Affero General Public License v >= 3.0
2 * without warranty, see README.md and license for details.
3 *
4 * SPDX-License-Identifier: AGPL-3.0-or-later
5 * License-Filename: LICENSES/AGPL-3.0.txt
6 *
7 * Copyright (C) 2018 by via donau
8 * – Österreichische Wasserstraßen-Gesellschaft mbH
9 * Software engineering by Intevation GmbH
10 *
11 * Author(s):
12 * Markus Kottländer <markus@intevation.de>
13 */
14
15 import { getCenter } from "ol/extent";
16
17 const init = () => {
18 return {
19 selectedGauge: null
20 };
21 };
22
23 export default {
24 init,
25 namespaced: true,
26 state: init(),
27 mutations: {
28 selectedGauge: (state, gauge) => {
29 state.selectedGauge = gauge;
30 }
31 },
32 actions: {
33 selectedGauge: ({ commit }, gauge) => {
34 commit("selectedGauge", gauge);
35
36 // configure splitscreen
37 let splitscreenConf = {
38 id: "gauge-waterlevel",
39 component: "waterlevel",
40 title: gauge.get("objname"),
41 icon: "ruler-vertical",
42 closeCallback: () => {
43 commit("selectedGauge", null);
44 },
45 expandCallback: () => {
46 commit(
47 "map/moveMap",
48 {
49 coordinates: getCenter(
50 gauge
51 .getGeometry()
52 .clone()
53 .transform("EPSG:3857", "EPSG:4326")
54 .getExtent()
55 ),
56 zoom: 17,
57 preventZoomOut: true
58 },
59 { root: true }
60 );
61 }
62 };
63 commit("application/addSplitscreen", splitscreenConf, {
64 root: true
65 });
66 commit("application/activeSplitscreenId", "gauge-waterlevel", {
67 root: true
68 });
69 commit("application/splitscreenLoading", false, { root: true });
70 commit("application/showSplitscreen", true, { root: true });
71 }
72 }
73 };