All Entrys Shown for Lecturer

A lecturer can now see all his entries in his lecture view. Entries from other semester are blue colored, cant be configured from the from lecture view and are not of relevance for the rule semester, since they don´t apply for the students, only for the lecturer him- or herself
This commit is contained in:
AliGitGut
2023-06-09 21:35:02 +02:00
parent b4020d0756
commit 394b920a4e
5 changed files with 185080 additions and 32 deletions
+43 -31
View File
@@ -42,6 +42,8 @@ export default function CalenderView(p) {
function readEntries() {
let url = baseURL + "/entries?semesterid=" + localStorage.getItem("currentsid") +
"&daynumber=" + currentWeekStartDay + "&yearnumber=" + currentYear + "&sessionid=" + localStorage.getItem("sessionid");
let currentsid = localStorage.getItem("currentsid")
try {
fetch(url).then(r => r.json()).then(en => {
@@ -51,7 +53,11 @@ export default function CalenderView(p) {
let maxLunchBreak = 0
let daySum = 0
for (let j = 0; j < en[i].length; j++) {
if (en[i][j] != null) {
if (en[i][j] != null){
console.log(currentsid + " " + en[i][j].semesterid)
}
if (en[i][j] != null && currentsid == (en[i][j]).semesterid) {
let elem = en[i][j]
if ((elem.timestart - 1) / 4 < 8) {
@@ -76,7 +82,7 @@ export default function CalenderView(p) {
let min = 24 * 3
for (let j2 = 0; j2 < en[i].length; j2++) {
if (en[i][j2] != null && (en[i][j2].timestart - 1) / 4 >= 11 && (en[i][j2].timestart - 1) / 4 <= 14) {
if (en[i][j2] != null && (en[i][j2].timestart - 1) / 4 >= 11 && (en[i][j2].timestart - 1) / 4 <= 14 && currentsid == (en[i][j2]).semesterid) {
if (en[i][j2].timestart < min && en[i][j2].timestart >= elem.timeend) {
min = en[i][j2].timestart
}
@@ -90,7 +96,6 @@ export default function CalenderView(p) {
}
}
console.log("test")
errorState[i] = ErrorType.Okay
}
@@ -260,6 +265,7 @@ export default function CalenderView(p) {
let currentColumnID = parseInt(e.currentTarget.id)
let currentId = e.target.id;
let currentUserID = localStorage.getItem("userid");
let currentsid = localStorage.getItem("currentsid")
if (e.button === 0) {
if (!currentId.includes("e")) {
@@ -273,7 +279,7 @@ export default function CalenderView(p) {
}
} else {
let parentID = parseInt(e.target.parentElement.id.replace("e", ""));
if (currentUserID == getElementInColumn(parentID, currentColumnID).usercreatedbyid) {
if (currentUserID == getElementInColumn(parentID, currentColumnID).usercreatedbyid && getElementInColumn(parentID, currentColumnID).semesterid == currentsid) {
grabbedDown = currentId.includes("down")
selectedElement = getElementInColumn(parentID, currentColumnID);
}
@@ -281,7 +287,7 @@ export default function CalenderView(p) {
}
} else if (e.button === 2) {
let parentID = parseInt(e.target.id.replace("e", ""));
if (currentUserID == getElementInColumn(parentID, currentColumnID).usercreatedbyid && currentId.includes("e")) {
if (currentUserID == getElementInColumn(parentID, currentColumnID).usercreatedbyid && currentId.includes("e") && getElementInColumn(parentID, currentColumnID).semesterid == currentsid) {
let id = parseInt(currentId.replace("e", ""))
errorState[currentColumnID] = ErrorType.Okay
deleteEntry(id)
@@ -317,12 +323,15 @@ export default function CalenderView(p) {
readEntries()
}
function getEntryColor(userCreatedByID, columnID) {
function getEntryColor(userCreatedByID, columnID, semesterid) {
let id = localStorage.getItem("userid");
let currentsid = localStorage.getItem("currentsid")
if (id == userCreatedByID) {
if (isDayOkay[columnID]) {
if (isDayOkay[columnID] && semesterid == currentsid) {
return "#77932b";
} else {
}else if(semesterid != currentsid){
return "#346991";
}else {
return "#e5a10e";
}
@@ -331,12 +340,17 @@ export default function CalenderView(p) {
}
}
function getResizeBarColor(userCreatedByID, columnID) {
function getResizeBarColor(userCreatedByID, columnID, semesterid) {
let id = localStorage.getItem("userid");
let currentsid = localStorage.getItem("currentsid")
if (id == userCreatedByID) {
if (isDayOkay[columnID]) {
if (isDayOkay[columnID] && currentsid == semesterid) {
return "#5a6c20";
} else {
} else if(currentsid != semesterid)
{
return "#346991"
}
else {
return "#c08809";
}
} else {
@@ -358,14 +372,12 @@ export default function CalenderView(p) {
let url = baseURL + "/semester/id?sessionid=" + localStorage.getItem("sessionid") +
"&id=" + localStorage.getItem("currentsid");
console.log(localStorage.getItem("currentsid"))
fetch(url).then(r => r.json()).then(s => {
currentWeekStartDay = s.startday - new Date(s.startyear, 0, s.startday).getUTCDay();
currentYear = s.startyear;
setStartYearCalenderSideBar(currentYear)
setEndYearCalenderSideBar(s.endyear)
//console.log(new Date(s.startyear, 0, s.startday).getMonth())
setHighlightMonth(new Date(s.startyear, 0, s.startday).getMonth())
setHighlightYear(currentYear)
@@ -501,17 +513,17 @@ export default function CalenderView(p) {
width: "100%",
gridRowStart: d.timestart,
gridRowEnd: d.timeend,
backgroundColor: getEntryColor(d.usercreatedbyid, 0)
backgroundColor: getEntryColor(d.usercreatedbyid, 0, d.semesterid)
}} id={d.id + "e"}>
<div className={"resize-grab"} id={"grabup"} style={{
backgroundColor: getResizeBarColor(d.usercreatedbyid, 0)
backgroundColor: getResizeBarColor(d.usercreatedbyid, 0, d.semesterid)
}}></div>
<div style={{maxHeight: "60%"}} className={"no-pointer-events"}>
<p>{internal_to_time(d.timestart) + " - " + internal_to_time(d.timeend)}</p>
<p>{d.info}</p>
</div>
<div className={"resize-grab"} id={"grabdown"} style={{
backgroundColor: getResizeBarColor(d.usercreatedbyid, 0)
backgroundColor: getResizeBarColor(d.usercreatedbyid, 0, d.semesterid)
}}></div>
</div>))}
</div>
@@ -527,18 +539,18 @@ export default function CalenderView(p) {
width: "100%",
gridRowStart: d.timestart,
gridRowEnd: d.timeend,
backgroundColor: getEntryColor(d.usercreatedbyid, 1)
backgroundColor: getEntryColor(d.usercreatedbyid, 1, d.semesterid)
}} id={d.id + "e"}>
<div className={"resize-grab"} id={"grabup"} style={{
backgroundColor: getResizeBarColor(d.usercreatedbyid, 1)
backgroundColor: getResizeBarColor(d.usercreatedbyid, 1, d.semesterid)
}}></div>
<div style={{maxHeight: "60%"}} className={"no-pointer-events"}>
<p>{internal_to_time(d.timestart) + " - " + internal_to_time(d.timeend)}</p>
<p>{d.info}</p>
</div>
<div className={"resize-grab"} id={"grabdown"} style={{
backgroundColor: getResizeBarColor(d.usercreatedbyid, 1)
backgroundColor: getResizeBarColor(d.usercreatedbyid, 1, d.semesterid)
}}></div>
</div>))}
</div>
@@ -555,18 +567,18 @@ export default function CalenderView(p) {
width: "100%",
gridRowStart: d.timestart,
gridRowEnd: d.timeend,
backgroundColor: getEntryColor(d.usercreatedbyid, 2)
backgroundColor: getEntryColor(d.usercreatedbyid, 2, d.semesterid)
}} id={d.id + "e"}>
<div className={"resize-grab"} id={"grabup"} style={{
backgroundColor: getResizeBarColor(d.usercreatedbyid, 2)
backgroundColor: getResizeBarColor(d.usercreatedbyid, 2, d.semesterid)
}}></div>
<div style={{maxHeight: "60%"}} className={"no-pointer-events"}>
<p>{internal_to_time(d.timestart) + " - " + internal_to_time(d.timeend)}</p>
<p>{d.info}</p>
</div>
<div className={"resize-grab"} id={"grabdown"} style={{
backgroundColor: getResizeBarColor(d.usercreatedbyid, 2)
backgroundColor: getResizeBarColor(d.usercreatedbyid, 2, d.semesterid)
}}></div>
</div>))}
</div>
@@ -582,18 +594,18 @@ export default function CalenderView(p) {
width: "100%",
gridRowStart: d.timestart,
gridRowEnd: d.timeend,
backgroundColor: getEntryColor(d.usercreatedbyid, 3)
backgroundColor: getEntryColor(d.usercreatedbyid, 3, d.semesterid)
}} id={d.id + "e"}>
<div className={"resize-grab"} id={"grabup"} style={{
backgroundColor: getResizeBarColor(d.usercreatedbyid, 3)
backgroundColor: getResizeBarColor(d.usercreatedbyid, 3, d.semesterid)
}}></div>
<div style={{maxHeight: "60%"}} className={"no-pointer-events"}>
<p>{internal_to_time(d.timestart) + " - " + internal_to_time(d.timeend)}</p>
<p>{d.info}</p>
</div>
<div className={"resize-grab"} id={"grabdown"} style={{
backgroundColor: getResizeBarColor(d.usercreatedbyid, 3)
backgroundColor: getResizeBarColor(d.usercreatedbyid, 3, d.semesterid)
}}></div>
</div>))}
</div>
@@ -610,17 +622,17 @@ export default function CalenderView(p) {
width: "100%",
gridRowStart: d.timestart,
gridRowEnd: d.timeend,
backgroundColor: getEntryColor(d.usercreatedbyid, 4)
backgroundColor: getEntryColor(d.usercreatedbyid, 4, d.semesterid)
}} id={d.id + "e"}>
<div className={"resize-grab"} id={"grabup"} style={{
backgroundColor: getResizeBarColor(d.usercreatedbyid, 4)
backgroundColor: getResizeBarColor(d.usercreatedbyid, 4, d.semesterid)
}}></div>
<div style={{maxHeight: "60%"}} className={"no-pointer-events"}>
<p>{internal_to_time(d.timestart) + " - " + internal_to_time(d.timeend)}</p>
<p>{d.info}</p>
</div>
<div className={"resize-grab"} id={"grabdown"} style={{
backgroundColor: getResizeBarColor(d.usercreatedbyid, 4)
backgroundColor: getResizeBarColor(d.usercreatedbyid, 4, d.semesterid)
}}></div>
</div>))}
</div>
@@ -637,17 +649,17 @@ export default function CalenderView(p) {
width: "100%",
gridRowStart: d.timestart,
gridRowEnd: d.timeend,
backgroundColor: getEntryColor(d.usercreatedbyid, 5)
backgroundColor: getEntryColor(d.usercreatedbyid, 5, d.semesterid)
}} id={d.id + "e"}>
<div className={"resize-grab"} id={"grabup"} style={{
backgroundColor: getResizeBarColor(d.usercreatedbyid, 5)
backgroundColor: getResizeBarColor(d.usercreatedbyid, 5, d.semesterid)
}}></div>
<div style={{maxHeight: "60%"}} className={"no-pointer-events"}>
<p>{internal_to_time(d.timestart) + " - " + internal_to_time(d.timeend)}</p>
<p>{d.info}</p>
</div>
<div className={"resize-grab"} id={"grabdown"} style={{
backgroundColor: getResizeBarColor(d.usercreatedbyid, 5)
backgroundColor: getResizeBarColor(d.usercreatedbyid, 5, d.semesterid)
}}></div>
</div>))}
</div>