1
0
forked from PGL/Clyde

Filter and lists

This commit is contained in:
Wawilski 2024-04-11 15:47:56 +02:00
parent 95ef4023d6
commit adaa828810
6 changed files with 273 additions and 32 deletions

View File

@ -107,11 +107,11 @@ public class MockController {
//Schedule part
Lesson lesson_0_progra1 = new Lesson(progra1, "Mon Apr 01 2024 08:15", "Mon Apr 01 2024 10:15","rgb(0,50,100)","A0B2");
Lesson lesson_0_chemistry1 = new Lesson(chemistry1, "Wed Mar 27 2024 08:15", "Wed Mar 27 2024 09:15","rgb(100,50,0)","A0B2");
Lesson lesson_0_psycho1 = new Lesson(psycho1, "Sun Mar 24 2024 10:30 ","Sun Mar 24 2024 12:30 ","rgb(100,50,100)", "A0B2");
Lesson lesson_1_progra1 = new Lesson(progra1, "Mon Apr 02 2024 13:30", "Mon Apr 02 2024 15:30","rgb(0,50,100)","A0B2");
Lesson lesson_0_commun = new Lesson(commun, "Mon Apr 01 2024 10:30", "Mon Apr 01 2024 12:30","rgb(0,50,100)","A0B2");
Lesson lesson_0_progra1 = new Lesson(progra1, "Mon Apr 01 2024 08:15", "Mon Apr 01 2024 10:15","rgb(0,50,100)","A0B2","Course");
Lesson lesson_0_chemistry1 = new Lesson(chemistry1, "Wed Mar 27 2024 08:15", "Wed Mar 27 2024 09:15","rgb(100,50,0)","A0B2","TP");
Lesson lesson_0_psycho1 = new Lesson(psycho1, "Sun Mar 24 2024 10:30 ","Sun Mar 24 2024 12:30 ","rgb(100,50,100)", "A0B2","TD");
Lesson lesson_1_progra1 = new Lesson(progra1, "Mon Apr 02 2024 13:30", "Mon Apr 02 2024 15:30","rgb(0,50,100)","A0B2","TP");
Lesson lesson_0_commun = new Lesson(commun, "Mon Apr 01 2024 10:30", "Mon Apr 01 2024 12:30","rgb(0,50,100)","A0B2","Course");
Schedule infoBab1Schedule = new Schedule(infoBab1);
Schedule chemistryBab1Schedule = new Schedule(chemistryBab1);

View File

@ -103,9 +103,6 @@ public class UserController {
@GetMapping("/teachers")
public ResponseEntity<Iterable<HashMap<String,Object>>> getAllTeachers(@RequestHeader("Authorization") String token){
if (authServ.getUserFromToken(token) == null)
return new UnauthorizedResponse<>(null);
Iterable<User> teachers = userService.getAllTeachers();
return new ResponseEntity<>(ProtectionService.usersWithoutPasswords(teachers), HttpStatus.OK);

View File

@ -57,6 +57,10 @@ public class LessonService {
break;
case "local":
target.setLocal((String) entry.getValue());
break;
case "lessonType":
target.setLessonType((String) entry.getValue());
break;
}
}
lessonRepo.save(target);

View File

@ -82,6 +82,7 @@ public class ProtectionService {
toReturn.put("course",courseWithoutPassword(lesson.getCourse()));
toReturn.put("local",lesson.getLocal());
toReturn.put("color", lesson.getColor());
toReturn.put("lessonType",lesson.getLessonType());
return toReturn;
}

View File

@ -16,16 +16,20 @@ public class Lesson {
private String lessonStart;
private String lessonEnd;
private String color;
private String lessonType;
private String local;
public Lesson(Course course,String start, String end ,String color,String local){
public Lesson(Course course,String start, String end ,String color,String local,String lessonType){
this.lessonEnd = end;
this.course = course;
this.lessonStart = start;
this.color = color;
this.local = local;
this.lessonType = lessonType;
}
public Lesson() {
@ -59,6 +63,10 @@ public class Lesson {
return local;
}
public String getLessonType(){
return lessonType;
}
public void setLessonStart(String start){
this.lessonStart = start;
}
@ -74,4 +82,8 @@ public class Lesson {
public void setLocal(String local){
this.local = local;
}
public void setLessonType(String lessonType){
this.lessonType = lessonType;
}
}

View File

@ -3,11 +3,13 @@
import {getDifferenceTime,lastDateOfMonth,formatDate,getFirstDay,sortByDate,matrixFromList,sundayToTheEnd,getMarginTop,getHoursMinutes, monthFromList} from '../scheduleFunctions.js'
import {getAllSchedule, getOwnSchedule, getCurriculumSchedule} from "@/rest/scheduleRest.js";
import {getLessons, getOwnedLessons } from "@/rest/lessonSchedule.js"
import {isLogged, getSelf} from "@/rest/Users.js"
import {getAllCurriculums} from "@/rest/curriculum.js"
import {isLogged, getSelf,getTeachers} from "@/rest/Users.js"
import {getAllCurriculums, getcurriculum} from "@/rest/curriculum.js"
const trueSchedule = ref()
const log = await isLogged();
const schedule = ref();
const curriculum = ref();
const shift = ref(getFirstDay(new Date()).getDay());
let value = 1;
const len = ref(lastDateOfMonth(new Date()));
@ -18,8 +20,8 @@
const allSchedules = await getAllSchedule();
let counter = 0;
const ownSchedule = ref();
console.log(allSchedules)
const filter = ref("null");
const subFilter = ref("null");
let user;
if(log){
@ -34,8 +36,9 @@
}
if(user.role == "Student"){
const trueSchedule = await getOwnSchedule();
ownSchedule.value = trueSchedule.lessons;}
trueSchedule.value = await getOwnSchedule();
ownSchedule.value = trueSchedule.value.lessons;
curriculum.value = trueSchedule.value.curriculum;}
schedule.value = ownSchedule.value;
scheduleByWeek.value = sundayToTheEnd(matrixFromList(schedule.value,mondayOfWeek.value));
@ -46,8 +49,16 @@
const display =ref("Month")
const display =ref("Week");
const format = ref("Grid");
const filters = ["Type","Teacher","Course"];
const types = ["TP","TD","Course","Exam"];
const teachers = await getTeachers() ;
const courses = ref();
if(curriculum.value != null){
courses.value = curriculum.value.courses;
}
const days = ["Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi","Dimanche"];
const months = ["Janvier","Fevrier","Mars","Avril",'Mai',"Juin","Juillet","Aout","Septembre","Octobre","Novembre","Decembre"]
const firstDayOfMonth = ref(getFirstDay(new Date()))
@ -91,12 +102,97 @@
}
function dateOfMonth(i){
async function changeSchedule(){
return new Date(currentDate.value.getFullYear(),currentDate.value.getMonth(),i);
}
function sortSchedule(){
schedule.value =trueSchedule.value.lessons;
console.log(filter.value)
if(filter.value =="Teacher"){
schedule.value = sortByTeacher(schedule.value,subFilter.value);
scheduleByWeek.value = sundayToTheEnd(matrixFromList(schedule.value,mondayOfWeek.value));
month.value = monthFromList(schedule.value,currentDate.value.getMonth());
value = 1;
counter=0;
}
else if(filter.value =="Type"){
schedule.value = sortByType(schedule.value,subFilter.value);
scheduleByWeek.value = sundayToTheEnd(matrixFromList(schedule.value,mondayOfWeek.value));
month.value = monthFromList(schedule.value,currentDate.value.getMonth());
value = 1;
counter=0;
}
else if(filter.value =="Course"){
schedule.value = sortByCourse(schedule.value,subFilter.value);
scheduleByWeek.value = sundayToTheEnd(matrixFromList(schedule.value,mondayOfWeek.value));
month.value = monthFromList(schedule.value,currentDate.value.getMonth());
value = 1;
counter=0;
}
}
function sortByType(lessons,type){
if(type == null){
return lessons;
}
const matrix = [];
for (let element in lessons){
console.log(lessons[element].lessonType)
if(lessons[element].lessonType == type){
matrix.push(lessons[element])
}
}
return matrix
}
function sortByCourse(lessons,course){
if(course == null){
return lessons;
}
const matrix = [];
for (let element in lessons){
if(lessons[element].course.title == course.title){
matrix.push(lessons[element])
}
}
return matrix
}
function sortByTeacher(lessons, teacher){
if(teacher == null){
return lessons;
}
const matrix = [];
for (let element in lessons){
if(lessons[element].course.owner.regNo == teacher.regNo){
matrix.push(lessons[element])
}
}
return matrix
}
async function changeSchedule(){
schedule.value =trueSchedule.value.lessons;
curriculum.value = trueSchedule.value.curriculum;
scheduleByWeek.value = sundayToTheEnd(matrixFromList(schedule.value,mondayOfWeek.value));
month.value = monthFromList(schedule.value,currentDate.value.getMonth());
value = 1;
counter=0;
courses.value = (await getcurriculum(curriculum.value.curriculumId)).courses;
filter.value = "null";
subFilter.value = "null"
}
function changeWeek(i){
@ -145,7 +241,7 @@
</script>
<template>
<div class="grid">
<div class="schedule">
<div class="schedule" v-if="format == 'Grid'">
<template v-if="display=='Week'">
<table class="table">
<tr style="background-color:rgb(24,24,24)">
@ -184,7 +280,8 @@
<div class="infos" v-bind:style="{}">
<p class="childInfos">{{element[index].course.title}}</p>
<p class="childInfos">{{element[index].local}}</p>
<p class="childInfos">{{element[index].course.teacher}}</p>
<p class="childInfos">{{element[index].lessonType}}</p>
<p class="childInfos">{{element[index].course.owner.lastName}}</p>
</div>
<div class="hourEnd">
{{getHoursMinutes(element[index].lessonEnd)}}
@ -224,6 +321,7 @@
<div class="infos">
<p class="childInfos">{{element.course.title}}</p>
<p class="childInfos">{{element.local}}</p>
<p class="childInfos">{{element.lessonType}}</p>
<p class="childInfos">{{element.course.owner.lastName}}</p>
</div>
<div class="hourEnd">
@ -234,21 +332,97 @@
</div>
</td>
</tr>
</table>
</template>
</div>
<div class="schedule" v-else>
<div v-if="display == 'Week'">
<button @click="changeWeek(-7)">Previous</button>
<button @click="changeWeek(7)">Next</button>
<button @click="mondayOfWeek = getMonday(new Date());
scheduleByWeek != null ? scheduleByWeek = sundayToTheEnd(matrixFromList(schedule.value, mondayOfWeek)) : null;">Current</button>
<template v-for="i,index in 7">
<div class="body" style="background-color:#181818;">{{days[index]}} {{formatDate(getAnyDays(index))}}
</div>
<template v-if="scheduleByWeek != null">
<div class="body" style="background-color:#353535;" >
<div class="containerList" v-for="n,j in scheduleByWeek[index].length">
<div class="colorList" v-bind:style="{background:scheduleByWeek[index][j].color}"></div>
<div class="hoursList">{{ getHoursMinutes(scheduleByWeek[index][j].lessonStart)}}-{{getHoursMinutes(scheduleByWeek[index][j].lessonEnd)}}</div>
<div class="titleList">{{scheduleByWeek[index][j].course.title}}</div>
<div class="teacherList">{{scheduleByWeek[index][j].course.owner.lastName}}</div>
<div class="localList">{{scheduleByWeek[index][j].local}}</div>
<div class="typeList">{{scheduleByWeek[index][j].lessonType}}</div>
</div>
</div>
</template>
</template>
</div>
<div v-if="display == 'Month'">
<button @click="changeMonth(-1)">Previous</button>
<button @click="changeMonth(1)">Next</button>
<div class="body" >{{months[currentDate.getMonth()]}} {{currentDate.getFullYear()}}</div>
<template v-for="i,index in lastDateOfMonth(currentDate.getMonth())-1">
<div class="body" style="background-color:#181818;">{{ dateOfMonth(i).getDay()-1== -1 ? days[6] : days[dateOfMonth(i).getDay()-1] }} {{formatDate(dateOfMonth(i))}}
</div>
<template v-if="scheduleByWeek != null">
<div class="body" style="background-color:#353535;" >
<div class="containerList" v-for="n,j in month[i].length">
<div class="colorList" v-bind:style="{background:month[i][j].color}"></div>
<div class="hoursList">{{ getHoursMinutes(month[i][j].lessonStart)}}-{{getHoursMinutes(month[i][j].lessonEnd)}}</div>
<div class="titleList">{{month[i][j].course.title}}</div>
<div class="teacherList">{{month[i][j].course.owner.lastName}}</div>
<div class="localList">{{month[i][j].local}}</div>
<div class="typeList">{{month[i][j].lessonType}}</div>
</div>
</div>
</template>
</template>
</div>
</div>
<div class="options">
<button v-if="display=='Week'" @click="display='Month'">Month</button>
<button v-if="display=='Month'" @click="display='Week'; value=1;">Week</button>
<button v-if="verifUser()" @click="displayOwnSchedule()">OwnSchedule</button>
<select @change="changeSchedule()" v-model="schedule">
<option v-for="item in allSchedules" :value='item.lessons'>{{item.curriculum.option}}</option>
<select @change="changeSchedule()" v-model="trueSchedule">
<option v-for="item in allSchedules" :value='item'>{{item.curriculum.option}}</option>
</select>
<button v-if="display=='Week'" @click="display='Month'">Week</button>
<button v-if="display=='Month'" @click="display='Week'; value=1;">Month</button>
<button v-if="format == 'Grid'" @click="format ='List'">Grid</button>
<button v-if="format == 'List'" @click ="format = 'Grid'">List</button>
<button v-if="verifUser()" @click="displayOwnSchedule()">OwnSchedule</button>
<select v-if="schedule != null" @change="subFilter = 'null'" v-model="filter">
<option :value ="null">No Filter</option>
<option v-for="item in filters" :value="item">{{item}}</option>
</select>
<select @change="sortSchedule()" v-if="filter == 'Teacher'" v-model="subFilter">
<option :value ="null">No Filter</option>
<option v-for="item in teachers" :value=item>{{item.lastName}}</option>
</select>
<select @change="sortSchedule()" v-if="filter == 'Course'" v-model="subFilter">
<option :value ="null">No Filter</option>
<option v-for="item in courses" :value=item>{{item.title}}</option>
</select>
<select @change="sortSchedule()" v-if="filter == 'Type'" v-model="subFilter">
<option :value ="null">No Filter</option>
<option v-for="item in types" :value='item'>{{item}}</option>
</select>
</div>
</div>
@ -350,7 +524,7 @@
.infos{
height:100%;
width:100%;
font-size:0.85em;
font-size:0.75em;
display:flex;
flex-direction:column;
align-items:center;
@ -384,6 +558,59 @@
left:2%;
font-size:0.7em;
}
.containerList{
color:white;
height:100px;
font-size:20px;
display:grid;
grid-template-columns:5vw auto auto auto auto auto;
grid-template-areas:
"color hours title teacher local type";
}
.colorList{
grid-area:color;
align-self:center;
width:75%;
height:75%;
border:1px solid black;
border-radius:20%;
}
.hoursList{
grid-area:hours;
align-self:center;
}
.titleList{
grid-area:title;
align-self:center;
}
.teacherList {
grid-area:teacher;
align-self:center;
}
.localList{
grid-area:local;
align-self:center;
}
.typeList{
grid-area:type;
align-self:center;
}
.body {
color:white;
margin-top:2%;
width:100%;
border:2px solid black;
border-radius:9px;
}
</style>