Revert "Init"

This reverts commit aa790a20d6.
This commit is contained in:
brausjonas
2023-05-29 21:30:15 +02:00
parent aa790a20d6
commit d90303f5c5
41 changed files with 2416027 additions and 166 deletions
+68 -166
View File
@@ -23,13 +23,9 @@ export default function CalenderView(p) {
function readEntries() {
let url = "http://localhost:8080/entries?semesterid=" + localStorage.getItem("currentsid") +
"&daynumber=" + currentWeekStartDay + "&yearnumber=" + currentYear + "&sessionid=" + localStorage.getItem("sessionid");
try {
fetch(url).then(r => r.json()).then(en => {
setEntries(en)
})
}catch (e) {
}
fetch(url).then(r => r.json()).then(en => {
setEntries(en)
})
}
function pushEntry(currentColumnID, row) {
@@ -123,51 +119,12 @@ export default function CalenderView(p) {
let row = Math.floor((y_window - y_target_offset) / cellHeight) + 1;
let currentColumnID = parseInt(e.currentTarget.id)
if (grabbedDown) {
if (row - 1 > selectedElement.timestart) {
let free = true;
for(let i = 0; i < entries[currentColumnID].length; i++)
{
if(entries[currentColumnID][i] != null && selectedElement !== entries[currentColumnID][i])
{
if(row <= entries[currentColumnID][i].timeend &&
row >= entries[currentColumnID][i].timestart ||
row > entries[currentColumnID][i].timeend &&
selectedElement.timestart < entries[currentColumnID][i].timestart)
{
free = false;
break;
}
}
}
if(free) {
selectedElement.timeend = row + 1;
}
}
} else if (row + 2 < selectedElement.timeend)
if (grabbedDown)
{
let free = true;
for(let i = 0; i < entries[currentColumnID].length; i++)
{
if(entries[currentColumnID][i] != null && selectedElement !== entries[currentColumnID][i])
{
if(row < entries[currentColumnID][i].timeend &&
row >= entries[currentColumnID][i].timestart ||
row < entries[currentColumnID][i].timestart &&
selectedElement.timeend > entries[currentColumnID][i].timestart)
{
free = false;
break;
}
}
}
if(free)
{
selectedElement.timestart = row;
}
selectedElement.timeend = row + 1;
}else
{
selectedElement.timestart = row;
}
setUpdate(!update);
}
@@ -179,7 +136,6 @@ export default function CalenderView(p) {
let row = Math.floor((y_window - y_target_offset) / cellHeight) + 1;
let currentColumnID = parseInt(e.currentTarget.id)
let currentId = e.target.id;
let currentUserID = localStorage.getItem("userid");
if (e.button === 0) {
if (!currentId.includes("e")) {
@@ -188,16 +144,20 @@ export default function CalenderView(p) {
pushEntry(currentColumnID, row)
}
} else {
grabbedDown = currentId.includes("down")
/*
if(currentId.includes("up"))
{
grabbedDown = false;
}else grabbedDown = true;
*/
let parentID = parseInt(e.target.parentElement.id.replace("e", ""));
if(currentUserID == getElementInColumn(parentID, currentColumnID).usercreatedbyid) {
grabbedDown = currentId.includes("down")
selectedElement = getElementInColumn(parentID, currentColumnID);
}
selectedElement = getElementInColumn(parentID, currentColumnID);
}
}
} else if (e.button === 2) {
let parentID = parseInt(e.target.id.replace("e", ""));
if (currentUserID == getElementInColumn(parentID, currentColumnID).usercreatedbyid && currentId.includes("e")) {
if (currentId.includes("e")) {
let id = parseInt(currentId.replace("e", ""))
deleteEntry(id)
}
@@ -214,31 +174,6 @@ export default function CalenderView(p) {
readEntries()
}
function getEntryColor(userCreatedByID)
{
let id = localStorage.getItem("userid");
if(id == userCreatedByID)
{
return "#77932b";
}
else
{
return "#a2a2a2";
}
}
function getResizeBarColor(userCreatedByID)
{
let id = localStorage.getItem("userid");
if(id == userCreatedByID)
{
return "#5a6c20";
}
else{
return "#a2a2a2";
}
}
useEffect(() => {
semesterStart = 0;
currentWeekStartDay = 0;
@@ -259,25 +194,27 @@ export default function CalenderView(p) {
window.addEventListener("contextmenu", (e) => (e.preventDefault()))
window.addEventListener("keypress", (e) => {
try {
if (e.key === "+") {
cellHeight += 2
} else if (e.key === "-") {
if (cellHeight - 2 >= 8) {
cellHeight -= 2
}
if(e.key === "+")
{
scrollRef.current.scrollTop = scrollRef.current.scrollTop + 100;
cellHeight += 2
}
else if(e.key === "-")
{
if(cellHeight - 2 >= 8)
{
scrollRef.current.scrollTop = scrollRef.current.scrollTop - 100;
cellHeight -= 2
}
} catch (e) {
}
})
setInterval(function () {
if (selectedElement == null) {
setInterval(function(){
if (selectedElement == null){
readEntries()
}
}, 500);
}, 100);
}, [])
@@ -315,29 +252,18 @@ export default function CalenderView(p) {
justifyContent: "center",
alignItems: "center",
backgroundColor: "white",
gap: 5,
gap: 5
}}>
<div style={{borderRadius: 10, padding: 10, backgroundColor: "#f1f1f1"}} className={"box-shadow"}>
<div style={{ borderRadius: 10, padding: 10, backgroundColor: "#f1f1f1"}} className={"box-shadow"}>
<div>
<div className={"wochen-tag-container"}>
<div
className={"wochen-tag font-big"}>Montag {new Date(currentYear, 0, currentWeekStartDay).getDate()}.
</div>
<div
className={"wochen-tag font-big"}>Dienstag {new Date(currentYear, 0, currentWeekStartDay + 1).getDate()}.
</div>
<div
className={"wochen-tag font-big"}>Mittwoch {new Date(currentYear, 0, currentWeekStartDay + 2).getDate()}.
</div>
<div
className={"wochen-tag font-big"}>Donnerstag {new Date(currentYear, 0, currentWeekStartDay + 3).getDate()}.
</div>
<div
className={"wochen-tag font-big"}>Freitag {new Date(currentYear, 0, currentWeekStartDay + 4).getDate()}.
</div>
<div
className={"wochen-tag font-big"}>Samstag {new Date(currentYear, 0, currentWeekStartDay + 5).getDate()}.
</div>
<div className={"wochen-tag font-big"}>Montag {new Date(currentYear, 0, currentWeekStartDay).getDate()}.</div>
<div className={"wochen-tag font-big"}>Dienstag {new Date(currentYear, 0, currentWeekStartDay + 1).getDate()}.</div>
<div className={"wochen-tag font-big"}>Mittwoch {new Date(currentYear, 0, currentWeekStartDay + 2).getDate()}.</div>
<div className={"wochen-tag font-big"}>Donnerstag {new Date(currentYear, 0, currentWeekStartDay + 3).getDate()}.</div>
<div className={"wochen-tag font-big"}>Freitag {new Date(currentYear, 0, currentWeekStartDay + 4).getDate()}.</div>
<div className={"wochen-tag font-big"}>Samstag {new Date(currentYear, 0, currentWeekStartDay + 5).getDate()}.</div>
</div>
</div>
<div className={"calender-container"} ref={scrollRef}>
@@ -355,18 +281,14 @@ export default function CalenderView(p) {
width: "100%",
gridRowStart: d.timestart,
gridRowEnd: d.timeend,
backgroundColor: getEntryColor(d.usercreatedbyid)
backgroundColor: "#77932b"
}} id={d.id + "e"}>
<div className={"resize-grab"} id={"grabup"} style={{
backgroundColor: getResizeBarColor(d.usercreatedbyid)
}}></div>
<div className={"resize-grab"} id={"grabup"}></div>
<div style={{maxHeight: "60%"}} className={"no-pointer-events"}>
<p>{internal_to_time(d.timestart) + " - " + internal_to_time(d.timeend)}</p>
<p>Modul</p>
</div>
<div className={"resize-grab"} id={"grabdown"} style={{
backgroundColor: getResizeBarColor(d.usercreatedbyid)
}}></div>
<div className={"resize-grab"} id={"grabdown"}></div>
</div>))}
</div>
@@ -381,19 +303,15 @@ export default function CalenderView(p) {
width: "100%",
gridRowStart: d.timestart,
gridRowEnd: d.timeend,
backgroundColor: getEntryColor(d.usercreatedbyid)
backgroundColor: "#77932b"
}} id={d.id + "e"}>
<div className={"resize-grab"} id={"grabup"} style={{
backgroundColor: getResizeBarColor(d.usercreatedbyid)
}}></div>
<div className={"resize-grab"} id={"grabup"}></div>
<div style={{maxHeight: "60%"}} className={"no-pointer-events"}>
<p>{internal_to_time(d.timestart) + " - " + internal_to_time(d.timeend)}</p>
<p>Modul</p>
</div>
<div className={"resize-grab"} id={"grabdown"} style={{
backgroundColor: getResizeBarColor(d.usercreatedbyid)
}}></div>
<div className={"resize-grab"} id={"grabdown"}></div>
</div>))}
</div>
@@ -409,19 +327,15 @@ export default function CalenderView(p) {
width: "100%",
gridRowStart: d.timestart,
gridRowEnd: d.timeend,
backgroundColor: getEntryColor(d.usercreatedbyid)
backgroundColor: "#77932b"
}} id={d.id + "e"}>
<div className={"resize-grab"} id={"grabup"} style={{
backgroundColor: getResizeBarColor(d.usercreatedbyid)
}}></div>
<div className={"resize-grab"} id={"grabup"}></div>
<div style={{maxHeight: "60%"}} className={"no-pointer-events"}>
<p>{internal_to_time(d.timestart) + " - " + internal_to_time(d.timeend)}</p>
<p>Modul</p>
</div>
<div className={"resize-grab"} id={"grabdown"} style={{
backgroundColor: getResizeBarColor(d.usercreatedbyid)
}}></div>
<div className={"resize-grab"} id={"grabdown"}></div>
</div>))}
</div>
@@ -436,19 +350,15 @@ export default function CalenderView(p) {
width: "100%",
gridRowStart: d.timestart,
gridRowEnd: d.timeend,
backgroundColor: getEntryColor(d.usercreatedbyid)
backgroundColor: "#77932b"
}} id={d.id + "e"}>
<div className={"resize-grab"} id={"grabup"} style={{
backgroundColor: getResizeBarColor(d.usercreatedbyid)
}}></div>
<div className={"resize-grab"} id={"grabup"}></div>
<div style={{maxHeight: "60%"}} className={"no-pointer-events"}>
<p>{internal_to_time(d.timestart) + " - " + internal_to_time(d.timeend)}</p>
<p>Moduel etc.</p>
</div>
<div className={"resize-grab"} id={"grabdown"} style={{
backgroundColor: getResizeBarColor(d.usercreatedbyid)
}}></div>
<div className={"resize-grab"} id={"grabdown"}></div>
</div>))}
</div>
@@ -464,18 +374,14 @@ export default function CalenderView(p) {
width: "100%",
gridRowStart: d.timestart,
gridRowEnd: d.timeend,
backgroundColor: getEntryColor(d.usercreatedbyid)
backgroundColor: "#77932b"
}} id={d.id + "e"}>
<div className={"resize-grab"} id={"grabup"} style={{
backgroundColor: getResizeBarColor(d.usercreatedbyid)
}}></div>
<div className={"resize-grab"} id={"grabup"}></div>
<div style={{maxHeight: "60%"}} className={"no-pointer-events"}>
<p>{internal_to_time(d.timestart) + " - " + internal_to_time(d.timeend)}</p>
<p>Modul</p>
</div>
<div className={"resize-grab"} id={"grabdown"} style={{
backgroundColor: getResizeBarColor(d.usercreatedbyid)
}}></div>
<div className={"resize-grab"} id={"grabdown"}></div>
</div>))}
</div>
@@ -491,18 +397,14 @@ export default function CalenderView(p) {
width: "100%",
gridRowStart: d.timestart,
gridRowEnd: d.timeend,
backgroundColor: getEntryColor(d.usercreatedbyid)
backgroundColor: "#77932b"
}} id={d.id + "e"}>
<div className={"resize-grab"} id={"grabup"} style={{
backgroundColor: getResizeBarColor(d.usercreatedbyid)
}}></div>
<div className={"resize-grab"} id={"grabup"}></div>
<div style={{maxHeight: "60%"}} className={"no-pointer-events"}>
<p>{internal_to_time(d.timestart) + " - " + internal_to_time(d.timeend)}</p>
<p>Modul</p>
</div>
<div className={"resize-grab"} id={"grabdown"} style={{
backgroundColor: getResizeBarColor(d.usercreatedbyid)
}}></div>
<div className={"resize-grab"} id={"grabdown"}></div>
</div>))}
</div>
</div>
@@ -518,15 +420,15 @@ export default function CalenderView(p) {
justifyContent: "space-around",
alignItems: "center",
}} className={"no-pointer-events"}>
<div style={{
borderBottom: "1px solid #363636",
}}><p style={{
color: "gray",
marginTop: cellHeight - 3,
marginRight: 120,
fontSize: 12,
textAlign: "center"
}}>{internal_to_time(i + 1)}</p></div>
<div style={{
borderBottom: "1px solid #363636",
}}><p style={{
color: "gray",
marginTop: cellHeight - 3,
marginRight: 120,
fontSize: 12,
textAlign: "center"
}}>{internal_to_time(i + 1)}</p></div>
<div style={{
borderBottom: "1px solid #363636",
+1
View File
@@ -338,6 +338,7 @@ Calender View
height: 6px;
cursor: ns-resize;
width: 100%;
background-color: #5a6c20;
}