Added Status Check
This commit is contained in:
@@ -43,8 +43,9 @@ export default function CalenderView(p) {
|
||||
function readEntries() {
|
||||
let url = baseURL + "/entries?semesterid=" + localStorage.getItem("currentsid") +
|
||||
"&daynumber=" + currentWeekStartDay + "&yearnumber=" + currentYear + "&sessionid=" + localStorage.getItem("sessionid");
|
||||
let currentsid = localStorage.getItem("currentsid")
|
||||
let userid = localStorage.getItem("userid")
|
||||
// let currentsid = localStorage.getItem("currentsid")
|
||||
// let userid = localStorage.getItem("userid")
|
||||
let moduleid = localStorage.getItem("moduleid");
|
||||
|
||||
try {
|
||||
fetch(url).then(r => r.json()).then(en => {
|
||||
@@ -55,7 +56,8 @@ export default function CalenderView(p) {
|
||||
let maxLunchBreak = 0
|
||||
let daySum = 0
|
||||
for (let j = 0; j < en[i].length; j++) {
|
||||
if (en[i][j] != null && currentsid == (en[i][j]).semesterid) {
|
||||
// if (en[i][j] != null && currentsid == (en[i][j]).semesterid) {
|
||||
if (en[i][j] != null && moduleid == (en[i][j]).moduleid) {
|
||||
let elem = en[i][j]
|
||||
|
||||
if ((elem.timestart - 1) / 4 < 8) {
|
||||
@@ -80,7 +82,8 @@ export default function CalenderView(p) {
|
||||
let min = 24 * 3
|
||||
|
||||
for (let j2 = 0; j2 < en[i].length; j2++) {
|
||||
if (en[i][j2] != null && (en[i][j2].timestart - 1) / 4 >= 11 && (en[i][j2].timestart - 1) / 4 <= 14 && currentsid == (en[i][j2]).semesterid) {
|
||||
// if (en[i][j2] != null && (en[i][j2].timestart - 1) / 4 >= 11 && (en[i][j2].timestart - 1) / 4 <= 14 && currentsid == (en[i][j2]).semesterid) {
|
||||
if (en[i][j2] != null && (en[i][j2].timestart - 1) / 4 >= 11 && (en[i][j2].timestart - 1) / 4 <= 14 && moduleid == (en[i][j2]).moduleid) {
|
||||
if (en[i][j2].timestart < min && en[i][j2].timestart >= elem.timeend) {
|
||||
min = en[i][j2].timestart
|
||||
}
|
||||
@@ -111,10 +114,12 @@ export default function CalenderView(p) {
|
||||
for (let k = 0; k < 20; k++) {
|
||||
if (en[i][k] != null){
|
||||
|
||||
if (en[i][k].semesterid != currentsid)
|
||||
// if (en[i][k].semesterid != currentsid)
|
||||
if (en[i][k].moduleid != moduleid)
|
||||
{
|
||||
for (let l = 0; l < 20; l++) {
|
||||
if (en[i][l] != null && en[i][l].usercreatedbyid != userid) {
|
||||
// if (en[i][l] != null && en[i][l].usercreatedbyid != userid) {
|
||||
if (en[i][l] != null && en[i][l].moduleid != moduleid) {
|
||||
if (en[i][l].timestart <= en[i][k].timestart && en[i][l].timeend >= en[i][k].timeend) {
|
||||
en[i][k] = null;
|
||||
break
|
||||
@@ -128,9 +133,11 @@ export default function CalenderView(p) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (en[i][k] != null && en[i][k].usercreatedbyid != userid) {
|
||||
// if (en[i][k] != null && en[i][k].usercreatedbyid != userid) {
|
||||
if (en[i][k] != null && en[i][k].moduleid != moduleid) {
|
||||
for (let l = 0; l < 20; l++) {
|
||||
if (en[i][l] != null && en[i][l].semesterid != currentsid) {
|
||||
// if (en[i][l] != null && en[i][l].semesterid != currentsid) {
|
||||
if (en[i][l] != null && en[i][l].moduleid != moduleid) {
|
||||
if (en[i][l].timestart <= en[i][k].timestart && en[i][l].timeend >= en[i][k].timeend) {
|
||||
en[i][k] = null;
|
||||
break
|
||||
@@ -171,6 +178,7 @@ export default function CalenderView(p) {
|
||||
"usercreatedbyid": localStorage.getItem("userid"),
|
||||
"timestart": row,
|
||||
"timeend": row + 3,
|
||||
"moduleid": localStorage.getItem("moduleid"),
|
||||
"info": localStorage.getItem("currentmodulename")
|
||||
}
|
||||
fetch(url, {
|
||||
@@ -236,6 +244,7 @@ export default function CalenderView(p) {
|
||||
"yearnumber": 0,
|
||||
"semesterid": 0,
|
||||
"usercreatedbyid": 0,
|
||||
"moduleid": 0,
|
||||
"timestart": selectedElement.timestart,
|
||||
"timeend": selectedElement.timeend,
|
||||
"info": ""
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import {baseURL} from "@/components/Constants";
|
||||
|
||||
export default function HourCounter(){
|
||||
|
||||
function countTimePlanned(){
|
||||
const entryurl = baseURL + "/entries/planned?sessionid=" + localStorage.getItem("sessionid");
|
||||
const moduleid = localStorage.getItem("moduleid")
|
||||
let hoursPlanned = 0
|
||||
|
||||
fetch(entryurl).then(response => response.json()).then(entries => {
|
||||
entries.forEach(e => {
|
||||
hoursPlanned += e.timeend - e.timestart
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
console.log(20-countTimePlanned());
|
||||
|
||||
}
|
||||
@@ -1,7 +1,30 @@
|
||||
import React from "react"
|
||||
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)
|
||||
{
|
||||
let testindex = 1;
|
||||
const modules = p.modules;
|
||||
|
||||
let url = baseURL + "/entries/planned?sessionid=" + localStorage.getItem("sessionid");
|
||||
|
||||
fetch(url).then(response => response.json()).then(e => {
|
||||
modules.forEach(modules => {
|
||||
e.forEach(e => {
|
||||
if (e.moduleid == modules.id){
|
||||
testindex = 2;
|
||||
if (modules.activated == 0){
|
||||
testindex = 3;
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
console.log(testindex);
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
if(p.progress > 100) p.progress = 100;
|
||||
let classNames = ["not-started", "started", "finished"];
|
||||
let index = p.progress / 50;
|
||||
|
||||
@@ -110,7 +110,7 @@ export default function SemesterOverview(p) {
|
||||
localStorage.setItem("currentsid", e.id)
|
||||
funcButtonEdit(e, m);
|
||||
}}/>
|
||||
<StatusBar progress={0}/>
|
||||
{/*<StatusBar progress={0}/>*/}
|
||||
<div style={
|
||||
{
|
||||
display:"flex",
|
||||
|
||||
@@ -67,7 +67,7 @@ export default function SemesteroverviewLecturer(p) {
|
||||
editable={false} text={semesterNames[index]} text2={e.name}
|
||||
onClick={(f) => onClickSemester(e, f)}
|
||||
/>
|
||||
<StatusBar progress={0}/>
|
||||
<StatusBar progress={0} modules={entries}/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
Binary file not shown.
+186202
File diff suppressed because it is too large
Load Diff
@@ -52,9 +52,9 @@ public class DataBaseHandler
|
||||
{
|
||||
try
|
||||
{
|
||||
st.executeUpdate("insert into entries (daynumber, yearnumber, semesterid, usercreatedbyid, timestart, timeend, info) values (" +
|
||||
st.executeUpdate("insert into entries (daynumber, yearnumber, semesterid, usercreatedbyid, timestart, timeend, moduleid, info) values (" +
|
||||
entry.getDaynumber() + ", " + entry.getYearnumber() + ", " + entry.getSemesterid() + ", " +
|
||||
entry.getUsercreatedbyid() + ", " + entry.getTimestart() + ", " + entry.getTimeend() + ", '" + entry.getInfo() + "')"
|
||||
entry.getUsercreatedbyid() + ", " + entry.getTimestart() + ", " + entry.getTimeend() + ", " + entry.getModuleid() + " ,'" + entry.getInfo() + "')"
|
||||
);
|
||||
}
|
||||
catch(Exception e)
|
||||
@@ -156,6 +156,25 @@ public class DataBaseHandler
|
||||
}
|
||||
}
|
||||
|
||||
public Entry[] getAllEntries(int userid)
|
||||
{
|
||||
try {
|
||||
ResultSet rs = st.executeQuery("select * from entries where " +
|
||||
"usercreatedbyid=" + userid);
|
||||
List<Entry> entriestate = new ArrayList<>();
|
||||
Entry current = null;
|
||||
while((current = resultSetToEntry(rs)) != null)
|
||||
{
|
||||
entriestate.add(current);
|
||||
}
|
||||
Entry[] entryArray = new Entry[entriestate.toArray().length];
|
||||
return entriestate.toArray(entryArray);
|
||||
}catch (Exception e){
|
||||
System.out.println(e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteEntry(int id)
|
||||
{
|
||||
try
|
||||
@@ -193,6 +212,7 @@ public class DataBaseHandler
|
||||
rs.getInt("timestart"),
|
||||
rs.getInt("timeend"),
|
||||
rs.getInt("semesterid"),
|
||||
rs.getInt("moduleid"),
|
||||
rs.getString("info")
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,9 +10,10 @@ public class Entry
|
||||
private int timestart;
|
||||
private int timeend;
|
||||
private int semesterid;
|
||||
private int moduleid;
|
||||
private String info;
|
||||
|
||||
public Entry(int id, int daynumber, int yearnumber, int usercreatedbyid, int timestart, int timeend, int semesterid, String info)
|
||||
public Entry(int id, int daynumber, int yearnumber, int usercreatedbyid, int timestart, int timeend, int semesterid, int moduleid, String info)
|
||||
{
|
||||
this.id = id;
|
||||
this.daynumber = daynumber;
|
||||
@@ -21,6 +22,7 @@ public class Entry
|
||||
this.timestart = timestart;
|
||||
this.timeend = timeend;
|
||||
this.semesterid = semesterid;
|
||||
this.moduleid = moduleid;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
@@ -59,6 +61,8 @@ public class Entry
|
||||
return semesterid;
|
||||
}
|
||||
|
||||
public int getModuleid() {return moduleid;}
|
||||
|
||||
public String getInfo()
|
||||
{
|
||||
return info;
|
||||
|
||||
@@ -60,22 +60,36 @@ public class EntriesController
|
||||
|
||||
@CrossOrigin
|
||||
@GetMapping("/entries/planned")
|
||||
public ResponseEntity<Integer[]> getEntries(@RequestParam(name = "semesterid") int semesterid,
|
||||
@RequestParam(name = "sessionid") String sessionid)
|
||||
public ResponseEntity<Entry[]> getAllEntries(@RequestParam(name = "sessionid") String sessionid)
|
||||
{
|
||||
User sessionUser = UserSessionIDHandler.getUserBySessionID(sessionid);
|
||||
if (sessionUser != null)
|
||||
{
|
||||
var entries = db.getAllEntries(semesterid, sessionUser.getId());
|
||||
var count = 0;
|
||||
for (int i = 0; i < entries.length; i++) {
|
||||
count += entries[i].getTimeend()-entries[i].getTimestart();
|
||||
}
|
||||
return new ResponseEntity<>(new Integer[]{count}, HttpStatus.OK);
|
||||
var entries = db.getAllEntries(sessionUser.getId());
|
||||
|
||||
return new ResponseEntity<>(entries, HttpStatus.OK);
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
|
||||
}
|
||||
|
||||
// @CrossOrigin
|
||||
// @GetMapping("/entries")
|
||||
// public ResponseEntity<Integer[]> getEntries(@RequestParam(name = "semesterid") int semesterid,
|
||||
// @RequestParam(name = "sessionid") String sessionid)
|
||||
// {
|
||||
// User sessionUser = UserSessionIDHandler.getUserBySessionID(sessionid);
|
||||
// if (sessionUser != null)
|
||||
// {
|
||||
// var entries = db.getAllEntries(semesterid, sessionUser.getId());
|
||||
// var count = 0;
|
||||
// for (int i = 0; i < entries.length; i++) {
|
||||
// count += entries[i].getTimeend()-entries[i].getTimestart();
|
||||
// }
|
||||
// return new ResponseEntity<>(new Integer[]{count}, HttpStatus.OK);
|
||||
// }
|
||||
// return new ResponseEntity<>(HttpStatus.FORBIDDEN);
|
||||
// }
|
||||
|
||||
/**
|
||||
POST
|
||||
A new entry to the database. Every user except of admins is allowed
|
||||
|
||||
Reference in New Issue
Block a user