File size: 3,940 Bytes
6bcf797
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
89
90
91
{% extends "admin/base.html" %}

{% block title %}Отчеты анализа{% endblock %}

{% block content %}
<div class="admin-header">
    <h1><i class="fas fa-chart-bar"></i> Отчеты анализа</h1>
    <div class="admin-actions">
        <form class="filter-form" method="get" action="{{ url_for('admin_bp.view_reports') }}">
            <select class="form-select" name="emotion" onchange="this.form.submit()">
                <option value="">Все эмоции</option>
                {% for emotion in emotions %}
                <option value="{{ emotion.emotion }}" {% if emotion.emotion == current_emotion %}selected{% endif %}>
                    {{ emotion_map.get(emotion.emotion, emotion.emotion) }}
                </option>
                {% endfor %}
            </select>
        </form>
    </div>
</div>

<div class="card">
    <div class="card-body">
        <div class="table-responsive">
            <table class="table table-hover">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>Пользователь</th>
                        <th>Текст</th>
                        <th>Эмоция</th>
                        <th>Уверенность</th>
                        <th>Дата</th>
                    </tr>
                </thead>
                <tbody>
                    {% for report in reports.items %}
                    <tr>
                        <td>{{ report.id }}</td>
                        <td>{{ report.user.username }}</td>
                        <td class="text-truncate" style="max-width: 200px;" title="{{ report.content }}">
                            {{ report.content }}
                        </td>
                        <td>
                            <span class="badge" style="background: {{ get_emotion_color(report.emotion) }}">
                                {{ emotion_map.get(report.emotion, report.emotion) }}
                            </span>
                        </td>
                        <td>{{ (report.confidence * 100)|round(1) }}%</td>
                        <td>{{ report.created_at|datetimeformat }}</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>

        <!-- Пагинация -->
        <nav aria-label="Page navigation">
            <ul class="pagination justify-content-center">
                {% if reports.has_prev %}
                <li class="page-item">
                    <a class="page-link" href="{{ url_for('admin_bp.view_reports', page=reports.prev_num, emotion=current_emotion) }}">
                        &laquo;
                    </a>
                </li>
                {% endif %}

                {% for page_num in reports.iter_pages(left_edge=1, right_edge=1, left_current=2, right_current=3) %}
                    {% if page_num %}
                        <li class="page-item {% if page_num == reports.page %}active{% endif %}">
                            <a class="page-link" href="{{ url_for('admin_bp.view_reports', page=page_num, emotion=current_emotion) }}">
                                {{ page_num }}
                            </a>
                        </li>
                    {% else %}
                        <li class="page-item disabled"><span class="page-link">...</span></li>
                    {% endif %}
                {% endfor %}

                {% if reports.has_next %}
                <li class="page-item">
                    <a class="page-link" href="{{ url_for('admin_bp.view_reports', page=reports.next_num, emotion=current_emotion) }}">
                        &raquo;
                    </a>
                </li>
                {% endif %}
            </ul>
        </nav>
    </div>
</div>
{% endblock %}