2024-04-01 16:51:18 +02:00
|
|
|
<script setup>
|
|
|
|
import { ref } from 'vue'
|
2024-04-07 14:33:51 +02:00
|
|
|
import {getDifferenceTime,lastDateOfMonth,formatDate,getFirstDay,sortByDate,matrixFromList,sundayToTheEnd,getMarginTop,getHoursMinutes, monthFromList} from '../scheduleFunctions.js'
|
|
|
|
import {getAllSchedule} from "@/rest/scheduleRest.js";
|
|
|
|
|
|
|
|
const test = await getAllSchedule();
|
|
|
|
|
|
|
|
console.log(test);
|
|
|
|
|
2024-04-01 16:51:18 +02:00
|
|
|
const schedule = [
|
|
|
|
{
|
2024-04-04 14:44:35 +02:00
|
|
|
course:{
|
|
|
|
id:14,
|
|
|
|
name:"Math Pour L'info",
|
|
|
|
faculty:"Science",
|
|
|
|
teacher:"Doofenschmirtz",
|
|
|
|
assistants:[14,25,13],},
|
|
|
|
|
|
|
|
start:"Mon Apr 01 2024 08:15",
|
|
|
|
|
|
|
|
end:"Mon Apr 01 2024 10:15",
|
|
|
|
color:"rgb(0,50,100)",
|
|
|
|
local:"A0B2"
|
|
|
|
},
|
|
|
|
{course:{
|
|
|
|
id:12,
|
|
|
|
name:"Calculus",
|
|
|
|
faculty:"Science",
|
|
|
|
teacher:"Doofenschmirtz",
|
|
|
|
assistants:[],
|
|
|
|
|
|
|
|
},
|
|
|
|
start:"Wed Mar 27 2024 08:15",
|
|
|
|
end:"Wed Mar 27 2024 09:15",
|
|
|
|
color:"rgb(100,50,0)",
|
|
|
|
local:"A0B2"
|
2024-04-01 16:51:18 +02:00
|
|
|
},
|
2024-04-04 14:44:35 +02:00
|
|
|
{course:{
|
|
|
|
id:2,
|
|
|
|
name:"Physique II",
|
|
|
|
faculty:"Science",
|
|
|
|
teacher:3,
|
|
|
|
assistants:[],
|
|
|
|
|
|
|
|
},
|
|
|
|
start:"Sun Mar 24 2024 10:30 ",
|
|
|
|
end:"Sun Mar 24 2024 12:30 ",
|
|
|
|
color:"rgb(100,50,100)",
|
|
|
|
local:"A0B2"
|
2024-04-01 16:51:18 +02:00
|
|
|
},
|
2024-04-04 14:44:35 +02:00
|
|
|
{course:{
|
|
|
|
id:14,
|
|
|
|
name:"Math Pour L'info",
|
|
|
|
faculty:"Science",
|
|
|
|
teacher:14,
|
|
|
|
assistants:[14,25,13],
|
|
|
|
},
|
|
|
|
start:"Sun Mar 24 2024 13:30",
|
|
|
|
end:"Sun Mar 24 2024 15:30",
|
|
|
|
color:"rgb(100,0,50)",
|
|
|
|
local:"A0B2"
|
2024-04-01 16:51:18 +02:00
|
|
|
}]
|
2024-04-04 14:44:35 +02:00
|
|
|
|
|
|
|
const display =ref("Month")
|
2024-04-01 16:51:18 +02:00
|
|
|
|
2024-04-04 14:44:35 +02:00
|
|
|
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(schedule[1].start)))
|
|
|
|
|
2024-04-01 16:51:18 +02:00
|
|
|
function getMonday(d) {
|
|
|
|
d = new Date(d);
|
2024-04-04 14:44:35 +02:00
|
|
|
d.setHours(0,0,0);
|
2024-04-01 16:51:18 +02:00
|
|
|
var day = d.getDay(),
|
|
|
|
diff = d.getDate() - day + (day == 0 ? -6 : 1);
|
|
|
|
return new Date(d.setDate(diff));
|
|
|
|
}
|
|
|
|
|
|
|
|
function getAnyDays(d){
|
|
|
|
var day = new Date(mondayOfWeek.value);
|
|
|
|
day.setDate(day.getDate() + d );
|
|
|
|
return day;
|
|
|
|
}
|
2024-04-04 14:44:35 +02:00
|
|
|
const mondayOfWeek =ref(getMonday(new Date()))
|
|
|
|
const currentDate = ref(new Date())
|
2024-04-01 16:51:18 +02:00
|
|
|
|
2024-04-04 14:44:35 +02:00
|
|
|
|
2024-04-01 16:51:18 +02:00
|
|
|
function isNotCourse(element){
|
|
|
|
return element==null;
|
|
|
|
}
|
2024-04-04 14:44:35 +02:00
|
|
|
|
2024-04-01 16:51:18 +02:00
|
|
|
|
|
|
|
function durationCourse(element){
|
|
|
|
const hour = element.end.substring(3,5) -element.start.substring(3,5);
|
|
|
|
return (element.end - element.start)%2;
|
|
|
|
}
|
2024-04-04 14:44:35 +02:00
|
|
|
const scheduleByWeek = ref(sundayToTheEnd(matrixFromList(schedule,mondayOfWeek.value)));
|
|
|
|
const month = ref(monthFromList(schedule,new Date().getMonth()));
|
|
|
|
const shift = ref(getFirstDay(new Date()).getDay());
|
|
|
|
let value = 1;
|
|
|
|
const len = ref(lastDateOfMonth(new Date()));
|
|
|
|
|
|
|
|
function changeWeek(i){
|
|
|
|
const temp = getAnyDays(i);
|
|
|
|
mondayOfWeek.value = temp;
|
|
|
|
scheduleByWeek.value = sundayToTheEnd(matrixFromList(schedule, mondayOfWeek.value))
|
2024-04-02 16:52:40 +02:00
|
|
|
}
|
|
|
|
|
2024-04-04 14:44:35 +02:00
|
|
|
function changeMonth(i){
|
|
|
|
const temp = currentDate.value;
|
|
|
|
currentDate.value = new Date( ( 0< temp.getMonth()+i < 13 ? temp.getFullYear() : temp.getFullYear()+i), (0< temp.getMonth()+i <13 ? temp.getMonth()+i : 12 ),1);
|
|
|
|
month.value = monthFromList(schedule,currentDate.value.getMonth())
|
|
|
|
shift.value= getFirstDay(currentDate.value).getDay();
|
|
|
|
len.value= lastDateOfMonth(currentDate.value);
|
|
|
|
value = 1;
|
2024-04-02 16:52:40 +02:00
|
|
|
}
|
|
|
|
|
2024-04-04 14:44:35 +02:00
|
|
|
function isAValue(){
|
|
|
|
if(value-shift.value<0){
|
|
|
|
value++;
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if(value-shift.value<len.value){
|
|
|
|
value++;
|
|
|
|
return true;}
|
|
|
|
|
|
|
|
if(value-shift.value>=len.value){
|
|
|
|
return false
|
|
|
|
}
|
2024-04-02 16:52:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-04-01 16:51:18 +02:00
|
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<div class="grid">
|
|
|
|
<div class="schedule">
|
2024-04-04 14:44:35 +02:00
|
|
|
<template v-if="display=='Week'">
|
2024-04-01 16:51:18 +02:00
|
|
|
<table class="table">
|
|
|
|
<tr style="background-color:rgb(24,24,24)">
|
2024-04-04 14:44:35 +02:00
|
|
|
<th>
|
|
|
|
<button @click="changeWeek(-7)">Previous</button>
|
|
|
|
<button @click="changeWeek(7)">Next</button>
|
|
|
|
<button @click="mondayOfWeek = getMonday(new Date()); scheduleByWeek = sundayToTheEnd(matrixFromList(schedule, mondayOfWeek))">Current</button>
|
|
|
|
|
|
|
|
</th>
|
|
|
|
<th class="header" v-for='d,index in 7' >
|
|
|
|
<p class="childHeader">
|
|
|
|
{{days[index]}}
|
|
|
|
</p>
|
|
|
|
<p class="childHeader">
|
|
|
|
{{formatDate(getAnyDays(index))}}
|
|
|
|
</p>
|
|
|
|
</th>
|
|
|
|
|
|
|
|
|
2024-04-01 16:51:18 +02:00
|
|
|
</tr>
|
|
|
|
<tr v-for="(n,index) in 12">
|
|
|
|
<th class="hour">{{8 + index}}:00-{{9+index}}:00</th>
|
|
|
|
<td v-for="m in 7"></td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
<div class="courseGrid">
|
2024-04-02 16:52:40 +02:00
|
|
|
<div class="dayCourse" v-for="element in scheduleByWeek">
|
|
|
|
<template v-for="i,index in element.length">
|
|
|
|
<div class="course" v-bind:style="{background:element[index].color,
|
|
|
|
height:((getDifferenceTime(element[index].end,element[index].start)/7.2)-0.5)+'%', top:((getMarginTop(element, index, index-1)/7.20))+'%'}">
|
2024-04-04 14:44:35 +02:00
|
|
|
<div class="hourStart">
|
|
|
|
{{getHoursMinutes(element[index].start)}}
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<div class="infos" v-bind:style="{}">
|
|
|
|
<p class="childInfos">{{element[index].course.name}}</p>
|
|
|
|
<p class="childInfos">{{element[index].local}}</p>
|
|
|
|
<p class="childInfos">{{element[index].course.teacher}}</p>
|
|
|
|
</div>
|
|
|
|
<div class="hourEnd">
|
|
|
|
{{getHoursMinutes(element[index].end)}}
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-04-02 16:52:40 +02:00
|
|
|
</template>
|
2024-04-01 16:51:18 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-04-04 14:44:35 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<template v-else>
|
|
|
|
<table class="table">
|
|
|
|
<tr style="background-color:rgb(24,24,24); height:8.33%;">
|
|
|
|
<th colspan="7" class="header">
|
|
|
|
<div>{{months[currentDate.getMonth()]}} {{currentDate.getFullYear()}}</div>
|
|
|
|
<button style="position:absolute; top:0; left:0;" @click="changeMonth(-1)">previous</button>
|
|
|
|
<button style="position:absolute; bottom:0; left:0;"@click="changeMonth(1)">next</button>
|
|
|
|
|
|
|
|
</th>
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
<tr style="background-color:rgb(24,24,24); height:8.33%;" >
|
|
|
|
<th class="header" v-for='d,index in 7' >
|
|
|
|
{{days[index]}}
|
|
|
|
</th>
|
|
|
|
</tr>
|
|
|
|
<tr v-for="n in 5" style="height:16.67%;">
|
|
|
|
<td v-for="m,i in 7" style="height:16.67%; position:relative;">
|
|
|
|
|
|
|
|
<div v-if="isAValue()" style="top:0; right:2%; border-radius:20%;color:rgb(200,200,200) ; position:absolute;z-index:50;">{{value-shift}}</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div style="overflow-y:scroll; height:100%;" >
|
|
|
|
<template v-for="element in month[value-shift]">
|
|
|
|
<div class="course" v-bind:style="{background:element.color, height:100+'%'}">
|
|
|
|
|
|
|
|
<div class="hourStart">
|
|
|
|
{{getHoursMinutes(element.start)}}
|
|
|
|
</div>
|
|
|
|
<div class="infos">
|
|
|
|
<p class="childInfos">{{element.course.name}}</p>
|
|
|
|
<p class="childInfos">{{element.local}}</p>
|
|
|
|
<p class="childInfos">{{element.course.teacher}}</p>
|
|
|
|
</div>
|
|
|
|
<div class="hourEnd">
|
|
|
|
{{getHoursMinutes(element.end)}}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
</table>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</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>
|
2024-04-01 16:51:18 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<style scoped>
|
|
|
|
.grid{
|
|
|
|
display:grid;
|
|
|
|
margin-top:2%;
|
|
|
|
align-items:center;
|
|
|
|
justify-content:center;
|
2024-04-04 14:44:35 +02:00
|
|
|
grid-template-columns:72vw 14.5vw;
|
|
|
|
column-gap:2vw;
|
|
|
|
overflow:hidden;
|
|
|
|
grid-template-areas:"schedule options";
|
2024-04-01 16:51:18 +02:00
|
|
|
}
|
|
|
|
.schedule{
|
2024-04-04 14:44:35 +02:00
|
|
|
position:relative;
|
|
|
|
overflow-y:scroll;
|
2024-04-01 16:51:18 +02:00
|
|
|
border-radius:20px;
|
|
|
|
grid-area:schedule;
|
|
|
|
width:100%;
|
|
|
|
height:85vh;
|
|
|
|
background-color:rgba(255,255,255,0.1);
|
|
|
|
}
|
|
|
|
.options{
|
2024-04-04 14:44:35 +02:00
|
|
|
display:flex;
|
|
|
|
flex-direction:column;
|
2024-04-01 16:51:18 +02:00
|
|
|
border-radius:20px;
|
|
|
|
grid-area:options;
|
|
|
|
background-color:rgba(255,255,255,0.1);
|
|
|
|
width:100%;
|
|
|
|
height:85vh;
|
|
|
|
}
|
|
|
|
|
|
|
|
.table{
|
|
|
|
width:100%;
|
|
|
|
height:100%;
|
|
|
|
border-spacing:0;
|
|
|
|
border-collapse:separate;
|
|
|
|
border-radius: 20px;
|
|
|
|
border: 2px solid black
|
|
|
|
}
|
|
|
|
|
|
|
|
.hour{
|
|
|
|
background-color:rgb(72,72,72)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
.header{
|
|
|
|
width:12.5%;
|
|
|
|
color:#FFFFFF;
|
2024-04-04 14:44:35 +02:00
|
|
|
position:relative;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.childHeader{
|
|
|
|
margin-top:0;
|
|
|
|
margin-bottom:0;
|
|
|
|
max-height:14.28%
|
|
|
|
|
2024-04-01 16:51:18 +02:00
|
|
|
}
|
|
|
|
table th:not(:last-child),
|
|
|
|
table td:not(:last-child) {
|
|
|
|
border-right: 1px solid black;
|
|
|
|
}
|
|
|
|
|
|
|
|
table tr:not(:last-child)>td,
|
|
|
|
table tr:not(:last-child)>th
|
|
|
|
{
|
|
|
|
border-bottom:1px solid black;
|
|
|
|
}
|
|
|
|
|
|
|
|
.courseGrid{
|
|
|
|
top:13.75%;
|
|
|
|
left:12.5%;
|
|
|
|
position:absolute;
|
|
|
|
width:87.5%;
|
|
|
|
height:86.25%;
|
|
|
|
display:grid;
|
|
|
|
grid-template-columns:repeat(7,1fr);
|
|
|
|
}
|
|
|
|
|
2024-04-04 14:44:35 +02:00
|
|
|
|
2024-04-01 16:51:18 +02:00
|
|
|
.course{
|
2024-04-02 16:52:40 +02:00
|
|
|
position:relative;
|
|
|
|
border: 1px solid black;
|
|
|
|
border-radius:10px;
|
|
|
|
width:90%;
|
|
|
|
margin-left:auto;
|
|
|
|
margin-right:auto;
|
|
|
|
display:grid;
|
|
|
|
grid-template-rows:1fr 1fr 1fr;
|
|
|
|
}
|
|
|
|
|
|
|
|
.dayCourse{
|
|
|
|
display:block;
|
2024-04-01 16:51:18 +02:00
|
|
|
}
|
2024-04-04 14:44:35 +02:00
|
|
|
|
|
|
|
.infos{
|
|
|
|
height:100%;
|
|
|
|
width:100%;
|
|
|
|
font-size:0.85em;
|
|
|
|
display:flex;
|
|
|
|
flex-direction:column;
|
|
|
|
align-items:center;
|
|
|
|
justify-content:center;
|
|
|
|
position:absolute;
|
|
|
|
}
|
2024-04-01 16:51:18 +02:00
|
|
|
|
2024-04-04 14:44:35 +02:00
|
|
|
.childInfos{
|
|
|
|
text-align:center;
|
|
|
|
margin-top:0%;
|
|
|
|
margin-bottom:0%;
|
|
|
|
overflow:hidden;
|
|
|
|
}
|
|
|
|
|
|
|
|
.hourStart{
|
|
|
|
background-color:rgb(200,200,200);
|
|
|
|
border-radius:5px;
|
|
|
|
position:absolute;
|
|
|
|
top:2%;
|
|
|
|
left:2%;
|
|
|
|
font-size:0.75em;
|
|
|
|
|
|
|
|
border: 1px solid black;
|
|
|
|
}
|
|
|
|
|
|
|
|
.hourEnd{
|
|
|
|
background-color:rgb(200,200,200);
|
|
|
|
border-radius:3px;
|
|
|
|
position:absolute;
|
|
|
|
bottom:2%;
|
|
|
|
left:2%;
|
|
|
|
font-size:0.7em;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-04-01 16:51:18 +02:00
|
|
|
</style>
|