209 lines
5.7 KiB
JavaScript
209 lines
5.7 KiB
JavaScript
import Vue from 'vue'
|
|
import VueRouter from 'vue-router'
|
|
import FinanzerView from '@/views/FinanzerView'
|
|
import Login from '@/views/Login'
|
|
import store from '@/store/index'
|
|
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'
|
|
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'
|
|
import ServiceManagement from '../components/vorstand/ServiceManagement'
|
|
import Config from '@/components/user/Config'
|
|
import Jobs from '@/components/user/Jobs'
|
|
import PriceList from '@/components/pricelist/PriceList'
|
|
import ManagementNavigation from '@/components/vorstand/ManagementNavigation'
|
|
import GastroNavigation from '@/components/gastro/GastroNavigation'
|
|
import PriceListView from '@/views/contents/PriceListView'
|
|
import UserManager from '@/components/vorstand/UserManager'
|
|
import WorkgroupManagement from '@/components/vorstand/WorkgroupManagement'
|
|
import JobKindManager from '@/components/vorstand/JobKindManager'
|
|
import JobsRequest from '@/components/user/JobsRequest'
|
|
|
|
Vue.use(VueRouter)
|
|
|
|
const rootPath = ''
|
|
|
|
const routes = [
|
|
{
|
|
path: rootPath + '/cookies',
|
|
name: 'cookies'
|
|
},
|
|
{
|
|
path: rootPath + '/pricelist',
|
|
name: 'priceListNoLogin',
|
|
component: PriceListView
|
|
},
|
|
{
|
|
path: rootPath + '/login',
|
|
name: 'login',
|
|
component: Login
|
|
},
|
|
{
|
|
path: rootPath + '/main',
|
|
name: 'main',
|
|
component: MainView,
|
|
children: [
|
|
{
|
|
path: 'management',
|
|
name: 'management',
|
|
components: { nav: ManagementNavigation, default: BarView },
|
|
children: [
|
|
{
|
|
name: 'serviceManagement',
|
|
path: 'servicemanagement/:year/:month',
|
|
component: ServiceManagement
|
|
},
|
|
{
|
|
path: 'usermanager',
|
|
name: 'userManager',
|
|
component: UserManager
|
|
},
|
|
{
|
|
path: 'workgroupmanagement',
|
|
name: 'workgroupManagement',
|
|
component: WorkgroupManagement
|
|
},
|
|
{
|
|
path: 'jobkindmanagement',
|
|
name: 'jobkindManagement',
|
|
component: JobKindManager
|
|
}
|
|
]
|
|
},
|
|
{
|
|
path: 'user',
|
|
name: 'user',
|
|
components: { nav: UserNavigation, default: UserView },
|
|
children: [
|
|
{
|
|
path: 'add',
|
|
name: 'add',
|
|
component: AddAmount
|
|
},
|
|
{
|
|
path: 'overview',
|
|
name: 'userOverview',
|
|
component: CreditOverview
|
|
},
|
|
{
|
|
path: 'config',
|
|
name: 'userConfig',
|
|
component: Config
|
|
},
|
|
{
|
|
path: 'jobs/:year/:month',
|
|
name: 'userJobs',
|
|
component: Jobs
|
|
},
|
|
{
|
|
path: 'jobRequests/:kind',
|
|
name: 'jobRequests',
|
|
component: JobsRequest
|
|
}
|
|
]
|
|
},
|
|
{
|
|
path: 'bar',
|
|
name: 'bar',
|
|
components: { nav: BarNavigation, default: BarView },
|
|
children: [
|
|
{
|
|
path: 'geruecht',
|
|
name: 'geruecht',
|
|
component: GeruechteView
|
|
}
|
|
]
|
|
},
|
|
{
|
|
path: 'finanzer',
|
|
name: 'finanzer',
|
|
components: { default: FinanzerView, nav: FinanzerNavigation },
|
|
children: [
|
|
{
|
|
path: 'overview',
|
|
name: 'overview',
|
|
component: Overview
|
|
},
|
|
{
|
|
path: 'user/:id',
|
|
name: 'activeUser',
|
|
props: true,
|
|
component: User
|
|
}
|
|
]
|
|
},
|
|
{
|
|
path: 'gastro',
|
|
name: 'gastro',
|
|
components: { nav: GastroNavigation, default: BarView },
|
|
children: [
|
|
{
|
|
path: 'pricelist',
|
|
name: 'gastroPricelist',
|
|
component: PriceList
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
path: '*',
|
|
redirect: {
|
|
name: 'login'
|
|
}
|
|
}
|
|
]
|
|
|
|
const router = new VueRouter({
|
|
mode: 'history',
|
|
base: process.env.BASE_URL,
|
|
routes
|
|
})
|
|
|
|
router.beforeEach((to, from, next) => {
|
|
store.dispatch('fetchAccessToken')
|
|
if (to.name === 'main') {
|
|
if (to.name ==='finanzer' || to.name === 'overview' || to.name === 'activeUser') {
|
|
if (!store.state.login.user.group.includes('moneymaster')) {
|
|
next({name: 'login'})
|
|
}
|
|
}
|
|
if (to.name === 'bar' || to.name === 'geruecht') {
|
|
if (!store.state.login.user.group.includes('bar')) {
|
|
next({name: 'login'})
|
|
}
|
|
}
|
|
if (to.name === 'user' || to.name === 'userOverview' || to.name === 'userConfig' || to.name === 'userJobs' || to.name === 'jobRequests') {
|
|
if (!store.state.login.user.group.includes('user')) {
|
|
next({name: 'login'})
|
|
}
|
|
}
|
|
if (!store.state.login.user.accessToken) {
|
|
next({name: 'login'})
|
|
}
|
|
}
|
|
if (to.name === 'login') {
|
|
if (store.state.login.user.accessToken) {
|
|
if (store.state.login.user.group.includes('moneymaster')) {
|
|
next({name: 'overview'})
|
|
} else if (store.state.login.user.group.includes('bar')) {
|
|
next({name: 'geruecht'})
|
|
} else if (store.state.login.user.group.includes('user')) {
|
|
next({name: 'add'})
|
|
} else if (store.state.login.user.group.includes('extern')) {
|
|
next({name: 'main'})
|
|
}
|
|
}
|
|
}
|
|
next()
|
|
})
|
|
|
|
export default router
|