import { restGet } from './restConsumer.js' import { ref, computed } from 'vue' import i18n from '@/i18n.js' // Liste des apps import LoginPage from '@/Apps/Login.vue' import Inscription from "@/Apps/Inscription.vue" import Profil from "@/Apps/Profil.vue" import Courses from "@/Apps/ManageCourses.vue" import Users from "@/Apps/UsersList.vue" import Students from "@/Apps/StudentsList.vue" const apps = { '/login': LoginPage, '/inscription': Inscription, '/profil': Profil, '/manage-courses' : Courses, '/users-list' : Users, '/students-list' : Students, } const appsList = { 'Msg': { path: '#/msg', icon: 'fa-comment', text: i18n("app.messages") }, 'Notification': { path: '#/notifs', icon: 'fa-bell', text: i18n("app.notifications") }, 'Forum': { path: '#/forum', icon: 'fa-envelope', text: i18n("app.forum") }, 'Schedule': { path: '#/schedule', icon: 'fa-calendar-days', text: i18n("app.schedules") }, 'Inscription': { path: '#/inscription', icon: 'fa-users', text: i18n("app.inscription.requests") }, 'ManageCourses': { path: '#/manage-courses', icon: 'fa-book', text: i18n("app.manage.courses") }, 'StudentsList':{ path: '#/students-list',icon: 'fa-users',text: i18n("app.studentList")}, 'UsersList':{ path: '#/users-list',icon: 'fa-users',text: i18n("app.users")}, } const currentPath = ref(window.location.hash) export const currentView = computed(() => { return apps[currentPath.value.slice(1) || '/'] }) /** * Return the list of app accesible by a logged (or not) * user. */ export async function appList(){ let ret = []; let userAppList = await restGet("/apps"); for (let userapp in userAppList) { if(appsList[userAppList[userapp]] != null){ ret.push(appsList[userAppList[userapp]]) } } return ret; } /** * Check if the specified page is authorized for the * user */ export async function checkPage(page){ return restGet("/apps/" + page) } window.addEventListener('hashchange', () => { currentPath.value = window.location.hash }) // vim:set noet sts=0 sw=4 ts=2 tw=2: