mirror of
https://github.com/AudebertAdrien/ft_transcendence.git
synced 2026-02-04 11:40:25 +01:00
Ca casse les couilles, tounroi veut pas s'afficher, I need chatgpt plus prenium extra !
This commit is contained in:
parent
0a0641db1f
commit
b1c865acae
2
makefile
2
makefile
@ -32,7 +32,7 @@ ps:
|
|||||||
db-shell:
|
db-shell:
|
||||||
$(COMPOSE) exec db psql -U 42student players_db
|
$(COMPOSE) exec db psql -U 42student players_db
|
||||||
|
|
||||||
re : destroy down up
|
re: destroy down up
|
||||||
|
|
||||||
help:
|
help:
|
||||||
@echo "Usage:"
|
@echo "Usage:"
|
||||||
|
|||||||
@ -4,9 +4,7 @@ from django.urls import path, include
|
|||||||
from . import views
|
from . import views
|
||||||
from .views import player_list, tournoi_list, match_list
|
from .views import player_list, tournoi_list, match_list
|
||||||
from rest_framework.routers import DefaultRouter
|
from rest_framework.routers import DefaultRouter
|
||||||
from .views import match_list_json
|
from .views import match_list_json, player_list_json, tournoi_list_json
|
||||||
from .views import player_list_json
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
@ -20,4 +18,5 @@ urlpatterns = [
|
|||||||
path('tournois/', tournoi_list, name='tournoi_list'),
|
path('tournois/', tournoi_list, name='tournoi_list'),
|
||||||
path('api/match_list/', match_list_json, name='match_list_json'),
|
path('api/match_list/', match_list_json, name='match_list_json'),
|
||||||
path('api/player_list/', player_list_json, name='player_list_json'),
|
path('api/player_list/', player_list_json, name='player_list_json'),
|
||||||
|
path('api/tournoi_list/', tournoi_list_json, name='tournoi_list_json')
|
||||||
]
|
]
|
||||||
|
|||||||
@ -114,6 +114,20 @@ def player_list_json(request):
|
|||||||
# Renvoie les données en JSON
|
# Renvoie les données en JSON
|
||||||
return JsonResponse(data)
|
return JsonResponse(data)
|
||||||
|
|
||||||
|
def tournoi_list_json(request):
|
||||||
|
# Récupère tous les joueurs
|
||||||
|
tournois = Tournoi.objects.all()
|
||||||
|
|
||||||
|
# Crée un dictionnaire avec les informations des joueurs
|
||||||
|
data = {
|
||||||
|
'tournois': list(tournois.values(
|
||||||
|
'id', 'name', 'nbr_player', 'date', 'winner'
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
# Renvoie les données en JSON
|
||||||
|
return JsonResponse(data)
|
||||||
|
|
||||||
|
|
||||||
####################### THEOUCHE PART ############################
|
####################### THEOUCHE PART ############################
|
||||||
|
|
||||||
|
|||||||
@ -18,6 +18,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
const menuButton = document.querySelector('.burger-menu');
|
const menuButton = document.querySelector('.burger-menu');
|
||||||
const playerList = document.getElementById('player-list');
|
const playerList = document.getElementById('player-list');
|
||||||
const matchList = document.getElementById('match-list');
|
const matchList = document.getElementById('match-list');
|
||||||
|
const tournoiList = document.getElementById('tournoi-list');
|
||||||
const dropdownMenu = document.getElementById('dropdown-menu');
|
const dropdownMenu = document.getElementById('dropdown-menu');
|
||||||
|
|
||||||
const pongElements = document.getElementById('pong-elements');
|
const pongElements = document.getElementById('pong-elements');
|
||||||
@ -283,26 +284,26 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
|
|
||||||
function showTable(tableId) {
|
function showTable(tableId) {
|
||||||
// Masquer tous les tableaux
|
// Masquer tous les tableaux
|
||||||
if (playerList) {
|
printf('Entering showTable')
|
||||||
playerList.style.display = 'none';
|
console.log('Entering showTable', tableId);
|
||||||
}
|
if (playerList) playerList.style.display = 'none';
|
||||||
if (matchList) {
|
if (matchList) matchList.style.display = 'none';
|
||||||
matchList.style.display = 'none';
|
if (tournoiList) tournoiList.style.display = 'none';
|
||||||
}
|
|
||||||
|
|
||||||
// Afficher le tableau sélectionné
|
// Afficher le tableau sélectionné
|
||||||
if (tableId === 'player-list') {
|
if (tableId === 'player-list') {
|
||||||
if (playerList) {
|
print('Showing player list');
|
||||||
playerList.style.display = 'block';
|
if (playerList) playerList.style.display = 'block';
|
||||||
}
|
|
||||||
fetchPlayers();
|
fetchPlayers();
|
||||||
} else if (tableId === 'match-list') {
|
} else if (tableId === 'match-list') {
|
||||||
if (matchList) {
|
print('Showing match list');
|
||||||
matchList.style.display = 'block';
|
if (matchList) matchList.style.display = 'block';
|
||||||
}
|
|
||||||
fetchMatches();
|
fetchMatches();
|
||||||
|
} else if (tableId === 'tournoi-list') {
|
||||||
|
print('Showing tournoi list');
|
||||||
|
if (tournoiList) tournoiList.style.display = 'block';
|
||||||
|
fetchTournois();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Masquer le menu après la sélection
|
// Masquer le menu après la sélection
|
||||||
if (dropdownMenu) {
|
if (dropdownMenu) {
|
||||||
dropdownMenu.style.display = 'none';
|
dropdownMenu.style.display = 'none';
|
||||||
@ -345,6 +346,19 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
.catch(error => console.error('Error fetching match data:', error));
|
.catch(error => console.error('Error fetching match data:', error));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fetchTournois(){
|
||||||
|
print('Fetching tournois...');
|
||||||
|
fetch('/api/tournoi_list/')
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
print('Tournois data:', data);
|
||||||
|
if (data.tournois) {
|
||||||
|
displayTournois(data.tournois);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => console.error('Error fetching match data:', error));
|
||||||
|
}
|
||||||
|
|
||||||
function displayMatches(matches) {
|
function displayMatches(matches) {
|
||||||
const matchListBody = document.querySelector('#match-list tbody');
|
const matchListBody = document.querySelector('#match-list tbody');
|
||||||
matchListBody.innerHTML = '';
|
matchListBody.innerHTML = '';
|
||||||
@ -394,4 +408,26 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function displayTournois(tournois) {
|
||||||
|
print('Displaying tournois:');
|
||||||
|
const tournoisListBody = document.querySelector('#tournoi-list tbody');
|
||||||
|
tournoisListBody.innerHTML = '';
|
||||||
|
|
||||||
|
if (tournois.length === 0) {
|
||||||
|
print('No tournois to display');
|
||||||
|
}
|
||||||
|
|
||||||
|
tournois.forEach(tournoi => {
|
||||||
|
const row = document.createElement('tr');
|
||||||
|
row.innerHTML = `
|
||||||
|
<td>${tournoi.id}</td>
|
||||||
|
<td>${tournoi.name}</td>
|
||||||
|
<td>${tournoi.nbr_player}</td>
|
||||||
|
<td>${tournoi.date}</td>
|
||||||
|
<td>${tournoi.winner.name}</td>
|
||||||
|
`;
|
||||||
|
tournoisListBody.appendChild(row);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@ -208,6 +208,8 @@
|
|||||||
<div id="dropdown-menu" class="dropdown-content">
|
<div id="dropdown-menu" class="dropdown-content">
|
||||||
<a href="#" data-table="player-list">Players</a>
|
<a href="#" data-table="player-list">Players</a>
|
||||||
<a href="#" data-table="match-list">Matches</a>
|
<a href="#" data-table="match-list">Matches</a>
|
||||||
|
<a href="#" data-table="tournoi-list">Tournois</a>
|
||||||
|
<a href="#" data-table="blockchain-list">blockchain</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -268,7 +270,7 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="player-list" class="content-list" style="display:none;">
|
<div id="player-list" class="content-list" style="display: none;">
|
||||||
<h1>Players</h1>
|
<h1>Players</h1>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@ -314,6 +316,36 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="tournoi-list" class="content-list" style="display: none;">
|
||||||
|
<h1>Tournois</h1>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Nbr_players</th>
|
||||||
|
<th>Date</th>
|
||||||
|
<th>Winner</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for tournoi in tournois %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ tournoi.id }}</td>
|
||||||
|
<td>{{ tournoi.name }}</td>
|
||||||
|
<td>{{ tournoi.nbr_player }}</td>
|
||||||
|
<td>{{ tournoi.date }}</td>
|
||||||
|
<td>{{ tournoi.winner.name }}</td>
|
||||||
|
</tr>
|
||||||
|
{% empty %}
|
||||||
|
<tr>
|
||||||
|
<td colspan="14">No tournois found.</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
<script src="{% static 'game.js' %}"></script>
|
<script src="{% static 'game.js' %}"></script>
|
||||||
<script>
|
<script>
|
||||||
const translations = {
|
const translations = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user