Merge Of Branches Multiselect
This commit is contained in:
@@ -796,7 +796,7 @@ export default function CalenderView(p) {
|
|||||||
width: "90%",
|
width: "90%",
|
||||||
backgroundColor: e === ErrorType.Okay ? "white" : "#e5a10e",
|
backgroundColor: e === ErrorType.Okay ? "white" : "#e5a10e",
|
||||||
borderRadius: 15,
|
borderRadius: 15,
|
||||||
display: "flex",
|
display: e === ErrorType.Okay ? "none" : "flex",
|
||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
gap: 10,
|
gap: 10,
|
||||||
|
|||||||
@@ -3,407 +3,357 @@ import {useRouter} from "next/router";
|
|||||||
import {useEffect, useState} from "react";
|
import {useEffect, useState} from "react";
|
||||||
import Background from "@/components/Background";
|
import Background from "@/components/Background";
|
||||||
import {baseURL} from "@/components/Constants";
|
import {baseURL} from "@/components/Constants";
|
||||||
|
import Back from "@/components/Back";
|
||||||
|
|
||||||
|
let modulesDummy = [
|
||||||
|
["Analysis", "Theo Inf 1"],
|
||||||
|
["Lineare Algebra", "Anwendungsprojekt"],
|
||||||
|
["Theo Inf 3", "Software Eng"],
|
||||||
|
["Security", "BWL"],
|
||||||
|
["Software Eng", "Security"],
|
||||||
|
["Studienarbeit", "Bachelor"]
|
||||||
|
]
|
||||||
|
|
||||||
let userModuleMapping = new Map()
|
let tempSemesterNumber = 0
|
||||||
|
let update = false
|
||||||
|
|
||||||
|
let baseMapping = []
|
||||||
|
|
||||||
export default function InputForm(p) {
|
export default function InputForm(p) {
|
||||||
|
|
||||||
let startDateParam = "";
|
const [startDate, setStartDate] = useState("0000-00-00")
|
||||||
let endDateParam = "";
|
const [endDate, setEndDate] = useState("0000-00-00")
|
||||||
let courseNameParam = "";
|
const [courseName, setCourseName] = useState("")
|
||||||
|
const [semesterNumber, setSemesterNumber] = useState(0)
|
||||||
if (p.startDate != null) startDateParam = p.startDate;
|
const [users, setUsers] = useState([])
|
||||||
if (p.endDate != null) endDateParam = p.endDate;
|
const [modulesSelectorValues, setModulesSelectorValues] = useState(["nothing", "nothing"])
|
||||||
if (p.courseName != null) courseNameParam = p.courseName;
|
const [userModulesMapping, setUserModulesMapping] = useState({})
|
||||||
|
const [isChecked, setIsChecked] = useState([])
|
||||||
const router = useRouter();
|
const [isActivated, setIsActivated] = useState([])
|
||||||
|
const router = useRouter()
|
||||||
const [startDate, setStartDate] = useState(startDateParam);
|
|
||||||
const [endDate, setEndDate] = useState(endDateParam);
|
|
||||||
const [courseName, setCourseName] = useState(courseNameParam);
|
|
||||||
const [users, setUsers] = useState([]);
|
|
||||||
const [checkedSelected, setCheckedSelected] = useState(new Array(100).fill(false))
|
|
||||||
const [activatedSelected, setActivatedSelected] = useState(new Array(100).fill(false))
|
|
||||||
const [modulesNames, setModulesNames] = useState(new Array(100).fill("Please Select"))
|
|
||||||
|
|
||||||
async function getAllUsers() {
|
|
||||||
let sessionid = localStorage.getItem("sessionid");
|
|
||||||
let url = baseURL + "/users/all?sessionid=" + sessionid;
|
|
||||||
|
|
||||||
await fetch(url).then(response => response.json()).then(async user => {
|
|
||||||
setUsers(user)
|
|
||||||
let mURL = baseURL + "/module/suid?sessionid=" + localStorage.getItem("sessionid") + "&semesterid=" + localStorage.getItem("currentsid") + "&userid=";
|
|
||||||
for(let i = 0; i < user.length; i++)
|
|
||||||
{
|
|
||||||
mURL += user[i].id;
|
|
||||||
if(i < user.length - 1)
|
|
||||||
{
|
|
||||||
mURL += "a";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fetch(mURL).then(result => result.json()).then(m => {
|
|
||||||
let temp = []
|
|
||||||
|
|
||||||
for(let i = 0; i < user.length; i++)
|
|
||||||
{
|
|
||||||
temp.push(m[i] != null);
|
|
||||||
}
|
|
||||||
|
|
||||||
setCheckedSelected(temp);
|
|
||||||
|
|
||||||
temp = []
|
|
||||||
|
|
||||||
for(let i = 0; i < user.length; i++)
|
|
||||||
{
|
|
||||||
temp.push(m[i] != null && m[i].activated === 1);
|
|
||||||
|
|
||||||
if(m[i] != null) {
|
|
||||||
let tempModuleInfo = new UserModuleInfo();
|
|
||||||
tempModuleInfo.setModuleName(m[i].name);
|
|
||||||
tempModuleInfo.setActivated(m[i].activated);
|
|
||||||
tempModuleInfo.setChecked(true);
|
|
||||||
tempModuleInfo.setUserid(user[i].id)
|
|
||||||
userModuleMapping.set(user[i].id, tempModuleInfo)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setActivatedSelected(temp);
|
|
||||||
|
|
||||||
temp = []
|
|
||||||
|
|
||||||
for(let i = 0; i < user.length; i++)
|
|
||||||
{
|
|
||||||
temp.push(m[i] == null ? "Please Select" : m[i].name);
|
|
||||||
}
|
|
||||||
|
|
||||||
setModulesNames(temp);
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
for(let i = 0; i < user.length; i++)
|
|
||||||
{
|
|
||||||
if(!userModuleMapping.has(user[i].id)) {
|
|
||||||
let tempModuleInfo = new UserModuleInfo();
|
|
||||||
tempModuleInfo.setModuleName("Please Select");
|
|
||||||
tempModuleInfo.setActivated(0);
|
|
||||||
tempModuleInfo.setChecked(false);
|
|
||||||
tempModuleInfo.setUserid(user[i].id)
|
|
||||||
userModuleMapping.set(user[i].id, tempModuleInfo)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getAllUsers()
|
|
||||||
userModuleMapping.clear();
|
let base = baseURL + "/semester/id?sessionid=" + localStorage.getItem("sessionid") + "&id=" + localStorage.getItem("currentsid")
|
||||||
|
fetch(base).then(r => r.json()).then(j => {
|
||||||
|
setCourseName(j.name)
|
||||||
|
|
||||||
|
let tempStartDate = new Date(parseInt(j.startyear), 0, parseInt(j.startday))
|
||||||
|
let tempEndDate = new Date(parseInt(j.endyear), 0, parseInt(j.endday))
|
||||||
|
|
||||||
|
setStartDate(tempStartDate.getFullYear() + "-" + ((tempStartDate.getMonth() + 1).toString().padStart(2, "0")) + "-" + tempStartDate.getDate().toString().padStart(2, "0"))
|
||||||
|
setEndDate(tempEndDate.getFullYear() + "-" + ((tempEndDate.getMonth() + 1).toString().padStart(2, "0")) + "-" + tempEndDate.getDate().toString().padStart(2, "0"))
|
||||||
|
|
||||||
|
setSemesterNumber(j.number)
|
||||||
|
tempSemesterNumber = j.number
|
||||||
|
|
||||||
|
}).then(() => {
|
||||||
|
readModules()
|
||||||
|
update = true
|
||||||
|
}).catch(() => readModules())
|
||||||
|
|
||||||
|
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
function readModules() {
|
||||||
|
let usersTemp = []
|
||||||
|
|
||||||
async function onCreateClicked() {
|
let userURL = baseURL + "/users/all?sessionid=" + localStorage.getItem("sessionid")
|
||||||
let startSplit = startDate.split("-");
|
fetch(userURL).then(r => r.json()).then(j => {
|
||||||
let endSplit = endDate.split("-");
|
setUsers(j)
|
||||||
let startYear = parseInt(startSplit[0]);
|
usersTemp = j
|
||||||
let endYear = parseInt(endSplit[0]);
|
let temp = [false, false, false]
|
||||||
|
let temp2 = []
|
||||||
|
for (let i = 0; i < j.length; i++) {
|
||||||
|
temp.push(false)
|
||||||
|
temp2.push(false)
|
||||||
|
}
|
||||||
|
setIsChecked(temp)
|
||||||
|
setIsActivated(temp2)
|
||||||
|
}).then(() => {
|
||||||
|
let modulesURL = baseURL + "/module/bysemesterid?sessionid=" + localStorage.getItem("sessionid") + "&semesterid=" + localStorage.getItem("currentsid");
|
||||||
|
fetch(modulesURL).then(r => r.json()).then(j => {
|
||||||
|
|
||||||
//month - 1 because jan = 0, day like month... but because of next lines 3 to 4 not - 1
|
setUserModulesMapping(j)
|
||||||
let startInternalDate = new Date(startYear, parseInt(startSplit[1]) - 1, parseInt(startSplit[2]))
|
baseMapping = j
|
||||||
let endInternalDate = new Date(endYear, parseInt(endSplit[1]) - 1, parseInt(endSplit[2]))
|
|
||||||
|
|
||||||
let startDayInYear = Math.round((startInternalDate - new Date(startYear, 0, 0)) / (1000 * 60 * 60 * 24));
|
let temp = isChecked.slice()
|
||||||
let endDayInYear = Math.round((endInternalDate - new Date(endYear, 0, 0)) / (1000 * 60 * 60 * 24));
|
let temp2 = isActivated.slice()
|
||||||
|
|
||||||
let id = p.courseName == null ? 0 : localStorage.getItem("currentsid");
|
for (let i = 0; i < usersTemp.length; i++) {
|
||||||
|
let currentUser = usersTemp[i]
|
||||||
|
|
||||||
let json = {
|
let found = false
|
||||||
"id": id,
|
let foundModuleLast = null
|
||||||
|
for (let f = 0; f < j.length; f++) {
|
||||||
|
let currentModule = j[f]
|
||||||
|
|
||||||
|
if (currentModule.userid === currentUser.id) {
|
||||||
|
found = true
|
||||||
|
foundModuleLast = currentModule
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (found) {
|
||||||
|
temp[i] = true
|
||||||
|
|
||||||
|
temp2[i] = foundModuleLast.activated === 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsChecked(temp)
|
||||||
|
setIsActivated(temp2)
|
||||||
|
})
|
||||||
|
}).then(() => {
|
||||||
|
setModulesSelectorValues(modulesDummy[tempSemesterNumber])
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function onCourseNameChange(e) {
|
||||||
|
setCourseName(e.target.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
function onStartDateChange(e) {
|
||||||
|
setStartDate(e.target.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
function onEndDateChange(e) {
|
||||||
|
setEndDate(e.target.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSemesterNumberChange(e) {
|
||||||
|
setSemesterNumber(e.target.value)
|
||||||
|
setModulesSelectorValues(modulesDummy[e.target.value])
|
||||||
|
}
|
||||||
|
|
||||||
|
function isOptionSelected(e, userid) {
|
||||||
|
let found = false;
|
||||||
|
|
||||||
|
for (let i = 0; i < userModulesMapping.length; i++) {
|
||||||
|
let current = userModulesMapping[i]
|
||||||
|
if (current.name === e && current.userid === userid) {
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onCheckedChange(e, index) {
|
||||||
|
let temp = isChecked.slice()
|
||||||
|
temp[index] = e.target.checked
|
||||||
|
setIsChecked(temp)
|
||||||
|
|
||||||
|
if (!e.target.checked) {
|
||||||
|
let temp = []
|
||||||
|
let currentUser = users[index]
|
||||||
|
for (let j = 0; j < userModulesMapping.length; j++) {
|
||||||
|
if (userModulesMapping[j].userid !== currentUser.id) {
|
||||||
|
temp.push(userModulesMapping[j])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setUserModulesMapping(temp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onActivatedChange(e, index) {
|
||||||
|
|
||||||
|
let temp = isActivated.slice()
|
||||||
|
temp[index] = e.target.checked
|
||||||
|
setIsActivated(temp)
|
||||||
|
|
||||||
|
let userid = users[index].id
|
||||||
|
|
||||||
|
for (let j = 0; j < userModulesMapping.length; j++) {
|
||||||
|
if (userModulesMapping[j].userid === userid) {
|
||||||
|
userModulesMapping[j].activated = e.target.checked ? 1 : 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onModuleSelectionChange(e, index) {
|
||||||
|
let userid = users[index].id
|
||||||
|
|
||||||
|
let newMapping = []
|
||||||
|
let oldNamesIds = new Map()
|
||||||
|
|
||||||
|
for (let j = 0; j < userModulesMapping.length; j++) {
|
||||||
|
let currentModuleMapping = userModulesMapping[j]
|
||||||
|
if (currentModuleMapping.userid != userid) {
|
||||||
|
newMapping.push(currentModuleMapping)
|
||||||
|
} else {
|
||||||
|
oldNamesIds.set(currentModuleMapping.name, currentModuleMapping.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let found = false
|
||||||
|
for (let i = 0; i < e.target.options.length; i++) {
|
||||||
|
|
||||||
|
let currentOption = e.target.options[i]
|
||||||
|
if (currentOption.selected) {
|
||||||
|
found = true
|
||||||
|
|
||||||
|
newMapping.push({
|
||||||
|
"id": oldNamesIds.has(currentOption.value) ? oldNamesIds.get(currentOption.value) : -1,
|
||||||
|
"userid": userid,
|
||||||
|
"semesterid": -1,
|
||||||
|
"name": currentOption.value,
|
||||||
|
"activated": isActivated[index] ? 1 : 0
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let temp = isChecked.slice()
|
||||||
|
temp[index] = found
|
||||||
|
setIsChecked(temp)
|
||||||
|
|
||||||
|
setUserModulesMapping(newMapping)
|
||||||
|
}
|
||||||
|
|
||||||
|
function onButtonAbort() {
|
||||||
|
router.back()
|
||||||
|
}
|
||||||
|
|
||||||
|
function onButtonSave() {
|
||||||
|
let tempDateStart = new Date(parseInt(startDate.split("-")[0]), parseInt(startDate.split("-")[1]) - 1, parseInt(startDate.split("-")[2]))
|
||||||
|
let tempDateEnd = new Date(parseInt(endDate.split("-")[0]), parseInt(endDate.split("-")[1]) - 1, parseInt(endDate.split("-")[2]))
|
||||||
|
|
||||||
|
let startDayInYear = Math.round((tempDateStart - new Date(tempDateStart.getFullYear(), 0, 0)) / (1000 * 60 * 60 * 24))
|
||||||
|
let endDayInYear = Math.round((tempDateEnd - new Date(tempDateEnd.getFullYear(), 0, 0)) / (1000 * 60 * 60 * 24))
|
||||||
|
|
||||||
|
|
||||||
|
let semesterJson = {
|
||||||
|
"id": update ? localStorage.getItem("currentsid") : 0,
|
||||||
"startday": startDayInYear,
|
"startday": startDayInYear,
|
||||||
"endday": endDayInYear,
|
"endday": endDayInYear,
|
||||||
"name": courseName,
|
"name": courseName,
|
||||||
"startyear": startYear,
|
"startyear": tempDateStart.getFullYear(),
|
||||||
"endyear": endYear
|
"endyear": tempDateEnd.getFullYear(),
|
||||||
|
"number": semesterNumber
|
||||||
}
|
}
|
||||||
|
|
||||||
let url = baseURL + "/semester?sessionid=" + localStorage.getItem("sessionid");
|
fetch(baseURL + "/semester?sessionid=" + localStorage.getItem("sessionid"), {
|
||||||
let method = p.courseName == null ? "POST" : "PUT";
|
method: update ? "PUT" : "POST",
|
||||||
|
|
||||||
|
|
||||||
let semesterid = localStorage.getItem("currentsid");
|
|
||||||
let tempsid = 0;
|
|
||||||
await fetch(url, {
|
|
||||||
method: method,
|
|
||||||
headers: {"Content-Type": "application/json"},
|
headers: {"Content-Type": "application/json"},
|
||||||
body: JSON.stringify(json)
|
body: JSON.stringify(semesterJson)
|
||||||
}).then(response => response.json()).then(semester => {
|
}).then(r => r.json()).then(async sem => {
|
||||||
tempsid = semester.id
|
let semesterID = sem.id
|
||||||
});
|
|
||||||
|
|
||||||
|
for (let i = 0; i < baseMapping.length; i++) {
|
||||||
if (method === "POST") {
|
let found = false
|
||||||
semesterid = tempsid;
|
for (let j = 0; j < userModulesMapping.length; j++) {
|
||||||
|
if (baseMapping[i].name === userModulesMapping[j].name) {
|
||||||
|
found = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let [key, value] of userModuleMapping) {
|
if (!found) {
|
||||||
|
fetch(baseURL + "/module?sessionid=" + localStorage.getItem("sessionid") + "&id=" + baseMapping[i].id, {
|
||||||
let json1 = {
|
|
||||||
"id": 0,
|
|
||||||
"userid": value.getUserid(),
|
|
||||||
"semesterid": semesterid,
|
|
||||||
"name": value.getModuleName(),
|
|
||||||
"activated": value.getActivated()
|
|
||||||
}
|
|
||||||
if (value.getChecked()) {
|
|
||||||
let updateURL = baseURL + "/module?sessionid=" + localStorage.getItem("sessionid");
|
|
||||||
await fetch(updateURL, {
|
|
||||||
method: method,
|
|
||||||
headers: {"Content-Type": "application/json"},
|
|
||||||
body: JSON.stringify(json1)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
let deleteURL = baseURL + "/module?sessionid=" + localStorage.getItem("sessionid") +
|
|
||||||
"&semesterid=" + semesterid +
|
|
||||||
"&userid=" + value.getUserid();
|
|
||||||
await fetch(deleteURL, {
|
|
||||||
method: "DELETE"
|
method: "DELETE"
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
router.back();
|
for (let i = 0; i < userModulesMapping.length; i++) {
|
||||||
}
|
|
||||||
|
|
||||||
class UserModuleInfo {
|
userModulesMapping[i].semesterid = semesterID
|
||||||
constructor() {
|
setTimeout(() => {
|
||||||
this.moduleName = "";
|
console.log(userModulesMapping[i])
|
||||||
this.userid = 0;
|
fetch(baseURL + "/module?sessionid=" + localStorage.getItem("sessionid"), {
|
||||||
this.activated = 0
|
method: userModulesMapping[i].id === -1 ? "POST" : "PUT",
|
||||||
this.checked = false
|
headers: {"Content-Type": "application/json"},
|
||||||
}
|
body: JSON.stringify(userModulesMapping[i])
|
||||||
|
})
|
||||||
getModuleName() {
|
}, i * 100)
|
||||||
return this.moduleName
|
|
||||||
}
|
|
||||||
|
|
||||||
getUserid() {
|
|
||||||
return this.userid
|
|
||||||
}
|
|
||||||
|
|
||||||
getActivated() {
|
|
||||||
return this.activated
|
|
||||||
}
|
|
||||||
|
|
||||||
getChecked() {
|
|
||||||
return this.checked
|
|
||||||
}
|
|
||||||
|
|
||||||
setModuleName(name) {
|
|
||||||
this.moduleName = name
|
|
||||||
}
|
|
||||||
|
|
||||||
setUserid(id) {
|
|
||||||
this.userid = id
|
|
||||||
}
|
|
||||||
|
|
||||||
setActivated(a) {
|
|
||||||
this.activated = a
|
|
||||||
}
|
|
||||||
|
|
||||||
setChecked(b) {
|
|
||||||
this.checked = b
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onModuleClicked(user, module, index) {
|
|
||||||
|
|
||||||
if (userModuleMapping.has(user.id)) {
|
|
||||||
let temp = userModuleMapping.get(user.id)
|
|
||||||
temp.setModuleName(module)
|
|
||||||
temp.setUserid(user.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
let temp = [];
|
|
||||||
|
|
||||||
for(let i = 0; i < modulesNames.length; i++)
|
|
||||||
{
|
|
||||||
temp.push(modulesNames[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
temp[index] = module;
|
|
||||||
|
|
||||||
setModulesNames(temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
function onSelectedCheckBox(user, state, index) {
|
|
||||||
if (userModuleMapping.has(user.id)) {
|
|
||||||
userModuleMapping.get(user.id).setChecked(state.target.checked);
|
|
||||||
} else {
|
|
||||||
let temp = new UserModuleInfo()
|
|
||||||
temp.setChecked(state.target.checked)
|
|
||||||
temp.setUserid(user.id)
|
|
||||||
userModuleMapping.set(user.id, temp)
|
|
||||||
}
|
|
||||||
let temp = []
|
|
||||||
|
|
||||||
for(let i = 0; i < checkedSelected.length; i++)
|
|
||||||
{
|
|
||||||
temp.push(checkedSelected[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
temp[index] = state.target.checked;
|
|
||||||
|
|
||||||
setCheckedSelected(temp);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
function onActivatedCheckBox(user, state, index) {
|
router.back()
|
||||||
if (userModuleMapping.has(user.id)) {
|
|
||||||
let t = state.target.checked ? 1 : 0;
|
|
||||||
userModuleMapping.get(user.id).setActivated(t);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let temp = []
|
|
||||||
|
|
||||||
for(let i = 0; i < checkedSelected.length; i++)
|
|
||||||
{
|
|
||||||
temp.push(activatedSelected[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
temp[index] = state.target.checked;
|
|
||||||
|
|
||||||
setActivatedSelected(temp);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Background/>
|
<Background/>
|
||||||
<div className="inputForm box-shadow">
|
<div className={"box-shadow input-form round-border"}>
|
||||||
<p style={{
|
|
||||||
fontSize: "18px",
|
<p>Kursname</p>
|
||||||
color: "#777777",
|
<input type={"text"} className={"box-shadow round-border"} style={{padding: 8, width: "100%"}}
|
||||||
fontWeight: 500,
|
onChange={e => onCourseNameChange(e)} value={courseName}/>
|
||||||
width: 150
|
|
||||||
}}>Kursname</p>
|
<div style={{display: "flex", justifyContent: "flex-start", gap: 40}}>
|
||||||
<input className="courseNameInput box-shadow" value={courseName}
|
<p>Theorie Anfang</p>
|
||||||
onChange={(e) => setCourseName(e.target.value)}/>
|
<p>Theorie Ende</p>
|
||||||
<div className="semesterRangeInput">
|
|
||||||
<div className="semesterDateLables">
|
|
||||||
<p className="semesterDateLable" style={{
|
|
||||||
fontSize: " 18px",
|
|
||||||
color: "#777777",
|
|
||||||
fontWeight: 500,
|
|
||||||
width: 150
|
|
||||||
}}>Theorie Anfang</p>
|
|
||||||
<p className="semesterDateLable" style={{
|
|
||||||
fontSize: " 18px",
|
|
||||||
color: "#777777",
|
|
||||||
fontWeight: 500,
|
|
||||||
width: 150
|
|
||||||
}}>Theorie Ende</p>
|
|
||||||
</div>
|
</div>
|
||||||
<div className={"MeinTest"}>
|
<div style={{display: "flex", justifyContent: "flex-start", gap: 20}}>
|
||||||
<div className="semesterDateInputPair">
|
<input type={"date"} className={"box-shadow round-border"} style={{padding: 8}}
|
||||||
<input type="date" id="start" className={"box-shadow selector"} value={startDate}
|
onChange={e => onStartDateChange(e)} value={startDate}/>
|
||||||
style={{
|
<input type={"date"} className={"box-shadow round-border"} style={{padding: 8}}
|
||||||
padding: 5,
|
onChange={e => onEndDateChange(e)} value={endDate}/>
|
||||||
backgroundColor: (startDate == "" || startDate >= endDate) ? "#E44747" : "white"
|
|
||||||
}}
|
|
||||||
onChange={(e) => setStartDate(e.target.value)}/>
|
|
||||||
<p className="inputFieldSeperator">-</p>
|
|
||||||
<input type="date" id="start" className={"box-shadow selector"} value={endDate}
|
|
||||||
style={{
|
|
||||||
padding: 5,
|
|
||||||
backgroundColor: (endDate == "" || startDate >= endDate) ? "#E44747" : "white"
|
|
||||||
}}
|
|
||||||
onChange={(e) => setEndDate(e.target.value)}/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
<p>Semester Wählen</p>
|
||||||
<div className="round-border dozentSelector">
|
<select className={"round-border box-shadow"} style={{padding: 5, width: "100%"}} value={semesterNumber}
|
||||||
|
onChange={e => onSemesterNumberChange(e)}>
|
||||||
|
<option value={0}>1. Semester</option>
|
||||||
|
<option value={1}>2. Semester</option>
|
||||||
|
<option value={2}>3. Semester</option>
|
||||||
|
<option value={3}>4. Semester</option>
|
||||||
|
<option value={4}>5. Semester</option>
|
||||||
|
<option value={5}>6. Semester</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<div className={"table-wrapper"}>
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<th style={{
|
<th>Wählen</th>
|
||||||
fontSize: " 18px",
|
<th>Freischalten</th>
|
||||||
color: "#777777",
|
<th>Dozent</th>
|
||||||
fontWeight: 500,
|
<th>Modul</th>
|
||||||
}}>Wählen
|
|
||||||
</th>
|
|
||||||
<th style={{
|
|
||||||
fontSize: " 18px",
|
|
||||||
color: "#777777",
|
|
||||||
fontWeight: 500,
|
|
||||||
}}>Freischalten
|
|
||||||
</th>
|
|
||||||
<th style={{
|
|
||||||
fontSize: " 18px",
|
|
||||||
color: "#777777",
|
|
||||||
fontWeight: 500,
|
|
||||||
textAlign: "center"
|
|
||||||
}}>Dozent
|
|
||||||
</th>
|
|
||||||
<th style={{
|
|
||||||
fontSize: " 18px",
|
|
||||||
color: "#777777",
|
|
||||||
fontWeight: 500,
|
|
||||||
textAlign: "center",
|
|
||||||
}}>Modul
|
|
||||||
</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
{users.map((user, i) => (
|
{
|
||||||
|
users.map((user, index) => (
|
||||||
<tr>
|
<tr>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<div style={{
|
<input type={"checkbox"} checked={isChecked[index]}
|
||||||
display: "flex",
|
onChange={e => onCheckedChange(e, index)}/>
|
||||||
flexDirection: "row",
|
|
||||||
justifyContent: "center",
|
|
||||||
}}><input type="checkbox" onChange={(e) => {
|
|
||||||
onSelectedCheckBox(user, e, i)
|
|
||||||
}} checked={checkedSelected[i]}/></div>
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<div style={{
|
<input type={"checkbox"} checked={isActivated[index]}
|
||||||
display: "flex",
|
onChange={e => onActivatedChange(e, index)}/>
|
||||||
flexDirection: "row",
|
|
||||||
justifyContent: "center",
|
|
||||||
}}><input type="checkbox" onChange={(e) => {
|
|
||||||
onActivatedCheckBox(user, e, i);
|
|
||||||
}} checked={activatedSelected[i]}/></div>
|
|
||||||
</td>
|
</td>
|
||||||
<td style={{textAlign: "center"}}>{user.firstName + " " + user.lastName}</td>
|
<td>
|
||||||
<select id={"userSelect"} name={"userSelect"} className={"box-shadow selector"}
|
{user.firstName + " " + user.lastName}
|
||||||
multiple={false} style={{
|
</td>
|
||||||
maxHeight: 80,
|
<td>
|
||||||
marginTop: 10,
|
<select multiple={true} className={"box-shadow round-border"}
|
||||||
padding: "5px 2px"
|
style={{padding: 5}}
|
||||||
}} onChange={(e) => {
|
onChange={e => onModuleSelectionChange(e, index)}>
|
||||||
onModuleClicked(user, e.target.value, i)
|
{modulesSelectorValues.map(msv => (
|
||||||
}} value={modulesNames[i]}>
|
<option value={msv}
|
||||||
<option value={"Please Select"}>Please Select</option>
|
selected={isOptionSelected(msv, user.id)}>{msv}</option>
|
||||||
<option value={"Programmieren"}>Programmieren</option>
|
|
||||||
<option value={"BWL"}>BWL</option>
|
|
||||||
<option value={"Lineare Algebra"}>Lineare Algebra</option>
|
|
||||||
<option value={"Analysis"}>Analysis</option>
|
|
||||||
<option value={"AnwendungsProjekt"}>AnwendungsProjekt</option>
|
|
||||||
</select>
|
|
||||||
</tr>
|
|
||||||
))}
|
))}
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
))
|
||||||
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div id="buttons">
|
|
||||||
<Button color="rgba(54,54,54,0.64)" width="100px" height="30px" text="Abbrechen" onClick={() => {
|
<div style={{
|
||||||
router.back()
|
display: "flex",
|
||||||
}}/>
|
justifyContent: "flex-end",
|
||||||
<Button color="#77932b" width="100px" height="30px" text="Speichern" onClick={() => { (startDate == "" || endDate == ""|| startDate >= endDate) ? () => {} : onCreateClicked()}
|
alignItems: "center",
|
||||||
}/>
|
width: "100%",
|
||||||
|
gap: 10
|
||||||
|
}}>
|
||||||
|
<Button text={"Abbrechen"} onClick={onButtonAbort}/>
|
||||||
|
<Button text={"Speichern"} color={"#77932b"} onClick={onButtonSave}/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ export default function SemesterOverview(p) {
|
|||||||
<Background/>
|
<Background/>
|
||||||
{
|
{
|
||||||
entries.map(e => (
|
entries.map(e => (
|
||||||
<div className={"semester-tile box-shadow"}>
|
<div className={"semester-tile box-shadow"} onClick={(f) => onClickSemester(e, f)}>
|
||||||
<SemesterTile text={e.name} onClick={(f) => onClickSemester(e, f)} onButtonDeleteClick={() => {
|
<SemesterTile text={e.name} onClick={(f) => onClickSemester(e, f)} onButtonDeleteClick={() => {
|
||||||
localStorage.setItem("currentsid", e.id)
|
localStorage.setItem("currentsid", e.id)
|
||||||
setModalHint(e.name + " Löschen?");
|
setModalHint(e.name + " Löschen?");
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export default function SemesteroverviewLecturer(p) {
|
|||||||
{entries.map((e, index) => (
|
{entries.map((e, index) => (
|
||||||
<div className={"semester-tile box-shadow"} style={{
|
<div className={"semester-tile box-shadow"} style={{
|
||||||
backgroundColor: e.activated == 1 ? "#ffffff" : "#aaaaaa"
|
backgroundColor: e.activated == 1 ? "#ffffff" : "#aaaaaa"
|
||||||
}}>
|
}} onClick={(f) => onClickSemester(e, f)}>
|
||||||
<SemesterTile
|
<SemesterTile
|
||||||
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)}
|
||||||
|
|||||||
@@ -73,6 +73,48 @@ body {
|
|||||||
box-shadow: 0 0 10px rgba(0, 0, 0,1);
|
box-shadow: 0 0 10px rgba(0, 0, 0,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Input Form
|
||||||
|
*/
|
||||||
|
|
||||||
|
.input-form
|
||||||
|
{
|
||||||
|
width: 600px;
|
||||||
|
background-color: white;
|
||||||
|
padding: 30px;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: space-around;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
table
|
||||||
|
{
|
||||||
|
width: 550px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-wrapper
|
||||||
|
{
|
||||||
|
max-height: 40%;
|
||||||
|
overflow-y: scroll;
|
||||||
|
}
|
||||||
|
|
||||||
|
td
|
||||||
|
{
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-form p, .input-form th
|
||||||
|
{
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #5e5e5e;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Button
|
Button
|
||||||
*/
|
*/
|
||||||
@@ -117,6 +159,7 @@ Step Progress Bar
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
max-width: 400px;
|
max-width: 400px;
|
||||||
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.steps {
|
.steps {
|
||||||
@@ -127,6 +170,7 @@ Step Progress Bar
|
|||||||
gap: 20px;
|
gap: 20px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.step {
|
.step {
|
||||||
@@ -138,6 +182,7 @@ Step Progress Bar
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
color: white;
|
color: white;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.steps .not-started {
|
.steps .not-started {
|
||||||
@@ -391,99 +436,6 @@ Calender View
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
inputForm
|
|
||||||
*/
|
|
||||||
|
|
||||||
input {
|
|
||||||
border-width: 2px;
|
|
||||||
border-radius: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.courseNameInput {
|
|
||||||
width: 300px;
|
|
||||||
padding: 5px;
|
|
||||||
border: none;
|
|
||||||
background-color: white;
|
|
||||||
border-radius: 5px;
|
|
||||||
font-family: Arial, serif;
|
|
||||||
}
|
|
||||||
|
|
||||||
.selector
|
|
||||||
{
|
|
||||||
border-width: 0;
|
|
||||||
border-radius: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.semesterDateInput {
|
|
||||||
width: 150px;
|
|
||||||
padding: 5px;
|
|
||||||
border: none;
|
|
||||||
background-color: white;
|
|
||||||
border-radius: 5px;
|
|
||||||
font-family: Arial, serif;
|
|
||||||
}
|
|
||||||
|
|
||||||
.semesterDateLables, .semesterDateInputPair {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
justify-content: left;
|
|
||||||
padding: 0;
|
|
||||||
border: none;
|
|
||||||
background-color: white;
|
|
||||||
border-radius: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.inputFieldSeperator {
|
|
||||||
width: 40px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.semesterDateLable {
|
|
||||||
margin-right: 32px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.semesterRangeInput {
|
|
||||||
margin-top: 50px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.inputForm {
|
|
||||||
width: 600px;
|
|
||||||
height: 600px;
|
|
||||||
padding: 20px;
|
|
||||||
/*border: solid;*/
|
|
||||||
border-radius: 10px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
background-color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
#buttons {
|
|
||||||
align-self: flex-end;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: flex-end;
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dozentSelector {
|
|
||||||
height: 350px;
|
|
||||||
/*border: solid;*/
|
|
||||||
margin-top: 20px;
|
|
||||||
width: 500px;
|
|
||||||
padding: 10px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
th {
|
|
||||||
text-align: left;
|
|
||||||
padding: 0 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
td {
|
|
||||||
padding: 0 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Login
|
Login
|
||||||
*/
|
*/
|
||||||
@@ -574,9 +526,6 @@ SemesterTile
|
|||||||
font-size: 23px;
|
font-size: 23px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.semester-tile .step-container {
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.Error
|
.Error
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,15 +10,12 @@ import java.sql.*;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DataBaseHandler
|
public class DataBaseHandler {
|
||||||
{
|
|
||||||
//singleton instance of database handler
|
//singleton instance of database handler
|
||||||
private static DataBaseHandler instance = null;
|
private static DataBaseHandler instance = null;
|
||||||
|
|
||||||
public static DataBaseHandler getInstance()
|
public static DataBaseHandler getInstance() {
|
||||||
{
|
if (instance == null) {
|
||||||
if (instance == null)
|
|
||||||
{
|
|
||||||
instance = new DataBaseHandler();
|
instance = new DataBaseHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,22 +28,19 @@ public class DataBaseHandler
|
|||||||
private Statement st;
|
private Statement st;
|
||||||
private boolean encrypted = false;
|
private boolean encrypted = false;
|
||||||
|
|
||||||
public DataBaseHandler()
|
public DataBaseHandler() {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
//connect to the local database
|
//connect to the local database
|
||||||
connection = DriverManager.getConnection("jdbc:h2:./database", "adm", "73bgjfdsfJ!934");
|
connection = DriverManager.getConnection("jdbc:h2:./database", "adm", "73bgjfdsfJ!934");
|
||||||
st = connection.createStatement();
|
st = connection.createStatement();
|
||||||
} catch (SQLException e)
|
} catch (SQLException e) {
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
ENTRIES
|
* ENTRIES
|
||||||
*/
|
*/
|
||||||
public void addEntry(Entry entry)
|
public void addEntry(Entry entry)
|
||||||
{
|
{
|
||||||
@@ -63,10 +57,8 @@ public class DataBaseHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entry[][] getEntries(int semesterid, int daynumber, int yearnumber)
|
public Entry[][] getEntries(int semesterid, int daynumber, int yearnumber) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
ResultSet rs = st.executeQuery("select * from entries where " +
|
ResultSet rs = st.executeQuery("select * from entries where " +
|
||||||
"semesterid=" + semesterid +
|
"semesterid=" + semesterid +
|
||||||
" and yearnumber=" + yearnumber +
|
" and yearnumber=" + yearnumber +
|
||||||
@@ -74,20 +66,16 @@ public class DataBaseHandler
|
|||||||
|
|
||||||
List<Entry> entryList = new ArrayList<>();
|
List<Entry> entryList = new ArrayList<>();
|
||||||
Entry current = null;
|
Entry current = null;
|
||||||
while((current = resultSetToEntry(rs)) != null)
|
while ((current = resultSetToEntry(rs)) != null) {
|
||||||
{
|
|
||||||
entryList.add(current);
|
entryList.add(current);
|
||||||
}
|
}
|
||||||
|
|
||||||
Entry[][] entries = new Entry[6][20];
|
Entry[][] entries = new Entry[6][20];
|
||||||
for(int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++) {
|
||||||
{
|
|
||||||
int f = 0;
|
int f = 0;
|
||||||
|
|
||||||
for(int j = 0; j < entryList.size(); j++)
|
for (int j = 0; j < entryList.size(); j++) {
|
||||||
{
|
if (entryList.get(j).getDaynumber() == i + daynumber) {
|
||||||
if(entryList.get(j).getDaynumber() == i + daynumber)
|
|
||||||
{
|
|
||||||
entries[i][f] = entryList.get(j);
|
entries[i][f] = entryList.get(j);
|
||||||
f++;
|
f++;
|
||||||
}
|
}
|
||||||
@@ -95,16 +83,13 @@ public class DataBaseHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
return entries;
|
return entries;
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Entry[][] getAllEntrys(int semesterid, int daynumber, int yearnumber, int userid)
|
public Entry[][] getAllEntrys(int semesterid, int daynumber, int yearnumber, int userid) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
ResultSet rs = st.executeQuery("select * from entries where " +
|
ResultSet rs = st.executeQuery("select * from entries where " +
|
||||||
"semesterid<>" + semesterid +
|
"semesterid<>" + semesterid +
|
||||||
@@ -113,45 +98,38 @@ public class DataBaseHandler
|
|||||||
" and daynumber between " + daynumber + " and " + daynumber + 6);
|
" and daynumber between " + daynumber + " and " + daynumber + 6);
|
||||||
List<Entry> entryList = new ArrayList<>();
|
List<Entry> entryList = new ArrayList<>();
|
||||||
Entry current = null;
|
Entry current = null;
|
||||||
while((current = resultSetToEntry(rs)) != null)
|
while ((current = resultSetToEntry(rs)) != null) {
|
||||||
{
|
|
||||||
entryList.add(current);
|
entryList.add(current);
|
||||||
}
|
}
|
||||||
Entry[][] entries = new Entry[6][20];
|
Entry[][] entries = new Entry[6][20];
|
||||||
for(int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++) {
|
||||||
{
|
|
||||||
int f = 0;
|
int f = 0;
|
||||||
|
|
||||||
for(int j = 0; j < entryList.size(); j++)
|
for (int j = 0; j < entryList.size(); j++) {
|
||||||
{
|
if (entryList.get(j).getDaynumber() == i + daynumber) {
|
||||||
if(entryList.get(j).getDaynumber() == i + daynumber)
|
|
||||||
{
|
|
||||||
entries[i][f] = entryList.get(j);
|
entries[i][f] = entryList.get(j);
|
||||||
f++;
|
f++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return entries;
|
return entries;
|
||||||
}catch(Exception e)
|
} catch (Exception e) {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entry[] getAllEntries(int semesterid, int userid)
|
public Entry[] getAllEntries(int semesterid, int userid) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
ResultSet rs = st.executeQuery("select * from entries where " +
|
ResultSet rs = st.executeQuery("select * from entries where " +
|
||||||
"semesterid=" + semesterid +
|
"semesterid=" + semesterid +
|
||||||
" and usercreatedbyid=" + userid);
|
" and usercreatedbyid=" + userid);
|
||||||
List<Entry> entriestate = new ArrayList<>();
|
List<Entry> entriestate = new ArrayList<>();
|
||||||
Entry current = null;
|
Entry current = null;
|
||||||
while((current = resultSetToEntry(rs)) != null)
|
while ((current = resultSetToEntry(rs)) != null) {
|
||||||
{
|
|
||||||
entriestate.add(current);
|
entriestate.add(current);
|
||||||
}
|
}
|
||||||
return entriestate.toArray(new Entry[0]);
|
return entriestate.toArray(new Entry[0]);
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -175,26 +153,18 @@ public class DataBaseHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteEntry(int id)
|
public void deleteEntry(int id) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
st.executeUpdate("delete from entries where id=" + id);
|
st.executeUpdate("delete from entries where id=" + id);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateEntry(Entry entry)
|
public void updateEntry(Entry entry) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
st.executeUpdate("update entries set timeend=" + entry.getTimeend() + ", timestart=" + entry.getTimestart() + " where id=" + entry.getId());
|
st.executeUpdate("update entries set timeend=" + entry.getTimeend() + ", timestart=" + entry.getTimestart() + " where id=" + entry.getId());
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -224,105 +194,81 @@ public class DataBaseHandler
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
SEMESTER
|
* SEMESTER
|
||||||
*/
|
*/
|
||||||
//get a semester object by its name
|
//get a semester object by its name
|
||||||
public Semester getSemester(String name)
|
public Semester getSemester(String name) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
ResultSet rs = st.executeQuery("select * from SEMESTER where name = '" + name + "'");
|
ResultSet rs = st.executeQuery("select * from SEMESTER where name = '" + name + "'");
|
||||||
return resultSetToSemester(rs);
|
return resultSetToSemester(rs);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Semester getSemester(int id)
|
public Semester getSemester(int id) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
ResultSet rs = st.executeQuery("select * from semester where id=" + id);
|
ResultSet rs = st.executeQuery("select * from semester where id=" + id);
|
||||||
return resultSetToSemester(rs);
|
return resultSetToSemester(rs);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//write a new semester to the database returns if process was successful
|
//write a new semester to the database returns if process was successful
|
||||||
public Semester addSemester(Semester s)
|
public Semester addSemester(Semester s) {
|
||||||
{
|
try {
|
||||||
try
|
st.executeUpdate("insert into SEMESTER (startday, endday, name, startyear, endyear, number) values (" + s.getStartday() + ", " + s.getEndday() + ", '" + s.getName() + "', " + s.getStartyear() + ", " + s.getEndyear() + ", " + s.getNumber() + ")");
|
||||||
{
|
|
||||||
st.executeUpdate("insert into SEMESTER (startday, endday, name, startyear, endyear) values (" + s.getStartday() + ", " + s.getEndday() + ", '" + s.getName() + "', " + s.getStartyear() + ", " + s.getEndyear() + ")");
|
|
||||||
return getSemester(s.getName());
|
return getSemester(s.getName());
|
||||||
|
|
||||||
} catch (Exception e)
|
} catch (Exception e) {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Semester[] getAllSemesters()
|
public Semester[] getAllSemesters() {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
ResultSet rs = st.executeQuery("select * from semester");
|
ResultSet rs = st.executeQuery("select * from semester");
|
||||||
List<Semester> semestersList = new ArrayList<>();
|
List<Semester> semestersList = new ArrayList<>();
|
||||||
Semester s = null;
|
Semester s = null;
|
||||||
while((s = resultSetToSemester(rs)) != null)
|
while ((s = resultSetToSemester(rs)) != null) {
|
||||||
{
|
|
||||||
semestersList.add(s);
|
semestersList.add(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
return semestersList.toArray(new Semester[0]);
|
return semestersList.toArray(new Semester[0]);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Semester updateSemester(Semester semester)
|
public Semester updateSemester(Semester semester) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
st.executeUpdate("update semester set startday=" + semester.getStartday() + ", " +
|
st.executeUpdate("update semester set startday=" + semester.getStartday() + ", " +
|
||||||
"endday=" + semester.getEndday() + ", " +
|
"endday=" + semester.getEndday() + ", " +
|
||||||
"name='" + semester.getName() + "', " +
|
"name='" + semester.getName() + "', " +
|
||||||
"startyear=" + semester.getStartyear() + ", " +
|
"startyear=" + semester.getStartyear() + ", " +
|
||||||
|
"number=" + semester.getNumber() + ", " +
|
||||||
"endyear=" + semester.getEndyear() + " where id=" + semester.getId());
|
"endyear=" + semester.getEndyear() + " where id=" + semester.getId());
|
||||||
|
|
||||||
return getSemester(semester.getId());
|
return getSemester(semester.getId());
|
||||||
} catch (SQLException e)
|
} catch (SQLException e) {
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteSemester(int id)
|
public void deleteSemester(int id) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
st.executeUpdate("DELETE FROM modules WHERE semesterid=" + id);
|
st.executeUpdate("DELETE FROM modules WHERE semesterid=" + id);
|
||||||
|
|
||||||
st.executeUpdate("delete from semester where id=" + id);
|
st.executeUpdate("delete from semester where id=" + id);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Semester resultSetToSemester(ResultSet rs)
|
public Semester resultSetToSemester(ResultSet rs) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
rs.next();
|
rs.next();
|
||||||
return new Semester(
|
return new Semester(
|
||||||
rs.getInt("id"),
|
rs.getInt("id"),
|
||||||
@@ -330,17 +276,16 @@ public class DataBaseHandler
|
|||||||
rs.getInt("endday"),
|
rs.getInt("endday"),
|
||||||
rs.getString("name"),
|
rs.getString("name"),
|
||||||
rs.getInt("startyear"),
|
rs.getInt("startyear"),
|
||||||
rs.getInt("endyear")
|
rs.getInt("endyear"),
|
||||||
|
rs.getInt("number")
|
||||||
);
|
);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
MODULE
|
* MODULE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//get a module object by its id
|
//get a module object by its id
|
||||||
@@ -348,22 +293,17 @@ public class DataBaseHandler
|
|||||||
try {
|
try {
|
||||||
ResultSet rs = st.executeQuery("SELECT * FROM modules WHERE id=" + id);
|
ResultSet rs = st.executeQuery("SELECT * FROM modules WHERE id=" + id);
|
||||||
return resultSetToModule(rs);
|
return resultSetToModule(rs);
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Module getModule(int userid, int semesterid)
|
public Module getModule(int userid, int semesterid) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
ResultSet rs = st.executeQuery("select * from modules where userid=" + userid + " and semesterid=" + semesterid);
|
ResultSet rs = st.executeQuery("select * from modules where userid=" + userid + " and semesterid=" + semesterid);
|
||||||
|
|
||||||
return resultSetToModule(rs);
|
return resultSetToModule(rs);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -374,96 +314,64 @@ public class DataBaseHandler
|
|||||||
ResultSet rs = st.executeQuery("SELECT * FROM modules WHERE userid = " + userid);
|
ResultSet rs = st.executeQuery("SELECT * FROM modules WHERE userid = " + userid);
|
||||||
List<Module> moduleList = new ArrayList<>();
|
List<Module> moduleList = new ArrayList<>();
|
||||||
Module m = null;
|
Module m = null;
|
||||||
while((m = resultSetToModule(rs)) != null)
|
while ((m = resultSetToModule(rs)) != null) {
|
||||||
{
|
|
||||||
moduleList.add(m);
|
moduleList.add(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
return moduleList.toArray(new Module[0]);
|
return moduleList.toArray(new Module[0]);
|
||||||
|
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex){
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Module addModule(Module m)
|
public Module addModule(Module m) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
st.executeUpdate("insert into modules (userid, semesterid, name, activated) " +
|
st.executeUpdate("insert into modules (userid, semesterid, name, activated) " +
|
||||||
"Values (" + m.getUserid() + ", " + m.getsemesterid() + ", '" + m.getName() + "', " + m.getActivated() + ")");
|
"Values (" + m.getUserid() + ", " + m.getsemesterid() + ", '" + m.getName() + "', " + m.getActivated() + ")");
|
||||||
return getModule(m.getUserid(), m.getsemesterid());
|
return getModule(m.getUserid(), m.getsemesterid());
|
||||||
|
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Module[] getAllModules() {
|
public Module[] getAllModules() {
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
ResultSet rs = st.executeQuery("SELECT * FROM modules");
|
ResultSet rs = st.executeQuery("SELECT * FROM modules");
|
||||||
List<Module> moduleList = new ArrayList<>();
|
List<Module> moduleList = new ArrayList<>();
|
||||||
Module m = null;
|
Module m = null;
|
||||||
while((m = resultSetToModule(rs)) != null)
|
while ((m = resultSetToModule(rs)) != null) {
|
||||||
{
|
|
||||||
moduleList.add(m);
|
moduleList.add(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
return moduleList.toArray(new Module[0]);
|
return moduleList.toArray(new Module[0]);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Module getModuleBySemesterUserID(int userid, int semesterid)
|
public Module updateModule(Module m) {
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ResultSet rs = st.executeQuery("select * from modules where userid=" + userid + " and semesterid=" + semesterid);
|
|
||||||
return resultSetToModule(rs);
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
return new Module(-1, 0, 0, "", 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Module updateModule(Module m)
|
|
||||||
{
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Module module = getModule(m.getUserid(), m.getsemesterid());
|
|
||||||
if(module == null)
|
|
||||||
{
|
|
||||||
addModule(m);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
st.executeUpdate("update modules set activated=" + m.getActivated() + ", semesterid=" + m.getsemesterid() + ", name='" + m.getName() + "' where id=" + module.getid());
|
|
||||||
}
|
|
||||||
|
|
||||||
Module test = getModule(m.getUserid(), m.getsemesterid());
|
|
||||||
System.out.println(test.getActivated());
|
st.executeUpdate("update modules set activated=" + m.getActivated() + ", semesterid=" + m.getsemesterid() + ", name='" + m.getName() + "' where id=" + m.getid());
|
||||||
return test;
|
|
||||||
}
|
|
||||||
catch (SQLException ex) {
|
return null;
|
||||||
|
} catch (SQLException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean deleteModule(int semesterid, int userid)
|
public boolean deleteModule(int id) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
st.executeUpdate("delete from modules where semesterid=" + semesterid + " and userid=" + userid);
|
st.executeUpdate("delete from modules where id=" + id);
|
||||||
return true;
|
return true;
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch(Exception ex) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -477,89 +385,72 @@ public class DataBaseHandler
|
|||||||
rs.getInt("semesterid"),
|
rs.getInt("semesterid"),
|
||||||
rs.getString("name"),
|
rs.getString("name"),
|
||||||
rs.getInt("activated"));
|
rs.getInt("activated"));
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
USER
|
* USER
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//Alle User, die nicht admin sind
|
//Alle User, die nicht admin sind
|
||||||
public User[] getAllUsers()
|
public User[] getAllUsers() {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
ResultSet rs = st.executeQuery("select * from users where permission=0");
|
ResultSet rs = st.executeQuery("select * from users where permission=0");
|
||||||
|
|
||||||
User u = null;
|
User u = null;
|
||||||
|
|
||||||
List<User> output = new ArrayList<>();
|
List<User> output = new ArrayList<>();
|
||||||
|
|
||||||
while((u = resultSetToUser(rs)) != null)
|
while ((u = resultSetToUser(rs)) != null) {
|
||||||
{
|
|
||||||
u.clearOutPassword();
|
u.clearOutPassword();
|
||||||
output.add(u);
|
output.add(u);
|
||||||
}
|
}
|
||||||
|
|
||||||
return output.toArray(new User[0]);
|
return output.toArray(new User[0]);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//einen User
|
//einen User
|
||||||
public User getUser(String mail, String password)
|
public User getUser(String mail, String password) {
|
||||||
{
|
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
ResultSet rs = st.executeQuery("select * from users where mail = '" + mail + "' and password = '" + password + "'");
|
ResultSet rs = st.executeQuery("select * from users where mail = '" + mail + "' and password = '" + password + "'");
|
||||||
return resultSetToUser(rs);
|
return resultSetToUser(rs);
|
||||||
} catch (Exception e)
|
} catch (Exception e) {
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public User getUser(int id)
|
public User getUser(int id) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
ResultSet rs = st.executeQuery("select * from users where id=" + id);
|
ResultSet rs = st.executeQuery("select * from users where id=" + id);
|
||||||
return resultSetToUser(rs);
|
return resultSetToUser(rs);
|
||||||
} catch (Exception e)
|
} catch (Exception e) {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public User getUser(String mail)
|
public User getUser(String mail) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
ResultSet rs = st.executeQuery("select * from users where mail='" + mail + "'");
|
ResultSet rs = st.executeQuery("select * from users where mail='" + mail + "'");
|
||||||
User u = resultSetToUser(rs);
|
User u = resultSetToUser(rs);
|
||||||
if(u != null) u.clearOutPassword();
|
if (u != null) u.clearOutPassword();
|
||||||
|
|
||||||
return u;
|
return u;
|
||||||
} catch (SQLException e)
|
} catch (SQLException e) {
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public User resultSetToUser(ResultSet rs)
|
public User resultSetToUser(ResultSet rs) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
rs.next();
|
rs.next();
|
||||||
return new User(
|
return new User(
|
||||||
rs.getInt("id"),
|
rs.getInt("id"),
|
||||||
@@ -569,27 +460,21 @@ public class DataBaseHandler
|
|||||||
rs.getString("password"),
|
rs.getString("password"),
|
||||||
rs.getInt("permission")
|
rs.getInt("permission")
|
||||||
);
|
);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//add a new user object to the database returns if process was successful
|
//add a new user object to the database returns if process was successful
|
||||||
public User addUser(User user)
|
public User addUser(User user) {
|
||||||
{
|
|
||||||
//check if mail and passwort (key user information) is given
|
//check if mail and passwort (key user information) is given
|
||||||
if (user.getMail() == null || user.getPassword() == null)
|
if (user.getMail() == null || user.getPassword() == null) {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
String password = user.getPassword();
|
String password = user.getPassword();
|
||||||
if(encrypted)
|
if (encrypted) {
|
||||||
{
|
|
||||||
RSA rsa = RSA.getInstance();
|
RSA rsa = RSA.getInstance();
|
||||||
byte[] psw = rsa.loadByteArray(password);
|
byte[] psw = rsa.loadByteArray(password);
|
||||||
try {
|
try {
|
||||||
@@ -600,20 +485,16 @@ public class DataBaseHandler
|
|||||||
}
|
}
|
||||||
st.executeUpdate("insert into users (firstname, lastname, mail, password, permission) values (" + "'" + user.getFirstName() + "', '" + user.getLastName() + "', '" + user.getMail() + "', '" + password + "', " + 0 + ")");
|
st.executeUpdate("insert into users (firstname, lastname, mail, password, permission) values (" + "'" + user.getFirstName() + "', '" + user.getLastName() + "', '" + user.getMail() + "', '" + password + "', " + 0 + ")");
|
||||||
return getUser(user.getMail(), user.getPassword());
|
return getUser(user.getMail(), user.getPassword());
|
||||||
} catch (Exception e)
|
} catch (Exception e) {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public User updateUser(User user, int id, boolean elevationRequestByAdmin)
|
public User updateUser(User user, int id, boolean elevationRequestByAdmin) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
String password = user.getPassword();
|
String password = user.getPassword();
|
||||||
if(encrypted)
|
if (encrypted) {
|
||||||
{
|
|
||||||
RSA rsa = RSA.getInstance();
|
RSA rsa = RSA.getInstance();
|
||||||
byte[] psw = rsa.loadByteArray(password);
|
byte[] psw = rsa.loadByteArray(password);
|
||||||
try {
|
try {
|
||||||
@@ -623,17 +504,14 @@ public class DataBaseHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!elevationRequestByAdmin)
|
if (!elevationRequestByAdmin) {
|
||||||
{
|
|
||||||
st.executeUpdate("update users set " +
|
st.executeUpdate("update users set " +
|
||||||
"firstname='" + user.getFirstName() + "', " +
|
"firstname='" + user.getFirstName() + "', " +
|
||||||
"lastname='" + user.getLastName() + "', " +
|
"lastname='" + user.getLastName() + "', " +
|
||||||
"mail='" + user.getMail() + "', " +
|
"mail='" + user.getMail() + "', " +
|
||||||
"password='" + password + "' " +
|
"password='" + password + "' " +
|
||||||
"where id=" + id);
|
"where id=" + id);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
st.executeUpdate("update users set " +
|
st.executeUpdate("update users set " +
|
||||||
"firstname='" + user.getFirstName() + "', " +
|
"firstname='" + user.getFirstName() + "', " +
|
||||||
"lastname='" + user.getLastName() + "', " +
|
"lastname='" + user.getLastName() + "', " +
|
||||||
@@ -644,17 +522,14 @@ public class DataBaseHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
return getUser(id);
|
return getUser(id);
|
||||||
} catch (SQLException e)
|
} catch (SQLException e) {
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean deleteUser(String mail)
|
public boolean deleteUser(String mail) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
ResultSet rs = st.executeQuery("SELECT id FROM user WHERE mail='" + mail + "'");
|
ResultSet rs = st.executeQuery("SELECT id FROM user WHERE mail='" + mail + "'");
|
||||||
rs.next();
|
rs.next();
|
||||||
int id = rs.getInt("id");
|
int id = rs.getInt("id");
|
||||||
@@ -662,9 +537,7 @@ public class DataBaseHandler
|
|||||||
|
|
||||||
st.executeUpdate("delete from users where mail='" + mail + "'");
|
st.executeUpdate("delete from users where mail='" + mail + "'");
|
||||||
return true;
|
return true;
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,14 +9,16 @@ public class Semester
|
|||||||
private String name;
|
private String name;
|
||||||
private int startyear;
|
private int startyear;
|
||||||
private int endyear;
|
private int endyear;
|
||||||
|
private int number;
|
||||||
|
|
||||||
public Semester(int id, int startday, int endday, String name, int startyear, int endyear) {
|
public Semester(int id, int startday, int endday, String name, int startyear, int endyear, int number) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.startday = startday;
|
this.startday = startday;
|
||||||
this.endday = endday;
|
this.endday = endday;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.startyear = startyear;
|
this.startyear = startyear;
|
||||||
this.endyear = endyear;
|
this.endyear = endyear;
|
||||||
|
this.number = number;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
@@ -42,4 +44,6 @@ public class Semester
|
|||||||
public int getEndyear() {
|
public int getEndyear() {
|
||||||
return endyear;
|
return endyear;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getNumber(){return number; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,11 +40,11 @@ public class EntriesController
|
|||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
var idx = 0;
|
var idx = 0;
|
||||||
for (int j = 0; j < 20; j++) {
|
for (int j = 0; j < 20; j++) {
|
||||||
if (lonelyEntry[i][j] != null){
|
if (lonelyEntry != null && lonelyEntry[i][j] != null){
|
||||||
combinedEntry[i][idx] = lonelyEntry[i][j];
|
combinedEntry[i][idx] = lonelyEntry[i][j];
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
if (happyEntry[i][j] != null){
|
if (happyEntry != null && happyEntry[i][j] != null){
|
||||||
combinedEntry[i][idx] = happyEntry[i][j];
|
combinedEntry[i][idx] = happyEntry[i][j];
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,29 +53,23 @@ public class ModuleController
|
|||||||
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
|
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
GET
|
|
||||||
Get A Module by the matching semester and user id (important for edit function in frontend)
|
|
||||||
*/
|
|
||||||
@CrossOrigin
|
@CrossOrigin
|
||||||
@GetMapping("/module/suid")
|
@GetMapping("/module/bysemesterid")
|
||||||
public ResponseEntity<Module[]> getModulesBySemesterUserID(@RequestParam(name = "sessionid") String sessionid, @RequestParam(name = "userid") String userid, @RequestParam(name = "semesterid") int semesterid)
|
public ResponseEntity<Module[]> getModulesBySemesterID(@RequestParam(name="sessionid") String sessionID, @RequestParam(name="semesterid") int semesterid)
|
||||||
{
|
{
|
||||||
User user = UserSessionIDHandler.getUserBySessionID(sessionid);
|
User user = UserSessionIDHandler.getUserBySessionID(sessionID);
|
||||||
String[] userIDSSplit = userid.split("a");
|
|
||||||
int[] userIDS = new int[userIDSSplit.length];
|
|
||||||
for(int i = 0; i < userIDS.length; i++)
|
|
||||||
{
|
|
||||||
userIDS[i] = Integer.parseInt(userIDSSplit[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(user != null && user.getPermissions() == UserPermissions.admin.getValue())
|
if(user != null && user.getPermissions() == UserPermissions.admin.getValue())
|
||||||
{
|
{
|
||||||
|
Module[] tempModuleArray = db.getAllModules();
|
||||||
List<Module> result = new ArrayList<>();
|
List<Module> result = new ArrayList<>();
|
||||||
|
|
||||||
for(int i = 0; i < userIDS.length; i++)
|
for(int i = 0; i < tempModuleArray.length; i++)
|
||||||
{
|
{
|
||||||
result.add(db.getModuleBySemesterUserID(userIDS[i], semesterid));
|
if(tempModuleArray[i].getsemesterid() == semesterid)
|
||||||
|
{
|
||||||
|
result.add(tempModuleArray[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ResponseEntity<>(result.toArray(new Module[0]), HttpStatus.OK);
|
return new ResponseEntity<>(result.toArray(new Module[0]), HttpStatus.OK);
|
||||||
@@ -114,7 +108,6 @@ public class ModuleController
|
|||||||
public ResponseEntity<Module> addModule(@RequestBody Module module, @RequestParam(name = "sessionid") String sessionID)
|
public ResponseEntity<Module> addModule(@RequestBody Module module, @RequestParam(name = "sessionid") String sessionID)
|
||||||
{
|
{
|
||||||
|
|
||||||
System.out.println("test1");
|
|
||||||
User user = UserSessionIDHandler.getUserBySessionID(sessionID);
|
User user = UserSessionIDHandler.getUserBySessionID(sessionID);
|
||||||
|
|
||||||
if (user.getPermissions() == UserPermissions.admin.getValue())
|
if (user.getPermissions() == UserPermissions.admin.getValue())
|
||||||
@@ -163,12 +156,12 @@ public class ModuleController
|
|||||||
*/
|
*/
|
||||||
@CrossOrigin
|
@CrossOrigin
|
||||||
@DeleteMapping("/module")
|
@DeleteMapping("/module")
|
||||||
public void deleteModule(@RequestParam(name = "sessionid") String sessionid, @RequestParam(name = "semesterid") int semesterid, @RequestParam(name = "userid") int userid)
|
public void deleteModule(@RequestParam(name = "sessionid") String sessionid, @RequestParam(name="id") int id)
|
||||||
{
|
{
|
||||||
User u = UserSessionIDHandler.getUserBySessionID(sessionid);
|
User u = UserSessionIDHandler.getUserBySessionID(sessionid);
|
||||||
if (u != null && u.getPermissions() == UserPermissions.admin.getValue())
|
if (u != null && u.getPermissions() == UserPermissions.admin.getValue())
|
||||||
{
|
{
|
||||||
db.deleteModule(semesterid, userid);
|
db.deleteModule(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class SemesterController
|
|||||||
return new ResponseEntity<>(s, HttpStatus.OK);
|
return new ResponseEntity<>(s, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
return new ResponseEntity<>(null, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
|
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
|
||||||
|
|||||||
Reference in New Issue
Block a user