new C'hnages

This commit is contained in:
saeid
2019-08-21 14:49:33 +04:30
parent 2db3d32960
commit 6c8966e777
128 changed files with 261 additions and 162 deletions
+96
View File
@@ -0,0 +1,96 @@
/**
* Vue Router
*
* @library
*
* https://router.vuejs.org/en/
*/
// Lib imports
import Vue from 'vue'
// import VueAnalytics from 'vue-analytics'
import Router from 'vue-router'
import Meta from 'vue-meta'
import { TokenService } from '@/services'
// Routes
import paths from './paths'
function route (options) {
let path = options.path;
let view = options.view;
let name = options.name;
let meta = (options.meta) ? options.meta : '';
return {
name: name || view,
path,
meta,
component: (resovle) => import(
`@/views/${view}.vue`
).then(resovle)
}
}
Vue.use(Router)
// Create a new router
const router = new Router({
mode: 'history',
routes: paths.map(path => route(path)).concat([
{ path: '*', redirect: '/dashboard' }
]),
scrollBehavior (to, from, savedPosition) {
if (savedPosition) {
return savedPosition
}
if (to.hash) {
return { selector: to.hash }
}
return { x: 0, y: 0 }
}
})
Vue.use(Meta)
import {$hasRole} from '@/services/acl/role';
router.beforeEach((to, from, next) => {
const isPublic = to.matched.some(record => record.meta.public);
const onlyWhenLoggedOut = to.matched.some(record => record.meta.onlyWhenLoggedOut);
const loggedIn = !!TokenService.getToken();
const roles = (to.meta && to.meta.roles) ? to.meta.roles : null;
if (!isPublic && !loggedIn) {
return next({
path:'/login',
query: {redirect: to.fullPath} // Store the full path to redirect the user to after login
});
}
// Do not allow user to visit login page or register page if they are logged in
if (loggedIn && onlyWhenLoggedOut && policy) {
return next('/')
}
// Do not allow user to visit Pages then not access roles
if (roles && !$hasRole(roles)) {
return next('/')
}
next();
});
// Bootstrap Analytics
// Set in .env
// https://github.com/MatteoGabriele/vue-analytics
// if (process.env.GOOGLE_ANALYTICS) {
// Vue.use(VueAnalytics, {
// id: process.env.GOOGLE_ANALYTICS,
// router,
// autoTracking: {
// page: process.env.NODE_ENV !== 'development'
// }
// })
// }
export default router
+197
View File
@@ -0,0 +1,197 @@
/**
* Define all of your application routes here
* for more information on routes, see the
* official documentation https://router.vuejs.org/en/
*/
export default [
{
path: '/dashboard',
name: 'Dashboard',
view: 'Dashboard',
},
{
path: '/my-info',
name: 'MyInfo',
view: 'User/MyInfo'
},
{
path: '/manage-users',
name: 'ManageUsers',
view: 'User/List',
meta: {
roles: 'Admin|Supervisor'
}
},
{
path: '/test-type/create',
name: 'AddTestType',
view: 'TestType/AddEdit'
},
{
path: '/test-type/:testType/edit',
name: 'EditTestType',
view: 'TestType/AddEdit',
meta: {
roles: 'Admin'
}
},
{
path: '/test-types',
name: 'ListTestType',
view: 'TestType/List',
meta: {
roles: 'Admin'
}
},
{
path: '/medical-center',
name: 'ManageMedicalCenter',
view: 'MedicalCenter/List',
meta: {
roles: 'Admin'
}
},
{
path: '/medical-center/create',
name: 'AddMedicalCenter',
view: 'MedicalCenter/AddEdit',
meta: {
roles: 'Admin'
}
},
{
path: '/medical-center/:medicalCenter/edit',
name: 'EditMedicalCenter',
view: 'MedicalCenter/AddEdit',
meta: {
roles: 'Admin'
}
},
{
path: '/add-operator/:medicalCenter',
name: 'AddOperator',
view: 'Auth/Register',
meta: {
roles: 'Admin'
}
},
{
path: '/operator-list/:medicalCenter',
name: 'OperatorList',
view: 'MedicalCenter/OperatorList',
meta: {
roles: 'Admin'
}
},
{
path: '/login',
name: 'Login',
view: 'Auth/Login',
meta: {
public: true, // Allow access to even if not logged in
onlyWhenLoggedOut: true
}
},
{
path: '/register',
name: 'Register',
view: 'Auth/Register',
meta: {
public: true, // Allow access to even if not logged in
onlyWhenLoggedOut: true,
roles: 'Admin'
}
},
{
path: '/forgot-password',
name: 'ForgotPassword',
view: 'Auth/ForgotPassword',
meta: {
public: true, // Allow access to even if not logged in
onlyWhenLoggedOut: true
},
},
{
path: '/ShowTestResult/:testResult',
name: 'ShowTestResult',
view: 'TestResult/Show',
meta: {
public: true,
},
},
{
path: '/resualt-test',
name: 'AllResultTest',
view: 'TestResult/List'
},
{
path: '/add-test-result',
name: 'SubmitTestResult',
view: 'TestResult/AddEdit'
},
{
path: '/test-result/:testResult/edit',
name: 'EditTestResult',
view: 'TestResult/AddEdit'
},
{
path: '/test-result/NotVerified',
name: 'NotVerifyTestResult',
view: 'TestResult/List'
},
{
path: '/statistics',
name: 'Statistics',
view: 'Statistics/Chart'
},
{
path: '/add-package',
name: 'AddPackage',
view: 'Package/AddEdit'
},
{
path: '/packages',
name: 'AllPackage',
view: 'Package/List'
},
{
path: '/package/:package/edit',
name: 'EditPackage',
view: 'Package/AddEdit'
},
{
path: '/add-cycle',
name: 'AddCycle',
view: 'Cycle/AddEdit'
},
{
path: '/cycles',
name: 'AllCycle',
view: 'Cycle/List'
},
{
path: '/cycle/:cycle/edit',
name: 'EditCycle',
view: 'Cycle/AddEdit'
},
{
path: '/add-Item',
name: 'AddItem',
view: 'Item/AddEdit'
},
{
path: '/Items',
name: 'AllItem',
view: 'Item/List'
},
{
path: '/Item/:Item/edit',
name: 'EditItem',
view: 'Item/AddEdit'
},
{
path: '/tickets',
name: 'Tickets',
view: 'Tickets/List'
},
]