Dodanie funkcjonalności

This commit is contained in:
Arek 2022-06-18 14:35:43 +02:00
parent d8b0af0461
commit a040ea2b21
13 changed files with 161 additions and 90 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 => {
if (`${tournament.id}` == localStorage.getItem("tournamentId")) {
console.log(`${tournament.rang}`)
htmlDate = `
<h1 class="tournamentInfo">${tournament.name}</h1>
<h2 class="tournamentInfo">${tournament.places}</br>

View File

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

View File

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

View File

@ -34,16 +34,16 @@
<div class="dropdown">
<button class="dropbtn">Gotówka</button>
<div class="dropdown-content">
<a href="#">Gotówka</a>
<a href="#">Przelew</a>
<a href="#">Bitcoin</a>
<a id="paymentMethodCash">Gotówka</a>
<a id="paymentMethodTransfer">Przelew</a>
<a id="paymentMethodBitcoin">Bitcoin</a>
</div>
</div>
</div>
<!-- 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
</button>

View File

@ -2,13 +2,46 @@ var coll = document.getElementsByClassName("collapsible");
var i;
for (i = 0; i < coll.length; i++) {
coll[i].addEventListener("click", function() {
coll[i].addEventListener("click", function () {
this.classList.toggle("active");
var content = this.nextElementSibling;
if (content.style.maxHeight){
if (content.style.maxHeight) {
content.style.maxHeight = null;
} else {
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 @@
</head>
<body>
<body onload="registrationsGet()">
<header>
<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 class="linkBox">
<!-- <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="../../../ranking/index.html">Ranking</a>
<a class="header_link" href="../../../index.html">Kalendarz turniejów</a>
@ -39,18 +41,18 @@
</div>
<!-- OPEN-->
<button type="button" class="collapsible">Zapisani na turniej - OPEN</button>
<div class="collapsibleContent">
<div class="participant">
To ja
</div>
<!-- <button type="button" class="collapsible">Zapisani na turniej - OPEN</button>
<div class="collapsibleContent">
<div class="tournamen">
To ja
</div>
</div> -->
<!-- MIKST-->
<!-- MIKST-->
<button type="button" class="collapsible">Zapisani na turniej - MIKST</button>
<div class="collapsibleContent">
<main id="tournament8">
Hejo
</main>
</div>

View File

@ -79,3 +79,10 @@ main {
border: 1px solid black;
}
.zapisani {
width: 100px;
height: auto;
display: flex;
flex-direction: column;
}

View File

@ -20,21 +20,45 @@ function checkRoleCreator() {
})
.then(res => res.json())
.then(json => {
let test = (json['id'])
renderTournaments(test)
let organiser = (json['id'])
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 html = '';
tournaments.forEach(tournament => {
// console.log(test)
organiser = `${tournament.creator}`;
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});">
<div class="tournamentIconBox">
<img class="tournamentIcon" src="_main%20page/cup.svg" alt="">
@ -50,9 +74,10 @@ async function renderTournaments(test) {
</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>
`;
`
html += htmlSegment;
}
else {
@ -80,9 +105,6 @@ async function renderTournaments(test) {
container.innerHTML = html;
}
function checkRoleforDelete() {
}
function logout() {
localStorage.clear();
@ -135,15 +157,3 @@ function checkRole() {
}
}
// 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'
}
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",
"pointsForTournament": "1",
"places": "1",
"roles": document.getElementById("category").value,
"roles": "role",
"ranked": document.getElementById("rank").value,
"place": document.getElementById("place").value,
"from": "2020-10-10 10:10:10",
"to": "2020-10-10 10:10:10",
"rang": "rang1",
"from": document.getElementById("term_from").value,
"to": document.getElementById("term_to").value,
"rang": document.getElementById("rank").value,
"entryFee": document.getElementById("entry-fee").value,
"director": document.getElementById("director").value,
"phone": document.getElementById("phone").value,
"entriesTo": "2020-10-10 10:10:10",
"entriesTo": document.getElementById("entries").value,
"additionalInformations": document.getElementById("add-info").value,
"categotry": "cat1",
"categotry": document.getElementById("category").value,
"visibility": "TRUE"
}
)

View File

@ -1,6 +1,6 @@
<!DOCTYPE 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>
<meta charset="UTF-8">
@ -9,20 +9,20 @@
<title>Padel Tournaments System</title>
<link href="style.css" rel="stylesheet">
<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>
<body onload="logoutVisibility(); loginVisibility()">
<header>
<div class="logoBox">
<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 class="linkBox">
<!-- <span class="dot">JM</span>-->
<button class="loginButton" type="submit" onclick="window.location.href='../../normal_user/logowanie/index.html'"
id="login">LOGOWANIE</button>
<button class="loginButton" type="submit"
onclick="window.location.href='../../normal_user/logowanie/index.html'" id="login">LOGOWANIE</button>
<button class="loginButton" id="logout" onclick="logout()">Wyloguj</button>
<a class="header_link" href="../../normal_user/kontakt/index.html">Kontakt</a>

View File

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