2024-03-09 18:41:20 +01:00
|
|
|
import { restGet } from './restConsumer.js'
|
2024-03-16 16:57:52 +01:00
|
|
|
import { ref, computed } from 'vue'
|
|
|
|
import i18n from '@/i18n.js'
|
2024-03-09 18:41:20 +01:00
|
|
|
|
2024-03-16 16:57:52 +01:00
|
|
|
// Liste des apps
|
|
|
|
import LoginPage from '@/Apps/Login.vue'
|
|
|
|
import Inscription from "@/Apps/Inscription.vue"
|
|
|
|
import Profil from "@/Apps/Profil.vue"
|
2024-03-17 13:24:24 +01:00
|
|
|
import Courses from "@/Apps/ManageCourses.vue"
|
|
|
|
import Users from "@/Apps/UsersList.vue"
|
|
|
|
import Students from "@/Apps/StudentsList.vue"
|
2024-03-22 13:54:52 +01:00
|
|
|
import Msg from "@/Apps/Msg.vue"
|
2024-03-16 16:57:52 +01:00
|
|
|
|
|
|
|
const apps = {
|
|
|
|
'/login': LoginPage,
|
|
|
|
'/inscription': Inscription,
|
|
|
|
'/profil': Profil,
|
|
|
|
'/manage-courses' : Courses,
|
2024-03-17 13:24:24 +01:00
|
|
|
'/users-list' : Users,
|
|
|
|
'/students-list' : Students,
|
2024-03-22 13:54:52 +01:00
|
|
|
'/msg' : Msg,
|
2024-03-16 16:57:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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") },
|
2024-03-17 13:24:24 +01:00
|
|
|
'StudentsList':{ path: '#/students-list',icon: 'fa-users',text: i18n("app.studentList")},
|
|
|
|
'UsersList':{ path: '#/users-list',icon: 'fa-users',text: i18n("app.users")},
|
2024-03-16 16:57:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
2024-03-09 18:41:20 +01:00
|
|
|
export async function appList(){
|
2024-03-16 16:57:52 +01:00
|
|
|
let ret = [];
|
|
|
|
let userAppList = await restGet("/apps");
|
|
|
|
for (let userapp in userAppList) {
|
|
|
|
if(appsList[userAppList[userapp]] != null){
|
|
|
|
ret.push(appsList[userAppList[userapp]])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
2024-03-09 18:41:20 +01:00
|
|
|
}
|
|
|
|
|
2024-03-16 16:57:52 +01:00
|
|
|
/**
|
|
|
|
* Check if the specified page is authorized for the
|
|
|
|
* user
|
|
|
|
*/
|
2024-03-09 18:41:20 +01:00
|
|
|
export async function checkPage(page){
|
2024-03-16 16:57:52 +01:00
|
|
|
return restGet("/apps/" + page)
|
2024-03-09 18:41:20 +01:00
|
|
|
}
|
2024-03-16 16:57:52 +01:00
|
|
|
|
|
|
|
window.addEventListener('hashchange', () => {
|
|
|
|
currentPath.value = window.location.hash
|
|
|
|
})
|
|
|
|
|
|
|
|
// vim:set noet sts=0 sw=4 ts=2 tw=2:
|