view client/src/store/application.js @ 3632:943c454d5633 single-beam

Merged default into single-beam branch.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 11 Jun 2019 14:46:14 +0200
parents 30a9fdac70f0
children a688a478e35f
line wrap: on
line source

/* 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>
 *   Bernhard E. Reiter <bernhard.reiter@intevation.de>
 */

import { version } from "../../package.json";

// initial state
const init = () => {
  return {
    userManualUrl: process.env.VUE_APP_USER_MANUAL_URL,
    appTitle: process.env.VUE_APP_TITLE,
    secondaryLogo: process.env.VUE_APP_SECONDARY_LOGO_URL,
    logoForPDF: process.env.VUE_APP_LOGO_FOR_PDF_URL,
    popup: null,
    paneSetup: "DEFAULT",
    paneRotate: 1,
    showSidebar: false,
    showUsermenu: false,
    showSearchbar: false,
    showSearchbarLastState: false,
    showIdentify: false,
    showLayers: true,
    showPdfTool: false,
    showContextBox: false,
    showProfiles: false,
    showGauges: false,
    showFairwayDepth: false,
    showFairwayDepthLNWL: false,
    contextBoxContent: null, // bottlenecks, imports, staging
    expandToolbar: false,
    countries: ["AT", "SK", "HU", "HR", "RS", "BiH", "BG", "RO", "UA"],
    searchQuery: "",
    version,
    tempRoute: "",
    config: {}
  };
};

export default {
  init,
  namespaced: true,
  state: init(),
  getters: {
    versionStr: state => {
      // version number from package.json
      let versionStr = "v" + state.version;

      // hg revision
      if (
        process.env.VUE_APP_HGREV &&
        (state.version.includes("dev") ||
          state.version.includes("beta") ||
          state.version.includes("alpha"))
      )
        // a '+' according to semver 2.0.0 starts a build meta info section
        // which shall only have [0-9A-Za-z-] chars
        // and is to be ignored when determining the order
        versionStr += "+" + process.env.VUE_APP_HGREV;

      return versionStr;
    }
  },
  mutations: {
    setTempRoute: (state, tempRoute) => {
      state.tempRoute = tempRoute;
    },
    popup: (state, popup) => {
      state.popup = popup;
    },
    paneSetup: (state, setup) => {
      state.paneSetup = setup;
    },
    paneRotate: (state, rotate) => {
      if (rotate) {
        state.paneRotate = rotate;
      } else {
        state.paneRotate++;
        if (state.paneRotate === 5) state.paneRotate = 1;
      }
    },
    showSidebar: (state, show) => {
      state.showSidebar = show;
    },
    showUsermenu: (state, show) => {
      state.showUsermenu = show;
    },
    showSearchbar: (state, show) => {
      state.showSearchbar = show;
    },
    showIdentify: (state, show) => {
      state.showIdentify = show;
    },
    showLayers: (state, show) => {
      state.showLayers = show;
    },
    showPdfTool: (state, show) => {
      state.showPdfTool = show;
    },
    showContextBox: (state, show) => {
      state.showContextBox = show;
    },
    showProfiles: (state, show) => {
      state.showProfiles = show;
    },
    showGauges: (state, show) => {
      state.showGauges = show;
    },
    showFairwayDepth: (state, show) => {
      state.showFairwayDepth = show;
    },
    showFairwayDepthLNWL: (state, show) => {
      state.showFairwayDepthLNWL = show;
    },
    contextBoxContent: (state, context) => {
      state.contextBoxContent = context;
      if (context) {
        state.showSearchbarLastState = state.showSearchbar;
      }
    },
    expandToolbar: (state, expandToolbar) => {
      state.expandToolbar = expandToolbar;
    },
    searchQuery: (state, searchQuery) => {
      state.searchQuery = searchQuery;
    },
    config: (state, config) => {
      state.config = config;
    }
  },
  actions: {
    loadConfig({ commit, state }) {
      if (!Object.keys(state.config).length) {
        setTimeout(() => {
          commit("config", {
            ecdis_url: "https://service.d4d-portal.info/wms/",
            bn_revtime_multiplier: 1.5,
            gm_min_values_14d: 1124,
            gm_latest_hours: 24,
            gm_forecast_offset_24h: 15,
            gm_forecast_offset_72h: 15,
            gm_forecast_vs_reality_nsc_24h: -12.5,
            gm_forecast_vs_reality_nsc_72h: -12.5,
            morphology_classbreaks: [
              1,
              1.5,
              1.7,
              1.9,
              2.1,
              2.3,
              2.5,
              2.7,
              2.9,
              3.1,
              3.3,
              3.5,
              4.0,
              4.5,
              5,
              5.5,
              6,
              6.5,
              7
            ],
            morphology_classbreaks_compare: [
              -2,
              -1.9,
              -1.8,
              -1.7,
              -1.6,
              -1.5,
              -1.4,
              -1.3,
              -1.2,
              -1.1,
              -1,
              -0.9,
              -0.8,
              -0.7,
              -0.6,
              -0.5,
              -0.4,
              -0.3,
              -0.2,
              -0.1,
              0,
              0.1,
              0.2,
              0.3,
              0.4,
              0.5,
              0.6,
              0.7,
              0.8,
              0.9,
              1,
              1.1,
              1.2,
              1.3,
              1.4,
              1.5,
              1.6,
              1.7,
              1.8,
              1.9,
              2
            ]
          });
        }, 1000);
      }
    }
  }
};