2019-12-20 13:01:36 +00:00
|
|
|
import Vue from 'vue'
|
|
|
|
import VueRouter from 'vue-router'
|
2020-01-14 21:01:24 +00:00
|
|
|
import FinanzerView from '@/views/FinanzerView'
|
|
|
|
import Login from '@/views/Login'
|
|
|
|
import store from '@/store/index'
|
2020-01-17 00:01:10 +00:00
|
|
|
import GeruechteView from '../views/contents/GeruechteView'
|
|
|
|
import AddAmount from '../components/user/AddAmount'
|
|
|
|
import CreditOverview from '../components/user/CreditOverview'
|
|
|
|
import MainView from '../views/MainView'
|
|
|
|
import UserView from '../views/UserView'
|
|
|
|
import BarView from '../views/BarView'
|
2020-01-17 21:11:19 +00:00
|
|
|
import UserNavigation from '../components/user/UserNavigation'
|
|
|
|
import BarNavigation from '../components/baruser/BarNavigation'
|
|
|
|
import FinanzerNavigation from '../components/finanzer/FinanzerNavigation'
|
|
|
|
import Overview from '../components/finanzer/Overview'
|
|
|
|
import User from '../components/finanzer/User'
|
2020-01-18 11:49:49 +00:00
|
|
|
import ServiceManagement from '../components/vorstand/ServiceManagement'
|
2020-02-16 19:35:13 +00:00
|
|
|
import Config from '@/components/user/Config'
|
|
|
|
import Jobs from '@/components/user/Jobs'
|
2020-03-01 18:18:58 +00:00
|
|
|
import PriceList from '@/components/pricelist/PriceList'
|
2020-03-05 20:16:47 +00:00
|
|
|
import ManagementNavigation from '@/components/vorstand/ManagementNavigation'
|
|
|
|
import GastroNavigation from '@/components/gastro/GastroNavigation'
|
|
|
|
import PriceListView from '@/views/contents/PriceListView'
|
|
|
|
import UserManager from '@/components/vorstand/UserManager'
|
2020-06-05 20:50:10 +00:00
|
|
|
import WorkgroupManagement from '@/components/vorstand/WorkgroupManagement'
|
|
|
|
import JobKindManager from '@/components/vorstand/JobKindManager'
|
|
|
|
import JobsRequest from '@/components/user/JobsRequest'
|
2019-12-20 13:01:36 +00:00
|
|
|
|
|
|
|
Vue.use(VueRouter)
|
|
|
|
|
2020-05-27 10:09:54 +00:00
|
|
|
const rootPath = ''
|
|
|
|
|
2019-12-20 13:01:36 +00:00
|
|
|
const routes = [
|
2020-03-04 22:10:18 +00:00
|
|
|
{
|
2020-05-27 10:09:54 +00:00
|
|
|
path: rootPath + '/cookies',
|
2020-03-05 20:16:47 +00:00
|
|
|
name: 'cookies'
|
2020-03-04 22:10:18 +00:00
|
|
|
},
|
2020-02-27 20:54:28 +00:00
|
|
|
{
|
2020-05-27 10:09:54 +00:00
|
|
|
path: rootPath + '/pricelist',
|
2020-02-27 20:54:28 +00:00
|
|
|
name: 'priceListNoLogin',
|
2020-03-01 18:18:58 +00:00
|
|
|
component: PriceListView
|
2020-02-27 20:54:28 +00:00
|
|
|
},
|
2019-12-20 13:01:36 +00:00
|
|
|
{
|
2020-05-27 10:09:54 +00:00
|
|
|
path: rootPath + '/login',
|
2020-01-14 21:01:24 +00:00
|
|
|
name: 'login',
|
2019-12-21 07:20:25 +00:00
|
|
|
component: Login
|
2019-12-20 13:01:36 +00:00
|
|
|
},
|
2019-12-21 07:20:25 +00:00
|
|
|
{
|
2020-05-27 10:09:54 +00:00
|
|
|
path: rootPath + '/main',
|
2020-01-17 00:01:10 +00:00
|
|
|
name: 'main',
|
|
|
|
component: MainView,
|
|
|
|
children: [
|
2020-03-01 18:18:58 +00:00
|
|
|
{
|
|
|
|
path: 'management',
|
|
|
|
name: 'management',
|
2020-03-05 20:16:47 +00:00
|
|
|
components: { nav: ManagementNavigation, default: BarView },
|
2020-03-01 18:18:58 +00:00
|
|
|
children: [
|
|
|
|
{
|
2020-05-24 21:24:58 +00:00
|
|
|
name: 'serviceManagement',
|
|
|
|
path: 'servicemanagement/:year/:month',
|
2020-03-01 18:18:58 +00:00
|
|
|
component: ServiceManagement
|
2020-03-03 21:29:32 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: 'usermanager',
|
2020-05-27 10:09:54 +00:00
|
|
|
name: 'userManager',
|
2020-03-03 21:29:32 +00:00
|
|
|
component: UserManager
|
2020-05-16 21:24:14 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: 'workgroupmanagement',
|
2020-05-27 10:09:54 +00:00
|
|
|
name: 'workgroupManagement',
|
2020-05-16 21:24:14 +00:00
|
|
|
component: WorkgroupManagement
|
2020-05-17 18:22:03 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: 'jobkindmanagement',
|
2020-05-27 10:09:54 +00:00
|
|
|
name: 'jobkindManagement',
|
2020-05-17 18:22:03 +00:00
|
|
|
component: JobKindManager
|
2020-03-01 18:18:58 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2020-01-17 00:01:10 +00:00
|
|
|
{
|
|
|
|
path: 'user',
|
|
|
|
name: 'user',
|
2020-03-01 18:18:58 +00:00
|
|
|
components: { nav: UserNavigation, default: UserView },
|
2020-01-17 00:01:10 +00:00
|
|
|
children: [
|
|
|
|
{
|
|
|
|
path: 'add',
|
|
|
|
name: 'add',
|
|
|
|
component: AddAmount
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: 'overview',
|
|
|
|
name: 'userOverview',
|
|
|
|
component: CreditOverview
|
2020-01-26 22:55:59 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: 'config',
|
|
|
|
name: 'userConfig',
|
|
|
|
component: Config
|
2020-01-27 18:56:56 +00:00
|
|
|
},
|
|
|
|
{
|
2020-05-24 21:24:58 +00:00
|
|
|
path: 'jobs/:year/:month',
|
2020-01-27 18:56:56 +00:00
|
|
|
name: 'userJobs',
|
|
|
|
component: Jobs
|
2020-02-25 21:34:45 +00:00
|
|
|
},
|
|
|
|
{
|
2020-05-27 10:09:54 +00:00
|
|
|
path: 'jobRequests/:kind',
|
2020-02-25 21:34:45 +00:00
|
|
|
name: 'jobRequests',
|
2020-05-27 10:09:54 +00:00
|
|
|
component: JobsRequest
|
2020-01-17 00:01:10 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: 'bar',
|
|
|
|
name: 'bar',
|
2020-03-01 18:18:58 +00:00
|
|
|
components: { nav: BarNavigation, default: BarView },
|
2020-01-17 00:01:10 +00:00
|
|
|
children: [
|
|
|
|
{
|
|
|
|
path: 'geruecht',
|
|
|
|
name: 'geruecht',
|
|
|
|
component: GeruechteView
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: 'finanzer',
|
|
|
|
name: 'finanzer',
|
2020-03-01 18:18:58 +00:00
|
|
|
components: { default: FinanzerView, nav: FinanzerNavigation },
|
2020-01-17 21:11:19 +00:00
|
|
|
children: [
|
|
|
|
{
|
|
|
|
path: 'overview',
|
2020-05-27 10:09:54 +00:00
|
|
|
name: 'overview',
|
2020-01-17 21:11:19 +00:00
|
|
|
component: Overview
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: 'user/:id',
|
|
|
|
name: 'activeUser',
|
|
|
|
props: true,
|
|
|
|
component: User
|
2020-03-01 18:18:58 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: 'gastro',
|
|
|
|
name: 'gastro',
|
2020-03-05 20:16:47 +00:00
|
|
|
components: { nav: GastroNavigation, default: BarView },
|
2020-03-01 18:18:58 +00:00
|
|
|
children: [
|
2020-01-18 11:49:49 +00:00
|
|
|
{
|
2020-03-01 18:18:58 +00:00
|
|
|
path: 'pricelist',
|
|
|
|
name: 'gastroPricelist',
|
|
|
|
component: PriceList
|
2020-01-17 21:11:19 +00:00
|
|
|
}
|
|
|
|
]
|
2020-01-17 00:01:10 +00:00
|
|
|
}
|
|
|
|
]
|
2019-12-21 07:20:25 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '*',
|
|
|
|
redirect: {
|
2020-01-14 21:01:24 +00:00
|
|
|
name: 'login'
|
2019-12-21 07:20:25 +00:00
|
|
|
}
|
2020-01-14 21:01:24 +00:00
|
|
|
}
|
2019-12-20 13:01:36 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
const router = new VueRouter({
|
2019-12-21 07:20:25 +00:00
|
|
|
mode: 'history',
|
|
|
|
base: process.env.BASE_URL,
|
2019-12-20 13:01:36 +00:00
|
|
|
routes
|
|
|
|
})
|
|
|
|
|
2019-12-21 07:20:25 +00:00
|
|
|
router.beforeEach((to, from, next) => {
|
2020-01-14 21:01:24 +00:00
|
|
|
store.dispatch('fetchAccessToken')
|
2020-01-17 00:01:10 +00:00
|
|
|
if (to.fullPath.includes('/main')) {
|
|
|
|
if (to.fullPath.includes('/main/finanzer')) {
|
2020-01-05 22:39:30 +00:00
|
|
|
if (!store.state.login.user.group.includes('moneymaster')) {
|
2019-12-26 09:31:36 +00:00
|
|
|
next('/login')
|
|
|
|
}
|
|
|
|
}
|
2020-01-17 00:01:10 +00:00
|
|
|
if (to.fullPath.includes('/main/bar')) {
|
2020-01-05 22:39:30 +00:00
|
|
|
if (!store.state.login.user.group.includes('bar')) {
|
2019-12-26 09:31:36 +00:00
|
|
|
next('/login')
|
|
|
|
}
|
|
|
|
}
|
2020-01-17 00:01:10 +00:00
|
|
|
if (to.fullPath.includes('/main/user')) {
|
|
|
|
if (!store.state.login.user.group.includes('user')) {
|
|
|
|
next('/login')
|
|
|
|
}
|
|
|
|
}
|
2020-01-05 22:39:30 +00:00
|
|
|
if (!store.state.login.user.accessToken) {
|
2019-12-21 07:20:25 +00:00
|
|
|
next('/login')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (to.fullPath === '/login') {
|
2020-01-05 22:39:30 +00:00
|
|
|
if (store.state.login.user.accessToken) {
|
|
|
|
if (store.state.login.user.group.includes('moneymaster')) {
|
2020-02-27 21:19:31 +00:00
|
|
|
next('/main/finanzer/overview')
|
2020-01-05 22:39:30 +00:00
|
|
|
} else if (store.state.login.user.group.includes('bar')) {
|
2020-01-17 00:01:10 +00:00
|
|
|
next('/main/bar/geruecht')
|
|
|
|
} else if (store.state.login.user.group.includes('user')) {
|
|
|
|
next('/main/user/add')
|
2020-03-04 20:12:08 +00:00
|
|
|
} else if (store.state.login.user.group.includes('extern')) {
|
|
|
|
next('/main')
|
2019-12-26 09:31:36 +00:00
|
|
|
}
|
2019-12-21 07:20:25 +00:00
|
|
|
}
|
|
|
|
}
|
2020-01-14 21:01:24 +00:00
|
|
|
next()
|
|
|
|
})
|
2019-12-21 07:20:25 +00:00
|
|
|
|
2019-12-20 13:01:36 +00:00
|
|
|
export default router
|