Merge remote-tracking branch 'origin/master'

This commit is contained in:
Lewy 2022-06-19 01:27:52 +02:00
commit 0e6089e820
13 changed files with 160 additions and 86 deletions

15
frontend/index.html Normal file
View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body onload='location.href = "normal_user/index.html"'>
</body>
</html>

View File

@ -17,6 +17,8 @@ async function renderTournaments() {
tournaments.forEach(tournament => { tournaments.forEach(tournament => {
if (`${tournament.id}` == localStorage.getItem("tournamentId")) { if (`${tournament.id}` == localStorage.getItem("tournamentId")) {
console.log(`${tournament.rang}`)
htmlDate = ` htmlDate = `
<h1 class="tournamentInfo">${tournament.name}</h1> <h1 class="tournamentInfo">${tournament.name}</h1>
<h2 class="tournamentInfo">${tournament.places}</br> <h2 class="tournamentInfo">${tournament.places}</br>

View File

@ -14,7 +14,7 @@
<header> <header>
<div class="logoBox"> <div class="logoBox">
<a class="header_link" href="../../index.html"><img class="logo" src="../../../_global/logo.svg" <a class="header_link" href="../../index.html"><img class="logo" src="../../../_global/logo.svg"
alt="Logo error"></a> alt="Logo error"></a>
</div> </div>
<div class="linkBox"> <div class="linkBox">
<!-- <span class="dot">JM</span>--> <!-- <span class="dot">JM</span>-->
@ -38,10 +38,9 @@
</div> </div>
</div> </div>
<div class="signInBox"> <div class="signInBox">
<a href="zapisy%20na%20turniej/index.html"> <button class="signIn" >ZAPISZ SIĘ!</button> <button class="signIn" onclick="window.location.href='zapisy na turniej/index.html'">ZAPISZ
</a> SIĘ!</button>
</div> </div>
</div> </div>

View File

@ -49,29 +49,31 @@ function login() {
} }
// function checkRole() { function tournamentSave() {
// fetch('https://dragonmaster.pl/inz/user', { fetch('https://dragonmaster.pl/inz/registration', {
// method: "GET", method: "PUT",
// headers: { headers: {
// 'Content-type': 'application/json' Authorization: ("Bearer " + localStorage.getItem("token"))
// }, },
// body: JSON.stringify( body: JSON.stringify(
// { {
// "token": document.getElementById("loginusername").value, "paymentmethod": "cash",
// "password": document.getElementById("loginpassword").value "tournament": localStorage.getItem('tournamentId'),
// } "partner": document.getElementById("ID_input").value
// ) }
// } )
// ) }
// .then(res => { )
// if (res.ok) { .then(res => {
// alert("Teraz mozesz się zalogować!") if (res.ok) {
// } alert("Udało się zapisać!")
// else { console.log("Coś poszło nie tak!") }
// return res }
// }) else { console.log("Coś poszło nie tak!") }
// .then(res => res.json()) return res
// .then(data => console.log(data['token']?.length > 0 ? localStorage.setItem("token", data['token']) : 'niedziaua')) })
// .catch(error => console.log(error)) .then(res => res.json())
// .then(token1 => token = token1) .catch(error => console.log(error))
// } }

View File

@ -34,16 +34,16 @@
<div class="dropdown"> <div class="dropdown">
<button class="dropbtn">Gotówka</button> <button class="dropbtn">Gotówka</button>
<div class="dropdown-content"> <div class="dropdown-content">
<a href="#">Gotówka</a> <a id="paymentMethodCash">Gotówka</a>
<a href="#">Przelew</a> <a id="paymentMethodTransfer">Przelew</a>
<a href="#">Bitcoin</a> <a id="paymentMethodBitcoin">Bitcoin</a>
</div> </div>
</div> </div>
</div> </div>
<!-- trzeba dać cssy buttonowi bo zmieniłem z form na button --> <!-- trzeba dać cssy buttonowi bo zmieniłem z form na button -->
<button class="myButton" id="loginsubmit" onclick="login()"> <button class="myButton" id="loginsubmit" onclick="tournamentSave()">
WYŚLIJ ZGŁOSZENIE WYŚLIJ ZGŁOSZENIE
</button> </button>

View File

@ -2,13 +2,46 @@ var coll = document.getElementsByClassName("collapsible");
var i; var i;
for (i = 0; i < coll.length; i++) { for (i = 0; i < coll.length; i++) {
coll[i].addEventListener("click", function() { coll[i].addEventListener("click", function () {
this.classList.toggle("active"); this.classList.toggle("active");
var content = this.nextElementSibling; var content = this.nextElementSibling;
if (content.style.maxHeight){ if (content.style.maxHeight) {
content.style.maxHeight = null; content.style.maxHeight = null;
} else { } else {
content.style.maxHeight = content.scrollHeight + "px"; content.style.maxHeight = content.scrollHeight + "px";
} }
}); });
} }
function acceptPlayers(id) {
console.log(id)
const requestOptions = {
method: 'POST',
headers: {
'Authorization': ("Bearer " + localStorage.getItem("token"))
},
body: JSON.stringify({ title: id })
};
fetch('https://dragonmaster.pl/inz_swag/registration/payedUsingCash', requestOptions)
.then(response => response.json())
.then(data => console.log("ok"));
}
// GET request using fetch with set headers
function registrationsGet() {
let id = localStorage.getItem('tournamentId');
const element = document.getElementById('tournament8');
const headers = {
'Authorization': ("Bearer " + localStorage.getItem("token"))
};
fetch('https://dragonmaster.pl/inz/registrations' + '?id=' + id, { headers })
.then(response => response.json())
.then(data => element.innerHTML = data.map(dataItem =>
`<div class="zapisani">${dataItem.userid} ${dataItem.paymenttype} ${dataItem.paymentstatus} ${dataItem.partner} <button id="paymentAccepted" onclick="acceptPlayers(${dataItem.id})">dopusc do turnieju</button> <span id="paymentCheck"></span> <br><div>`)
);
}

View File

@ -11,15 +11,17 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/pretty-checkbox@3.0/dist/pretty-checkbox.min.css"/> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/pretty-checkbox@3.0/dist/pretty-checkbox.min.css"/>
</head> </head>
<body> <body onload="registrationsGet()">
<header> <header>
<div class="logoBox"> <div class="logoBox">
<a class="header_link" href="../../../index.html"><img class="logo" src="../../../../_global/logo.svg" alt="Logo error"></a> <a class="header_link" href="../../../index.html"><img class="logo" src="../../../../_global/logo.svg"
alt="Logo error"></a>
</div> </div>
<div class="linkBox"> <div class="linkBox">
<!-- <span class="dot">JM</span>--> <!-- <span class="dot">JM</span>-->
<button class="loginButton" type="submit" onclick="window.location.href='../../../logowanie/index.html'">LOGOWANIE</button> <button class="loginButton" type="submit"
onclick="window.location.href='../../../logowanie/index.html'">LOGOWANIE</button>
<a class="header_link" href="../../../kontakt/index.html">Kontakt</a> <a class="header_link" href="../../../kontakt/index.html">Kontakt</a>
<a class="header_link" href="../../../ranking/index.html">Ranking</a> <a class="header_link" href="../../../ranking/index.html">Ranking</a>
<a class="header_link" href="../../../index.html">Kalendarz turniejów</a> <a class="header_link" href="../../../index.html">Kalendarz turniejów</a>
@ -145,11 +147,14 @@
</div> </div>
</div> </div>
</div> -->
<!-- MIKST--> <!-- MIKST-->
<button type="button" class="collapsible">Zapisani na turniej - MIKST</button> <button type="button" class="collapsible">Zapisani na turniej - MIKST</button>
<div class="collapsibleContent"> <div class="collapsibleContent">
Brak zawodników mikst <main id="tournament8">
</main>
</div> </div>
</div> </div>

View File

@ -123,5 +123,13 @@ main {
padding-top: 2%; padding-top: 2%;
padding-right: 2%; padding-right: 2%;
border: 1px solid black;
}
.zapisani {
width: 100px;
height: auto;
display: flex;
flex-direction: column;
line-height: 200%; line-height: 200%;
} }

View File

@ -20,21 +20,45 @@ function checkRoleCreator() {
}) })
.then(res => res.json()) .then(res => res.json())
.then(json => { .then(json => {
let test = (json['id']) let organiser = (json['id'])
renderTournaments(test) renderTournaments(organiser)
}) })
} }
async function renderTournaments(test) { function tournamentDelete(id) {
event.cancelBubble = true;
if (event.stopPropagation) event.stopPropagation();
console.log(id)
fetch('https://dragonmaster.pl/inz/tournament', {
method: "DELETE",
headers: {
'Content-type': 'application/json',
Authorization: ("Bearer " + localStorage.getItem("token"))
},
body: JSON.stringify(
{
"id": id
}
)
}
)
.then(res => res.json())
.then(data => console.log(data))
.catch(error => console.log(error))
}
async function renderTournaments(organiserTournament) {
let tournaments = await showTournaments(); let tournaments = await showTournaments();
let html = ''; let html = '';
tournaments.forEach(tournament => { tournaments.forEach(tournament => {
// console.log(test) // console.log(test)
organiser = `${tournament.creator}`; organiser = `${tournament.creator}`;
console.log(organiser)
// console.log(organiser) // console.log(organiser)
if (organiser == test) { if (organiser == organiserTournament) {
let htmlSegment = `<div class = "tournamentBox" onclick="window.location.href='_main page/pojedynczy_turniej/index.html'; saveIdTournament(${tournament.id});"> let htmlSegment = `<div class = "tournamentBox" onclick="window.location.href='_main page/pojedynczy_turniej/index.html'; saveIdTournament(${tournament.id});">
<div class="tournamentIconBox"> <div class="tournamentIconBox">
<img class="tournamentIcon" src="_main%20page/cup.svg" alt=""> <img class="tournamentIcon" src="_main%20page/cup.svg" alt="">
@ -50,9 +74,10 @@ async function renderTournaments(test) {
</div> </div>
<img class="dots" id="deleteMatch" src="src/trash.svg"> <input type="image" src="src/trash.svg" class="dots" onclick="tournamentDelete(${tournament.id});location.reload();"/>
</div> </div>
`; `
html += htmlSegment; html += htmlSegment;
} }
else { else {
@ -80,9 +105,6 @@ async function renderTournaments(test) {
container.innerHTML = html; container.innerHTML = html;
} }
function checkRoleforDelete() {
}
function logout() { function logout() {
localStorage.clear(); localStorage.clear();
@ -134,16 +156,4 @@ function checkRole() {
document.getElementById("creator").style.display = "none"; document.getElementById("creator").style.display = "none";
} }
} }
// function creatorVisibility() {
// if (localStorage.getItem("token") == null) {
// document.getElementById("creator").style.display = "none";
// }
// else if (checkRole()) {
// document.getElementById("creator").style.display = "none";
// }
// else {
// document.getElementById("creator").style.display = "";
// }
// }

View File

@ -12,7 +12,7 @@ function checkRole() {
window.location.href = '../index.html' window.location.href = '../index.html'
} }
else { else {
window.location.href = '../../panel_organizatora/dodawanie turnieju/index.html' window.location.href = '../index.html'
} }
}) })

View File

@ -41,18 +41,18 @@ function createTournament() {
"typeOfLadder": "string", "typeOfLadder": "string",
"pointsForTournament": "1", "pointsForTournament": "1",
"places": "1", "places": "1",
"roles": document.getElementById("category").value, "roles": "role",
"ranked": document.getElementById("rank").value, "ranked": document.getElementById("rank").value,
"place": document.getElementById("place").value, "place": document.getElementById("place").value,
"from": "2020-10-10 10:10:10", "from": document.getElementById("term_from").value,
"to": "2020-10-10 10:10:10", "to": document.getElementById("term_to").value,
"rang": "rang1", "rang": document.getElementById("rank").value,
"entryFee": document.getElementById("entry-fee").value, "entryFee": document.getElementById("entry-fee").value,
"director": document.getElementById("director").value, "director": document.getElementById("director").value,
"phone": document.getElementById("phone").value, "phone": document.getElementById("phone").value,
"entriesTo": "2020-10-10 10:10:10", "entriesTo": document.getElementById("entries").value,
"additionalInformations": document.getElementById("add-info").value, "additionalInformations": document.getElementById("add-info").value,
"categotry": "cat1", "categotry": document.getElementById("category").value,
"visibility": "TRUE" "visibility": "TRUE"
} }
) )

