File size: 3,654 Bytes
21a8272
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
92
93
94
95
96
97
98
99
{% extends "base.html" %}
{% block content %}

<div class="card">
    <h2>History</h2>
    <p class="subtitle">
        View and export your past tone analyses. Data is private to your account.
    </p>

    <!-- Search -->
    <div class="history-search">
        <form method="GET">
            <input type="text" name="q" value="{{ search or '' }}"

                   placeholder="Search text..."

                   style="max-width: 260px; padding: 8px;">
            <button type="submit" class="btn-secondary">Search</button>
        </form>
    </div>

    <!-- Filter buttons -->
    <div class="filter-buttons">
        <a href="{{ url_for('history_view') }}"

           class="filter-btn {% if not active_filter %}active{% endif %}">
            All
        </a>
        <a href="{{ url_for('history_view', label='Aggressive', q=search) }}"

           class="filter-btn {% if active_filter|lower == 'aggressive' %}active{% endif %}">
            Aggressive
        </a>
        <a href="{{ url_for('history_view', label='Neutral', q=search) }}"

           class="filter-btn {% if active_filter|lower == 'neutral' %}active{% endif %}">
            Neutral
        </a>
        <a href="{{ url_for('history_view', label='Polite', q=search) }}"

           class="filter-btn {% if active_filter|lower == 'polite' %}active{% endif %}">
            Polite
        </a>
        <a href="{{ url_for('history_view', label='Friendly', q=search) }}"

           class="filter-btn {% if active_filter|lower == 'friendly' %}active{% endif %}">
            Friendly
        </a>
    </div>

    <!-- Actions -->
    <div class="history-actions">
        <a href="{{ url_for('export_csv') }}">
            <button type="button" class="btn-secondary">Export CSV</button>
        </a>
        <a href="{{ url_for('export_pdf') }}">
            <button type="button" class="btn-secondary">Export PDF</button>
        </a>

        <form method="POST" action="{{ url_for('clear_history') }}"

              onsubmit="return confirm('Clear all history for your account?');">
            <input type="hidden" name="csrf_token" value="{{ csrf_token }}">
            <button type="submit" class="btn-danger">Clear History</button>
        </form>
    </div>

    <!-- Table -->
    {% if history %}
        <div class="table-wrapper">
            <table class="table">
                <thead>
                    <tr>
                        <th>Time (UTC)</th>
                        <th>Label</th>
                        <th>Severity</th>
                        <th>Threat</th>
                        <th>Polite</th>
                        <th>Friendly</th>
                        <th>Text</th>
                    </tr>
                </thead>
                <tbody>
                    {% for e in history %}
                        <tr>
                            <td>{{ e.created_at.isoformat() }}</td>
                            <td>{{ e.label }}</td>
                            <td>{{ e.severity }}</td>
                            <td>{{ e.threat_score }}</td>
                            <td>{{ e.politeness_score }}</td>
                            <td>{{ e.friendly_score }}</td>
                            <td>{{ e.text[:120] }}{% if e.text|length > 120 %}...{% endif %}</td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    {% else %}
        <p class="empty">No entries yet. Analyze some text to see your history here.</p>
    {% endif %}
</div>

{% endblock %}