Added Status Check
This commit is contained in:
@@ -43,8 +43,9 @@ export default function CalenderView(p) {
|
|||||||
function readEntries() {
|
function readEntries() {
|
||||||
let url = baseURL + "/entries?semesterid=" + localStorage.getItem("currentsid") +
|
let url = baseURL + "/entries?semesterid=" + localStorage.getItem("currentsid") +
|
||||||
"&daynumber=" + currentWeekStartDay + "&yearnumber=" + currentYear + "&sessionid=" + localStorage.getItem("sessionid");
|
"&daynumber=" + currentWeekStartDay + "&yearnumber=" + currentYear + "&sessionid=" + localStorage.getItem("sessionid");
|
||||||
let currentsid = localStorage.getItem("currentsid")
|
// let currentsid = localStorage.getItem("currentsid")
|
||||||
let userid = localStorage.getItem("userid")
|
// let userid = localStorage.getItem("userid")
|
||||||
|
let moduleid = localStorage.getItem("moduleid");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fetch(url).then(r => r.json()).then(en => {
|
fetch(url).then(r => r.json()).then(en => {
|
||||||
@@ -55,7 +56,8 @@ export default function CalenderView(p) {
|
|||||||
let maxLunchBreak = 0
|
let maxLunchBreak = 0
|
||||||
let daySum = 0
|
let daySum = 0
|
||||||
for (let j = 0; j < en[i].length; j++) {
|
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]
|
let elem = en[i][j]
|
||||||
|
|
||||||
if ((elem.timestart - 1) / 4 < 8) {
|
if ((elem.timestart - 1) / 4 < 8) {
|
||||||
@@ -80,7 +82,8 @@ export default function CalenderView(p) {
|
|||||||
let min = 24 * 3
|
let min = 24 * 3
|
||||||
|
|
||||||
for (let j2 = 0; j2 < en[i].length; j2++) {
|
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) {
|
if (en[i][j2].timestart < min && en[i][j2].timestart >= elem.timeend) {
|
||||||
min = en[i][j2].timestart
|
min = en[i][j2].timestart
|
||||||
}
|
}
|
||||||
@@ -111,10 +114,12 @@ export default function CalenderView(p) {
|
|||||||
for (let k = 0; k < 20; k++) {
|
for (let k = 0; k < 20; k++) {
|
||||||
if (en[i][k] != null){
|
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++) {
|
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) {
|
if (en[i][l].timestart <= en[i][k].timestart && en[i][l].timeend >= en[i][k].timeend) {
|
||||||
en[i][k] = null;
|
en[i][k] = null;
|
||||||
break
|
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++) {
|
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) {
|
if (en[i][l].timestart <= en[i][k].timestart && en[i][l].timeend >= en[i][k].timeend) {
|
||||||
en[i][k] = null;
|
en[i][k] = null;
|
||||||
break
|
break
|
||||||
@@ -171,6 +178,7 @@ export default function CalenderView(p) {
|
|||||||
"usercreatedbyid": localStorage.getItem("userid"),
|
"usercreatedbyid": localStorage.getItem("userid"),
|
||||||
"timestart": row,
|
"timestart": row,
|
||||||
"timeend": row + 3,
|
"timeend": row + 3,
|
||||||
|
"moduleid": localStorage.getItem("moduleid"),
|
||||||
"info": localStorage.getItem("currentmodulename")
|
"info": localStorage.getItem("currentmodulename")
|
||||||
}
|
}
|
||||||
fetch(url, {
|
fetch(url, {
|
||||||
@@ -236,6 +244,7 @@ export default function CalenderView(p) {
|
|||||||
"yearnumber": 0,
|
"yearnumber": 0,
|
||||||
"semesterid": 0,
|
"semesterid": 0,
|
||||||
"usercreatedbyid": 0,
|
"usercreatedbyid": 0,
|
||||||
|
"moduleid": 0,
|
||||||
"timestart": selectedElement.timestart,
|
"timestart": selectedElement.timestart,
|
||||||
"timeend": selectedElement.timeend,
|
"timeend": selectedElement.timeend,
|
||||||
"info": ""
|
"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)
|
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;
|
if(p.progress > 100) p.progress = 100;
|
||||||
let classNames = ["not-started", "started", "finished"];
|
let classNames = ["not-started", "started", "finished"];
|
||||||
let index = p.progress / 50;
|
let index = p.progress / 50;
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ export default function SemesterOverview(p) {
|
|||||||
localStorage.setItem("currentsid", e.id)
|
localStorage.setItem("currentsid", e.id)
|
||||||
funcButtonEdit(e, m);
|
funcButtonEdit(e, m);
|
||||||
}}/>
|
}}/>
|
||||||
<StatusBar progress={0}/>
|
{/*<StatusBar progress={0}/>*/}
|
||||||
<div style={
|
<div style={
|
||||||
{
|
{
|
||||||
display:"flex",
|
display:"flex",
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ export default function SemesteroverviewLecturer(p) {
|
|||||||
editable={false} text={semesterNames[index]} text2={e.name}
|
editable={false} text={semesterNames[index]} text2={e.name}
|
||||||
onClick={(f) => onClickSemester(e, f)}
|
onClick={(f) => onClickSemester(e, f)}
|
||||||
/>
|
/>
|
||||||
<StatusBar progress={0}/>
|
<StatusBar progress={0} modules={entries}/>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</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
|
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.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)
|
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)
|
public void deleteEntry(int id)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -193,6 +212,7 @@ public class DataBaseHandler
|
|||||||
rs.getInt("timestart"),
|
rs.getInt("timestart"),
|
||||||
rs.getInt("timeend"),
|
rs.getInt("timeend"),
|
||||||
rs.getInt("semesterid"),
|
rs.getInt("semesterid"),
|
||||||
|
rs.getInt("moduleid"),
|
||||||
rs.getString("info")
|
rs.getString("info")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,9 +10,10 @@ public class Entry
|
|||||||
private int timestart;
|
private int timestart;
|
||||||
private int timeend;
|
private int timeend;
|
||||||
private int semesterid;
|
private int semesterid;
|
||||||
|
private int moduleid;
|
||||||
private String info;
|
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.id = id;
|
||||||
this.daynumber = daynumber;
|
this.daynumber = daynumber;
|
||||||
@@ -21,6 +22,7 @@ public class Entry
|
|||||||
this.timestart = timestart;
|
this.timestart = timestart;
|
||||||
this.timeend = timeend;
|
this.timeend = timeend;
|
||||||
this.semesterid = semesterid;
|
this.semesterid = semesterid;
|
||||||
|
this.moduleid = moduleid;
|
||||||
this.info = info;
|
this.info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,6 +61,8 @@ public class Entry
|
|||||||
return semesterid;
|
return semesterid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getModuleid() {return moduleid;}
|
||||||
|
|
||||||
public String getInfo()
|
public String getInfo()
|
||||||
{
|
{
|
||||||
return info;
|
return info;
|
||||||
|
|||||||
@@ -60,22 +60,36 @@ public class EntriesController
|
|||||||
|
|
||||||
@CrossOrigin
|
@CrossOrigin
|
||||||
@GetMapping("/entries/planned")
|
@GetMapping("/entries/planned")
|
||||||
public ResponseEntity<Integer[]> getEntries(@RequestParam(name = "semesterid") int semesterid,
|
public ResponseEntity<Entry[]> getAllEntries(@RequestParam(name = "sessionid") String sessionid)
|
||||||
@RequestParam(name = "sessionid") String sessionid)
|
|
||||||
{
|
{
|
||||||
User sessionUser = UserSessionIDHandler.getUserBySessionID(sessionid);
|
User sessionUser = UserSessionIDHandler.getUserBySessionID(sessionid);
|
||||||
if (sessionUser != null)
|
if (sessionUser != null)
|
||||||
{
|
{
|
||||||
var entries = db.getAllEntries(semesterid, sessionUser.getId());
|
var entries = db.getAllEntries(sessionUser.getId());
|
||||||
var count = 0;
|
|
||||||
for (int i = 0; i < entries.length; i++) {
|
return new ResponseEntity<>(entries, HttpStatus.OK);
|
||||||
count += entries[i].getTimeend()-entries[i].getTimestart();
|
|
||||||
}
|
|
||||||
return new ResponseEntity<>(new Integer[]{count}, HttpStatus.OK);
|
|
||||||
}
|
}
|
||||||
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
|
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
|
POST
|
||||||
A new entry to the database. Every user except of admins is allowed
|
A new entry to the database. Every user except of admins is allowed
|
||||||
|
|||||||
Reference in New Issue
Block a user