View File

@ -1,6 +1,6 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html" xmlns="http://www.w3.org/1999/html" <html lang="en" xmlns="http://www.w3.org/1999/html" xmlns="http://www.w3.org/1999/html"
xmlns="http://www.w3.org/1999/html"> xmlns="http://www.w3.org/1999/html">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
@ -9,20 +9,20 @@
<title>Padel Tournaments System</title> <title>Padel Tournaments System</title>
<link href="style.css" rel="stylesheet"> <link href="style.css" rel="stylesheet">
<script type="text/javascript" src="app.js"></script> <script type="text/javascript" src="app.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/pretty-checkbox@3.0/dist/pretty-checkbox.min.css"/> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/pretty-checkbox@3.0/dist/pretty-checkbox.min.css" />
</head> </head>
<body onload="logoutVisibility(); loginVisibility()"> <body onload="logoutVisibility(); loginVisibility()">
<header> <header>
<div class="logoBox"> <div class="logoBox">
<a class="header_link" href="../../normal_user/index.html"><img class="logo" src="../../_global/logo.svg" <a class="header_link" href="../../normal_user/index.html"><img class="logo" src="../../_global/logo.svg"
alt="Logo error"></a> alt="Logo error"></a>
</div> </div>
<div class="linkBox"> <div class="linkBox">
<!-- <span class="dot">JM</span>--> <!-- <span class="dot">JM</span>-->
<button class="loginButton" type="submit" onclick="window.location.href='../../normal_user/logowanie/index.html'" <button class="loginButton" type="submit"
id="login">LOGOWANIE</button> onclick="window.location.href='../../normal_user/logowanie/index.html'" id="login">LOGOWANIE</button>
<button class="loginButton" id="logout" onclick="logout()">Wyloguj</button> <button class="loginButton" id="logout" onclick="logout()">Wyloguj</button>
<a class="header_link" href="../../normal_user/kontakt/index.html">Kontakt</a> <a class="header_link" href="../../normal_user/kontakt/index.html">Kontakt</a>

