Mercurial > gemma
annotate client/src/router.js @ 2212:733cfc3db48a pdf-export
started pdf template administration
moved templates to vuex store, to have them available in pdf box and systen configuration.
author | Markus Kottlaender <markus@intevation.de> |
---|---|
date | Wed, 06 Feb 2019 16:19:16 +0100 |
parents | 11669276e197 |
children | 5f3110aa1ad1 |
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 */ |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
1244
diff
changeset
|
22 const Login = () => import("./components/Login.vue"); |
466
e3035621cc52
refac: Small improvement of loading time with code splitting
Thomas Junk <thomas.junk@intevation.de>
parents:
285
diff
changeset
|
23 |
3 | 24 Vue.use(Router); |
25 | |
26 const router = new Router({ | |
27 routes: [ | |
28 { | |
6 | 29 path: "/login", |
3 | 30 name: "login", |
31 component: Login | |
32 }, | |
33 { | |
581 | 34 path: "/usermanagement", |
35 name: "usermanagement", | |
1671
89b38d7e7b6a
included bundleanalyzer buildstep
Thomas Junk <thomas.junk@intevation.de>
parents:
1610
diff
changeset
|
36 component: () => import("./components/usermanagement/Usermanagement.vue"), |
278
9c1dfadb53aa
feat: usermanagement - route established and secured
Thomas Junk <thomas.junk@intevation.de>
parents:
165
diff
changeset
|
37 meta: { |
9c1dfadb53aa
feat: usermanagement - route established and secured
Thomas Junk <thomas.junk@intevation.de>
parents:
165
diff
changeset
|
38 requiresAuth: true |
9c1dfadb53aa
feat: usermanagement - route established and secured
Thomas Junk <thomas.junk@intevation.de>
parents:
165
diff
changeset
|
39 }, |
9c1dfadb53aa
feat: usermanagement - route established and secured
Thomas Junk <thomas.junk@intevation.de>
parents:
165
diff
changeset
|
40 beforeEnter: (to, from, next) => { |
285
8e22d1f16f81
refactor: better variable naming
Thomas Junk <thomas.junk@intevation.de>
parents:
284
diff
changeset
|
41 const isSysadmin = store.getters["user/isSysAdmin"]; |
284
96860b2bbc0d
fix: User management only for sysadmin
Thomas Junk <thomas.junk@intevation.de>
parents:
278
diff
changeset
|
42 if (!isSysadmin) { |
278
9c1dfadb53aa
feat: usermanagement - route established and secured
Thomas Junk <thomas.junk@intevation.de>
parents:
165
diff
changeset
|
43 next("/"); |
9c1dfadb53aa
feat: usermanagement - route established and secured
Thomas Junk <thomas.junk@intevation.de>
parents:
165
diff
changeset
|
44 } else { |
9c1dfadb53aa
feat: usermanagement - route established and secured
Thomas Junk <thomas.junk@intevation.de>
parents:
165
diff
changeset
|
45 next(); |
9c1dfadb53aa
feat: usermanagement - route established and secured
Thomas Junk <thomas.junk@intevation.de>
parents:
165
diff
changeset
|
46 } |
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 { |
713
badbc0207418
feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents:
592
diff
changeset
|
50 path: "/logs", |
badbc0207418
feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents:
592
diff
changeset
|
51 name: "logs", |
1671
89b38d7e7b6a
included bundleanalyzer buildstep
Thomas Junk <thomas.junk@intevation.de>
parents:
1610
diff
changeset
|
52 component: () => import("./components/Logs.vue"), |
713
badbc0207418
feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents:
592
diff
changeset
|
53 meta: { |
badbc0207418
feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents:
592
diff
changeset
|
54 requiresAuth: true |
badbc0207418
feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents:
592
diff
changeset
|
55 }, |
badbc0207418
feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents:
592
diff
changeset
|
56 beforeEnter: (to, from, next) => { |
badbc0207418
feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents:
592
diff
changeset
|
57 const isSysadmin = store.getters["user/isSysAdmin"]; |
badbc0207418
feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents:
592
diff
changeset
|
58 if (!isSysadmin) { |
badbc0207418
feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents:
592
diff
changeset
|
59 next("/"); |
badbc0207418
feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents:
592
diff
changeset
|
60 } else { |
badbc0207418
feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents:
592
diff
changeset
|
61 next(); |
badbc0207418
feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents:
592
diff
changeset
|
62 } |
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 { |
853 | 66 path: "/systemconfiguration", |
67 name: "systemconfiguration", | |
2212
733cfc3db48a
started pdf template administration
Markus Kottlaender <markus@intevation.de>
parents:
1801
diff
changeset
|
68 component: () => |
733cfc3db48a
started pdf template administration
Markus Kottlaender <markus@intevation.de>
parents:
1801
diff
changeset
|
69 import("./components/systemconfiguration/Systemconfiguration.vue"), |
853 | 70 meta: { |
71 requiresAuth: true | |
72 }, | |
73 beforeEnter: (to, from, next) => { | |
74 const isSysadmin = store.getters["user/isSysAdmin"]; | |
75 if (!isSysadmin) { | |
76 next("/"); | |
77 } else { | |
78 next(); | |
79 } | |
80 } | |
81 }, | |
82 { | |
1173 | 83 path: "/importqueue", |
1801
11669276e197
renamed pathname importqueue
Thomas Junk <thomas.junk@intevation.de>
parents:
1797
diff
changeset
|
84 name: "importqueues", |
1671
89b38d7e7b6a
included bundleanalyzer buildstep
Thomas Junk <thomas.junk@intevation.de>
parents:
1610
diff
changeset
|
85 component: () => import("./components/importqueue/Importqueue.vue"), |
1173 | 86 meta: { |
87 requiresAuth: true | |
88 }, | |
89 beforeEnter: (to, from, next) => { | |
1429
f4b3fb43b311
automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents:
1363
diff
changeset
|
90 const isWaterwayAdmin = store.getters["user/isWaterwayAdmin"]; |
f4b3fb43b311
automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents:
1363
diff
changeset
|
91 if (!isWaterwayAdmin) { |
f4b3fb43b311
automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents:
1363
diff
changeset
|
92 next("/"); |
f4b3fb43b311
automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents:
1363
diff
changeset
|
93 } else { |
f4b3fb43b311
automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents:
1363
diff
changeset
|
94 next(); |
f4b3fb43b311
automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents:
1363
diff
changeset
|
95 } |
f4b3fb43b311
automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents:
1363
diff
changeset
|
96 } |
f4b3fb43b311
automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents:
1363
diff
changeset
|
97 }, |
f4b3fb43b311
automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents:
1363
diff
changeset
|
98 { |
1793
c0532a94a0b5
importlog links forward to the according importqueue-entry
Thomas Junk <thomas.junk@intevation.de>
parents:
1753
diff
changeset
|
99 path: "/importqueue/:id", |
c0532a94a0b5
importlog links forward to the according importqueue-entry
Thomas Junk <thomas.junk@intevation.de>
parents:
1753
diff
changeset
|
100 name: "importqueue", |
c0532a94a0b5
importlog links forward to the according importqueue-entry
Thomas Junk <thomas.junk@intevation.de>
parents:
1753
diff
changeset
|
101 component: () => import("./components/importqueue/Importqueue.vue"), |
c0532a94a0b5
importlog links forward to the according importqueue-entry
Thomas Junk <thomas.junk@intevation.de>
parents:
1753
diff
changeset
|
102 meta: { |
c0532a94a0b5
importlog links forward to the according importqueue-entry
Thomas Junk <thomas.junk@intevation.de>
parents:
1753
diff
changeset
|
103 requiresAuth: true |
c0532a94a0b5
importlog links forward to the according importqueue-entry
Thomas Junk <thomas.junk@intevation.de>
parents:
1753
diff
changeset
|
104 }, |
c0532a94a0b5
importlog links forward to the according importqueue-entry
Thomas Junk <thomas.junk@intevation.de>
parents:
1753
diff
changeset
|
105 beforeEnter: (to, from, next) => { |
c0532a94a0b5
importlog links forward to the according importqueue-entry
Thomas Junk <thomas.junk@intevation.de>
parents:
1753
diff
changeset
|
106 const isWaterwayAdmin = store.getters["user/isWaterwayAdmin"]; |
c0532a94a0b5
importlog links forward to the according importqueue-entry
Thomas Junk <thomas.junk@intevation.de>
parents:
1753
diff
changeset
|
107 if (!isWaterwayAdmin) { |
c0532a94a0b5
importlog links forward to the according importqueue-entry
Thomas Junk <thomas.junk@intevation.de>
parents:
1753
diff
changeset
|
108 next("/"); |
c0532a94a0b5
importlog links forward to the according importqueue-entry
Thomas Junk <thomas.junk@intevation.de>
parents:
1753
diff
changeset
|
109 } else { |
c0532a94a0b5
importlog links forward to the according importqueue-entry
Thomas Junk <thomas.junk@intevation.de>
parents:
1753
diff
changeset
|
110 next(); |
c0532a94a0b5
importlog links forward to the according importqueue-entry
Thomas Junk <thomas.junk@intevation.de>
parents:
1753
diff
changeset
|
111 } |
c0532a94a0b5
importlog links forward to the according importqueue-entry
Thomas Junk <thomas.junk@intevation.de>
parents:
1753
diff
changeset
|
112 } |
c0532a94a0b5
importlog links forward to the according importqueue-entry
Thomas Junk <thomas.junk@intevation.de>
parents:
1753
diff
changeset
|
113 }, |
c0532a94a0b5
importlog links forward to the according importqueue-entry
Thomas Junk <thomas.junk@intevation.de>
parents:
1753
diff
changeset
|
114 { |
1607
38f91897ca69
import sounding result in new section
Thomas Junk <thomas.junk@intevation.de>
parents:
1559
diff
changeset
|
115 path: "/importsoundingresults", |
38f91897ca69
import sounding result in new section
Thomas Junk <thomas.junk@intevation.de>
parents:
1559
diff
changeset
|
116 name: "importsoundingresults", |
1671
89b38d7e7b6a
included bundleanalyzer buildstep
Thomas Junk <thomas.junk@intevation.de>
parents:
1610
diff
changeset
|
117 component: () => import("./components/ImportSoundingresults.vue"), |
1607
38f91897ca69
import sounding result in new section
Thomas Junk <thomas.junk@intevation.de>
parents:
1559
diff
changeset
|
118 meta: { |
38f91897ca69
import sounding result in new section
Thomas Junk <thomas.junk@intevation.de>
parents:
1559
diff
changeset
|
119 requiresAuth: true |
38f91897ca69
import sounding result in new section
Thomas Junk <thomas.junk@intevation.de>
parents:
1559
diff
changeset
|
120 }, |
38f91897ca69
import sounding result in new section
Thomas Junk <thomas.junk@intevation.de>
parents:
1559
diff
changeset
|
121 beforeEnter: (to, from, next) => { |
38f91897ca69
import sounding result in new section
Thomas Junk <thomas.junk@intevation.de>
parents:
1559
diff
changeset
|
122 const isWaterwayAdmin = store.getters["user/isWaterwayAdmin"]; |
38f91897ca69
import sounding result in new section
Thomas Junk <thomas.junk@intevation.de>
parents:
1559
diff
changeset
|
123 if (!isWaterwayAdmin) { |
38f91897ca69
import sounding result in new section
Thomas Junk <thomas.junk@intevation.de>
parents:
1559
diff
changeset
|
124 next("/"); |
38f91897ca69
import sounding result in new section
Thomas Junk <thomas.junk@intevation.de>
parents:
1559
diff
changeset
|
125 } else { |
38f91897ca69
import sounding result in new section
Thomas Junk <thomas.junk@intevation.de>
parents:
1559
diff
changeset
|
126 next(); |
38f91897ca69
import sounding result in new section
Thomas Junk <thomas.junk@intevation.de>
parents:
1559
diff
changeset
|
127 } |
38f91897ca69
import sounding result in new section
Thomas Junk <thomas.junk@intevation.de>
parents:
1559
diff
changeset
|
128 } |
38f91897ca69
import sounding result in new section
Thomas Junk <thomas.junk@intevation.de>
parents:
1559
diff
changeset
|
129 }, |
38f91897ca69
import sounding result in new section
Thomas Junk <thomas.junk@intevation.de>
parents:
1559
diff
changeset
|
130 { |
1753
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
131 path: "/importwaterwayprofiles", |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
132 name: "waterwayprofiles", |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
133 component: () => import("./components/ImportWaterwayProfiles"), |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
134 meta: { |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
135 requiresAuth: true |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
136 }, |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
137 beforeEnter: (to, from, next) => { |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
138 const isWaterwayAdmin = store.getters["user/isWaterwayAdmin"]; |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
139 if (!isWaterwayAdmin) { |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
140 next("/"); |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
141 } else { |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
142 next(); |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
143 } |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
144 } |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
145 }, |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
146 { |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
147 path: "/importapprovedgaugemeasurement", |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
148 name: "approvedgaugemeasurement", |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
149 component: () => import("./components/ImportApprovedGaugeMeasurement"), |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
150 meta: { |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
151 requiresAuth: true |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
152 }, |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
153 beforeEnter: (to, from, next) => { |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
154 const isWaterwayAdmin = store.getters["user/isWaterwayAdmin"]; |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
155 if (!isWaterwayAdmin) { |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
156 next("/"); |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
157 } else { |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
158 next(); |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
159 } |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
160 } |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
161 }, |
68bd990dd8e5
feat: added import dialogs for approved gauge meas. and waterway profiles
Thomas Junk <thomas.junk@intevation.de>
parents:
1671
diff
changeset
|
162 { |
1429
f4b3fb43b311
automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents:
1363
diff
changeset
|
163 path: "/importschedule", |
f4b3fb43b311
automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents:
1363
diff
changeset
|
164 name: "importschedule", |
1671
89b38d7e7b6a
included bundleanalyzer buildstep
Thomas Junk <thomas.junk@intevation.de>
parents:
1610
diff
changeset
|
165 component: () => import("./components/importschedule/Importschedule.vue"), |
1429
f4b3fb43b311
automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents:
1363
diff
changeset
|
166 meta: { |
f4b3fb43b311
automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents:
1363
diff
changeset
|
167 requiresAuth: true |
f4b3fb43b311
automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents:
1363
diff
changeset
|
168 }, |
f4b3fb43b311
automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents:
1363
diff
changeset
|
169 beforeEnter: (to, from, next) => { |
f4b3fb43b311
automatic imports WIP added
Thomas Junk <thomas.junk@intevation.de>
parents:
1363
diff
changeset
|
170 const isWaterwayAdmin = store.getters["user/isWaterwayAdmin"]; |
1173 | 171 if (!isWaterwayAdmin) { |
1142
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
1122
diff
changeset
|
172 next("/"); |
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
1122
diff
changeset
|
173 } else { |
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
1122
diff
changeset
|
174 next(); |
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
1122
diff
changeset
|
175 } |
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
1122
diff
changeset
|
176 } |
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
1122
diff
changeset
|
177 }, |
dc3f0277628a
feat: Importqueue listing (Proof of concept)
Thomas Junk <thomas.junk@intevation.de>
parents:
1122
diff
changeset
|
178 { |
6 | 179 path: "/", |
30 | 180 name: "mainview", |
1671
89b38d7e7b6a
included bundleanalyzer buildstep
Thomas Junk <thomas.junk@intevation.de>
parents:
1610
diff
changeset
|
181 component: () => import("./components/Main.vue"), |
3 | 182 meta: { |
183 requiresAuth: true | |
160
061209505028
feat: Login and logout with session restoration implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
30
diff
changeset
|
184 }, |
061209505028
feat: Login and logout with session restoration implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
30
diff
changeset
|
185 beforeEnter: (to, from, next) => { |
165
4bf2173748f3
refactor: extracted the string to milisecondconversion
Thomas Junk <thomas.junk@intevation.de>
parents:
162
diff
changeset
|
186 const expiresFromPastSession = toMillisFromString( |
4bf2173748f3
refactor: extracted the string to milisecondconversion
Thomas Junk <thomas.junk@intevation.de>
parents:
162
diff
changeset
|
187 localStorage.getItem("expires") |
4bf2173748f3
refactor: extracted the string to milisecondconversion
Thomas Junk <thomas.junk@intevation.de>
parents:
162
diff
changeset
|
188 ); |
162
9908260d1e6a
Refactor: Login expiry refactored to lib
Thomas Junk <thomas.junk@intevation.de>
parents:
160
diff
changeset
|
189 if (sessionStillActive(expiresFromPastSession)) { |
1122
a4c74a95c177
minor store refactoring
Markus Kottlaender <markus@intevation.de>
parents:
1019
diff
changeset
|
190 store.commit("user/setUser", localStorage.getItem("user")); |
a4c74a95c177
minor store refactoring
Markus Kottlaender <markus@intevation.de>
parents:
1019
diff
changeset
|
191 store.commit("user/setExpires", expiresFromPastSession); |
a4c74a95c177
minor store refactoring
Markus Kottlaender <markus@intevation.de>
parents:
1019
diff
changeset
|
192 store.commit("user/setRoles", localStorage.getItem("roles")); |
a4c74a95c177
minor store refactoring
Markus Kottlaender <markus@intevation.de>
parents:
1019
diff
changeset
|
193 store.commit("user/setIsAuthenticate", true); |
162
9908260d1e6a
Refactor: Login expiry refactored to lib
Thomas Junk <thomas.junk@intevation.de>
parents:
160
diff
changeset
|
194 } else { |
1296
99c039e86624
replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents:
1276
diff
changeset
|
195 store.commit("reset"); |
1122
a4c74a95c177
minor store refactoring
Markus Kottlaender <markus@intevation.de>
parents:
1019
diff
changeset
|
196 store.commit("user/clearAuth"); |
160
061209505028
feat: Login and logout with session restoration implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
30
diff
changeset
|
197 } |
061209505028
feat: Login and logout with session restoration implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
30
diff
changeset
|
198 next(); |
3 | 199 } |
200 }, | |
201 { | |
202 path: "*", | |
203 component: Login | |
204 } | |
205 ] | |
206 }); | |
207 | |
208 router.beforeEach((to, from, next) => { | |
209 const requiresAuth = to.matched.some(record => record.meta.requiresAuth); | |
1122
a4c74a95c177
minor store refactoring
Markus Kottlaender <markus@intevation.de>
parents:
1019
diff
changeset
|
210 const loggedIn = store.state.user.isAuthenticated; |
165
4bf2173748f3
refactor: extracted the string to milisecondconversion
Thomas Junk <thomas.junk@intevation.de>
parents:
162
diff
changeset
|
211 const expiresFromPastSession = toMillisFromString( |
4bf2173748f3
refactor: extracted the string to milisecondconversion
Thomas Junk <thomas.junk@intevation.de>
parents:
162
diff
changeset
|
212 localStorage.getItem("expires") |
4bf2173748f3
refactor: extracted the string to milisecondconversion
Thomas Junk <thomas.junk@intevation.de>
parents:
162
diff
changeset
|
213 ); |
162
9908260d1e6a
Refactor: Login expiry refactored to lib
Thomas Junk <thomas.junk@intevation.de>
parents:
160
diff
changeset
|
214 const authRequired = |
9908260d1e6a
Refactor: Login expiry refactored to lib
Thomas Junk <thomas.junk@intevation.de>
parents:
160
diff
changeset
|
215 requiresAuth && !(loggedIn || sessionStillActive(expiresFromPastSession)); |
9908260d1e6a
Refactor: Login expiry refactored to lib
Thomas Junk <thomas.junk@intevation.de>
parents:
160
diff
changeset
|
216 if (authRequired) { |
6 | 217 next("/login"); |
162
9908260d1e6a
Refactor: Login expiry refactored to lib
Thomas Junk <thomas.junk@intevation.de>
parents:
160
diff
changeset
|
218 } else if (!authRequired) { |
3 | 219 next(); |
220 } else { | |
221 next(); | |
222 } | |
223 }); | |
224 | |
225 export default router; |