File size: 4,961 Bytes
cb18dab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
{% extends 'base.html' %}

{% block title %}Tableau de bord Admin{% endblock %}

{% block content %}
<div class="mb-8 flex justify-between items-center px-4">
    <h1 class="text-3xl font-bold text-gray-900">Tableau de bord Admin</h1>
    <div class="space-x-2">
        <a href="{{ url_for('admin_boards') }}" class="bg-blue-100 hover:bg-blue-200 text-blue-800 px-4 py-2 rounded-lg font-medium">Gérer les Planches</a>
        <a href="{{ url_for('admin_logout') }}" class="bg-gray-200 hover:bg-gray-300 text-gray-700 px-4 py-2 rounded-lg font-medium">Déconnexion</a>
    </div>
</div>

{% with messages = get_flashed_messages() %}
    {% if messages %}
        <div class="px-4 mb-4">
        {% for message in messages %}
            <div class="bg-green-50 text-green-700 border border-green-200 p-3 rounded-lg">{{ message }}</div>
        {% endfor %}
        </div>
    {% endif %}
{% endwith %}

<div class="bg-white rounded-xl border border-gray-200 shadow-sm overflow-hidden mx-4">
    <div class="overflow-x-auto">
        <table class="min-w-full divide-y divide-gray-200">
            <thead class="bg-gray-50">
                <tr>
                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ID</th>
                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Type</th>
                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Board</th>
                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Contenu/Fichier</th>
                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">IP</th>
                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Date</th>
                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Action</th>
                </tr>
            </thead>
            <tbody class="bg-white divide-y divide-gray-200 text-gray-700">
                {% for post in posts %}
                <tr class="hover:bg-gray-50">
                    <td class="px-6 py-4 whitespace-nowrap">
                        <a href="{{ url_for('thread', thread_id=post.thread_id if post.thread_id else post.id) }}#post-{{ post.id }}" target="_blank" class="text-blue-600 hover:underline font-medium">
                            {{ post.id }}
                        </a>
                    </td>
                    <td class="px-6 py-4 whitespace-nowrap">
                        {% if post.thread_id %}
                        <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800">Réponse</span>
                        {% else %}
                        <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800">Fil</span>
                        {% endif %}
                    </td>
                    <td class="px-6 py-4 whitespace-nowrap">
                        /{{ post.board.slug }}/
                    </td>
                    <td class="px-6 py-4">
                        <div class="max-w-xs truncate text-xs">
                            {{ post.content|default('', true) }}
                            {% if post.filename %}
                            <br>
                            <span class="text-blue-500">[Fichier : {{ post.original_filename }}]</span>
                            {% endif %}
                        </div>
                    </td>
                    <td class="px-6 py-4 whitespace-nowrap text-xs">
                        {{ post.ip_address }}
                    </td>
                    <td class="px-6 py-4 whitespace-nowrap text-xs">
                        {{ post.created_at.strftime('%Y-%m-%d %H:%M') }}
                    </td>
                    <td class="px-6 py-4 whitespace-nowrap">
                        <div class="flex space-x-2">
                            <form action="{{ url_for('delete_post', post_id=post.id) }}" method="POST" onsubmit="return confirm('Êtes-vous sûr de vouloir supprimer ce post ?');">
                                <button type="submit" class="text-red-600 hover:text-red-800 font-bold text-sm">Supprimer</button>
                            </form>
                            <form action="{{ url_for('ban_ip', post_id=post.id) }}" method="POST" onsubmit="return confirm('Êtes-vous sûr de vouloir BANNIR cette IP ?');">
                                <button type="submit" class="text-orange-600 hover:text-orange-800 font-bold text-sm">Bannir IP</button>
                            </form>
                        </div>
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
</div>
{% endblock %}