diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/client/src/store/gauges.js	Tue Mar 12 08:37:09 2019 +0100
@@ -0,0 +1,73 @@
+/* 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 <markus@intevation.de>
+ */
+
+import { getCenter } from "ol/extent";
+
+const init = () => {
+  return {
+    selectedGauge: null
+  };
+};
+
+export default {
+  init,
+  namespaced: true,
+  state: init(),
+  mutations: {
+    selectedGauge: (state, gauge) => {
+      state.selectedGauge = gauge;
+    }
+  },
+  actions: {
+    selectedGauge: ({ commit }, gauge) => {
+      commit("selectedGauge", gauge);
+
+      // configure splitscreen
+      let splitscreenConf = {
+        id: "gauge-waterlevel",
+        component: "waterlevel",
+        title: gauge.get("objname"),
+        icon: "ruler-vertical",
+        closeCallback: () => {
+          commit("selectedGauge", null);
+        },
+        expandCallback: () => {
+          commit(
+            "map/moveMap",
+            {
+              coordinates: getCenter(
+                gauge
+                  .getGeometry()
+                  .clone()
+                  .transform("EPSG:3857", "EPSG:4326")
+                  .getExtent()
+              ),
+              zoom: 17,
+              preventZoomOut: true
+            },
+            { root: true }
+          );
+        }
+      };
+      commit("application/addSplitscreen", splitscreenConf, {
+        root: true
+      });
+      commit("application/activeSplitscreenId", "gauge-waterlevel", {
+        root: true
+      });
+      commit("application/splitscreenLoading", false, { root: true });
+      commit("application/showSplitscreen", true, { root: true });
+    }
+  }
+};