Nearly finish
This commit is contained in:
		| @ -53,6 +53,7 @@ public class MockController { | |||||||
|         User joe = new User("Mama","Joe","student@student.com","roundabout","DaWarudo",new Date(0), null,Role.Student,passwordEncoder.encode("student")); |         User joe = new User("Mama","Joe","student@student.com","roundabout","DaWarudo",new Date(0), null,Role.Student,passwordEncoder.encode("student")); | ||||||
|         User meh = new User("Inspiration","lackOf","secretary@secretary.com","a Box","the street",new Date(0), null,Role.Secretary,passwordEncoder.encode("secretary")); |         User meh = new User("Inspiration","lackOf","secretary@secretary.com","a Box","the street",new Date(0), null,Role.Secretary,passwordEncoder.encode("secretary")); | ||||||
|         User joke = new User("CthemBalls","Lemme","teacher@teacher.com","lab","faculty",new Date(0), null,Role.Teacher,passwordEncoder.encode("teacher")); |         User joke = new User("CthemBalls","Lemme","teacher@teacher.com","lab","faculty",new Date(0), null,Role.Teacher,passwordEncoder.encode("teacher")); | ||||||
|  |         User joke = new User("hhoo","yeay","teacher2@teacher2.com","lab","faculty",new Date(0), null,Role.Teacher,passwordEncoder.encode("teacher")); | ||||||
|         User lena = new User("Louille","Lena","inscriptionService@InscriptionService.com","no","yes",new Date(0), null,Role.InscriptionService,passwordEncoder.encode("inscriptionService")); |         User lena = new User("Louille","Lena","inscriptionService@InscriptionService.com","no","yes",new Date(0), null,Role.InscriptionService,passwordEncoder.encode("inscriptionService")); | ||||||
|         mockUsers = new ArrayList<>(Arrays.asList(herobrine,joe,meh,joke,lena)); |         mockUsers = new ArrayList<>(Arrays.asList(herobrine,joe,meh,joke,lena)); | ||||||
|  |  | ||||||
| @ -91,7 +92,7 @@ public class MockController { | |||||||
|         CurriculumCourseService.save(new CurriculumCourse(chemistryBab1,chemistry1)); |         CurriculumCourseService.save(new CurriculumCourse(chemistryBab1,chemistry1)); | ||||||
|  |  | ||||||
|  |  | ||||||
|         InscriptionRequest inscriptionRequest = new InscriptionRequest("helen","prenom","non","helen@gmail.com","america",new Date(),(long) 1,RequestState.Refused,"yes.png","password"); |         InscriptionRequest inscriptionRequest = new InscriptionRequest("helen","prenom","non","helen@gmail.com","america",new Date(),(long) 1,RequestState.Pending,"yes.png","password"); | ||||||
|  |  | ||||||
|         inscriptionService.save(inscriptionRequest); |         inscriptionService.save(inscriptionRequest); | ||||||
|          |          | ||||||
|  | |||||||
| @ -12,8 +12,10 @@ window.onhashchange = function() { | |||||||
|     prevURL = currentURL; |     prevURL = currentURL; | ||||||
|     currentURL = window.location.hash; |     currentURL = window.location.hash; | ||||||
| } | } | ||||||
|  | const Logged = ref(isLogged()); | ||||||
|  |  | ||||||
| window.addEventListener('hashchange', () => { | window.addEventListener('hashchange', () => { | ||||||
|  if(location.hash === "#/home" && prevURL === "#/login"){ |  if((location.hash === "#/home" && prevURL === "#/login") || location.hash === "#/home" && prevURL === "#/profil" && !Logged)){ | ||||||
| 		window.location.reload(); | 		window.location.reload(); | ||||||
|  } |  } | ||||||
| }) | }) | ||||||
| @ -24,7 +26,6 @@ window.addEventListener('hashchange', () => { | |||||||
|   const login=ref(i18n("app.login")) |   const login=ref(i18n("app.login")) | ||||||
|   const active=ref(false) |   const active=ref(false) | ||||||
|  |  | ||||||
|   const Logged = ref(isLogged()); |  | ||||||
|  |  | ||||||
| 	const apps = ref([]) | 	const apps = ref([]) | ||||||
| 	appList().then(e => apps.value = e) | 	appList().then(e => apps.value = e) | ||||||
|  | |||||||
| @ -1,15 +1,22 @@ | |||||||
| <script setup> | <script setup> | ||||||
|   import i18n from "@/i18n.js" |   import i18n from "@/i18n.js" | ||||||
|  |   import {ref} from 'vue' | ||||||
|   import {validateRegister, getAllRegisters } from '@/rest/ServiceInscription.js' |   import {validateRegister, getAllRegisters } from '@/rest/ServiceInscription.js' | ||||||
|  |  | ||||||
|   const requests_example = await getAllRegisters(); |   const requests = ref(await getAllRegisters()); | ||||||
|   console.log(requests_example); |   console.log(requests); | ||||||
|  |  | ||||||
|  |   async function upPage(id,review){ | ||||||
|  |     await validateRegister(id,review); | ||||||
|  |     requests.value = await getAllRegisters(); | ||||||
|  |  | ||||||
|  |   } | ||||||
| </script> | </script> | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| <template>  | <template>  | ||||||
|   <div  v-for="item of requests_example"> |   <div  v-for="item of requests"> | ||||||
|   <div class="bodu" v-if="item.state === 'Pending'"> |   <div class="bodu" v-if="item.state === 'Pending'"> | ||||||
|   <div class="container"> |   <div class="container"> | ||||||
|   |   | ||||||
| @ -17,8 +24,8 @@ | |||||||
|     <div class="surname"><a>{{item.lastName}}</a></div> |     <div class="surname"><a>{{item.lastName}}</a></div> | ||||||
|     <div class="firstname"><a>{{item.firstName}}</a></div> |     <div class="firstname"><a>{{item.firstName}}</a></div> | ||||||
|     <div class="infos"><button style="background-color:rgb(105,05,105);" >{{i18n("request.moreInfos")}}</button></div> |     <div class="infos"><button style="background-color:rgb(105,05,105);" >{{i18n("request.moreInfos")}}</button></div> | ||||||
|     <div class="accept"><button @click="validateRegister(item.id,'Accepted')" style="background-color:rgb(0,105,50);">{{i18n("request.accept")}}</button></div> |     <div class="accept"><button @click="upPage(item.id,'Accepted')" style="background-color:rgb(0,105,50);">{{i18n("request.accept")}}</button></div> | ||||||
|     <div class="refuse"><button @click="validateRegister(item.id,'Refused')" style="background-color:rgb(105,0,0);">{{i18n("request.refuse")}}</button></div> |     <div class="refuse"><button @click="upPage(item.id,'Refused')" style="background-color:rgb(105,0,0);">{{i18n("request.refuse")}}</button></div> | ||||||
|   </div> |   </div> | ||||||
|   </div> |   </div> | ||||||
|   </div> |   </div> | ||||||
|  | |||||||
| @ -1,16 +1,27 @@ | |||||||
| <script setup> | <script setup> | ||||||
|   import {reactive, ref } from 'vue' |   import {reactive, ref } from 'vue' | ||||||
|   import {getSelf,alterSelf} from '../rest/Users.js' |   import {getSelf,alterSelf,disconnect,deleteUser} from '../rest/Users.js' | ||||||
|  |   import {getSelfCurriculum, getAllCurriculums} from '../rest/curriculum.js' | ||||||
|  |   import {getCourses} from "../rest/courses.js" | ||||||
|   import i18n from "@/i18n.js" |   import i18n from "@/i18n.js" | ||||||
|   import { uploadProfilePicture } from '@/rest/uploads.js' |   import { uploadProfilePicture } from '@/rest/uploads.js' | ||||||
|  |  | ||||||
|   const user = await getSelf(); |   const user = await getSelf(); | ||||||
|   console.log(user); |   console.log(user); | ||||||
|  |   const UserCurriculum = ref("");  | ||||||
|  |   const curricula = ref (await getAllCurriculums()); | ||||||
|  |   console.log(curricula) | ||||||
|  |   console.log(user.role === "Teacher") | ||||||
|  |   if(user.role === "Student"){ | ||||||
|  |     UserCurriculum.value = await getSelfCurriculum(); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   if(user.role === "Teacher"){ | ||||||
|  |     UserCurriculum.value = await getCourses("Teacher"); | ||||||
|  |     console.log(UserCurriculum.value) | ||||||
|  |   } | ||||||
|   const modif = ref(false); |   const modif = ref(false); | ||||||
|   const curric = ref(false); |   const curric = ref(false); | ||||||
|   const unreg = ref(false); |  | ||||||
|   const reg = ref(false); |   const reg = ref(false); | ||||||
|  |  | ||||||
|   const pattern = { |   const pattern = { | ||||||
| @ -43,8 +54,17 @@ | |||||||
|     } |     } | ||||||
|     toModify= Object.assign({}, pattern); |     toModify= Object.assign({}, pattern); | ||||||
|   } |   } | ||||||
|  |    | ||||||
|  |   async function unRegister(){ | ||||||
|  |     await deleteUser(user.regNo);  | ||||||
|  |      | ||||||
|  |      | ||||||
|  |   } | ||||||
|  |  | ||||||
|   function getPP(){ |   function getPP(){ | ||||||
|  |     if(user.profilePictureUrl === null){ | ||||||
|  |       return "/Clyde.png" | ||||||
|  |     } | ||||||
|     return user.profilePictureUrl |     return user.profilePictureUrl | ||||||
|   } |   } | ||||||
| </script> | </script> | ||||||
| @ -57,7 +77,7 @@ | |||||||
|  |  | ||||||
|     </div> |     </div> | ||||||
|       <div class="globalInfos"> |       <div class="globalInfos"> | ||||||
|         <div v-if="modif==false && curric==false && unreg==false && reg==false " class="infosContainer" > |         <div v-if="modif==false && curric==false && reg==false " class="infosContainer" > | ||||||
|           <div> |           <div> | ||||||
|             {{user.firstName}} {{user.lastName}}    |             {{user.firstName}} {{user.lastName}}    | ||||||
|           </div> |           </div> | ||||||
| @ -65,17 +85,17 @@ | |||||||
|             E-mail: {{user.email}}       |             E-mail: {{user.email}}       | ||||||
|           </div> |           </div> | ||||||
|           <div v-if="user.role==='Student'"> |           <div v-if="user.role==='Student'"> | ||||||
|             {{user.option}} {{i18n(user.role.toLowerCase())}}  |             {{user.option}} {{i18n(user.role)}}  | ||||||
|           </div> |           </div> | ||||||
|           <div v-else> |           <div v-else> | ||||||
|             Role:  {{i18n((user.role).toLowerCase())}}  |             Role:  {{i18n((user.role))}}  | ||||||
|           </div> |           </div> | ||||||
|           <div> |           <div> | ||||||
|             <button @click="modif=!modif"> {{i18n("profile.modify.data")}} </button> |             <button @click="modif=!modif"> {{i18n("profile.modify.data")}} </button> | ||||||
|           </div> |           </div> | ||||||
|           <div v-if="(user.role==='Student')"> |           <div v-if="(user.role==='Student')"> | ||||||
|             <button @click="reg=!reg">{{i18n("profile.reRegister")}}</button> |             <button @click="reg=!reg">{{i18n("profile.reRegister")}}</button> | ||||||
|             <button @click="unreg=!unreg" style="float:right;background-color:rgb(150,0,0);">{{i18n("profile.unRegister")}}</button> |             <button @click="unRegister()" style="float:right;background-color:rgb(150,0,0);">{{i18n("profile.unRegister")}}</button> | ||||||
|           </div> |           </div> | ||||||
|           <div v-if="(user.role==='Student')"> |           <div v-if="(user.role==='Student')"> | ||||||
|             <button @click="curric=!curric">{{i18n("profile.change.curriculum")}}</button> |             <button @click="curric=!curric">{{i18n("profile.change.curriculum")}}</button> | ||||||
| @ -108,28 +128,16 @@ | |||||||
|           </div> |           </div> | ||||||
|         </div> |         </div> | ||||||
|         <div v-else-if="curric" class="infosContainer"> |         <div v-else-if="curric" class="infosContainer"> | ||||||
|           <div> |           <div style="height:40px;"> | ||||||
|             {{i18n("curriculum")}}:   |             {{i18n("Curriculum")}}:   | ||||||
|             <select v-model="curriculum"> |             <select v-model="curriculum" > | ||||||
|               <option v-for="item in currcula">{{item}}</option>         |               <option v-for="item in curricula" style="font-size:20px;" :value="item">{{item.option}}</option>         | ||||||
|             </select> |             </select> | ||||||
|           </div> |           </div> | ||||||
|           <div> |  | ||||||
|             E-mail: |  | ||||||
|             <input type="mail" v-model="mail"> |  | ||||||
|           </div> |  | ||||||
|           <div> |  | ||||||
|             {{i18n("login.password")}}: |  | ||||||
|             <input type="password" v-model="assword"> |  | ||||||
|           </div> |  | ||||||
|           <div> |  | ||||||
|             {{i18n("login.cPassword")}}: |  | ||||||
|             <input type="password" id="confirm"> |  | ||||||
|           </div> |  | ||||||
|  |  | ||||||
|           <div> |           <div> | ||||||
|             <button @click=" curric=!curric;">{{i18n("courses.confirm")}}</button> |             <button @click=" curric=!curric;">{{i18n("courses.confirm")}}</button> | ||||||
|             <button @click="curric=!curric; resetInputs(personnalInfos,patternInfos);console.log(pattern)" style="float:right;">{{i18n("courses.back")}}</button> |             <button @click="curric=!curric; resetInputs(personnalInfos,patternInfos);" style="float:right;">{{i18n("courses.back")}}</button> | ||||||
|           </div> |           </div> | ||||||
|         </div> |         </div> | ||||||
|         <div v-else-if="reg" class="infosContainer"> |         <div v-else-if="reg" class="infosContainer"> | ||||||
| @ -155,43 +163,19 @@ | |||||||
|             <button @click=" reg=!reg; resetInputs(personnalInfos,patternInfos);console.log(pattern)" style="float:right;">{{i18n("courses.back")}}</button> |             <button @click=" reg=!reg; resetInputs(personnalInfos,patternInfos);console.log(pattern)" style="float:right;">{{i18n("courses.back")}}</button> | ||||||
|           </div> |           </div> | ||||||
|         </div> |         </div> | ||||||
|         <div v-else-if="unreg" class="infosContainer"> |  | ||||||
|           <div> |  | ||||||
|             E-mail:   |  | ||||||
|             <input type="mail" v-model="toModify.email" /> |  | ||||||
|           </div> |  | ||||||
|           <div> |  | ||||||
|             {{i18n("profile.address")}}: |  | ||||||
|             <input type="text" v-model="toModify.address"> |  | ||||||
|           </div> |  | ||||||
|           <div> |  | ||||||
|             {{i18n("login.password")}}: |  | ||||||
|             <input type="password" v-model="toModify.password"> |  | ||||||
|           </div> |  | ||||||
|           <div> |  | ||||||
|             {{i18n("login.cPassword")}}: |  | ||||||
|             <input type="password" id="confirm"> |  | ||||||
|           </div> |  | ||||||
|  |  | ||||||
|           <div> |  | ||||||
|             <button @click=" unreg=!unreg;">{{i18n("courses.confirm")}}</button> |  | ||||||
|             <button @click=" unreg=!unreg; resetInputs(personnalInfos,patternInfos);console.log(pattern)" style="float:right;">{{i18n("courses.back")}}</button> |  | ||||||
|           </div> |  | ||||||
|         </div> |  | ||||||
|  |  | ||||||
|       </div> |       </div> | ||||||
|        |        | ||||||
|       <div v-if="modif==false && curric==false && unreg==false && reg==false "class="moreInfos"> |       <div v-if="modif==false && curric==false && reg==false "class="moreInfos"> | ||||||
|  |  | ||||||
|         <div v-if="(user.role==='Student')"> |         <div v-if="(user.role ==='Student')"> | ||||||
|           <div class="listTitle"> |           <div class="listTitle"> | ||||||
|             {{i18n("profile.course.list")}} |             {{i18n("profile.course.list")}} | ||||||
|           </div> |           </div> | ||||||
|           <div  class="listElement " |           <div  class="listElement" v-for="item in UserCurriculum.courses"> | ||||||
|           v-for="item in user.curriculum"> |  | ||||||
|           <div class=" containerElement"> |           <div class=" containerElement"> | ||||||
|             <div class="name"> {{item.name}} </div> |             <div class="name"> {{item.title}} </div> | ||||||
|             <div class="teacher">{{item.teacher}}</div>  |             <div class="teacher">{{item.owner.lastName}}</div>  | ||||||
|             <div class="credits">Credits:{{item.credits}}</div>   |             <div class="credits">Credits:{{item.credits}}</div>   | ||||||
|           </div> |           </div> | ||||||
|           </div> |           </div> | ||||||
| @ -200,14 +184,6 @@ | |||||||
|         <div> |         <div> | ||||||
|         </div> |         </div> | ||||||
|      |      | ||||||
|       <div v-if="(user.role==='Teacher')"> |  | ||||||
|           <div class="listTitle"> |  | ||||||
|             {{i18n("profile.course.list")}} |  | ||||||
|           </div> |  | ||||||
|           <div class="listElement " v-for="item in user.coursesOwned"> |  | ||||||
|           {{item.name}}        |  | ||||||
|           </div> |  | ||||||
|         </div> |  | ||||||
|       </div> |       </div> | ||||||
|   </div> |   </div> | ||||||
| </div> | </div> | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| import { restGet, restPost, restPatch} from './restConsumer.js' | import { restGet, restPost, restPatch, restDelete} from './restConsumer.js' | ||||||
| import { getCookie, setCookie } from '@/utils.js' | import { getCookie, setCookie } from '@/utils.js' | ||||||
|  |  | ||||||
| export async function login(user, pass, exp){ | export async function login(user, pass, exp){ | ||||||
| @ -143,3 +143,9 @@ export async function getSelf(){ | |||||||
| export async function alterSelf(data){ | export async function alterSelf(data){ | ||||||
| 	return restPatch("/user", data); | 	return restPatch("/user", data); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  | export async function deleteUser(id){ | ||||||
|  |   return restDelete("/user/" + id) | ||||||
|  | } | ||||||
|  | |||||||
| @ -43,3 +43,8 @@ export async function getcurriculum(id){ | |||||||
| export async function altercurriculum(id, courses){ | export async function altercurriculum(id, courses){ | ||||||
| 	return restPatch("/curriculum/" + id, courses); | 	return restPatch("/curriculum/" + id, courses); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | export async function getSelfCurriculum(){ | ||||||
|  |   return restGet("/curriculum"); | ||||||
|  | } | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user