View File

@ -30,29 +30,28 @@
function createTournament() { function createTournament() {
fetch('https://dragonmaster.pl/inz/tournament', { fetch('https://dragonmaster.pl/inz/tournament', {
method: "PUT", method: "POST",
headers: { headers: {
'Content-type': 'application/json', 'Content-type': 'application/json',
Authorization: ("Bearer " + localStorage.getItem("token")) Authorization: ("Bearer " + localStorage.getItem("token"))
}, },
body: JSON.stringify( body: JSON.stringify(
{ {
"id": localStorage.getItem('tournamentId'),
"name": document.getElementById("name").value, "name": document.getElementById("name").value,
"typeOfLadder": "string", "typeOfLadder": "string",
"pointsForTournament": "1", "pointsForTournament": "1",
"places": "1", "places": document.getElementById("place").value,
"roles": document.getElementById("category").value, "roles": document.getElementById("category").value,
"ranked": document.getElementById("rank").value, "from": document.getElementById("term_from").value,
"place": document.getElementById("place").value, "to": document.getElementById("term_to").value,
"from": "2020-10-10 10:10:10", "rang": document.getElementById("rank").value,
"to": "2020-10-10 10:10:10",
"rang": "rang1",
"entryFee": document.getElementById("entry-fee").value, "entryFee": document.getElementById("entry-fee").value,
"director": document.getElementById("director").value, "director": document.getElementById("director").value,
"phone": document.getElementById("phone").value, "phone": document.getElementById("phone").value,
"entriesTo": "2020-10-10 10:10:10", "entriesTo": document.getElementById("entries").value,
"additionalInformations": document.getElementById("add-info").value, "additionalInformations": document.getElementById("add-info").value,
"categotry": "cat1", "categotry": document.getElementById("category").value,
"visibility": "TRUE" "visibility": "TRUE"
} }
) )
@ -64,6 +63,7 @@ function createTournament() {
.catch(error => console.log(error)) .catch(error => console.log(error))
} }
function logout() { function logout() {
localStorage.clear(); localStorage.clear();
location.reload(); location.reload();