FINAL WITHOUT CLEAN
This commit is contained in:
@ -9,9 +9,13 @@
|
||||
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();
|
||||
@ -43,10 +47,13 @@
|
||||
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());
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -101,10 +108,79 @@
|
||||
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){
|
||||
@ -112,7 +188,7 @@
|
||||
lessonsList.push(schedule.value[element]);
|
||||
}
|
||||
}
|
||||
focusLessons.value = lessonsList;
|
||||
focusLessons.value = lessonsList;}
|
||||
}
|
||||
|
||||
|
||||
@ -161,7 +237,6 @@
|
||||
}
|
||||
const matrix = [];
|
||||
for (let element in lessons){
|
||||
console.log(lessons[element].lessonType)
|
||||
if(lessons[element].lessonType == type){
|
||||
matrix.push(lessons[element])
|
||||
}
|
||||
@ -207,18 +282,24 @@
|
||||
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)
|
||||
scheduleByWeek.value = sundayToTheEnd(matrixFromList(schedule.value, mondayOfWeek.value))
|
||||
if(jsonMod.value){
|
||||
scheduleByWeek.value = sundayToTheEnd(matrixFromList(jsonSchedule.value, mondayOfWeek.value))}
|
||||
else{
|
||||
scheduleByWeek.value = sundayToTheEnd(matrixFromList(schedule.value, mondayOfWeek.value))}
|
||||
|
||||
}
|
||||
|
||||
function changeMonth(i){
|
||||
@ -228,8 +309,14 @@
|
||||
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())}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -245,11 +332,14 @@
|
||||
return true;}
|
||||
|
||||
if(value-shift.value==len.value){
|
||||
done = true;
|
||||
counter++;
|
||||
|
||||
|
||||
if(counter> 35){
|
||||
counter=1;
|
||||
value = 2;
|
||||
done = false;
|
||||
return true; }
|
||||
return false;
|
||||
}
|
||||
@ -298,10 +388,11 @@
|
||||
|
||||
</div>
|
||||
<div class="infos">
|
||||
<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>
|
||||
<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>
|
||||
|
||||
</div>
|
||||
<div class="hourEnd">
|
||||
{{getHoursMinutes(element[index].lessonEnd)}}
|
||||
@ -333,16 +424,17 @@
|
||||
<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 class="course" @click.native="lessonFocus(element)" v-bind:style="{background:element.color, height:100+'%'}">
|
||||
<div v-if="!done"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">{{element.course.title}}</p>
|
||||
<p class="childInfos">{{element.local}}</p>
|
||||
<p class="childInfos">{{element.lessonType}}</p>
|
||||
<p class="childInfos">{{element.course.owner.lastName}}</p>
|
||||
<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>
|
||||
|
||||
</div>
|
||||
<div class="hourEnd">
|
||||
{{getHoursMinutes(element.lessonEnd)}}
|
||||
@ -421,9 +513,10 @@
|
||||
<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>
|
||||
<button v-if="verifUser()" @click="jsonMod=false ;displayOwnSchedule();">OwnSchedule</button>
|
||||
<button v-if="importedJSON != null" @click="switchToJSON()">Switch to JSON FILE</button>
|
||||
|
||||
<select v-if="schedule != null" @change="subFilter = 'null'" v-model="filter">
|
||||
<select v-if="schedule != null && !jsonMod" @change="subFilter = 'null'" v-model="filter">
|
||||
<option :value ="null">No Filter</option>
|
||||
<option v-for="item in filters" :value="item">{{item}}</option>
|
||||
</select>
|
||||
@ -439,8 +532,14 @@
|
||||
<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" class="moreInfos">
|
||||
<div v-if="focus != null && !jsonMod" 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>
|
||||
@ -465,16 +564,18 @@
|
||||
</template>
|
||||
<style scoped>
|
||||
.grid{
|
||||
min-width:1200px;
|
||||
display:grid;
|
||||
margin-top:2%;
|
||||
align-items:center;
|
||||
justify-content:center;
|
||||
grid-template-columns:72vw 14.5vw;
|
||||
grid-template-columns:72% 14.5%;
|
||||
column-gap:2vw;
|
||||
overflow:hidden;
|
||||
grid-template-areas:"schedule options";
|
||||
}
|
||||
.schedule{
|
||||
min-width:900px;
|
||||
position:relative;
|
||||
overflow-y:scroll;
|
||||
border-radius:20px;
|
||||
@ -490,8 +591,9 @@
|
||||
background-color:rgba(255,255,255,0.1);
|
||||
width:100%;
|
||||
height:85vh;
|
||||
min-width:240px;
|
||||
|
||||
grid-template-rows:30% 70%;
|
||||
grid-template-rows:40% 60%;
|
||||
}
|
||||
|
||||
.settings{
|
||||
|
Reference in New Issue
Block a user