comparison client/src/router.js @ 2329:514193fd0120

refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
author Thomas Junk <thomas.junk@intevation.de>
date Tue, 19 Feb 2019 14:57:48 +0100
parents c98491f9c466
children c69432c1c4ac
comparison
equal deleted inserted replaced
2328:c98491f9c466 2329:514193fd0120
18 import store from "./store"; 18 import store from "./store";
19 import { sessionStillActive, toMillisFromString } from "./lib/session"; 19 import { sessionStillActive, toMillisFromString } from "./lib/session";
20 20
21 /* facilitate codesplitting */ 21 /* facilitate codesplitting */
22 const Login = () => import("./components/Login.vue"); 22 const Login = () => import("./components/Login.vue");
23 const Main = () => import("./components/Main.vue");
23 24
24 Vue.use(Router); 25 Vue.use(Router);
25 26
26 const router = new Router({ 27 const router = new Router({
27 routes: [ 28 routes: [
78 next(); 79 next();
79 } 80 }
80 } 81 }
81 }, 82 },
82 { 83 {
83 path: "/importqueue", 84 path: "/importqueue/:id?",
84 name: "importqueues",
85 component: () => import("./components/importqueue/Importqueue.vue"),
86 meta: {
87 requiresAuth: true
88 },
89 beforeEnter: (to, from, next) => {
90 const isWaterwayAdmin = store.getters["user/isWaterwayAdmin"];
91 if (!isWaterwayAdmin) {
92 next("/");
93 } else {
94 next();
95 }
96 }
97 },
98 {
99 path: "/importqueue/:id",
100 name: "importqueue", 85 name: "importqueue",
101 component: () => import("./components/importqueue/Importqueue.vue"), 86 component: () => import("./components/importqueue/Importqueue.vue"),
102 meta: { 87 meta: {
103 requiresAuth: true 88 requiresAuth: true
104 }, 89 },
176 } 161 }
177 }, 162 },
178 { 163 {
179 path: "/", 164 path: "/",
180 name: "mainview", 165 name: "mainview",
181 component: () => import("./components/Main.vue"), 166 component: Main,
182 meta: { 167 meta: {
183 requiresAuth: true 168 requiresAuth: true
169 },
170 beforeEnter: (to, from, next) => {
171 store.commit("application/showContextBox", false);
172 store.commit("application/contextBoxContent", "");
173 store.commit("application/showSearchbar", false);
174 next();
175 }
176 },
177 {
178 path: "/bottlenecks",
179 name: "mainview",
180 component: Main,
181 meta: {
182 requiresAuth: true
183 },
184 beforeEnter: (to, from, next) => {
185 store.commit("application/showContextBox", true);
186 store.commit("application/contextBoxContent", "bottlenecks");
187 store.commit("application/showSearchbar", true);
188 next();
189 }
190 },
191 {
192 path: "/review/:id?",
193 name: "mainview",
194 component: Main,
195 meta: {
196 requiresAuth: true
197 },
198 beforeEnter: (to, from, next) => {
199 const isWaterwayAdmin = store.getters["user/isWaterwayAdmin"];
200 if (!isWaterwayAdmin) {
201 next("/");
202 } else {
203 store.commit("application/showContextBox", true);
204 store.commit("application/contextBoxContent", "staging");
205 store.commit("application/showSearchbar", true);
206 next();
207 }
208 }
209 },
210 {
211 path: "/stretches",
212 name: "mainview",
213 component: Main,
214 meta: {
215 requiresAuth: true
216 },
217 beforeEnter: (to, from, next) => {
218 const isSysadmin = store.getters["user/isSysAdmin"];
219 if (!isSysadmin) {
220 next("/");
221 } else {
222 store.commit("application/showContextBox", true);
223 store.commit("application/contextBoxContent", "stretches");
224 store.commit("application/showSearchbar", true);
225 next();
226 }
184 } 227 }
185 }, 228 },
186 { 229 {
187 path: "*", 230 path: "*",
188 component: Login 231 component: Login