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 Index = () => import(/* webpackChunkName: "index" */ '@/pages/Index')
|
||||||
const Dashboard = () => import(/* webpackChunkName: "dashboard" */ '@/pages/Dashboard');
|
const Dashboard = () => import(/* webpackChunkName: "dashboard" */ '@/pages/Dashboard')
|
||||||
const DashboardIndex = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/DashboardIndex');
|
const DashboardIndex = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/DashboardIndex')
|
||||||
const DashboardUsers = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/DashboardUsers');
|
const DashboardUsers = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/DashboardUsers')
|
||||||
const DashboardServices = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/DashboardServices');
|
const DashboardServices = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/DashboardServices')
|
||||||
const DashboardMessages = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/DashboardMessages');
|
const DashboardMessages = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/DashboardMessages')
|
||||||
const EditService = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/EditService');
|
const EditService = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/EditService')
|
||||||
const Logs = () => import(/* webpackChunkName: "dashboard" */ '@/pages/Logs');
|
const Logs = () => import(/* webpackChunkName: "dashboard" */ '@/pages/Logs')
|
||||||
const Help = () => import(/* webpackChunkName: "dashboard" */ '@/pages/Help');
|
const Help = () => import(/* webpackChunkName: "dashboard" */ '@/pages/Help')
|
||||||
const Settings = () => import(/* webpackChunkName: "dashboard" */ '@/pages/Settings');
|
const Settings = () => import(/* webpackChunkName: "dashboard" */ '@/pages/Settings')
|
||||||
const Login = () => import(/* webpackChunkName: "index" */ '@/pages/Login');
|
const Login = () => import(/* webpackChunkName: "index" */ '@/pages/Login')
|
||||||
const Service = () => import(/* webpackChunkName: "index" */ '@/pages/Service');
|
const Service = () => import(/* webpackChunkName: "index" */ '@/pages/Service')
|
||||||
const Setup = () => import(/* webpackChunkName: "index" */ '@/forms/Setup');
|
const Setup = () => import(/* webpackChunkName: "index" */ '@/forms/Setup')
|
||||||
const Incidents = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/Incidents');
|
const Incidents = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/Incidents')
|
||||||
const Checkins = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/Checkins');
|
const Checkins = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/Checkins')
|
||||||
const Failures = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/Failures');
|
const Failures = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/Failures')
|
||||||
const NotFound = () => import(/* webpackChunkName: "index" */ '@/pages/NotFound');
|
const NotFound = () => import(/* webpackChunkName: "index" */ '@/pages/NotFound')
|
||||||
const Importer = () => import(/* webpackChunkName: "index" */ '@/components/Dashboard/Importer');
|
const Importer = () => import(/* webpackChunkName: "index" */ '@/components/Dashboard/Importer')
|
||||||
const DashboardDowntimes = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/DashboardDowntimes');
|
|
||||||
const EditDowntime = () => import(/* webpackChunkName: "dashboard" */ '@/components/Dashboard/EditDowntime');
|
|
||||||
|
|
||||||
import VueRouter from 'vue-router';
|
import VueRouter from "vue-router";
|
||||||
import Api from './API';
|
import Api from "./API";
|
||||||
import store from './store';
|
import store from "./store"
|
||||||
|
|
||||||
const Loading = {
|
const Loading = {
|
||||||
template: '<div class="jumbotron">LOADING</div>'
|
template: '<div class="jumbotron">LOADING</div>'
|
||||||
};
|
}
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
{
|
{
|
||||||
|
@ -52,34 +50,34 @@ const routes = [
|
||||||
if (to.matched.some(record => record.meta.requiresAuth)) {
|
if (to.matched.some(record => record.meta.requiresAuth)) {
|
||||||
if (to.path !== '/login') {
|
if (to.path !== '/login') {
|
||||||
if(store.getters.loggedIn) {
|
if(store.getters.loggedIn) {
|
||||||
next();
|
next()
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
const token = $cookies.get('statping_auth');
|
const token = $cookies.get('statping_auth')
|
||||||
if (!token) {
|
if (!token) {
|
||||||
next('/login');
|
next('/login')
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const jwt = await Api.check_token(token);
|
const jwt = await Api.check_token(token)
|
||||||
store.commit('setAdmin', jwt.admin);
|
store.commit('setAdmin', jwt.admin)
|
||||||
if (jwt.admin) {
|
if (jwt.admin) {
|
||||||
store.commit('setLoggedIn', true);
|
store.commit('setLoggedIn', true)
|
||||||
store.commit('setUser', true);
|
store.commit('setUser', true)
|
||||||
} else {
|
} else {
|
||||||
store.commit('setLoggedIn', false);
|
store.commit('setLoggedIn', false)
|
||||||
next('/login');
|
next('/login')
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e)
|
||||||
next('/login');
|
next('/login')
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
next();
|
next()
|
||||||
} else {
|
} else {
|
||||||
next();
|
next()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
children: [{
|
children: [{
|
||||||
|
@ -223,21 +221,21 @@ const router = new VueRouter({
|
||||||
mode: 'history',
|
mode: 'history',
|
||||||
scrollBehavior (to, from, savedPosition) {
|
scrollBehavior (to, from, savedPosition) {
|
||||||
if (savedPosition) {
|
if (savedPosition) {
|
||||||
return savedPosition;
|
return savedPosition
|
||||||
} else {
|
} else {
|
||||||
return { x: 0, y: 0 };
|
return { x: 0, y: 0 }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
routes
|
routes
|
||||||
});
|
})
|
||||||
|
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
const nearestWithTitle = to.matched.slice().reverse().find(r => r.meta && r.meta.title);
|
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 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);
|
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));
|
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 => {
|
nearestWithMeta.meta.metaTags.map(tagDef => {
|
||||||
const tag = document.createElement('meta');
|
const tag = document.createElement('meta');
|
||||||
Object.keys(tagDef).forEach(key => {
|
Object.keys(tagDef).forEach(key => {
|
||||||
|
@ -250,4 +248,5 @@ router.beforeEach((to, from, next) => {
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
export default router;
|
export default router
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue