Function Status Bar and Time Validation
This commit is contained in:
-5
@@ -1,5 +0,0 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
||||
Generated
+9
@@ -9,6 +9,7 @@
|
||||
"version": "0.1.0",
|
||||
"dependencies": {
|
||||
"autoprefixer": "10.4.14",
|
||||
"feiertagejs": "^1.3.9",
|
||||
"next": "13.3.4",
|
||||
"postcss": "8.4.23",
|
||||
"react": "18.2.0",
|
||||
@@ -530,6 +531,14 @@
|
||||
"reusify": "^1.0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/feiertagejs": {
|
||||
"version": "1.3.9",
|
||||
"resolved": "https://registry.npmjs.org/feiertagejs/-/feiertagejs-1.3.9.tgz",
|
||||
"integrity": "sha512-tUP+WBv2OWBhPwe3NfqwCtjMq+ym598a42tfqmL0FySswEb9xs96p2iKwqqx+lxKieu1njJBRZKsFm92bJhxZw==",
|
||||
"engines": {
|
||||
"node": ">=8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/fill-range": {
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"autoprefixer": "10.4.14",
|
||||
"feiertagejs": "^1.3.9",
|
||||
"next": "13.3.4",
|
||||
"postcss": "8.4.23",
|
||||
"react": "18.2.0",
|
||||
|
||||
@@ -7,6 +7,8 @@ import {baseURL} from "@/components/Constants";
|
||||
import {ErrorType} from "@/components/ErrorType";
|
||||
import BasicDateCalendar from "@/components/CalendarSideBar";
|
||||
import feiertagejs from "feiertagejs";
|
||||
import PopUp from "@/components/PopUp";
|
||||
import {useRouter} from "next/router";
|
||||
|
||||
let cellHeight = 20;
|
||||
|
||||
@@ -19,6 +21,8 @@ let currentYear;
|
||||
let semesterStartYear;
|
||||
let semesterEndYear;
|
||||
let selectedElement;
|
||||
let lastEndTimeDrag;
|
||||
let lastStartTimeDrag;
|
||||
let grabbedDown;
|
||||
|
||||
let isDayOkay = [true, true, true, true, true, true]
|
||||
@@ -26,6 +30,8 @@ let isDayOkay = [true, true, true, true, true, true]
|
||||
let errorState = [ErrorType.Okay, ErrorType.Okay, ErrorType.Okay, ErrorType.Okay, ErrorType.Okay, ErrorType.Okay]
|
||||
let grayedOut = [false, false, false, false, false, false]
|
||||
|
||||
let timePlanned = 0
|
||||
|
||||
export default function CalenderView(p) {
|
||||
|
||||
const [entries, setEntries] = useState([[], [], [], [], [], []])
|
||||
@@ -38,6 +44,8 @@ export default function CalenderView(p) {
|
||||
const [endYearCalenderSideBar, setEndYearCalenderSideBar] = useState(2000)
|
||||
const [highlightMonth, setHighlightMonth] = useState(0)
|
||||
const [highlightYear, setHighlightYear] = useState(2000)
|
||||
const [popUpToggleAbgeben, setPopUpToggleAbgeben] = useState(false)
|
||||
const router = useRouter();
|
||||
|
||||
|
||||
function readEntries() {
|
||||
@@ -110,8 +118,7 @@ export default function CalenderView(p) {
|
||||
if (en[i][k] != null) {
|
||||
|
||||
|
||||
if (en[i][k].semesterid != currentsid)
|
||||
{
|
||||
if (en[i][k].semesterid != currentsid) {
|
||||
for (let l = 0; l < 20; l++) {
|
||||
if (en[i][l] != null && en[i][l].usercreatedbyid != userid) {
|
||||
if (en[i][l].timestart <= en[i][k].timestart && en[i][l].timeend >= en[i][k].timeend) {
|
||||
@@ -153,6 +160,26 @@ export default function CalenderView(p) {
|
||||
}
|
||||
|
||||
setEntries(en)
|
||||
|
||||
if(localStorage.getItem("admin") == 0)
|
||||
{
|
||||
let entriesURL = baseURL + "/entries/all/module?sessionid=" + localStorage.getItem("sessionid") + "&moduleid=" + localStorage.getItem("moduleid")
|
||||
fetch(entriesURL).then(r => r.json()).then(allEn => {
|
||||
|
||||
let moduleid = localStorage.getItem("moduleid")
|
||||
let sum = 0
|
||||
|
||||
for (let j = 0; j < allEn.length; j++) {
|
||||
if (allEn[j] != null && allEn[j].moduleid == moduleid) {
|
||||
sum += allEn[j].timeend - allEn[j].timestart
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sum /= 3
|
||||
timePlanned = sum
|
||||
})
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
|
||||
@@ -228,6 +255,18 @@ export default function CalenderView(p) {
|
||||
let id = selectedElement.id;
|
||||
|
||||
if ((selectedElement.timestart - 1) / 4 >= 7 && (selectedElement.timeend - 1) / 4 <= 18) {
|
||||
|
||||
let finalTimeEnd = selectedElement.timeend
|
||||
let deltaTimeEnd = (selectedElement.timeend - lastEndTimeDrag) / 3
|
||||
if (timePlanned + deltaTimeEnd > 20) {
|
||||
finalTimeEnd -= ((timePlanned + deltaTimeEnd) - 20) * 3
|
||||
}
|
||||
let finalTimeStart = selectedElement.timestart
|
||||
let deltaTimeStart = (lastStartTimeDrag - selectedElement.timestart) / 3
|
||||
if (deltaTimeStart + timePlanned > 20) {
|
||||
finalTimeStart += (timePlanned + deltaTimeStart - 20) * 3
|
||||
}
|
||||
|
||||
let url = baseURL + "/entries?sessionid=" + localStorage.getItem("sessionid");
|
||||
let json = {
|
||||
"id": id,
|
||||
@@ -235,8 +274,8 @@ export default function CalenderView(p) {
|
||||
"yearnumber": 0,
|
||||
"semesterid": 0,
|
||||
"usercreatedbyid": 0,
|
||||
"timestart": selectedElement.timestart,
|
||||
"timeend": selectedElement.timeend,
|
||||
"timestart": finalTimeStart,
|
||||
"timeend": finalTimeEnd,
|
||||
"info": "",
|
||||
"moduleid": localStorage.getItem("moduleid")
|
||||
}
|
||||
@@ -316,7 +355,7 @@ export default function CalenderView(p) {
|
||||
if (!currentId.includes("grab")) {
|
||||
if (!checkForElementAtRow(row + 2, currentColumnID) && !checkForElementAtRow(row + 1, currentColumnID)) {
|
||||
if ((row - 1) / 4 >= 7 && (row + 2) / 4 <= 18) {
|
||||
if (!grayedOut[currentColumnID]) {
|
||||
if (!grayedOut[currentColumnID] && timePlanned + 0.8 < 20) {
|
||||
pushEntry(currentColumnID, row)
|
||||
}
|
||||
}
|
||||
@@ -326,6 +365,8 @@ export default function CalenderView(p) {
|
||||
if (currentUserID == getElementInColumn(parentID, currentColumnID).usercreatedbyid && getElementInColumn(parentID, currentColumnID).moduleid == localStorage.getItem("moduleid")) {
|
||||
grabbedDown = currentId.includes("down")
|
||||
selectedElement = getElementInColumn(parentID, currentColumnID);
|
||||
lastEndTimeDrag = selectedElement.timeend
|
||||
lastStartTimeDrag = selectedElement.timestart
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -366,19 +407,25 @@ export default function CalenderView(p) {
|
||||
}
|
||||
|
||||
function getEntryColor(userCreatedByID, columnID, semesterid, moduleid) {
|
||||
console.log(moduleid)
|
||||
let id = localStorage.getItem("userid");
|
||||
let currentsid = localStorage.getItem("currentsid")
|
||||
if (id == userCreatedByID) {
|
||||
if (isDayOkay[columnID] && moduleid == localStorage.getItem("moduleid")) {
|
||||
return "#77932b";
|
||||
} else if (moduleid != localStorage.getItem("moduleid")) {
|
||||
return "#346991";
|
||||
} else {
|
||||
return "#e5a10e";
|
||||
}
|
||||
if(localStorage.getItem("admin") == 0)
|
||||
{
|
||||
if (id == userCreatedByID) {
|
||||
if (isDayOkay[columnID] && moduleid == localStorage.getItem("moduleid")) {
|
||||
return "#77932b";
|
||||
} else if (moduleid != localStorage.getItem("moduleid")) {
|
||||
return "#346991";
|
||||
} else {
|
||||
return "#e5a10e";
|
||||
}
|
||||
|
||||
} else {
|
||||
} else {
|
||||
return "#a2a2a2";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return "#a2a2a2";
|
||||
}
|
||||
}
|
||||
@@ -386,74 +433,83 @@ export default function CalenderView(p) {
|
||||
function getResizeBarColor(userCreatedByID, columnID, semesterid, moduleid) {
|
||||
let id = localStorage.getItem("userid");
|
||||
let currentsid = localStorage.getItem("currentsid")
|
||||
if (id == userCreatedByID) {
|
||||
if (isDayOkay[columnID] && moduleid == localStorage.getItem("moduleid")) {
|
||||
return "#5a6c20";
|
||||
} else if (moduleid != localStorage.getItem("moduleid")) {
|
||||
return "#346991"
|
||||
if(localStorage.getItem("admin") == 0)
|
||||
{
|
||||
if (id == userCreatedByID) {
|
||||
if (isDayOkay[columnID] && moduleid == localStorage.getItem("moduleid")) {
|
||||
return "#5a6c20";
|
||||
} else if (moduleid != localStorage.getItem("moduleid")) {
|
||||
return "#346991"
|
||||
} else {
|
||||
return "#c08809";
|
||||
}
|
||||
} else {
|
||||
return "#c08809";
|
||||
return "#a2a2a2";
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return "#a2a2a2";
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
semesterStart = 0;
|
||||
semesterEnd = 0;
|
||||
semesterStartYear = 0;
|
||||
semesterEndYear = 0;
|
||||
currentWeekStartDay = 0;
|
||||
currentYear = 2000;
|
||||
selectedElement = null;
|
||||
grabbedDown = false;
|
||||
errorState = [ErrorType.Okay, ErrorType.Okay, ErrorType.Okay, ErrorType.Okay, ErrorType.Okay, ErrorType.Okay]
|
||||
setTimeout(() => {
|
||||
semesterStart = 0;
|
||||
semesterEnd = 0;
|
||||
semesterStartYear = 0;
|
||||
semesterEndYear = 0;
|
||||
currentWeekStartDay = 0;
|
||||
currentYear = 2000;
|
||||
selectedElement = null;
|
||||
grabbedDown = false;
|
||||
errorState = [ErrorType.Okay, ErrorType.Okay, ErrorType.Okay, ErrorType.Okay, ErrorType.Okay, ErrorType.Okay]
|
||||
|
||||
let url = baseURL + "/semester/id?sessionid=" + localStorage.getItem("sessionid") +
|
||||
"&id=" + localStorage.getItem("currentsid");
|
||||
let url = baseURL + "/semester/id?sessionid=" + localStorage.getItem("sessionid") +
|
||||
"&id=" + 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)
|
||||
setHighlightMonth(new Date(s.startyear, 0, s.startday).getMonth())
|
||||
setHighlightYear(currentYear)
|
||||
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)
|
||||
setHighlightMonth(new Date(s.startyear, 0, s.startday).getMonth())
|
||||
setHighlightYear(currentYear)
|
||||
|
||||
semesterStart = s.startday;
|
||||
semesterEnd = s.endday;
|
||||
semesterStartYear = s.startyear;
|
||||
semesterEndYear = s.endyear;
|
||||
setStartDayCalenderSideBar(semesterStart)
|
||||
setEndDayCalenderSideBar(s.endday)
|
||||
semesterStart = s.startday;
|
||||
semesterEnd = s.endday;
|
||||
semesterStartYear = s.startyear;
|
||||
semesterEndYear = s.endyear;
|
||||
setStartDayCalenderSideBar(semesterStart)
|
||||
setEndDayCalenderSideBar(s.endday)
|
||||
|
||||
}).then(readEntries)
|
||||
}).then(readEntries)
|
||||
|
||||
scrollRef.current.scrollTop = 600;
|
||||
window.addEventListener("contextmenu", (e) => (e.preventDefault()))
|
||||
scrollRef.current.scrollTop = 600;
|
||||
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
|
||||
window.addEventListener("keypress", (e) => {
|
||||
try {
|
||||
if (e.key === "+") {
|
||||
cellHeight += 2
|
||||
} else if (e.key === "-") {
|
||||
if (cellHeight - 2 >= 8) {
|
||||
cellHeight -= 2
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
setInterval(function () {
|
||||
if (selectedElement == null) {
|
||||
readEntries()
|
||||
}
|
||||
}, 500);
|
||||
setInterval(function () {
|
||||
if (selectedElement == null) {
|
||||
readEntries()
|
||||
}
|
||||
}, 500);
|
||||
}, 100)
|
||||
}, [])
|
||||
|
||||
|
||||
@@ -498,6 +554,19 @@ export default function CalenderView(p) {
|
||||
justifyContent: "center",
|
||||
alignItems: "center"
|
||||
}}>
|
||||
<PopUp displayState={popUpToggleAbgeben ? "block" : "none"} hint={"Willst du wirklich abgeben?"}
|
||||
text1={"Abbrechen"} text2={"Abgeben"}
|
||||
function1={() => {
|
||||
setPopUpToggleAbgeben(false)
|
||||
}}
|
||||
function2={() => {
|
||||
fetch(baseURL + "/module/submit?sessionid=" + localStorage.getItem("sessionid") + "&id=" + localStorage.getItem("moduleid"), {
|
||||
method: "PUT"
|
||||
}).then(() => router.push("/semesteroverviewLecturer"))
|
||||
}}
|
||||
/>
|
||||
|
||||
|
||||
<p style={{
|
||||
fontSize: 40,
|
||||
marginBottom: 60
|
||||
@@ -837,6 +906,24 @@ export default function CalenderView(p) {
|
||||
</div>))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p style={{
|
||||
display: typeof window !== "undefined" && localStorage.getItem("admin") == 0 ? "block" : "none",
|
||||
marginTop: 10,
|
||||
fontSize: 20
|
||||
}}>{Math.floor(timePlanned)}h {(Math.floor(timePlanned * 3) - Math.floor(Math.floor(timePlanned) * 3)) * 15} min
|
||||
// 20h</p>
|
||||
|
||||
<div style={{
|
||||
display: typeof window !== "undefined" && localStorage.getItem("admin") == 0 ? "block" : "none",
|
||||
position: "absolute",
|
||||
right: 70,
|
||||
bottom: 20,
|
||||
}}>
|
||||
<Button color={timePlanned < 20 ? "#AAAAAA": "#77932b"} onClick={() => {
|
||||
Math.floor(timePlanned) == 20 ? setPopUpToggleAbgeben(true) : {}
|
||||
}} text={"Abgeben"} width={100} height={40}/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import {baseURL} from "@/components/Constants";
|
||||
|
||||
export default function HourCounter(){
|
||||
|
||||
function countTimePlanned(){
|
||||
const entryurl = baseURL + "/entries/module?moduleid=" + localStorage.getItem("moduleid") + "&sessionid=" + localStorage.getItem("sessionid");
|
||||
let hoursPlanned = 0
|
||||
|
||||
fetch(entryurl).then(response => response.json()).then(entries => {
|
||||
entries.forEach(e => {
|
||||
hoursPlanned += (e.timeend - e.timestart)/4;
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
console.log(20-countTimePlanned());
|
||||
|
||||
return(<p></p>);
|
||||
|
||||
}
|
||||
@@ -34,23 +34,29 @@ export default function InputForm(p) {
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
let base = baseURL + "/semester/id?sessionid=" + localStorage.getItem("sessionid") + "&id=" + localStorage.getItem("currentsid")
|
||||
fetch(base).then(r => r.json()).then(j => {
|
||||
setCourseName(j.name)
|
||||
setTimeout(() => {
|
||||
update = false;
|
||||
baseMapping = []
|
||||
|
||||
let tempStartDate = new Date(parseInt(j.startyear), 0, parseInt(j.startday))
|
||||
let tempEndDate = new Date(parseInt(j.endyear), 0, parseInt(j.endday))
|
||||
let base = baseURL + "/semester/id?sessionid=" + localStorage.getItem("sessionid") + "&id=" + localStorage.getItem("currentsid")
|
||||
fetch(base).then(r => r.json()).then(j => {
|
||||
|
||||
setStartDate(tempStartDate.getFullYear() + "-" + ((tempStartDate.getMonth() + 1).toString().padStart(2, "0")) + "-" + tempStartDate.getDate().toString().padStart(2, "0"))
|
||||
setEndDate(tempEndDate.getFullYear() + "-" + ((tempEndDate.getMonth() + 1).toString().padStart(2, "0")) + "-" + tempEndDate.getDate().toString().padStart(2, "0"))
|
||||
tempSemesterNumber = j.number
|
||||
setSemesterNumber(j.number)
|
||||
|
||||
setSemesterNumber(j.number)
|
||||
tempSemesterNumber = j.number
|
||||
|
||||
}).then(() => {
|
||||
readModules()
|
||||
update = true
|
||||
}).catch(() => readModules())
|
||||
setCourseName(j.name)
|
||||
|
||||
let tempStartDate = new Date(parseInt(j.startyear), 0, parseInt(j.startday))
|
||||
let tempEndDate = new Date(parseInt(j.endyear), 0, parseInt(j.endday))
|
||||
|
||||
setStartDate(tempStartDate.getFullYear() + "-" + ((tempStartDate.getMonth() + 1).toString().padStart(2, "0")) + "-" + tempStartDate.getDate().toString().padStart(2, "0"))
|
||||
setEndDate(tempEndDate.getFullYear() + "-" + ((tempEndDate.getMonth() + 1).toString().padStart(2, "0")) + "-" + tempEndDate.getDate().toString().padStart(2, "0"))
|
||||
}).then(() => {
|
||||
readModules()
|
||||
update = true
|
||||
}).catch(() => readModules())
|
||||
}, 100)
|
||||
|
||||
|
||||
}, [])
|
||||
@@ -103,9 +109,9 @@ export default function InputForm(p) {
|
||||
|
||||
setIsChecked(temp)
|
||||
setIsActivated(temp2)
|
||||
}).then(() => {
|
||||
setModulesSelectorValues(modulesDummy[tempSemesterNumber])
|
||||
})
|
||||
}).then(() => {
|
||||
setModulesSelectorValues(modulesDummy[tempSemesterNumber])
|
||||
})
|
||||
}
|
||||
|
||||
@@ -260,13 +266,12 @@ export default function InputForm(p) {
|
||||
|
||||
userModulesMapping[i].semesterid = semesterID
|
||||
setTimeout(() => {
|
||||
console.log(userModulesMapping[i])
|
||||
fetch(baseURL + "/module?sessionid=" + localStorage.getItem("sessionid"), {
|
||||
method: userModulesMapping[i].id === -1 ? "POST" : "PUT",
|
||||
headers: {"Content-Type": "application/json"},
|
||||
body: JSON.stringify(userModulesMapping[i])
|
||||
})
|
||||
}, i * 100)
|
||||
}, i * 200)
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
@@ -9,7 +9,8 @@ export default function PopUp(p) {
|
||||
return (
|
||||
<>
|
||||
<div style={{
|
||||
display: p.displayState
|
||||
display: p.displayState,
|
||||
zIndex: 1000
|
||||
}}>
|
||||
|
||||
<div className={"modal-container"}>
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
import StatusBar from "@/components/StatusBar";
|
||||
import React, {useEffect} from "react";
|
||||
import Button from "@/components/Button";
|
||||
import {deleteItem, editItem} from "@/components/Icons";
|
||||
|
||||
export default function SemesterTile(p)
|
||||
{
|
||||
let editable = true;
|
||||
|
||||
@@ -1,130 +1,15 @@
|
||||
import React, {useState, useEffect} from "react";
|
||||
import { baseURL } from "@/components/Constants";
|
||||
|
||||
export default function StatusBar(p) {
|
||||
const [index, setIndex] = useState(-1);
|
||||
if (p.module != null){
|
||||
const module = p.module;
|
||||
|
||||
useEffect(() => {
|
||||
const url = baseURL + "/entries/planned?sessionid=" + localStorage.getItem("sessionid");
|
||||
fetch(url)
|
||||
.then((response) => response.json())
|
||||
.then((entries) => {
|
||||
let newIndex = -1;
|
||||
if (entries !== null) {
|
||||
entries.forEach((e) => {
|
||||
if (e.moduleid == module.id) {
|
||||
if (module.activated == 0) {
|
||||
newIndex = 2;
|
||||
} else {
|
||||
if(newIndex < 1) {
|
||||
newIndex = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
if (newIndex === -1) {
|
||||
newIndex = 0;
|
||||
}
|
||||
}
|
||||
setIndex(newIndex);
|
||||
});
|
||||
}, [module.id, module.activated]);
|
||||
|
||||
}
|
||||
else if(p.semester != null){
|
||||
const semester = p.semester;
|
||||
// const [newIndex, setNewIndex] = useState(-1)
|
||||
const url = baseURL + "/entries/semester?semesterid=" + semester.id + "&sessionid=" + localStorage.getItem("sessionid");
|
||||
const moduleurl = baseURL + "/module/bysemesterid?sessionid=" + localStorage.getItem("sessionid") + "&semesterid=" + localStorage.getItem("currentsid");
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
fetch(url)
|
||||
.then((response) => response.json())
|
||||
.then((entries) => {
|
||||
// let newIndex = -1
|
||||
if (entries !== null) {
|
||||
const moduleurl = baseURL + "/module/bysemesterid?sessionid=" + localStorage.getItem("sessionid") + "&semesterid=" + localStorage.getItem("currentsid");
|
||||
fetch(moduleurl).then(response => response.json()).then(modules => {
|
||||
// let newIndex = -1
|
||||
let modulesWithEntries = [];
|
||||
let isSubmitted = true;
|
||||
modules.forEach(m => {
|
||||
entries.forEach(e => {
|
||||
if (e.moduleid === m.id) {
|
||||
if (!modulesWithEntries.includes(m)) {
|
||||
modulesWithEntries.push(m)
|
||||
}
|
||||
}
|
||||
if (m.activated === 1) {
|
||||
isSubmitted = false;
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
// entries.forEach(e => {
|
||||
//
|
||||
// const moduleurl = baseURL + "/module/bysemesterid?sessionid=" + localStorage.getItem("sessionid") + "&semesterid=" + localStorage.getItem("currentsid");
|
||||
// fetch(moduleurl).then(response => response.json()).then(modules => {
|
||||
// // let newIndex = -1
|
||||
// let modulesWithEntries = [];
|
||||
// let isSubmitted = true;
|
||||
// modules.forEach(m => {
|
||||
// if (e.moduleid === m.id){
|
||||
// if (!modulesWithEntries.includes(m)) {
|
||||
// modulesWithEntries.push(m)
|
||||
// }
|
||||
// }
|
||||
// if (m.activated === 1){
|
||||
// isSubmitted = false;
|
||||
// }
|
||||
// })
|
||||
// // const modulesWithoutEntries = modules.filter(element => !modulesWithEntries.includes(element));
|
||||
// // console.log(modulesWithoutEntries);
|
||||
// // if (modulesWithoutEntries.length === 0 && isSubmitted){
|
||||
// // newIndex = 2;
|
||||
// // console.log("newIndex: "+2)
|
||||
// // }
|
||||
// // else if(modulesWithEntries.length !== 0 && newIndex < 1 && newIndex <= -1){
|
||||
// // newIndex = 1;
|
||||
// // }
|
||||
// //
|
||||
// // if (newIndex == -1) {
|
||||
// // newIndex = 0;
|
||||
// // }
|
||||
// //
|
||||
// // setIndex(newIndex);
|
||||
// })
|
||||
// });
|
||||
let newIndex = -1
|
||||
const modulesWithoutEntries = modules.filter(element => !modulesWithEntries.includes(element));
|
||||
console.log(modulesWithoutEntries);
|
||||
if (modulesWithoutEntries.length === 0 && isSubmitted) {
|
||||
newIndex = 2;
|
||||
console.log("newIndex: " + 2)
|
||||
} else if (modulesWithEntries.length !== 0 && newIndex < 1 && newIndex <= -1) {
|
||||
newIndex = 1;
|
||||
}
|
||||
|
||||
if (newIndex == -1) {
|
||||
newIndex = 0;
|
||||
}
|
||||
|
||||
setIndex(newIndex);
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
}, [semester.id, semester.activated]);
|
||||
|
||||
}
|
||||
import React, {useState} from "react"
|
||||
import {baseURL} from "@/components/Constants";
|
||||
import {console} from "next/dist/compiled/@edge-runtime/primitives/console";
|
||||
|
||||
export default function StatusBar(p)
|
||||
{
|
||||
if(p.progress > 100) p.progress = 100;
|
||||
let classNames = ["not-started", "started", "finished"];
|
||||
let actives = ["", "", ""];
|
||||
actives[index] = "active";
|
||||
let index = p.progress / 50;
|
||||
|
||||
let actives = ["", "", ""]
|
||||
actives[index] = "active";
|
||||
|
||||
return (
|
||||
<div className={"step-container"}>
|
||||
@@ -132,13 +17,12 @@ export default function StatusBar(p) {
|
||||
<span className={"step " + classNames[0] + " " + actives[0]}>1</span>
|
||||
<span className={"step " + classNames[1] + " " + actives[1]}>2</span>
|
||||
<span className={"step " + classNames[2] + " " + actives[2]}>3</span>
|
||||
<div
|
||||
className={"progress-bar " + classNames[index]}
|
||||
style={{
|
||||
width: 100 + "%",
|
||||
}}
|
||||
<div className={"progress-bar " + classNames[index]}
|
||||
style={{
|
||||
width: p.progress + "%"
|
||||
}}
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
import Button from "@/components/Button";
|
||||
import { baseURL } from "@/components/Constants";
|
||||
import {useRouter} from "next/router";
|
||||
|
||||
export default function SubmitButton() {
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
position: "absolute",
|
||||
right: 70,
|
||||
bottom: 20,
|
||||
borderBottomRightRadius: 10,
|
||||
}}
|
||||
>
|
||||
<Button onClick={() => router.push("/submit")} text={"Abgeben"} color={"#77932b"} width={100} height={40} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
import {baseURL} from "@/components/Constants";
|
||||
import Button from "@/components/Button";
|
||||
|
||||
export default function SubmitWarning(p){
|
||||
|
||||
async function submit() {
|
||||
let url = baseURL + "/module?sessionid=" + localStorage.getItem("sessionid");
|
||||
|
||||
let json1 = {
|
||||
"id": localStorage.getItem("moduleid"),
|
||||
"userid": localStorage.getItem("userid"),
|
||||
"semesterid": localStorage.getItem("currentsid"),
|
||||
"name": localStorage.getItem("currentmodulename"),
|
||||
"activated": 0
|
||||
}
|
||||
|
||||
await fetch(url, {
|
||||
method: "PUT",
|
||||
headers: {"Content-Type": "application/json"},
|
||||
body: JSON.stringify(json1)
|
||||
})
|
||||
|
||||
p.onClick();
|
||||
p.onClick();
|
||||
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="box-shadow" style={{
|
||||
position: "absolute",
|
||||
top: 300,
|
||||
left: 0,
|
||||
right: 0,
|
||||
borderRadius: 5,
|
||||
textAlign: "center",
|
||||
fontSize: 20,
|
||||
margin: "auto",
|
||||
width: 600
|
||||
|
||||
}}>
|
||||
<p style={{paddingTop: 20, paddingBottom: 5}}>Möchten Sie wirklich abgeben?</p>
|
||||
<p>Danach können Sie keine Änderungen mehr vornehmen!</p>
|
||||
<div style={{
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
justifyContent: "center",
|
||||
paddingTop: 40,
|
||||
paddingBottom: 20
|
||||
}}>
|
||||
<Button onClick={() => submit()} text={"Bestätigen"} color={"#77932b"} width={100} height={40} />
|
||||
<div style={{width: 20}}></div>
|
||||
<Button onClick={() => p.onClick()} text={"Abbrechen"} color={"red"} width={100} height={40} />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import Back from "@/components/Back";
|
||||
import BasicDateCalendar from "@/components/CalendarSideBar";
|
||||
import {useRouter} from "next/router";
|
||||
import HelpButton from "@/components/HelpButton";
|
||||
import SubmitButton from "@/components/SubmitButton";
|
||||
|
||||
|
||||
export default function planning(p)
|
||||
@@ -26,7 +25,6 @@ export default function planning(p)
|
||||
<HelpButton/>
|
||||
<Background/>
|
||||
<CalenderView semesterName={semesterName}/>
|
||||
<SubmitButton />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -12,12 +12,76 @@ import StatusBar from "@/components/StatusBar";
|
||||
import {deleteItem, editItem} from "@/components/Icons";
|
||||
|
||||
export default function SemesterOverview(p) {
|
||||
async function getSemesters() {
|
||||
|
||||
const [progresses, setProgresses] = useState([])
|
||||
|
||||
async function getSemesters(set) {
|
||||
let urlTest = baseURL + "/semester/all?sessionid=" + localStorage.getItem("sessionid");
|
||||
|
||||
let allSemesters
|
||||
let allModules
|
||||
let allEntries
|
||||
|
||||
await fetch(urlTest).then(response => response.json()).then(s => {
|
||||
setEntries(s)
|
||||
allSemesters = s
|
||||
if (set) {
|
||||
setEntries(s)
|
||||
}
|
||||
}).then(() => {
|
||||
if(!set)
|
||||
{
|
||||
fetch(baseURL + "/module/all?sessionid=" + localStorage.getItem("sessionid")).then(r => r.json()).then(mod => {
|
||||
allModules = mod
|
||||
}).then(() => {
|
||||
fetch(baseURL + "/entries/all?sessionid=" + localStorage.getItem("sessionid")).then(r => r.json()).then(en => {
|
||||
allEntries = en
|
||||
}).then(() => {
|
||||
let modulesCountInSemester = []
|
||||
for (let i = 0; i < allSemesters.length; i++) {
|
||||
let count = 0
|
||||
for (let j = 0; j < allModules.length; j++) {
|
||||
if (allSemesters[i].id === allModules[j].semesterid) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
modulesCountInSemester.push(count)
|
||||
}
|
||||
|
||||
let temp = []
|
||||
for (let s = 0; s < allSemesters.length; s++) {
|
||||
let count = 0;
|
||||
|
||||
for (let i = 0; i < allModules.length; i++) {
|
||||
if (allModules[i].semesterid === allSemesters[s].id) {
|
||||
let sum = 0
|
||||
let ent = allEntries.filter(e => e.moduleid === allModules[i].id)
|
||||
for (let j = 0; j < ent.length; j++) {
|
||||
sum += ent[j].timeend - ent[j].timestart
|
||||
}
|
||||
|
||||
sum /= 3
|
||||
|
||||
if (sum >= 20 && allModules[i].activated === 0) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count === 0) {
|
||||
temp.push(0)
|
||||
} else if (count >= 1 && count !== modulesCountInSemester[s]) {
|
||||
temp.push(50)
|
||||
} else {
|
||||
temp.push(100)
|
||||
}
|
||||
|
||||
setProgresses(temp)
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
@@ -26,6 +90,7 @@ export default function SemesterOverview(p) {
|
||||
if (m.target === m.currentTarget) {
|
||||
localStorage.setItem("currentsid", e.id)
|
||||
router.push("/planning")
|
||||
localStorage.setItem("semestername", e.name + " Sem. " + (e.number + 1))
|
||||
}
|
||||
|
||||
}
|
||||
@@ -56,7 +121,7 @@ export default function SemesterOverview(p) {
|
||||
});
|
||||
|
||||
togglePopup();
|
||||
getSemesters();
|
||||
getSemesters(true);
|
||||
}
|
||||
|
||||
async function funcButtonEdit(e, m) {
|
||||
@@ -80,13 +145,18 @@ export default function SemesterOverview(p) {
|
||||
endDate: endDate.toISOString().slice(0, 10)
|
||||
},
|
||||
});
|
||||
getSemesters();
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getSemesters();
|
||||
|
||||
getSemesters(true);
|
||||
|
||||
}, [])
|
||||
useEffect(() => {
|
||||
setTimeout(() => {
|
||||
getSemesters(false)
|
||||
}, 1000)
|
||||
})
|
||||
|
||||
|
||||
const [entries, setEntries] = useState([])
|
||||
@@ -100,22 +170,23 @@ export default function SemesterOverview(p) {
|
||||
<HelpButton/>
|
||||
<Background/>
|
||||
{
|
||||
entries.map(e => (
|
||||
entries.map((e, index) => (
|
||||
<div className={"semester-tile box-shadow"} onClick={(f) => onClickSemester(e, f)}>
|
||||
<SemesterTile text={e.name} onClick={(f) => onClickSemester(e, f)} onButtonDeleteClick={() => {
|
||||
localStorage.setItem("currentsid", e.id)
|
||||
setModalHint(e.name + " Löschen?");
|
||||
togglePopup();
|
||||
}} onButtonEditClick={(m) => {
|
||||
<SemesterTile text={e.name + " Sem. " + (e.number + 1)} onClick={(f) => onClickSemester(e, f)}
|
||||
onButtonDeleteClick={() => {
|
||||
localStorage.setItem("currentsid", e.id)
|
||||
setModalHint(e.name + " Löschen?");
|
||||
togglePopup();
|
||||
}} onButtonEditClick={(m) => {
|
||||
localStorage.setItem("currentsid", e.id)
|
||||
funcButtonEdit(e, m);
|
||||
}}/>
|
||||
<StatusBar semester={e} module={null}/>
|
||||
<StatusBar progress={progresses[index]}/>
|
||||
<div style={
|
||||
{
|
||||
display:"flex",
|
||||
justifyContent:"center",
|
||||
alignItems:"center"
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
alignItems: "center"
|
||||
}
|
||||
}>
|
||||
<Button icon={deleteItem} width={30} height={30} color={"#ffffff"}
|
||||
|
||||
@@ -8,6 +8,9 @@ import HelpButton from "@/components/HelpButton";
|
||||
import StatusBar from "@/components/StatusBar";
|
||||
|
||||
export default function SemesteroverviewLecturer(p) {
|
||||
|
||||
const [timeStamps, setTimeStamps] = useState([])
|
||||
|
||||
function getModules() {
|
||||
let urlTest = baseURL + "/module/id?sessionid=" + localStorage.getItem("sessionid");
|
||||
|
||||
@@ -28,7 +31,30 @@ export default function SemesteroverviewLecturer(p) {
|
||||
sem.map(e => {
|
||||
temp.push(e.name + " Sem. " + (e.number + 1))
|
||||
})
|
||||
}).then(() => setSemesterNames(temp))
|
||||
}).then(() => setSemesterNames(temp)).then(() => {
|
||||
let entriesURL = baseURL + "/entries/all?sessionid=" + localStorage.getItem("sessionid")
|
||||
fetch(entriesURL).then(r => r.json()).then(en => {
|
||||
let tempTimeStamps = []
|
||||
for(let j = 0; j < m.length; j++)
|
||||
{
|
||||
let sum = 0
|
||||
let currentModule = m[j]
|
||||
for (let i = 0; i < en.length; i++)
|
||||
{
|
||||
if(currentModule.id === en[i].moduleid)
|
||||
{
|
||||
sum += en[i].timeend - en[i].timestart
|
||||
}
|
||||
}
|
||||
|
||||
sum /= 3
|
||||
tempTimeStamps.push(sum)
|
||||
}
|
||||
|
||||
setTimeStamps(tempTimeStamps)
|
||||
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
@@ -47,13 +73,32 @@ export default function SemesteroverviewLecturer(p) {
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
getModules();
|
||||
setTimeout(() => {
|
||||
getModules();
|
||||
}, 1000)
|
||||
}, [])
|
||||
|
||||
const [entries, setEntries] = useState([]);
|
||||
const [semesterNames, setSemesterNames] = useState([]);
|
||||
const router = useRouter();
|
||||
|
||||
function getProgressForTime(time, activated)
|
||||
{
|
||||
console.log(activated)
|
||||
|
||||
if(time === 0)
|
||||
{
|
||||
return 0
|
||||
}
|
||||
else if( 20 >= time > 0 && activated === 1)
|
||||
{
|
||||
return 50
|
||||
}
|
||||
else if(time >= 20 && activated === 0)
|
||||
{
|
||||
return 100
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={"semester-overview"}>
|
||||
@@ -68,7 +113,7 @@ export default function SemesteroverviewLecturer(p) {
|
||||
editable={false} text={semesterNames[index]} text2={e.name}
|
||||
onClick={(f) => onClickSemester(e, f, semesterNames[index])}
|
||||
/>
|
||||
<StatusBar module={e} semester={null}/>
|
||||
<StatusBar progress={getProgressForTime(timeStamps[index], e.activated)} module={e}/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
import Logout from "@/components/Logout";
|
||||
import SubmitWarning from "@/components/SubmitWarning";
|
||||
import Back from "@/components/Back";
|
||||
import {useRouter} from "next/router";
|
||||
import Background from "@/components/Background";
|
||||
|
||||
export default function Submit(){
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
return(
|
||||
<div>
|
||||
<Background />
|
||||
<Logout />
|
||||
<SubmitWarning onClick={() => router.back()}/>
|
||||
<Back onClick={() => router.back()}/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -183,6 +183,7 @@ Step Progress Bar
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
pointer-events: none;
|
||||
z-index: 101;
|
||||
}
|
||||
|
||||
.steps .not-started {
|
||||
@@ -213,7 +214,7 @@ Step Progress Bar
|
||||
position: absolute;
|
||||
height: 8px;
|
||||
background-color: #5d606e;
|
||||
z-index: -1;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user