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 (
-
-
+
+
{entries.map((e, index) => (
onClickSemester(e, f)}
+ editable = {false} text={semesterNames[index]} text2={e.name} onClick={(f) => onClickSemester(e, f)}
/>
))}
diff --git a/backend/src/main/java/com/example/backend/anwprj/controller/SemesterController.java b/backend/src/main/java/com/example/backend/anwprj/controller/SemesterController.java
index 7bf2e40..18bac7a 100644
--- a/backend/src/main/java/com/example/backend/anwprj/controller/SemesterController.java
+++ b/backend/src/main/java/com/example/backend/anwprj/controller/SemesterController.java
@@ -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
getSemestersAll(@RequestParam(name="ids") String ids, @RequestParam(name="sessionid") String sessionid)
+ {
+ String[] idsSplit = ids.split("a");
+
+ List 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 getSemester(@RequestParam(name="sessionid") String sessionid)