71 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			71 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| 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/ManageRequests.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"
 | |
| import AboutStudent from "@/Apps/Inscription/AboutStudent.vue";
 | |
| import Msg from "@/Apps/Msg.vue"
 | |
| import ManageRequests from "@/Apps/Inscription/ManageRequests.vue";
 | |
| 
 | |
| const apps = {
 | |
| 		'/login': LoginPage,
 | |
| 		'/requests': ManageRequests,
 | |
| 		'/profil': Profil,
 | |
| 		'/manage-courses' : Courses,
 | |
| 		'/users-list' : Users,
 | |
| 		'/students-list' : Students,
 | |
| 		'/msg' : Msg,
 | |
| }
 | |
| 
 | |
| 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") },
 | |
| 		'Requests': { path: '#/requests', icon: 'fa-users', text: "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:
 |