Skip to content

Commit

Permalink
feat: Adding namespace resolver page
Browse files Browse the repository at this point in the history
  • Loading branch information
tholulomo committed Aug 13, 2024
1 parent 5d7d66c commit eee1f11
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 29 deletions.
29 changes: 29 additions & 0 deletions app/src/pages/ns/Home.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<template>
<div class="section_pages">
<div v-if="!loading && !namespace" class="wrapper">
<h1 class="visualize_header-h1 article_title">
MaterialsMine Namespace Center
</h1>
<div class="article_subtitle">Welcome...</div>
</div>
<div v-else-if="!loading && namespace" class="wrapper">
<h1 class="visualize_header-h1 article_title">{{ namespace }}</h1>
<div class="article_subtitle">Additional information comming soon...</div>
</div>
</div>
</template>
<script>
export default {
name: 'Namespace',
data() {
return {
loading: false
};
},
computed: {
namespace() {
return this.$route.params?.namespace;
}
}
};
</script>
64 changes: 35 additions & 29 deletions app/src/router/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
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';
import nsRoutes from './module/ns';
Vue.use(VueRouter);

const routes = [
{
Expand All @@ -25,6 +26,11 @@ const routes = [
component: NanomineBase,
children: [...nanomineRoutes]
},
{
path: '/ns',
component: ExplorerBase,
children: [...nsRoutes]
},
{
path: '/mm',
component: MetamineBase,
Expand Down Expand Up @@ -57,24 +63,24 @@ 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) {
if (to.meta.requiresAuth && !store.getters['auth/isAuthenticated']) {
Expand All @@ -86,19 +92,19 @@ router.beforeEach(async function (to, _, next) {
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;
16 changes: 16 additions & 0 deletions app/src/router/module/ns.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const nsRoutes = [
{
path: '',
name: 'Namespace',
component: () => import('@/pages/ns/Home.vue'),
meta: { requiresAuth: false }
},
{
path: ':namespace',
name: 'Namespaces',
component: () => import('@/pages/ns/Home.vue'),
meta: { requiresAuth: false }
}
];

export default nsRoutes;

0 comments on commit eee1f11

Please sign in to comment.