From 6c54a84bb8e2544de77ad40de7a35897408b389d Mon Sep 17 00:00:00 2001 From: tholulomo Date: Sun, 23 Jun 2024 19:20:26 -0400 Subject: [PATCH] feat(#493): Append user portal, favorite chart page, user approved curation page listing and user unapproved curation page listing to routes --- app/src/router/index.js | 91 ++++++++++++++++----------------- app/src/router/module/portal.js | 88 ++++++++++++++++--------------- 2 files changed, 91 insertions(+), 88 deletions(-) diff --git a/app/src/router/index.js b/app/src/router/index.js index 3c4a8bf5..aedf4f74 100644 --- a/app/src/router/index.js +++ b/app/src/router/index.js @@ -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 = [ { @@ -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', @@ -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; diff --git a/app/src/router/module/portal.js b/app/src/router/module/portal.js index bbc3e466..f67a851b 100644 --- a/app/src/router/module/portal.js +++ b/app/src/router/module/portal.js @@ -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;