mirror of https://github.com/statping/statping
removed linting from routes
parent
40b5d6adcf
commit
287881423c
|
@ -1,31 +1,29 @@
|
|||
const Index = () => import(/* webpackChunkName: "index" */ '@/pages/Index');
|
||||
const Dashboard = () => import(/* webpackChunkName: "dashboard" */ '@/pages/Dashboard');
|
||||
const DashboardIndex = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/DashboardIndex');
|
||||
const DashboardUsers = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/DashboardUsers');
|
||||
const DashboardServices = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/DashboardServices');
|
||||
const DashboardMessages = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/DashboardMessages');
|
||||
const EditService = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/EditService');
|
||||
const Logs = () => import(/* webpackChunkName: "dashboard" */ '@/pages/Logs');
|
||||
const Help = () => import(/* webpackChunkName: "dashboard" */ '@/pages/Help');
|
||||
const Settings = () => import(/* webpackChunkName: "dashboard" */ '@/pages/Settings');
|
||||
const Login = () => import(/* webpackChunkName: "index" */ '@/pages/Login');
|
||||
const Service = () => import(/* webpackChunkName: "index" */ '@/pages/Service');
|
||||
const Setup = () => import(/* webpackChunkName: "index" */ '@/forms/Setup');
|
||||
const Incidents = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/Incidents');
|
||||
const Checkins = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/Checkins');
|
||||
const Failures = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/Failures');
|
||||
const NotFound = () => import(/* webpackChunkName: "index" */ '@/pages/NotFound');
|
||||
const Importer = () => import(/* webpackChunkName: "index" */ '@/components/Dashboard/Importer');
|
||||
const DashboardDowntimes = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/DashboardDowntimes');
|
||||
const EditDowntime = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/EditDowntime');
|
||||
const Index = () => import(/* webpackChunkName: "index" */ '@/pages/Index')
|
||||
const Dashboard = () => import(/* webpackChunkName: "dashboard" */ '@/pages/Dashboard')
|
||||
const DashboardIndex = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/DashboardIndex')
|
||||
const DashboardUsers = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/DashboardUsers')
|
||||
const DashboardServices = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/DashboardServices')
|
||||
const DashboardMessages = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/DashboardMessages')
|
||||
const EditService = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/EditService')
|
||||
const Logs = () => import(/* webpackChunkName: "dashboard" */ '@/pages/Logs')
|
||||
const Help = () => import(/* webpackChunkName: "dashboard" */ '@/pages/Help')
|
||||
const Settings = () => import(/* webpackChunkName: "dashboard" */ '@/pages/Settings')
|
||||
const Login = () => import(/* webpackChunkName: "index" */ '@/pages/Login')
|
||||
const Service = () => import(/* webpackChunkName: "index" */ '@/pages/Service')
|
||||
const Setup = () => import(/* webpackChunkName: "index" */ '@/forms/Setup')
|
||||
const Incidents = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/Incidents')
|
||||
const Checkins = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/Checkins')
|
||||
const Failures = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/Failures')
|
||||
const NotFound = () => import(/* webpackChunkName: "index" */ '@/pages/NotFound')
|
||||
const Importer = () => import(/* webpackChunkName: "index" */ '@/components/Dashboard/Importer')
|
||||
|
||||
import VueRouter from 'vue-router';
|
||||
import Api from './API';
|
||||
import store from './store';
|
||||
import VueRouter from "vue-router";
|
||||
import Api from "./API";
|
||||
import store from "./store"
|
||||
|
||||
const Loading = {
|
||||
template: '<div class="jumbotron">LOADING</div>'
|
||||
};
|
||||
}
|
||||
|
||||
const routes = [
|
||||
{
|
||||
|
@ -51,38 +49,38 @@ const routes = [
|
|||
beforeEnter: async (to, from, next) => {
|
||||
if (to.matched.some(record => record.meta.requiresAuth)) {
|
||||
if (to.path !== '/login') {
|
||||
if (store.getters.loggedIn) {
|
||||
next();
|
||||
return;
|
||||
if(store.getters.loggedIn) {
|
||||
next()
|
||||
return
|
||||
}
|
||||
const token = $cookies.get('statping_auth');
|
||||
const token = $cookies.get('statping_auth')
|
||||
if (!token) {
|
||||
next('/login');
|
||||
return;
|
||||
next('/login')
|
||||
return
|
||||
}
|
||||
try {
|
||||
const jwt = await Api.check_token(token);
|
||||
store.commit('setAdmin', jwt.admin);
|
||||
const jwt = await Api.check_token(token)
|
||||
store.commit('setAdmin', jwt.admin)
|
||||
if (jwt.admin) {
|
||||
store.commit('setLoggedIn', true);
|
||||
store.commit('setUser', true);
|
||||
store.commit('setLoggedIn', true)
|
||||
store.commit('setUser', true)
|
||||
} else {
|
||||
store.commit('setLoggedIn', false);
|
||||
next('/login');
|
||||
return;
|
||||
store.commit('setLoggedIn', false)
|
||||
next('/login')
|
||||
return
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
next('/login');
|
||||
return;
|
||||
console.error(e)
|
||||
next('/login')
|
||||
return
|
||||
}
|
||||
}
|
||||
next();
|
||||
next()
|
||||
} else {
|
||||
next();
|
||||
next()
|
||||
}
|
||||
},
|
||||
children: [ {
|
||||
children: [{
|
||||
path: '',
|
||||
component: DashboardIndex,
|
||||
meta: {
|
||||
|
@ -195,7 +193,7 @@ const routes = [
|
|||
requiresAuth: true,
|
||||
title: 'Statping - Import',
|
||||
}
|
||||
} ]
|
||||
}]
|
||||
},
|
||||
{
|
||||
path: '/login',
|
||||
|
@ -223,21 +221,21 @@ const router = new VueRouter({
|
|||
mode: 'history',
|
||||
scrollBehavior (to, from, savedPosition) {
|
||||
if (savedPosition) {
|
||||
return savedPosition;
|
||||
return savedPosition
|
||||
} else {
|
||||
return { x: 0, y: 0 };
|
||||
return { x: 0, y: 0 }
|
||||
}
|
||||
},
|
||||
routes
|
||||
});
|
||||
})
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
const nearestWithTitle = to.matched.slice().reverse().find(r => r.meta && r.meta.title);
|
||||
const nearestWithMeta = to.matched.slice().reverse().find(r => r.meta && r.meta.metaTags);
|
||||
const previousNearestWithMeta = from.matched.slice().reverse().find(r => r.meta && r.meta.metaTags);
|
||||
if (nearestWithTitle) {document.title = nearestWithTitle.meta.title;}
|
||||
if (nearestWithTitle) document.title = nearestWithTitle.meta.title;
|
||||
Array.from(document.querySelectorAll('[data-vue-router-controlled]')).map(el => el.parentNode.removeChild(el));
|
||||
if (!nearestWithMeta) {return next();}
|
||||
if (!nearestWithMeta) return next();
|
||||
nearestWithMeta.meta.metaTags.map(tagDef => {
|
||||
const tag = document.createElement('meta');
|
||||
Object.keys(tagDef).forEach(key => {
|
||||
|
@ -250,4 +248,5 @@ router.beforeEach((to, from, next) => {
|
|||
next();
|
||||
});
|
||||
|
||||
export default router;
|
||||
export default router
|
||||
|
||||
|
|
Loading…
Reference in New Issue