Skip to content

Commit

Permalink
feat(#493): Append user portal, favorite chart page, user approved cu…
Browse files Browse the repository at this point in the history
…ration page listing and user unapproved curation page listing to routes
  • Loading branch information
tholulomo committed Jun 23, 2024
1 parent 0076a36 commit 6c54a84
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 88 deletions.
91 changes: 43 additions & 48 deletions app/src/router/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import Vue from 'vue'
import VueRouter from 'vue-router'
import store from '@/store/index.js'
import ExplorerBase from '@/pages/explorer/Base.vue'
import MetamineBase from '@/pages/metamine/Base.vue'
import NanomineBase from '@/pages/nanomine/Base.vue'
import PortalBase from '@/pages/portal/Base.vue'
import XsdBase from '@/pages/portal/curation/xsd/Base.vue'
import NotFound from '@/pages/NotFound.vue'
import nanomineRoutes from '@/router/module/nanomine'
import metamineRoutes from '@/router/module/metamine'
import explorerRoutes from '@/router/module/explorer'
import portalRoutes from '@/router/module/portal'
import xsdRoutes from '@/router/module/xsd'
Vue.use(VueRouter)
import Vue from 'vue';
import VueRouter from 'vue-router';
import store from '@/store/index.js';
import ExplorerBase from '@/pages/explorer/Base.vue';
import MetamineBase from '@/pages/metamine/Base.vue';
import NanomineBase from '@/pages/nanomine/Base.vue';
import PortalBase from '@/pages/portal/Base.vue';
import XsdBase from '@/pages/portal/curation/xsd/Base.vue';
import NotFound from '@/pages/NotFound.vue';
import nanomineRoutes from '@/router/module/nanomine';
import metamineRoutes from '@/router/module/metamine';
import explorerRoutes from '@/router/module/explorer';
import portalRoutes from '@/router/module/portal';
import xsdRoutes from '@/router/module/xsd';
Vue.use(VueRouter);

const routes = [
{
Expand All @@ -23,37 +23,27 @@ const routes = [
{
path: '/nm',
component: NanomineBase,
children: [
...nanomineRoutes
]
children: [...nanomineRoutes]
},
{
path: '/mm',
component: MetamineBase,
children: [
...metamineRoutes
]
children: [...metamineRoutes]
},
{
path: '/explorer',
component: ExplorerBase,
children: [
...explorerRoutes
]
children: [...explorerRoutes]
},
{
path: '/xsd',
component: XsdBase,
children: [
...xsdRoutes
]
children: [...xsdRoutes]
},
{
path: '/portal',
component: PortalBase,
children: [
...portalRoutes
]
children: [...portalRoutes]
},
{
path: '/auth/:auth',
Expand All @@ -67,44 +57,49 @@ const routes = [
{ path: '/mm:notFound(.*)', component: NotFound },
{ path: '/nm:notFound(.*)', component: NotFound },
{ path: '/:notFound(.*)', component: NotFound }
]
];

const router = new VueRouter({
mode: 'history',
routes,
scrollBehavior (to, _, prevPosition) {
scrollBehavior(to, _, prevPosition) {
if (prevPosition) {
return prevPosition
return prevPosition;
}
if (to.hash) {
return {
el: to.hash,
behavior: 'smooth'
}
};
}
return { x: 0, y: 0 }
return { x: 0, y: 0 };
}
})
});

router.beforeEach(async function (to, _, next) {
router.beforeEach(async function (to, from, next) {
store.commit('auth/setLastPageVisit', from?.fullPath);
if (to.meta.requiresAuth && !store.getters['auth/isAuthenticated']) {
if (!store.getters['auth/isAuthenticated']) {
store.commit('setSnackbar', {
message: 'Re-authenticating...',
duration: 1500
}, { root: true })
store.commit(
'setSnackbar',
{
message: 'Re-authenticating...',
duration: 1500
},
{ root: true }
);

await store.dispatch('auth/tryLogin')
await store.dispatch('auth/tryLogin');
if (store.getters['auth/isAuthenticated']) {
return next()
return next();
}
}
next('')
next('');
} else if (to.meta.requiresUnauth && store.getters.auth.isAuthenticated) {
next()
next();
} else {
next()
next();
}
})
});

export default router
export default router;
88 changes: 48 additions & 40 deletions app/src/router/module/portal.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,83 +6,91 @@ const portalRoutes = [
meta: { requiresAuth: true }
},
{
path: 'deploy',
name: 'Deploy',
component: () => import('@/pages/portal/Deploy.vue'),
path: 'general-deployment',
name: 'GeneralDeployment',
component: () => import('@/pages/portal/deploy/GeneralDeployment.vue'),
meta: { requiresAuth: true }
},
{
path: 'ontology-deployment',
name: 'OntologyDeployment',
component: () => import('@/pages/portal/deploy/OntologyDeployment.vue'),
meta: { requiresAuth: true }
},
{
path: 'contact-inquiry',
name: 'ContactInquiry',
component: () =>
import(
'@/pages/portal/enquiries/ContactInquiry.vue'
),
component: () => import('@/pages/portal/enquiries/ContactInquiry.vue'),
meta: { requiresAuth: true }
},
{
path: 'resolved-inquiries',
name: 'ResolvedInquiries',
component: () =>
import(
'@/pages/portal/enquiries/ResolveInquiry.vue'
),
component: () => import('@/pages/portal/enquiries/ResolveInquiry.vue'),
meta: { requiresAuth: true }
},
{
path: 'manage-chart',
name: 'ManageChart',
component: () =>
import(
'@/pages/portal/chart/ManageChart.vue'
),
path: 'favoritechart',
name: 'AdminFavoriteChart',
component: () => import('@/pages/portal/chart/FavoriteChart.vue'),
meta: { requiresAuth: true }
},
{
path: 'delete-chart',
name: 'DeleteChart',
component: () =>
import(
'@/pages/portal/chart/DeleteChart.vue'
),
path: 'manage-chart',
name: 'ManageChart',
component: () => import('@/pages/portal/chart/ManageChart.vue'),
meta: { requiresAuth: true }
},
{
path: 'manage-curation',
name: 'ManageCuration',
component: () =>
import(
'@/pages/portal/curation/ManageCuration.vue'
),
component: () => import('@/pages/portal/curation/ManageCuration.vue'),
meta: { requiresAuth: true }
},
{
path: 'view-curation',
name: 'ViewCuration',
component: () =>
import(
'@/pages/portal/curation/ViewCuration.vue'
),
component: () => import('@/pages/portal/curation/ViewCuration.vue'),
meta: { requiresAuth: true }
},
{
path: 'view-schema',
name: 'ViewSchema',
component: () =>
import(
'@/pages/portal/curation/ViewSchema.vue'
),
component: () => import('@/pages/portal/curation/ViewSchema.vue'),
meta: { requiresAuth: true }
},
{
path: 'users',
name: 'ManageUsers',
component: () => import('@/pages/portal/ManageUsers.vue'),
meta: { requiresAuth: true }
},
{
path: 'user/favorite-charts',
name: 'FavoriteChart',
component: () => import('@/pages/portal/chart/FavoriteChart.vue'),
meta: { requiresAuth: true }
},
{
path: 'user/approved-curations',
name: 'ApprovedCuration',
component: () =>
import(
'@/pages/portal/ManageUsers.vue'
),
import('@/pages/portal/user/curation/ApprovedCuration.vue'),
meta: { requiresAuth: true }
},
{
path: 'user/unapproved-curations',
name: 'UnapprovedCuratedXML',
component: () =>
import('@/pages/portal/user/curation/UnapprovedCuration.vue'),
meta: { requiresAuth: true }
},
{
path: 'user',
name: 'UserPortalHome',
component: () => import('@/pages/portal/user/Home.vue'),
meta: { requiresAuth: true }
}
]
];

export default portalRoutes
export default portalRoutes;

0 comments on commit 6c54a84

Please sign in to comment.