Mercurial > gemma
annotate client/src/router.js @ 5650:cb3c4ba0f052 DQR adjustments
Merged default branch
author | Sascha Wilde <wilde@sha-bang.de> |
---|---|
date | Thu, 29 Jun 2023 13:18:54 +0200 |
parents | 10cbf467fd63 |
children |
rev | line source |
---|---|
1362
ca33ad696594
remove the first empyty lines
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1296
diff
changeset
|
1 /* This is Free Software under GNU Affero General Public License v >= 3.0 |
1019
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
853
diff
changeset
|
2 * without warranty, see README.md and license for details. |
1142
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
1122
diff
changeset
|
3 * |
1019
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
853
diff
changeset
|
4 * SPDX-License-Identifier: AGPL-3.0-or-later |
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
853
diff
changeset
|
5 * License-Filename: LICENSES/AGPL-3.0.txt |
1142
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
1122
diff
changeset
|
6 * |
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
1122
diff
changeset
|
7 * Copyright (C) 2018 by via donau |
1019
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
853
diff
changeset
|
8 * – Österreichische Wasserstraßen-Gesellschaft mbH |
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
853
diff
changeset
|
9 * Software engineering by Intevation GmbH |
1142
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
1122
diff
changeset
|
10 * |
1019
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
853
diff
changeset
|
11 * Author(s): |
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
853
diff
changeset
|
12 * Thomas Junk <thomas.junk@intevation.de> |
1363 | 13 * Bernhard Reiter <bernhard@intevation.de> |
14 * Markus Kottländer <markus@intevation.de> | |
1019
ca628dce90dd
Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents:
853
diff
changeset
|
15 */ |
3 | 16 import Vue from "vue"; |
17 import Router from "vue-router"; | |
18 import store from "./store"; | |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
1244
diff
changeset
|
19 import { sessionStillActive, toMillisFromString } from "./lib/session"; |
3 | 20 |
483
27502291e564
docs: Added comments on non trivial parts of the code
Thomas Junk <thomas.junk@intevation.de>
parents:
466
diff
changeset
|
21 /* facilitate codesplitting */ |
2985
1b8bb4f89227
client: removed .js and .vue extention from imports
Markus Kottlaender <markus@intevation.de>
parents:
2984
diff
changeset
|
22 const Login = () => import("./components/Login"); |
1b8bb4f89227
client: removed .js and .vue extention from imports
Markus Kottlaender <markus@intevation.de>
parents:
2984
diff
changeset
|
23 const Main = () => import("./components/Main"); |
466
e3035621cc52
refac: Small improvement of loading time with code splitting
Thomas Junk <thomas.junk@intevation.de>
parents:
285
diff
changeset
|
24 |
3 | 25 Vue.use(Router); |
26 | |
27 const router = new Router({ | |
28 routes: [ | |
29 { | |
6 | 30 path: "/login", |
3 | 31 name: "login", |
32 component: Login | |
33 }, | |
34 { | |
581 | 35 path: "/usermanagement", |
36 name: "usermanagement", | |
2985
1b8bb4f89227
client: removed .js and .vue extention from imports
Markus Kottlaender <markus@intevation.de>
parents:
2984
diff
changeset
|
37 component: () => import("./components/usermanagement/Usermanagement"), |
278
9c1dfadb53aa
feat: usermanagement - route established and secured
Thomas Junk <thomas.junk@intevation.de>
parents:
165
diff
changeset
|
38 meta: { |
9c1dfadb53aa
feat: usermanagement - route established and secured
Thomas Junk <thomas.junk@intevation.de>
parents:
165
diff
changeset
|
39 requiresAuth: true |
9c1dfadb53aa
feat: usermanagement - route established and secured
Thomas Junk <thomas.junk@intevation.de>
parents:
165
diff
changeset
|
40 }, |
9c1dfadb53aa
feat: usermanagement - route established and secured
Thomas Junk <thomas.junk@intevation.de>
parents:
165
diff
changeset
|
41 beforeEnter: (to, from, next) => { |
285
8e22d1f16f81
refactor: better variable naming
Thomas Junk <thomas.junk@intevation.de>
parents:
284
diff
changeset
|
42 const isSysadmin = store.getters["user/isSysAdmin"]; |
284
96860b2bbc0d
fix: User management only for sysadmin
Thomas Junk <thomas.junk@intevation.de>
parents:
278
diff
changeset
|
43 if (!isSysadmin) { |
2846
b42d10120cad
client: fixed router redirects when not logged in
Markus Kottlaender <markus@intevation.de>
parents:
2825
diff
changeset
|
44 next("/login"); |
278
9c1dfadb53aa
feat: usermanagement - route established and secured
Thomas Junk <thomas.junk@intevation.de>
parents:
165
diff
changeset
|
45 } else { |
9c1dfadb53aa
feat: usermanagement - route established and secured
Thomas Junk <thomas.junk@intevation.de>
parents:
165
diff
changeset
|
46 next(); |
9c1dfadb53aa
feat: usermanagement - route established and secured
Thomas Junk <thomas.junk@intevation.de>
parents:
165
diff
changeset
|
47 } |
9c1dfadb53aa
feat: usermanagement - route established and secured
Thomas Junk <thomas.junk@intevation.de>
parents:
165
diff
changeset
|
48 } |
9c1dfadb53aa
feat: usermanagement - route established and secured
Thomas Junk <thomas.junk@intevation.de>
parents:
165
diff
changeset
|
49 }, |
9c1dfadb53aa
feat: usermanagement - route established and secured
Thomas Junk <thomas.junk@intevation.de>
parents:
165
diff
changeset
|
50 { |
713
badbc0207418
feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents:
592
diff
changeset
|
51 path: "/logs", |
badbc0207418
feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents:
592
diff
changeset
|
52 name: "logs", |
2985
1b8bb4f89227
client: removed .js and .vue extention from imports
Markus Kottlaender <markus@intevation.de>
parents:
2984
diff
changeset
|
53 component: () => import("./components/Logs"), |
713
badbc0207418
feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents:
592
diff
changeset
|
54 meta: { |
badbc0207418
feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents:
592
diff
changeset
|
55 requiresAuth: true |
badbc0207418
feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents:
592
diff
changeset
|
56 }, |
badbc0207418
feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents:
592
diff
changeset
|
57 beforeEnter: (to, from, next) => { |
badbc0207418
feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents:
592
diff
changeset
|
58 const isSysadmin = store.getters["user/isSysAdmin"]; |
badbc0207418
feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents:
592
diff
changeset
|
59 if (!isSysadmin) { |
2846
b42d10120cad
client: fixed router redirects when not logged in
Markus Kottlaender <markus@intevation.de>
parents:
2825
diff
changeset
|
60 next("/login"); |
713
badbc0207418
feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents:
592
diff
changeset
|
61 } else { |
badbc0207418
feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents:
592
diff
changeset
|
62 next(); |
badbc0207418
feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents:
592
diff
changeset
|
63 } |
badbc0207418
feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents:
592
diff
changeset
|
64 } |
badbc0207418
feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents:
592
diff
changeset
|
65 }, |
badbc0207418
feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents:
592
diff
changeset
|
66 { |
853 | 67 path: "/systemconfiguration", |
68 name: "systemconfiguration", | |
2212
733cfc3db48a
started pdf template administration
Markus Kottlaender <markus@intevation.de>
parents:
1801
diff
changeset
|
69 component: () => |
2985
1b8bb4f89227
client: removed .js and .vue extention from imports
Markus Kottlaender <markus@intevation.de>
parents:
2984
diff
changeset
|
70 import("./components/systemconfiguration/Systemconfiguration"), |
853 | 71 meta: { |
72 requiresAuth: true | |
73 }, | |
74 beforeEnter: (to, from, next) => { | |
2277
5f3110aa1ad1
made configuration page accessible for waterway admins
Markus Kottlaender <markus@intevation.de>
parents:
2212
diff
changeset
|
75 const isWaterwayAdmin = store.getters["user/isWaterwayAdmin"]; |
5f3110aa1ad1
made configuration page accessible for waterway admins
Markus Kottlaender <markus@intevation.de>
parents:
2212
diff
changeset
|
76 if (!isWaterwayAdmin) { |
2846
b42d10120cad
client: fixed router redirects when not logged in
Markus Kottlaender <markus@intevation.de>
parents:
2825
diff
changeset
|
77 next("/login"); |
853 | 78 } else { |
79 next(); | |
80 } | |
81 } | |
82 }, | |
83 { | |
6 | 84 path: "/", |
30 | 85 name: "mainview", |
2984
61f69e8919d3
client: prepared splitview
Markus Kottlaender <markus@intevation.de>
parents:
2979
diff
changeset
|
86 component: Main, |
2329
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
87 meta: { |
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
88 requiresAuth: true |
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
89 }, |
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
90 beforeEnter: (to, from, next) => { |
2412 | 91 store.commit("application/searchQuery", ""); |
2329
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
92 store.commit("application/showContextBox", false); |
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
93 store.commit("application/contextBoxContent", ""); |
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
94 store.commit("application/showSearchbar", false); |
3693
10cbf467fd63
client: configuration: load settings beforeEach route but only if not present yet
Markus Kottlaender <markus@intevation.de>
parents:
3680
diff
changeset
|
95 next(); |
2329
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
96 } |
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
97 }, |
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
98 { |
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
99 path: "/bottlenecks", |
2378
c69432c1c4ac
router: fixed frontend routing. renamed routes. changed display according to new route names
Thomas Junk <thomas.junk@intevation.de>
parents:
2329
diff
changeset
|
100 name: "bottlenecks", |
2984
61f69e8919d3
client: prepared splitview
Markus Kottlaender <markus@intevation.de>
parents:
2979
diff
changeset
|
101 component: Main, |
2329
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
102 meta: { |
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
103 requiresAuth: true |
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
104 }, |
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
105 beforeEnter: (to, from, next) => { |
2412 | 106 store.commit("application/searchQuery", ""); |
2329
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
107 store.commit("application/showContextBox", true); |
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
108 store.commit("application/contextBoxContent", "bottlenecks"); |
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
109 store.commit("application/showSearchbar", true); |
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
110 next(); |
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
111 } |
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
112 }, |
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
113 { |
2968 | 114 path: "/imports/configuration", |
115 name: "importconfiguration", | |
2984
61f69e8919d3
client: prepared splitview
Markus Kottlaender <markus@intevation.de>
parents:
2979
diff
changeset
|
116 component: Main, |
2968 | 117 meta: { |
118 requiresAuth: true | |
119 }, | |
120 beforeEnter: (to, from, next) => { | |
121 const isWaterwayAdmin = store.getters["user/isWaterwayAdmin"]; | |
122 if (!isWaterwayAdmin) { | |
123 next("/login"); | |
124 } else { | |
125 store.commit("application/searchQuery", ""); | |
126 store.commit("application/showContextBox", true); | |
127 store.commit("application/contextBoxContent", "importconfiguration"); | |
128 store.commit("application/showSearchbar", true); | |
129 next(); | |
130 } | |
131 } | |
132 }, | |
133 { | |
2399 | 134 path: "/imports/overview/:id?", |
135 name: "importoverview", | |
2984
61f69e8919d3
client: prepared splitview
Markus Kottlaender <markus@intevation.de>
parents:
2979
diff
changeset
|
136 component: Main, |
2399 | 137 meta: { |
138 requiresAuth: true | |
139 }, | |
140 beforeEnter: (to, from, next) => { | |
141 const isWaterwayAdmin = store.getters["user/isWaterwayAdmin"]; | |
142 if (!isWaterwayAdmin) { | |
2846
b42d10120cad
client: fixed router redirects when not logged in
Markus Kottlaender <markus@intevation.de>
parents:
2825
diff
changeset
|
143 next("/login"); |
2399 | 144 } else { |
145 store.commit("application/showContextBox", true); | |
146 store.commit("application/contextBoxContent", "importoverview"); | |
147 store.commit("application/showSearchbar", true); | |
148 next(); | |
149 } | |
150 } | |
151 }, | |
152 { | |
2329
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
153 path: "/stretches", |
2378
c69432c1c4ac
router: fixed frontend routing. renamed routes. changed display according to new route names
Thomas Junk <thomas.junk@intevation.de>
parents:
2329
diff
changeset
|
154 name: "stretches", |
2984
61f69e8919d3
client: prepared splitview
Markus Kottlaender <markus@intevation.de>
parents:
2979
diff
changeset
|
155 component: Main, |
2329
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
156 meta: { |
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
157 requiresAuth: true |
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
158 }, |
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
159 beforeEnter: (to, from, next) => { |
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
160 const isSysadmin = store.getters["user/isSysAdmin"]; |
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
161 if (!isSysadmin) { |
2846
b42d10120cad
client: fixed router redirects when not logged in
Markus Kottlaender <markus@intevation.de>
parents:
2825
diff
changeset
|
162 next("/login"); |
2329
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
163 } else { |
2412 | 164 store.commit("application/searchQuery", ""); |
2329
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
165 store.commit("application/showContextBox", true); |
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
166 store.commit("application/contextBoxContent", "stretches"); |
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
167 store.commit("application/showSearchbar", true); |
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
168 next(); |
514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
Thomas Junk <thomas.junk@intevation.de>
parents:
2328
diff
changeset
|
169 } |
3 | 170 } |
171 }, | |
172 { | |
3298
ec27ee21f7bc
client: define sections: added route and support in context box
Markus Kottlaender <markus@intevation.de>
parents:
3134
diff
changeset
|
173 path: "/sections", |
ec27ee21f7bc
client: define sections: added route and support in context box
Markus Kottlaender <markus@intevation.de>
parents:
3134
diff
changeset
|
174 name: "sections", |
ec27ee21f7bc
client: define sections: added route and support in context box
Markus Kottlaender <markus@intevation.de>
parents:
3134
diff
changeset
|
175 component: Main, |
ec27ee21f7bc
client: define sections: added route and support in context box
Markus Kottlaender <markus@intevation.de>
parents:
3134
diff
changeset
|
176 meta: { |
ec27ee21f7bc
client: define sections: added route and support in context box
Markus Kottlaender <markus@intevation.de>
parents:
3134
diff
changeset
|
177 requiresAuth: true |
ec27ee21f7bc
client: define sections: added route and support in context box
Markus Kottlaender <markus@intevation.de>
parents:
3134
diff
changeset
|
178 }, |
ec27ee21f7bc
client: define sections: added route and support in context box
Markus Kottlaender <markus@intevation.de>
parents:
3134
diff
changeset
|
179 beforeEnter: (to, from, next) => { |
ec27ee21f7bc
client: define sections: added route and support in context box
Markus Kottlaender <markus@intevation.de>
parents:
3134
diff
changeset
|
180 const isWaterwayAdmin = store.getters["user/isWaterwayAdmin"]; |
ec27ee21f7bc
client: define sections: added route and support in context box
Markus Kottlaender <markus@intevation.de>
parents:
3134
diff
changeset
|
181 if (!isWaterwayAdmin) { |
ec27ee21f7bc
client: define sections: added route and support in context box
Markus Kottlaender <markus@intevation.de>
parents:
3134
diff
changeset
|
182 next("/login"); |
ec27ee21f7bc
client: define sections: added route and support in context box
Markus Kottlaender <markus@intevation.de>
parents:
3134
diff
changeset
|
183 } else { |
ec27ee21f7bc
client: define sections: added route and support in context box
Markus Kottlaender <markus@intevation.de>
parents:
3134
diff
changeset
|
184 store.commit("application/searchQuery", ""); |
ec27ee21f7bc
client: define sections: added route and support in context box
Markus Kottlaender <markus@intevation.de>
parents:
3134
diff
changeset
|
185 store.commit("application/showContextBox", true); |
ec27ee21f7bc
client: define sections: added route and support in context box
Markus Kottlaender <markus@intevation.de>
parents:
3134
diff
changeset
|
186 store.commit("application/contextBoxContent", "sections"); |
ec27ee21f7bc
client: define sections: added route and support in context box
Markus Kottlaender <markus@intevation.de>
parents:
3134
diff
changeset
|
187 store.commit("application/showSearchbar", true); |
ec27ee21f7bc
client: define sections: added route and support in context box
Markus Kottlaender <markus@intevation.de>
parents:
3134
diff
changeset
|
188 next(); |
ec27ee21f7bc
client: define sections: added route and support in context box
Markus Kottlaender <markus@intevation.de>
parents:
3134
diff
changeset
|
189 } |
ec27ee21f7bc
client: define sections: added route and support in context box
Markus Kottlaender <markus@intevation.de>
parents:
3134
diff
changeset
|
190 } |
ec27ee21f7bc
client: define sections: added route and support in context box
Markus Kottlaender <markus@intevation.de>
parents:
3134
diff
changeset
|
191 }, |
ec27ee21f7bc
client: define sections: added route and support in context box
Markus Kottlaender <markus@intevation.de>
parents:
3134
diff
changeset
|
192 { |
3134
ab00165540fe
available_fairway_depths: Component made visible
Thomas Junk <thomas.junk@intevation.de>
parents:
2985
diff
changeset
|
193 path: "/fairwaydepth", |
ab00165540fe
available_fairway_depths: Component made visible
Thomas Junk <thomas.junk@intevation.de>
parents:
2985
diff
changeset
|
194 name: "fairwaydepth", |
ab00165540fe
available_fairway_depths: Component made visible
Thomas Junk <thomas.junk@intevation.de>
parents:
2985
diff
changeset
|
195 component: () => import("./components/fairway/AvailableFairwayDepth"), |
ab00165540fe
available_fairway_depths: Component made visible
Thomas Junk <thomas.junk@intevation.de>
parents:
2985
diff
changeset
|
196 meta: { |
ab00165540fe
available_fairway_depths: Component made visible
Thomas Junk <thomas.junk@intevation.de>
parents:
2985
diff
changeset
|
197 requiresAuth: true |
ab00165540fe
available_fairway_depths: Component made visible
Thomas Junk <thomas.junk@intevation.de>
parents:
2985
diff
changeset
|
198 } |
ab00165540fe
available_fairway_depths: Component made visible
Thomas Junk <thomas.junk@intevation.de>
parents:
2985
diff
changeset
|
199 }, |
ab00165540fe
available_fairway_depths: Component made visible
Thomas Junk <thomas.junk@intevation.de>
parents:
2985
diff
changeset
|
200 { |
3 | 201 path: "*", |
2985
1b8bb4f89227
client: removed .js and .vue extention from imports
Markus Kottlaender <markus@intevation.de>
parents:
2984
diff
changeset
|
202 component: () => import("./components/PageNotFound") |
3 | 203 } |
204 ] | |
205 }); | |
206 | |
207 router.beforeEach((to, from, next) => { | |
165
4bf2173748f3
refactor: extracted the string to milisecondconversion
Thomas Junk <thomas.junk@intevation.de>
parents:
162
diff
changeset
|
208 const expiresFromPastSession = toMillisFromString( |
4bf2173748f3
refactor: extracted the string to milisecondconversion
Thomas Junk <thomas.junk@intevation.de>
parents:
162
diff
changeset
|
209 localStorage.getItem("expires") |
4bf2173748f3
refactor: extracted the string to milisecondconversion
Thomas Junk <thomas.junk@intevation.de>
parents:
162
diff
changeset
|
210 ); |
2328
c98491f9c466
router: cleanup auth code
Thomas Junk <thomas.junk@intevation.de>
parents:
2277
diff
changeset
|
211 if (sessionStillActive(expiresFromPastSession)) { |
c98491f9c466
router: cleanup auth code
Thomas Junk <thomas.junk@intevation.de>
parents:
2277
diff
changeset
|
212 store.commit("user/setUser", localStorage.getItem("user")); |
c98491f9c466
router: cleanup auth code
Thomas Junk <thomas.junk@intevation.de>
parents:
2277
diff
changeset
|
213 store.commit("user/setExpires", expiresFromPastSession); |
c98491f9c466
router: cleanup auth code
Thomas Junk <thomas.junk@intevation.de>
parents:
2277
diff
changeset
|
214 store.commit("user/setRoles", localStorage.getItem("roles")); |
c98491f9c466
router: cleanup auth code
Thomas Junk <thomas.junk@intevation.de>
parents:
2277
diff
changeset
|
215 store.commit("user/setIsAuthenticate", true); |
3693
10cbf467fd63
client: configuration: load settings beforeEach route but only if not present yet
Markus Kottlaender <markus@intevation.de>
parents:
3680
diff
changeset
|
216 // load settings only if not present yet |
10cbf467fd63
client: configuration: load settings beforeEach route but only if not present yet
Markus Kottlaender <markus@intevation.de>
parents:
3680
diff
changeset
|
217 if (Object.keys(store.state.application.config).length) { |
10cbf467fd63
client: configuration: load settings beforeEach route but only if not present yet
Markus Kottlaender <markus@intevation.de>
parents:
3680
diff
changeset
|
218 next(); |
10cbf467fd63
client: configuration: load settings beforeEach route but only if not present yet
Markus Kottlaender <markus@intevation.de>
parents:
3680
diff
changeset
|
219 } else { |
10cbf467fd63
client: configuration: load settings beforeEach route but only if not present yet
Markus Kottlaender <markus@intevation.de>
parents:
3680
diff
changeset
|
220 store.dispatch("application/loadConfig").then(() => next()); |
10cbf467fd63
client: configuration: load settings beforeEach route but only if not present yet
Markus Kottlaender <markus@intevation.de>
parents:
3680
diff
changeset
|
221 } |
2328
c98491f9c466
router: cleanup auth code
Thomas Junk <thomas.junk@intevation.de>
parents:
2277
diff
changeset
|
222 } else { |
c98491f9c466
router: cleanup auth code
Thomas Junk <thomas.junk@intevation.de>
parents:
2277
diff
changeset
|
223 store.commit("reset"); |
c98491f9c466
router: cleanup auth code
Thomas Junk <thomas.junk@intevation.de>
parents:
2277
diff
changeset
|
224 store.commit("user/clearAuth"); |
3693
10cbf467fd63
client: configuration: load settings beforeEach route but only if not present yet
Markus Kottlaender <markus@intevation.de>
parents:
3680
diff
changeset
|
225 const requiresAuth = to.matched.some(record => record.meta.requiresAuth); |
10cbf467fd63
client: configuration: load settings beforeEach route but only if not present yet
Markus Kottlaender <markus@intevation.de>
parents:
3680
diff
changeset
|
226 const redirectToLogin = requiresAuth && !store.state.user.isAuthenticated; |
10cbf467fd63
client: configuration: load settings beforeEach route but only if not present yet
Markus Kottlaender <markus@intevation.de>
parents:
3680
diff
changeset
|
227 if (redirectToLogin) { |
10cbf467fd63
client: configuration: load settings beforeEach route but only if not present yet
Markus Kottlaender <markus@intevation.de>
parents:
3680
diff
changeset
|
228 localStorage.setItem("tempRoute", to.path); |
10cbf467fd63
client: configuration: load settings beforeEach route but only if not present yet
Markus Kottlaender <markus@intevation.de>
parents:
3680
diff
changeset
|
229 next("/login"); |
10cbf467fd63
client: configuration: load settings beforeEach route but only if not present yet
Markus Kottlaender <markus@intevation.de>
parents:
3680
diff
changeset
|
230 } else { |
10cbf467fd63
client: configuration: load settings beforeEach route but only if not present yet
Markus Kottlaender <markus@intevation.de>
parents:
3680
diff
changeset
|
231 next(); |
10cbf467fd63
client: configuration: load settings beforeEach route but only if not present yet
Markus Kottlaender <markus@intevation.de>
parents:
3680
diff
changeset
|
232 } |
3 | 233 } |
234 }); | |
235 | |
236 export default router; |