view client/src/application/Main.vue @ 901:36731fbe51a2

bottom margin increased for bottleneckdeselection
author Thomas Junk <thomas.junk@intevation.de>
date Tue, 02 Oct 2018 16:25:10 +0200
parents 52fe3e20f750
children d612bc4dc3e9
line wrap: on
line source

<template>
    <div class="main d-flex flex-column">
        <Maplayer :drawMode="drawMode" :split="isSplitscreen" :lat="6155376" :long="1819178" :zoom="11"></Maplayer>
        <div v-if="isSplitscreen" class="profile d-flex flex-row">
            <FairwayProfile :minAlt="minAlt" maxAlt="maxAlt" :selectedWaterLevel="selectedWaterLevel" :fairwayCoordinates="fairwayCoordinates" :waterLevels="waterLevels" :data="currentProfile" :height="height" :width="width" :xScale="xAxis" :yScaleLeft="yAxisLeft" :yScaleRight="yAxisRight" :margin="margins" :totalLength="totalLength"></FairwayProfile>
        </div>
    </div>
</template>

<style lang="scss">
.profile {
  background-color: white;
  height: 50vh;
}
</style>

<script>
import Maplayer from "../map/Maplayer";
import FairwayProfile from "../fairway/Fairwayprofile";
import { mapGetters } from "vuex";
import debounce from "debounce";

export default {
  name: "mainview",
  components: {
    Maplayer,
    FairwayProfile
  },
  data() {
    return {
      width: null,
      height: null,
      margin: {
        top: 20,
        right: 40,
        bottom: 30,
        left: 40
      }
    };
  },
  computed: {
    ...mapGetters("application", ["isSplitscreen", "drawMode"]),
    ...mapGetters("fairwayprofile", [
      "currentProfile",
      "minAlt",
      "maxAlt",
      "totalLength",
      "waterLevels",
      "fairwayCoordinates",
      "selectedWaterLevel"
    ]),
    xAxis() {
      return [this.xScale.x, this.xScale.y];
    },
    yAxisLeft() {
      const hi = Math.max(this.maxAlt, this.selectedWaterLevel);
      return [this.yScaleLeft.lo, hi];
    },
    yAxisRight() {
      const hi =
        Math.max(this.maxAlt, this.selectedWaterLevel) -
        this.selectedWaterLevel;
      const lo = this.selectedWaterLevel - this.minAlt;
      return [-lo, hi];
    },
    margins() {
      return this.margin;
    },
    yScaleLeft() {
      return {
        lo: this.minAlt,
        hi: this.maxAlt
      };
    },
    xScale() {
      return {
        x: 0,
        y: this.totalLength
      };
    }
  },
  created() {
    window.addEventListener("resize", debounce(this.scaleFairwayProfile), 100);
    window.addEventListener("onbeforeprint", this.test);
  },
  updated() {
    this.scaleFairwayProfile();
  },
  destroyed() {
    window.removeEventListener("resize", debounce(this.scaleFairwayProfile));
  },
  methods: {
    test(evt) {
      console.log("test: ", evt);
    },
    scaleFairwayProfile() {
      if (!document.querySelector(".profile")) return;
      const clientHeight = document.querySelector(".profile").clientHeight;
      const clientWidth = document.querySelector(".profile").clientWidth;
      if (!clientHeight || !clientWidth) return;
      this.height = document.querySelector(".profile").clientHeight - 25;
      this.width = document.querySelector(".profile").clientWidth - 200;
    }
  }
};
</script>