view client/src/components/layers/Layers.vue @ 5075:aeb100b4c41b time-sliding

timeslider: prerequisites for time travel * splitting selected time to a) the actual time visible on map (in the toolbar) b) the actual selected time with the timeslider Analogous to an event "ongoing refresh" we have "ongoing timeslide". During this event (a) stays the same according to the information presented on the screen. (b) is not affected. As soon as the loaders settle, the next requests are started with the then "selected time" and the actual time visible on map is set to this new value. Reloading the layers "jumps back to now".
author Thomas Junk <thomas.junk@intevation.de>
date Fri, 13 Mar 2020 10:37:44 +0100
parents 9f0830a1845d
children fe63733750d7
line wrap: on
line source

<template>
  <div
    :class="[
      'box ui-element rounded bg-white text-nowrap',
      { expanded: showLayers }
    ]"
  >
    <div class="position-relative" style="width: 17rem; min-height: 350px;">
      <UIBoxHeader
        icon="layer-group"
        :title="label"
        :closeCallback="close"
        :actions="[
          {
            callback: refreshLayers,
            icon: sourcesLoading ? 'spinner' : 'sync'
          }
        ]"
      />
      <div class="small" v-if="openLayersMaps.length">
        <Layerselect layerId="OPENSTREETMAP" />
        <Layerselect layerId="INLANDECDIS" />
        <Layerselect layerId="WATERWAYAREA" />
        <Layerselect layerId="STRETCHES" />
        <Layerselect layerId="SECTIONS" />
        <Layerselect layerId="BOTTLENECKS" />
        <Layerselect layerId="BOTTLENECKISOLINE" />
        <Layerselect layerId="DIFFERENCES" />
        <Layerselect layerId="FAIRWAYDIMENSIONSLOS3" />
        <Layerselect layerId="FAIRWAYDIMENSIONSLOS2" />
        <Layerselect layerId="FAIRWAYDIMENSIONSLOS1" />
        <Layerselect layerId="WATERWAYAXIS" />
        <Layerselect layerId="WATERWAYPROFILES" />
        <Layerselect layerId="BOTTLENECKSTATUS" />
        <Layerselect layerId="BOTTLENECKFAIRWAYAVAILABILITY" />
        <Layerselect layerId="DATAAVAILABILITY" />
        <Layerselect layerId="DISTANCEMARKS" />
        <Layerselect layerId="DISTANCEMARKSAXIS" />
        <Layerselect layerId="GAUGES" />
        <Layerselect layerId="FAIRWAYMARKS" />
        <Layerselect v-if="reviewActive" layerId="FDREVIEWLAYER" />
      </div>
      <UISpinnerOverlay v-else style="top: 34px;" />
    </div>
  </div>
</template>

<script>
/* 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):
 * Thomas Junk <thomas.junk@intevation.de>
 * Markus Kottländer <markus.kottlaender@intevation.de>
 */
import { mapState, mapGetters } from "vuex";

export default {
  components: {
    Layerselect: () => import("./Layerselect")
  },
  computed: {
    ...mapState("application", ["showLayers"]),
    ...mapState("map", ["openLayersMaps", "reviewActive"]),
    ...mapGetters("map", ["openLayersMap"]),
    label() {
      return this.$gettext("Map Layers");
    },
    sourcesLoading() {
      let counter = 0;
      this.openLayersMaps.forEach(map => {
        let layers = map.getLayers().getArray();
        for (let i = 0; i < layers.length; i++) {
          if (layers[i].getSource().loading) counter++;
        }
      });
      return counter;
    }
  },
  watch: {
    reviewActive() {
      if (!this.reviewActive) {
        const fairwaydimensionLayer = this.openLayersMap().getLayer(
          "FDREVIEWLAYER"
        );
        fairwaydimensionLayer.setVisible(false);
      }
    }
  },
  methods: {
    close() {
      this.$store.commit("application/showLayers", false);
    },
    refreshLayers() {
      this.$store.commit("application/setCurrentVisibleTime", new Date());
      this.$store.commit("map/startRefreshLayers");
      this.$store.commit("map/startTimeSlide");
      this.$store.commit("gauges/deleteNashSutcliffeCache");
      this.$store.dispatch("map/refreshLayers");
      this.$nextTick(() => {
        this.$store.commit("map/finishRefreshLayers");
        this.$store.commit("map/finishTimeSlide");
      });
    }
  }
};
</script>