diff --git a/backend/api/views/project_view.py b/backend/api/views/project_view.py index 6c9a9d99..8ec27b23 100644 --- a/backend/api/views/project_view.py +++ b/backend/api/views/project_view.py @@ -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() diff --git a/frontend/src/components/Dummy.vue b/frontend/src/components/Dummy.vue new file mode 100644 index 00000000..dfb42325 --- /dev/null +++ b/frontend/src/components/Dummy.vue @@ -0,0 +1,8 @@ + + + diff --git a/frontend/src/main.ts b/frontend/src/main.ts index 50c6bd37..a42074f7 100644 --- a/frontend/src/main.ts +++ b/frontend/src/main.ts @@ -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); @@ -24,9 +23,7 @@ app.use(createI18n({ messages: { en, nl } })); -app.use(createRouter({ - history: createWebHistory(), routes -})); +app.use(router) app.use(PrimeVue, { ripple: true diff --git a/frontend/src/router/router.ts b/frontend/src/router/router.ts new file mode 100644 index 00000000..ea9bb2e9 --- /dev/null +++ b/frontend/src/router/router.ts @@ -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 diff --git a/frontend/src/router/routes.ts b/frontend/src/router/routes.ts deleted file mode 100644 index c8fcd623..00000000 --- a/frontend/src/router/routes.ts +++ /dev/null @@ -1,17 +0,0 @@ -import DashboardView from '@/views/dashboard/DashboardView.vue'; -import CourseView from '@/views/courses/CourseView.vue'; -import LoginView from '@/views/authentication/LoginView.vue'; -import CalendarView from '@/views/calendar/CalendarView.vue'; -import {RouteRecordRaw} from 'vue-router'; - -export const routes: RouteRecordRaw[] = [ - { path: '/auth/', children: [ - { path: 'login', component: LoginView, name: 'login' }, - ]}, - { path: '/', component: DashboardView, name: 'dashboard' }, - { path: '/calendar', component: CalendarView, name: 'calendar' }, - { path: '/courses/', children: [ - { path: ':id', component: CourseView, name: 'course-view' } - ]}, - { path: '/:pathMatch(.*)*', redirect: { name: 'dashboard' } } -]; \ No newline at end of file