Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Routes #160

Merged
merged 11 commits into from
Mar 23, 2024
Merged
2 changes: 1 addition & 1 deletion backend/api/views/project_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def structure_checks(self, request, **_):
@structure_checks.mapping.put
@swagger_auto_schema(request_body=StructureCheckAddSerializer)
def _add_structure_check(self, request: Request, **_):
"""Add a structure check to the project"""
"""Add a structure_check to the project"""

project: Project = self.get_object()

Expand Down
8 changes: 8 additions & 0 deletions frontend/src/components/Dummy.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<script setup lang="ts">
import { useRoute } from 'vue-router'

</script>

<template>
<h1>Unfinished Route: {{ useRoute().path }}</h1>
</template>
7 changes: 2 additions & 5 deletions frontend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import PrimeVue from 'primevue/config';
import Ripple from 'primevue/ripple';
import {createApp} from 'vue';
import {createI18n} from 'vue-i18n';
import {routes} from '@/router/routes.ts';
import router from './router/router';
import {createPinia} from 'pinia';
import {createRouter, createWebHistory} from 'vue-router';
import ToastService from 'primevue/toastservice';

const app = createApp(App);
Expand All @@ -24,9 +23,7 @@ app.use(createI18n({
messages: { en, nl }
}));

app.use(createRouter({
history: createWebHistory(), routes
}));
app.use(router)

app.use(PrimeVue, {
ripple: true
Expand Down
96 changes: 96 additions & 0 deletions frontend/src/router/router.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import { RouteRecordRaw, createWebHistory, createRouter } from 'vue-router';

// import { useUserStore } from '@/stores/userStore';
// TODO: after pinia setup is done

import DashboardView from '@/views/dashboard/DashboardView.vue';
import CourseView from '@/views/courses/CourseView.vue';
import Dummy from '@/components/Dummy.vue';
import LoginView from '@/views/authentication/LoginView.vue';
import CalendarView from '@/views/calendar/CalendarView.vue';

const routes: RouteRecordRaw[] = [
{ path: '/', component: DashboardView, name: 'dashboard' },

// Courses
{ path: '/courses', children: [
{ path: '', component: Dummy, name: 'courses' },
{ path: 'create', component: Dummy, name: 'course-create' },
// Single course
{ path: ':id', children: [
{ path: '', component: CourseView, name: 'course' },
{ path: 'edit', component: Dummy, name: 'course-edit' },
// Projects
{ path: 'projects', children: [
{ path: '', component: Dummy, name: 'projects' },
{ path: 'create', component: Dummy, name: 'project-create' },
// Single project
{ path: ':id', children: [
{ path: '', component: Dummy, name: 'project' },
{ path: 'edit', component: Dummy, name: 'project-edit' },
{ path: 'groups', component: Dummy, name: 'project-groups' },
{ path: 'submit', component: Dummy, name: 'project-submit' },
]}
]},
]},
]},

// Calendar
{ path: '/calendar', component: CalendarView, name: 'calendar' },

// Users
{ path: '/users', children: [
{ path: ':id', component: Dummy, name: 'user' },
{ path: 'students', children: [
{ path: '', component: Dummy, name: 'students' },
{ path: ':id', component: Dummy, name: 'student' },
]},
{ path: 'admins', children: [
{ path: '', component: Dummy, name: 'admins' },
{ path: ':id', component: Dummy, name: 'admin' },
]},
{ path: 'teachers', children: [
{ path: '', component: Dummy, name: 'teachers' },
{ path: ':id', component: Dummy, name: 'teacher' },
]},
{ path: 'assistants', children: [
{ path: '', component: Dummy, name: 'assistants' },
{ path: ':id', component: Dummy, name: 'assistant' },
]},
]},

// Faculties
{ path: '/faculties', component: Dummy, name: 'faculties' },
{ path: '/faculties/create', component: Dummy, name: 'faculty-create' },

// Notifications
{ path: '/notifications', component: Dummy, name: 'notifications' },
{ path: '/notifications/:id', component: Dummy, name: 'notification' },

// Authentication
{ path: '/auth/', children: [
{ path: 'login', component: LoginView, name: 'login' },
]},

// Page not found: redirect to dashboard
{ path: '/:pathMatch(.*)*', redirect: { name: 'dashboard' } }
];

const router = createRouter({
history: createWebHistory(),
routes,
})

// TODO: once pinia store is setup, implement navigation guards
// Navigation guard example:
router.beforeEach((to, _) => {
const isAdmin: boolean = false
if (to.name === 'faculty-create') {
if (!isAdmin) {
return false
}
}
})


export default router
17 changes: 0 additions & 17 deletions frontend/src/router/routes.ts

This file was deleted.

Loading