1
0
forked from PGL/Clyde

Compare commits

..

No commits in common. "7cdbf6de7466d428e21b42f88531974032fd2327" and "0ffc8077db34712ba0d053160176f842b06c1393" have entirely different histories.

10 changed files with 49 additions and 178 deletions

View File

@ -108,8 +108,6 @@ public class LessonRequestsController {
else{
lessonRequestServ.modifyDeleteRequest(lessonRequest, state);
lessonRequest.setState(state);
}
lessonRequestServ.save(lessonRequest);
return new ResponseEntity<>(HttpStatus.OK);

View File

@ -7,11 +7,8 @@ import ovh.herisson.Clyde.Tables.User;
public interface LessonChangesRequestRepository extends CrudRepository<LessonChangesRequest, Long> {
LessonChangesRequest findById(long id);
@Query("select lr from LessonChangesRequest lr where lr.user = ?1")
Iterable<LessonChangesRequest> findOwnRequests(User user);
@Query("select lr from LessonChangesRequest lr where lr.lessonId = ?1")
Iterable<LessonChangesRequest> findRequestByLessonId(long id);
}

View File

@ -74,17 +74,6 @@ public class LessonRequestService {
return true;
}
public Iterable<LessonChangesRequest> findRequestByLessonId(long id){
return lessonChangesRepo.findRequestByLessonId(id);
}
public void refuseAllByLessonId(long id){
Iterable<LessonChangesRequest> toRefuse = findRequestByLessonId(id);
for(LessonChangesRequest element : toRefuse)
element.setState(RequestState.Refused);
}
public boolean modifyChangeRequestState(Map<String, Object> updates, long lessonId,RequestState state){
if(state == RequestState.Accepted){
@ -98,8 +87,7 @@ public class LessonRequestService {
public void modifyDeleteRequest(LessonChangesRequest lessonChangesRequest, RequestState state){
if(state == RequestState.Accepted){
lessonServ.delete(lessonServ.findById(lessonChangesRequest.getLessonId()));
refuseAllByLessonId(lessonChangesRequest.getLessonId());
}
lessonChangesRequest.setState(state);}
}
public LessonChangesRequest createLessonRequest(Map<String,Object> lessonInfos) {

View File

@ -234,7 +234,6 @@ window.addEventListener('hashchange', () => {
.text {
right: 0%;
width: 0%;
visibility: collapse;
opacity: 0;
color: white;
font-size: 1.2em;
@ -243,8 +242,7 @@ window.addEventListener('hashchange', () => {
}
ul.vertical:hover .text {
opacity:1;
visibility:visible;
opacity: 1;
width: 60%;
transition-duration: .3s;
padding-left: 15px;

View File

@ -4,7 +4,6 @@ import i18n from "@/i18n.js"
import {ref} from 'vue'
import {changeRequestState, getAllRequests} from "@/rest/LessonRequests.js";
import {getLesson} from "@/rest/lessonSchedule.js";
import {getCourse} from "@/rest/courses.js"
import {formatDate, getHoursMinutes} from "@/scheduleFunctions.js";
const requests = ref(await getAllRequests());
@ -23,8 +22,7 @@ async function upPage(id,review){
async function AcceptSetup(id,type){
if(type !== 2 ){
editElementID.value = id
AcceptMod.value = true;
AcceptMod.value = !AcceptMod.value;
}
else{
await upPage(id,{local: null,state:'Accepted'});
@ -36,26 +34,21 @@ function editItem(item){
}
async function setMoreInfos(item){
moreInfos.value = Object.assign({},{})
moreInfos.value["requestType"] = requestTypes[item.requestType]
if(item.requestType == 0 || item.requestType == 1){
moreInfos.value["day"] = item.lessonStart == null ? null : formatDate(new Date(item.lessonStart))
moreInfos.value["start"] = item.lessonStart == null ? null : getHoursMinutes(new Date(item.lessonStart))
moreInfos.value["end"] = item.lessonEnd == null ? null : getHoursMinutes(new Date(item.lessonEnd))
moreInfos.value["day"] = formatDate(new Date(item.lessonStart))
moreInfos.value["start"] = getHoursMinutes(new Date(item.lessonStart));
moreInfos.value["end"] = getHoursMinutes(new Date(item.lessonEnd));
moreInfos.value["lessonType"] = item.lessonType;
moreInfos.value["course"] = item["course"] == null ? null:item.course.title}
[item["course"] == null ? moreInfos.value["course"] = null: moreInfos.value["course"]=item.course.title]
if (item.requestType==1 || item.requestType == 2){
let temp = await getLesson(item.lessonId);
if(item.requestType == 1 || item.requestType == 2){
let temp = await getLesson(item.lessonId);
if(item.requestType == 1){
moreInfos.value["course"] = temp.course.title;
moreInfos.value[item.requestType == 2 ? "day" : "old_day"] = formatDate(new Date(temp.lessonStart));
moreInfos.value[item.requestType == 2 ? "start" : "old_start"] = getHoursMinutes(new Date(temp.lessonStart));
moreInfos.value[item.requestType == 2 ? "end":"old_end"] = getHoursMinutes(new Date(temp.lessonEnd));
moreInfos.value[item.requestType == 2 ? "lessonType":"old_type"] = temp.lessonType;
moreInfos.value["old_day"] = formatDate(new Date(temp.lessonStart));
moreInfos.value["old_start"] = getHoursMinutes(new Date(temp.lessonStart));
moreInfos.value["old_end"] = getHoursMinutes(new Date(temp.lessonEnd));
moreInfos.value["old_type"] = temp.lessonType;
}}
editElementID.value = item.id ;
moreInfosMod.value =true;
}
</script>
@ -66,7 +59,8 @@ async function setMoreInfos(item){
<div class="body">
<div v-for="item of requests" :key="item.id" :style="{width:[moreInfosMod ? 95:70] + '%'}" class="centerer">
<button v-if="moreInfosMod && editElementID == item.id" @click="moreInfosMod = false; editElementID = ''; moreInfos='';">back</button>
<div v-if ="item.state === 'Pending'" class="listElement">
<div class="containerElement" v-if="editElementID !== item.id">
<div class="id">{{requestTypes[item.requestType]}}</div>
@ -74,20 +68,20 @@ async function setMoreInfos(item){
<div class="firstname">{{item.user.lastName}}</div>
<div class="infos">
<button @click=" setMoreInfos(item); console.log(item);" style="background-color:rgb(105,05,105);" >
<button @click=" editItem(item);moreInfosMod=!moreInfosMod; setMoreInfos(item); console.log(item);" style="background-color:rgb(105,05,105);" >
{{i18n("request.moreInfos")}}
</button></div>
<div class="accept"><button @click="AcceptSetup(item.id,item.requestType);" style="background-color:rgb(0,105,50);">{{i18n("request.accept")}}</button></div>
<div class="accept"><button @click="editItem(item); AcceptSetup(item.id,item.requestType);" style="background-color:rgb(0,105,50);">{{i18n("request.accept")}}</button></div>
<div class="refuse"><button @click="upPage(item.id,{local: null,state:'Refused'})" style="background-color:rgb(105,0,0);">{{i18n("request.refuse")}}</button></div>
</div>
<div v-else class="containerElement" style="width:auto; height:auto;">
<div v-if="AcceptMod" style="margin-left:20%;">
<div v-if="AcceptMod">
Local:
<select v-model="chosenLocal">
<option v-for="item in locals">{{item}}</option>
</select>
<button @click="AcceptMod = false;upPage(item.id,{local: chosenLocal, state:'Accepted'})">Accept</button>
<button @click="AcceptMod = !AcceptMod;upPage(item.id,{local: chosenLocal, state:'Accepted'})"></button>
</div>
<template v-if="moreInfosMod" v-for="(key,value) in moreInfos">
@ -98,6 +92,7 @@ async function setMoreInfos(item){
</div>
</div>
</template>
<button @click = "moreInfosMod = !moreInfosMod; editElementID = ''">back</button>
</div>
</div>
</div>

View File

@ -1,7 +1,7 @@
<script setup>
import { ref } from 'vue'
import i18n from '@/i18n.js'
import {formatDate,getHoursMinutes,sortByDate} from '../scheduleFunctions.js'
import {formatDate,getHoursMinutes} from '../scheduleFunctions.js'
import {getOwnedLessons} from "@/rest/lessonSchedule.js";
import {getSelf} from "@/rest/Users.js";
import {createRequest} from "@/rest/LessonRequests.js"
@ -12,7 +12,6 @@ import {getAllSchedule} from "@/rest/scheduleRest.js";
const curriculum = ref();
const allSchedules = ref(await getAllSchedule());
const schedule = ref(await getOwnedLessons());
schedule.value.sort((a,b) => sortByDate(b,a))
const createMod = ref(false);
const user = await getSelf();
const editElementID = ref();
@ -86,11 +85,6 @@ function setModify(lesson){
toModify.value.lessonType = lesson.lessonType
}
function setCreate(){
toModify.value = ref(Object.assign({},pattern));
createMod.value = !createMod.value;
}
async function createLessonRequest(){
if(requestType.value === 0 || requestType.value === 1){
//modify
@ -132,6 +126,7 @@ async function askChanges(i){
<template>
<div class="body">
<button @click="createMod = !createMod">Ask Create Request</button>
<div v-if="createMod">
<form class="listElement" style="width:40%; margin:0 auto 0 auto;">
<div style="margin-bottom:20px;">
@ -173,8 +168,7 @@ async function askChanges(i){
</div>
<button v-if="!createMod" @click="setCreate()" style="display:flex; margin:0 auto 0 auto;">Ask Create Request</button>
<div v-if="!createMod"v-for="element in schedule" style="width:50%;margin-left:auto; margin-right:auto;" >
<div v-if="editElementID !== element.lessonID" style ="padding:15px 15px 15px 15px;">
<button v-if="inFuture(element)" @click="editElementID = element.lessonID;setModify(element);">

View File

@ -9,13 +9,9 @@
const trueSchedule = ref()
const log = await isLogged();
const schedule = ref();
const importedJSON = ref();
const jsonSchedule = ref();
const jsonMod = ref(false);
const curriculum = ref();
const shift = ref(getFirstDay(new Date()).getDay());
let value = 1;
let done = false;
const len = ref(lastDateOfMonth(new Date()));
const scheduleByWeek = ref();
const month = ref();
@ -47,13 +43,10 @@
curriculum.value = trueSchedule.value.curriculum;}
schedule.value = ownSchedule.value;
schedule.value.sort((a,b) => sortByDate(a,b));
scheduleByWeek.value = sundayToTheEnd(matrixFromList(schedule.value,mondayOfWeek.value));
month.value = monthFromList(schedule.value,new Date().getMonth());
}
}
}
@ -108,79 +101,10 @@
month.value = monthFromList(schedule.value,currentDate.value.getMonth());
value = 1;
counter=0;
done = false;
}
function createJSON(){
const json = {"data":[]};
for(let element in schedule.value){
let item = {};
item["title"] = schedule.value[element].course.title + "\n" + schedule.value[element].course.owner.lastName+ "\n" + schedule.value[element].local
item["start"] = schedule.value[element].lessonStart;
item["end"] = schedule.value[element].lessonEnd;
item["color"] = schedule.value[element].color;
json.data.push(item)
}
return json
}
function exportJSON(){
let json = createJSON();
const data = JSON.stringify(json);
const blob = new Blob([data], {type:"application/json"});
const a = document.createElement('a');
a.href = URL.createObjectURL(blob);
a.download = "Schedule.json";
a.click();
}
function onFileChange(e) {
let files = e.target.files || e.dataTransfer.files;
if (!files.length) return;
readFile(files[0]);
}
function readFile(file) {
let reader = new FileReader();
reader.onload = e => {
let json = JSON.parse(e.target.result);
importedJSON.value = json
createScheduleFromJSON();
jsonMod.value= true;
};
reader.readAsText(file);
}
function createScheduleFromJSON(){
let jsonBrut = importedJSON.value;
let toEventList = [];
for(let element in jsonBrut["data"]){
let temp = {}
temp["title"] = jsonBrut["data"][element].title;
temp["lessonStart"] = jsonBrut["data"][element].start;
temp["lessonEnd"] = jsonBrut["data"][element].end;
temp["color"] = jsonBrut["data"][element].color;
toEventList.push(temp);
}
jsonSchedule.value = toEventList;
scheduleByWeek.value = sundayToTheEnd(matrixFromList(jsonSchedule.value,mondayOfWeek.value));
month.value = monthFromList(jsonSchedule.value,new Date().getMonth());
}
function switchToJSON(){
jsonMod.value = true;
scheduleByWeek.value = sundayToTheEnd(matrixFromList(jsonSchedule.value,mondayOfWeek.value));
month.value = monthFromList(jsonSchedule.value,new Date().getMonth());
}
function lessonFocus(element){
if(!jsonMod.value){
focus.value = element;
var lessonsList = [];
for (let element in schedule.value){
@ -188,7 +112,7 @@
lessonsList.push(schedule.value[element]);
}
}
focusLessons.value = lessonsList;}
focusLessons.value = lessonsList;
}
@ -237,6 +161,7 @@
}
const matrix = [];
for (let element in lessons){
console.log(lessons[element].lessonType)
if(lessons[element].lessonType == type){
matrix.push(lessons[element])
}
@ -282,24 +207,18 @@
month.value = monthFromList(schedule.value,currentDate.value.getMonth());
value = 1;
counter=0;
done = false;
courses.value = (await getcurriculum(curriculum.value.curriculumId)).courses;
filter.value = "null";
subFilter.value = "null"
focus.value = null;
focusLessons.value = null;
jsonMod.value = false;
}
function changeWeek(i){
const temp = getAnyDays(i);
mondayOfWeek.value = temp;
if(scheduleByWeek.value != null)
if(jsonMod.value){
scheduleByWeek.value = sundayToTheEnd(matrixFromList(jsonSchedule.value, mondayOfWeek.value))}
else{
scheduleByWeek.value = sundayToTheEnd(matrixFromList(schedule.value, mondayOfWeek.value))}
scheduleByWeek.value = sundayToTheEnd(matrixFromList(schedule.value, mondayOfWeek.value))
}
function changeMonth(i){
@ -309,14 +228,8 @@
len.value= lastDateOfMonth(currentDate.value);
value = 1;
counter = 0;
done=false;
if(month.value != null){
if(jsonMod.value){
month.value = monthFromList(jsonSchedule.value,currentDate.value.getMonth())}
}
else{
month.value = monthFromList(schedule.value,currentDate.value.getMonth())}
}
@ -332,14 +245,11 @@
return true;}
if(value-shift.value==len.value){
done = true;
counter++;
if(counter> 35){
counter=1;
value = 2;
done = false;
return true; }
return false;
}
@ -388,11 +298,10 @@
</div>
<div class="infos">
<p class="childInfos" >{{jsonMod ? element[index].title : element[index].course.title}}</p>
<p class="childInfos"v-if="!jsonMod">{{element[index].local}}</p>
<p class="childInfos"v-if="!jsonMod">{{element[index].lessonType}}</p>
<p class="childInfos"v-if="!jsonMod">{{element[index].course.owner.lastName}}</p>
<p class="childInfos">{{element[index].course.title}}</p>
<p class="childInfos">{{element[index].local}}</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)}}
@ -424,17 +333,16 @@
<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 v-if="month != null" style="overflow-y:scroll; height:100%;" >
<template v-for="element in month[value-shift]">
<div v-if="!done"class="course" @click.native="lessonFocus(element)" v-bind:style="{background:element.color, height:100+'%'}">
<div class="course" @click.native="lessonFocus(element)" v-bind:style="{background:element.color, height:100+'%'}">
<div class="hourStart">
{{getHoursMinutes(element.lessonStart)}}
</div>
<div class="infos">
<p class="childInfos" >{{jsonMod ? element.title : element.course.title}}</p>
<p class="childInfos"v-if="!jsonMod">{{element.local}}</p>
<p class="childInfos"v-if="!jsonMod">{{element.lessonType}}</p>
<p class="childInfos"v-if="!jsonMod">{{element.course.owner.lastName}}</p>
<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">
{{getHoursMinutes(element.lessonEnd)}}
@ -513,10 +421,9 @@
<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="jsonMod=false ;displayOwnSchedule();">OwnSchedule</button>
<button v-if="importedJSON != null" @click="switchToJSON()">Switch to JSON FILE</button>
<button v-if="verifUser()" @click="displayOwnSchedule()">OwnSchedule</button>
<select v-if="schedule != null && !jsonMod" @change="subFilter = 'null'" v-model="filter">
<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>
@ -532,14 +439,8 @@
<option :value ="null">No Filter</option>
<option v-for="item in types" :value='item'>{{item}}</option>
</select>
<button @click="exportJSON()" >Export JSON</button>
<div style="color:white;">IMPORT JSON</div>
<input type="file" @change="onFileChange" accept="application/JSON" ></input>
</div>
<div v-if="focus != null && !jsonMod" class="moreInfos">
<div v-if="focus != null" class="moreInfos">
<div class="body" style="background-color:rgb(50,50,50); height:10%; font-size:2em;" >More infos</div>
<div class="body" :style="{background:focus.color,height:auto,fontSize:1.2+'em', alignItems:center}">
{{focus.course.title}}</div>
@ -564,18 +465,16 @@
</template>
<style scoped>
.grid{
min-width:1200px;
display:grid;
margin-top:2%;
align-items:center;
justify-content:center;
grid-template-columns:72% 14.5%;
grid-template-columns:72vw 14.5vw;
column-gap:2vw;
overflow:hidden;
grid-template-areas:"schedule options";
}
.schedule{
min-width:900px;
position:relative;
overflow-y:scroll;
border-radius:20px;
@ -591,9 +490,8 @@
background-color:rgba(255,255,255,0.1);
width:100%;
height:85vh;
min-width:240px;
grid-template-rows:40% 60%;
grid-template-rows:30% 70%;
}
.settings{

View File

@ -15,9 +15,11 @@ export async function createRequest(request){
}
export async function changeRequestState(id, infos){
console.log(infos)
console.log(await getLessonRequest(id))
return restPatch("/requests/lessonRequest/" + id, infos);
}
export async function deleteRequest(id){
return restDelete("/requests/lessonRequest/"+id);
}
}

View File

@ -45,6 +45,7 @@ async function _rest(endPoint, config){
'Content-Type': 'application/json',
});
config['headers'] = config['headers'] == null ? headers : config['headers'];
console.log(config)
return toast.promise(fetch(restURL + endPoint, config),
{
pending: config['pending'] != null ? config['pending'] : 'pending',

View File

@ -24,9 +24,9 @@
}
export function sortByDate(a, b) {
const nameA = new Date(a.lessonStart); // ignore upper and lowercase
const nameB = new Date(b.lessonStart); // ignore upper and lowercase
const nameA = a.lessonStart; // ignore upper and lowercase
const nameB = b.lessonStart; // ignore upper and lowercase
if (nameA < nameB) {
return -1;
}