Lecturer Dashboard Finished Version
This commit is contained in:
@@ -5,6 +5,11 @@ import {deleteItem, editItem} from "@/components/Icons";
|
||||
|
||||
export default function SemesterTile(p)
|
||||
{
|
||||
let editable = true;
|
||||
if (p.editable != null)
|
||||
{
|
||||
editable = p.editable
|
||||
}
|
||||
useEffect(() =>
|
||||
{
|
||||
window.addEventListener("contextmenu", (e) => (e.preventDefault()))
|
||||
@@ -12,10 +17,15 @@ export default function SemesterTile(p)
|
||||
|
||||
return (
|
||||
<div onClick={(e) => p.onClick(e)} className={"semester-tile box-shadow"}>
|
||||
<p>{p.text}</p>
|
||||
<p style={{
|
||||
lineHeight: "80%"
|
||||
}}>{p.text}</p>
|
||||
<p style={{
|
||||
lineHeight: "80%"
|
||||
}}>{p.text2}</p>
|
||||
<StatusBar progress={0}/>
|
||||
<div style={{
|
||||
display: "flex",
|
||||
display: editable ? "flex" : "none",
|
||||
flexDirection: "row",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
|
||||
@@ -7,67 +7,60 @@ import PopUp from "@/components/PopUp";
|
||||
import Background from "@/components/Background";
|
||||
import Logout from "@/components/Logout";
|
||||
|
||||
export default function SemesteroverviewLecturer(p)
|
||||
{
|
||||
async function getSemesters()
|
||||
{
|
||||
|
||||
export default function SemesteroverviewLecturer(p) {
|
||||
function getModules() {
|
||||
let urlTest = "http://localhost:8080/module/id?sessionid=" + localStorage.getItem("sessionid");
|
||||
|
||||
await fetch(urlTest).then(response => response.json()).then(s => {
|
||||
setEntries(s)
|
||||
fetch(urlTest).then(response => response.json()).then(m => {
|
||||
setEntries(m);
|
||||
let args = "";
|
||||
for(let i = 0; i < m.length; i++)
|
||||
{
|
||||
args += m[i].semesterid;
|
||||
|
||||
if(i < m.length - 1)
|
||||
{
|
||||
args += "a";
|
||||
}
|
||||
}
|
||||
|
||||
let temp = []
|
||||
let semesterURL = "http://localhost:8080/semester/id/all?ids=" + args + "&sessionid=" + localStorage.getItem("sessionid");
|
||||
fetch(semesterURL).then(r => r.json()).then(sem => {
|
||||
sem.map(e => {
|
||||
temp.push(e.name)
|
||||
})
|
||||
}).then(() => setSemesterNames(temp))
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
function onClickSemester(e, m)
|
||||
{
|
||||
if(m.target === m.currentTarget)
|
||||
{
|
||||
function onClickSemester(e, m) {
|
||||
if (m.target === m.currentTarget) {
|
||||
localStorage.setItem("currentsid", e.id)
|
||||
router.push("/planning")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async function getSemesternameById(id){
|
||||
let urlname = "http://localhost:8080/semester/id?id=" + id + "&sessionid=" + localStorage.getItem("sessionid")
|
||||
let name= "";
|
||||
const response = await fetch(urlname);
|
||||
const data = await response.json();
|
||||
return data.name;
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getSemesters();
|
||||
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
async function fetchSemesterNames() {
|
||||
let names = await Promise.all(
|
||||
entries.map((e) => getSemesternameById(e.semesterid))
|
||||
)
|
||||
|
||||
setSemesterNames(names);
|
||||
}
|
||||
|
||||
fetchSemesterNames();
|
||||
getModules();
|
||||
}, [])
|
||||
|
||||
const [entries, setEntries] = useState([]);
|
||||
const [semesterNames, setSemesterNames] = useState([]);
|
||||
const [modalDisplay, setModalDisplay] = useState("none");
|
||||
const [modalHint, setModalHint] = useState("");
|
||||
const router = useRouter();
|
||||
|
||||
|
||||
return (
|
||||
<div className={"semester-overview"}>
|
||||
<Logout />
|
||||
<Background />
|
||||
<Logout/>
|
||||
<Background/>
|
||||
{entries.map((e, index) => (
|
||||
<SemesterTile
|
||||
text={semesterNames[index] + e.name} onClick={(f) => onClickSemester(e, f)}
|
||||
editable = {false} text={semesterNames[index]} text2={e.name} onClick={(f) => onClickSemester(e, f)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -9,6 +9,9 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
public class SemesterController
|
||||
{
|
||||
@@ -60,6 +63,23 @@ public class SemesterController
|
||||
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
|
||||
}
|
||||
|
||||
@CrossOrigin
|
||||
@GetMapping("/semester/id/all")
|
||||
public ResponseEntity<Semester[]> getSemestersAll(@RequestParam(name="ids") String ids, @RequestParam(name="sessionid") String sessionid)
|
||||
{
|
||||
String[] idsSplit = ids.split("a");
|
||||
|
||||
List<Semester> resultList = new ArrayList<>();
|
||||
|
||||
for(int i = 0; i < idsSplit.length; i++)
|
||||
{
|
||||
int currentID = Integer.parseInt(idsSplit[i]);
|
||||
resultList.add(db.getSemester(currentID));
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(resultList.toArray(new Semester[0]), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@CrossOrigin
|
||||
@GetMapping("/semester/all")
|
||||
public ResponseEntity<Semester[]> getSemester(@RequestParam(name="sessionid") String sessionid)
|
||||
|
||||
Reference in New Issue
Block a user