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