fix: 🐛 Fixing some bugs and made better tournament edition

This commit is contained in:
Arek 2022-06-19 13:14:20 +02:00
parent b8a7733623
commit 63aa19863f
13 changed files with 138 additions and 62 deletions

View File

@ -11,17 +11,18 @@ async function showTournaments() {
}
function logout() {
localStorage.clear();
localStorage.removeItem('token');
location.reload();
}
function logoutVisibility() {
if (localStorage.getItem("token") !== null) {
document.getElementById("logout").style.display = "";
document.getElementById("saverForTournament").style.display = "";
}
else {
document.getElementById("logout").style.display = "none";
document.getElementById("saverForTournament").style.display = "none";
}
}
@ -30,9 +31,11 @@ function logoutVisibility() {
function loginVisibility() {
if (localStorage.getItem("token") !== null) {
document.getElementById("login").style.display = "none";
document.getElementById("saverForTournament").style.display = "";
}
else {
document.getElementById("login").style.display = "";
document.getElementById("saverForTournament").style.display = "none";
}
}
@ -61,14 +64,14 @@ async function renderTournaments() {
htmlDate = `
<h1 class="tournamentInfo">${tournament.name}</h1>
<h2 class="tournamentInfo">Miejsc: ${tournament.places}</br>
<h2 class="tournamentInfo">Miejsce: ${tournament.place}</br>
${tournament.from} do ${tournament.to}</h2>`
let htmlSegment = `
<h1> ${tournament.name}</h1>
<h2>Miejsca: ${tournament.places}</h2>
<h2>Miejsce: ${tournament.place}</h2>
<h3 class="descriptor">Wpisowe:</h3>
${tournament.entryFee}

View File

@ -22,7 +22,7 @@
<!-- <span class="dot">JM</span>-->
<button class="loginButton" type="submit" onclick="window.location.href='../../../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="../../../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>
@ -33,7 +33,7 @@
<div class="bookmarks">
<nav>
<ul>
<ul class="header-list">
<li><a href="../index.html">Informacje</a></li>
<li><a href="../zapisy/index.html">Zapisy</a></li>
<li><a href="#">Drabinka</a></li>

View File

@ -51,4 +51,9 @@ main {
.tournaments {
display: flex;
}
.header-list {
display: flex;
}

View File

@ -20,7 +20,7 @@
<!-- <span class="dot">JM</span>-->
<button class="loginButton" type="submit" onclick="window.location.href='../../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="../../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>
@ -40,7 +40,8 @@
</div>
</div>
<div class="signInBox">
<button class="signIn" onclick="window.location.href='zapisy na turniej/index.html'">ZAPISZ
<button class="signIn" onclick="window.location.href='zapisy na turniej/index.html'"
id="saverForTournament">ZAPISZ
SIĘ!</button>
</div>

View File

@ -67,7 +67,7 @@ function tournamentSave() {
.then(res => {
if (res.ok) {
alert("Udało się zapisać!")
window.location.href = '../index.html'
}
else { console.log("Coś poszło nie tak!") }
return res

View File

@ -5,7 +5,7 @@
<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>Paddle tournament system</title>
<title>Padle tournament system</title>
<link href="style.css" rel="stylesheet">
</head>

View File

@ -22,7 +22,7 @@
<!-- <span class="dot">JM</span>-->
<button class="loginButton" type="submit" onclick="window.location.href='../../../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="../../../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>
@ -33,7 +33,7 @@
<div class="bookmarks">
<nav>
<ul>
<ul class="header-list">
<li><a href="../index.html">Informacje</a></li>
<li><a href="#">Zapisy</a></li>
<li><a href="../drabinka/index.html">Drabinka</a></li>
@ -42,7 +42,7 @@
</div>
<!-- OPEN-->
<button type="button" class="collapsible">Zapisani na turniej - OPEN</button>
<button type="button" class="collapsible">Zapisani na turniej</button>
<div class="collapsibleContent" id="playersList">
<div class="participant">
@ -52,8 +52,8 @@
</div>
<div class="partNames" id="partNames">
<span id="a">Adrian Trela</span>
<span id="b">Adam Kowalski</span>
<span id="a"></span>
<span id="b"></span>
</div>
<div class="partParameters">

View File

@ -87,6 +87,7 @@ main {
border: 1px solid #AFAFAF;
padding: -2px;
}
/*2'nd Layer*/
.partID {
width: 6%;
@ -99,7 +100,8 @@ main {
text-align: center;
padding-bottom: 0;
}
.partNames{
.partNames {
width: 47%;
height: 100%;
float: left;
@ -111,7 +113,8 @@ main {
line-height: 200%;
}
.partParameters{
.partParameters {
width: 47%;
height: 100%;
float: left;
@ -132,4 +135,8 @@ main {
display: flex;
flex-direction: column;
line-height: 200%;
}
.header-list {
display: flex;
}

View File

@ -9,7 +9,7 @@
<link href="_main%20page/style.css" rel="stylesheet">
<script type="text/javascript" src="app.js"></script>
</head>
<body onload="renderTournaments();logoutVisibility(); loginVisibility(); checkRole(); checkRoleCreator();">
<header>
<div class="logoBox">
@ -19,7 +19,7 @@
<!-- <span class="dot">JM</span>-->
<button class="loginButton" type="submit" onclick="window.location.href='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="kontakt/index.html">Kontakt</a>
<a class="header_link" href="ranking/index.html">Ranking</a>

View File

@ -53,43 +53,60 @@ function createTournament() {
let rankingChecker = checkRankingBox();
console.log(rankingChecker)
let checker = checkCheckBox();
console.log(checker)
fetch('https://dragonmaster.pl/inz/tournament', {
method: "PUT",
headers: {
'Content-type': 'application/json',
Authorization: ("Bearer " + localStorage.getItem("token"))
},
body: JSON.stringify(
{
"name": document.getElementById("name").value,
"typeOfLadder": "string",
"pointsForTournament": "1",
"places": "12",
"roles": "role",
"ranked": rankingChecker,
"place": document.getElementById("place").value,
"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": document.getElementById("entries").value,
"additionalInformations": document.getElementById("add-info").value,
"categotry": document.getElementById("category").value,
"visibility": checker
}
)
}
)
let name = document.getElementById("name").value
let place = document.getElementById("place").value
let from = document.getElementById("term_from").value
let to = document.getElementById("term_to").value
let rang = document.getElementById("rank").value
let entryFee = document.getElementById("entry-fee").value
let director = document.getElementById("director").value
let phone = document.getElementById("phone").value
let entriesTo = document.getElementById("entries").value
let additionalInformations = document.getElementById("add-info").value
let category = document.getElementById("category").value
.then(res => res.json())
.then(data => {
console.log(data)
window.location.href = '../../normal_user/index.html'
})
.catch(error => console.log(error))
console.log(checker)
if (name == null || name == "", place == null || place == "", from == null || from == "", to == null || to == "", rang == null || rang == "", entryFee == null || entryFee == "", director == null || director == "", phone == null || phone == "", entriesTo == null || entriesTo == "", additionalInformations == null || additionalInformations == "", category == null || category == "") {
alert("Nie można utowrzyć turnieju! Proszę wypełnić wszystkie pola!")
}
else {
fetch('https://dragonmaster.pl/inz/tournament', {
method: "PUT",
headers: {
'Content-type': 'application/json',
Authorization: ("Bearer " + localStorage.getItem("token"))
},
body: JSON.stringify(
{
"name": name,
"typeOfLadder": "string",
"pointsForTournament": "1",
"places": "12",
"roles": "role",
"ranked": rankingChecker,
"place": place,
"from": from,
"to": to,
"rang": rang,
"entryFee": entryFee,
"director": director,
"phone": phone,
"entriesTo": entriesTo,
"additionalInformations": additionalInformations,
"categotry": category,
"visibility": checker
}
)
}
)
.then(res => res.json())
.then(data => {
console.log(data)
window.location.href = '../../normal_user/index.html'
})
.catch(error => console.log(error))
}
}
function logout() {

View File

@ -23,7 +23,7 @@
<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>
<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/ranking/index.html">Ranking</a>
@ -82,7 +82,7 @@
<input id="phone">
</label>
<h3 class="descriptor">Zapisy</h3>
<h3 class="descriptor">Zapisy do</h3>
<label>
<input id="entries">
</label>

View File

@ -66,7 +66,7 @@ function createTournament() {
"name": document.getElementById("name").value,
"typeOfLadder": "string",
"pointsForTournament": "1",
"places": document.getElementById("place").value,
"place": document.getElementById("place").value,
"roles": document.getElementById("category").value,
"from": document.getElementById("term_from").value,
"to": document.getElementById("term_to").value,
@ -114,3 +114,46 @@ function loginVisibility() {
}
}
async function showTournaments() {
let url = 'https://dragonmaster.pl/inz/tournaments';
try {
let res = await fetch(url);
return await res.json();
} catch (error) {
console.log(error);
}
}
async function renderTournaments() {
let tournaments = await showTournaments();
tournaments.forEach(tournament => {
let rank = 0
if (`${tournament.approved}` == 0) {
rank = "Nie"
}
else if (`${tournament.approved}` == 1) {
rank = "Tak, ale niezatwierdzony"
}
else {
rank = "Tak"
}
if (`${tournament.id}` == localStorage.getItem("tournamentId")) {
console.log(`${tournament.rang}`)
document.getElementById("name").placeholder = `${tournament.name}`
document.getElementById("term_from").placeholder = `${tournament.from}`
document.getElementById("term_to").placeholder = `${tournament.to}`
document.getElementById("place").placeholder = `${tournament.place}`
document.getElementById("category").placeholder = `${tournament.roles}`
document.getElementById("rank").placeholder = `${tournament.rang}`
document.getElementById("entry-fee").placeholder = `${tournament.entryFee}`
document.getElementById("director").placeholder = `${tournament.director}`
document.getElementById("phone").placeholder = `${tournament.phone}`
document.getElementById("entries").placeholder = `${tournament.entriesTo}`
document.getElementById("add-info").placeholder = `${tournament.additionalInformations}`
}
});
}

View File

@ -12,7 +12,7 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/pretty-checkbox@3.0/dist/pretty-checkbox.min.css" />
</head>
<body onload="logoutVisibility(); loginVisibility()">
<body onload="logoutVisibility(); loginVisibility(); renderTournaments();">
<header>
<div class="logoBox">
<a class="header_link" href="../../normal_user/index.html"><img class="logo" src="../../_global/logo.svg"
@ -44,7 +44,7 @@
<li><a href="../../normal_user/_main%20page/pojedynczy_turniej/zapisy/index.html">Zapisy</a></li>
<li><a href="../../normal_user/_main%20page/pojedynczy_turniej/drabinka/index.html">Drabinka</a>
</li>
<li><a href="#">Wyniki</a></li>
<!-- <li><a href="#">Wyniki</a></li> -->
</ul>
</nav>
</div>
@ -65,7 +65,7 @@
<input id="term_to">
</label>
<h3 class="descriptor">Miejsc</h3>
<h3 class="descriptor">Miejsce</h3>
<label>
<input id="place">
</label>
@ -95,7 +95,7 @@
<input id="phone">
</label>
<h3 class="descriptor">Zapisy</h3>
<h3 class="descriptor">Zapisy do</h3>
<label>
<input id="entries">
</label>