Mercurial > gemma
view client/src/router.js @ 2716:eadf9ebc0d6b
client: waterlevel diagram: fixed animation bug when switching between gauges while having the splitscreen open
author | Markus Kottlaender <markus@intevation.de> |
---|---|
date | Mon, 18 Mar 2019 18:52:41 +0100 |
parents | a4962c302af0 |
children | 563bcd8b7d7b |
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> * Bernhard Reiter <bernhard@intevation.de> * Markus Kottländer <markus@intevation.de> */ import Vue from "vue"; import Router from "vue-router"; import store from "./store"; import { sessionStillActive, toMillisFromString } from "./lib/session"; /* facilitate codesplitting */ const Login = () => import("./components/Login.vue"); const Maplayer = () => import("./components/Maplayer.vue"); Vue.use(Router); const router = new Router({ routes: [ { path: "/login", name: "login", component: Login }, { path: "/usermanagement", name: "usermanagement", component: () => import("./components/usermanagement/Usermanagement.vue"), meta: { requiresAuth: true }, beforeEnter: (to, from, next) => { const isSysadmin = store.getters["user/isSysAdmin"]; if (!isSysadmin) { next("/"); } else { next(); } } }, { path: "/logs", name: "logs", component: () => import("./components/Logs.vue"), meta: { requiresAuth: true }, beforeEnter: (to, from, next) => { const isSysadmin = store.getters["user/isSysAdmin"]; if (!isSysadmin) { next("/"); } else { next(); } } }, { path: "/systemconfiguration", name: "systemconfiguration", component: () => import("./components/systemconfiguration/Systemconfiguration.vue"), meta: { requiresAuth: true }, beforeEnter: (to, from, next) => { const isWaterwayAdmin = store.getters["user/isWaterwayAdmin"]; if (!isWaterwayAdmin) { next("/"); } else { next(); } } }, { path: "/importsoundingresults", name: "importsoundingresults", component: () => import("./components/ImportSoundingresults.vue"), meta: { requiresAuth: true }, beforeEnter: (to, from, next) => { const isWaterwayAdmin = store.getters["user/isWaterwayAdmin"]; if (!isWaterwayAdmin) { next("/"); } else { next(); } } }, { path: "/importwaterwayprofiles", name: "waterwayprofiles", component: () => import("./components/ImportWaterwayProfiles"), meta: { requiresAuth: true }, beforeEnter: (to, from, next) => { const isWaterwayAdmin = store.getters["user/isWaterwayAdmin"]; if (!isWaterwayAdmin) { next("/"); } else { next(); } } }, { path: "/importapprovedgaugemeasurement", name: "approvedgaugemeasurement", component: () => import("./components/ImportApprovedGaugeMeasurement"), meta: { requiresAuth: true }, beforeEnter: (to, from, next) => { const isWaterwayAdmin = store.getters["user/isWaterwayAdmin"]; if (!isWaterwayAdmin) { next("/"); } else { next(); } } }, { path: "/importschedule", name: "importschedule", component: () => import("./components/importschedule/Importschedule.vue"), meta: { requiresAuth: true }, beforeEnter: (to, from, next) => { const isWaterwayAdmin = store.getters["user/isWaterwayAdmin"]; if (!isWaterwayAdmin) { next("/"); } else { next(); } } }, { path: "/", name: "mainview", component: Maplayer, meta: { requiresAuth: true }, beforeEnter: (to, from, next) => { store.commit("application/searchQuery", ""); store.commit("application/showContextBox", false); store.commit("application/contextBoxContent", ""); store.commit("application/showSearchbar", false); next(); } }, { path: "/bottlenecks", name: "bottlenecks", component: Maplayer, meta: { requiresAuth: true }, beforeEnter: (to, from, next) => { store.commit("application/searchQuery", ""); store.commit("application/showContextBox", true); store.commit("application/contextBoxContent", "bottlenecks"); store.commit("application/showSearchbar", true); next(); } }, { path: "/imports/overview/:id?", name: "importoverview", component: Maplayer, meta: { requiresAuth: true }, beforeEnter: (to, from, next) => { const isWaterwayAdmin = store.getters["user/isWaterwayAdmin"]; if (!isWaterwayAdmin) { next("/"); } else { store.commit("application/showContextBox", true); store.commit("application/contextBoxContent", "importoverview"); store.commit("application/showSearchbar", true); next(); } } }, { path: "/stretches", name: "stretches", component: Maplayer, meta: { requiresAuth: true }, beforeEnter: (to, from, next) => { const isSysadmin = store.getters["user/isSysAdmin"]; if (!isSysadmin) { next("/"); } else { store.commit("application/searchQuery", ""); store.commit("application/showContextBox", true); store.commit("application/contextBoxContent", "stretches"); store.commit("application/showSearchbar", true); next(); } } }, { path: "*", component: Login } ] }); router.beforeEach((to, from, next) => { const expiresFromPastSession = toMillisFromString( localStorage.getItem("expires") ); if (sessionStillActive(expiresFromPastSession)) { store.commit("user/setUser", localStorage.getItem("user")); store.commit("user/setExpires", expiresFromPastSession); store.commit("user/setRoles", localStorage.getItem("roles")); store.commit("user/setIsAuthenticate", true); } else { store.commit("reset"); store.commit("user/clearAuth"); } const requiresAuth = to.matched.some(record => record.meta.requiresAuth); const loggedIn = store.state.user.isAuthenticated; const authRequired = requiresAuth && !(loggedIn || sessionStillActive(expiresFromPastSession)); if (authRequired) { next("/login"); } else if (!authRequired) { next(); } else { next(); } }); export default router;