278 lines
15 KiB
HTML
278 lines
15 KiB
HTML
{% extends "layouts/base.html" %}
|
|
{% load i18n %}
|
|
|
|
{% block title %}{{ platform_name }} - {% trans "Comments" %} - PX360{% endblock %}
|
|
|
|
{% block extra_css %}
|
|
<style>
|
|
.page-header-gradient {
|
|
background: linear-gradient(135deg, #005696 0%, #0069a8 50%, #007bbd 100%);
|
|
color: white;
|
|
padding: 1.5rem 2rem;
|
|
border-radius: 1rem;
|
|
margin-bottom: 1.5rem;
|
|
box-shadow: 0 10px 15px -3px rgba(0, 86, 150, 0.2);
|
|
}
|
|
.section-card {
|
|
background: white;
|
|
border-radius: 1rem;
|
|
border: 2px solid #e2e8f0;
|
|
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
|
overflow: hidden;
|
|
transition: all 0.3s ease;
|
|
}
|
|
.stat-card {
|
|
background: white;
|
|
border-radius: 1rem;
|
|
border: 2px solid #e2e8f0;
|
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
|
|
transition: all 0.3s ease;
|
|
}
|
|
.stat-card:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
|
|
border-color: #005696;
|
|
}
|
|
</style>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<!-- Page Header -->
|
|
<div class="page-header-gradient">
|
|
<div class="flex justify-between items-center">
|
|
<div>
|
|
<a href="{% url 'social:dashboard' %}" class="inline-flex items-center text-white/80 hover:text-white mb-2 text-sm font-medium transition">
|
|
<i data-lucide="arrow-left" class="w-4 h-4 mr-2"></i>
|
|
{% trans "Back to Dashboard" %}
|
|
</a>
|
|
<h1 class="text-2xl font-bold flex items-center gap-3">
|
|
<i data-lucide="message-square" class="w-7 h-7"></i>
|
|
{{ platform_name }} - {% trans "Comments" %}
|
|
</h1>
|
|
<p class="text-blue-100 text-sm mt-1">{% trans "Monitor and analyze social media comments and reviews" %}</p>
|
|
</div>
|
|
<div class="flex items-center gap-3">
|
|
<a href="{% url 'social:export_comments_csv' platform_type=platform_type %}" class="inline-flex items-center px-4 py-2.5 bg-white/10 border-2 border-white/30 text-white font-medium rounded-xl hover:bg-white hover:text-navy transition">
|
|
<i data-lucide="file-spreadsheet" class="w-4 h-4 me-2"></i>
|
|
{% trans "Export CSV" %}
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Stats Cards -->
|
|
<div class="grid grid-cols-2 md:grid-cols-4 gap-4 mb-6">
|
|
<div class="stat-card p-5">
|
|
<div class="flex items-center gap-3">
|
|
<div class="w-12 h-12 bg-navy/10 rounded-xl flex items-center justify-center">
|
|
<i data-lucide="message-square" class="w-6 h-6 text-navy"></i>
|
|
</div>
|
|
<div>
|
|
<div class="text-2xl font-bold text-navy">{{ page_obj.paginator.count }}</div>
|
|
<div class="text-sm text-slate">{% trans "Total Comments" %}</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="stat-card p-5">
|
|
<div class="flex items-center gap-3">
|
|
<div class="w-12 h-12 bg-green-100 rounded-xl flex items-center justify-center">
|
|
<i data-lucide="smile" class="w-6 h-6 text-green-600"></i>
|
|
</div>
|
|
<div>
|
|
<div class="text-2xl font-bold text-green-600">{{ page_obj.paginator.count }}</div>
|
|
<div class="text-sm text-slate">{% trans "Analyzing..." %}</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="stat-card p-5">
|
|
<div class="flex items-center gap-3">
|
|
<div class="w-12 h-12 bg-blue-100 rounded-xl flex items-center justify-center">
|
|
<i data-lucide="brain" class="w-6 h-6 text-blue-600"></i>
|
|
</div>
|
|
<div>
|
|
<div class="text-2xl font-bold text-blue-600">AI</div>
|
|
<div class="text-sm text-slate">{% trans "Sentiment Analysis" %}</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="stat-card p-5">
|
|
<div class="flex items-center gap-3">
|
|
<div class="w-12 h-12 bg-purple-100 rounded-xl flex items-center justify-center">
|
|
<i data-lucide="zap" class="w-6 h-6 text-purple-600"></i>
|
|
</div>
|
|
<div>
|
|
<div class="text-2xl font-bold text-purple-600">{{ account.name }}</div>
|
|
<div class="text-sm text-slate">{% trans "Account" %}</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Filter Bar -->
|
|
<div class="section-card mb-6">
|
|
<div class="p-4">
|
|
<form method="get" class="flex flex-wrap gap-3 items-end">
|
|
<div class="flex-1 min-w-[200px]">
|
|
<label class="block text-xs font-bold text-slate uppercase mb-1.5">{% trans "Search" %}</label>
|
|
<input type="text" name="search" value="{{ search_query|default:'' }}" placeholder="{% trans 'Search comments...' %}"
|
|
class="w-full px-4 py-2 border-2 border-slate-200 rounded-xl text-sm focus:border-navy focus:ring-2 focus:ring-navy/20 outline-none transition">
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs font-bold text-slate uppercase mb-1.5">{% trans "Sentiment" %}</label>
|
|
<select name="sentiment" class="px-4 py-2 border-2 border-slate-200 rounded-xl text-sm bg-white focus:border-navy focus:ring-2 focus:ring-navy/20 outline-none transition">
|
|
<option value="">{% trans "All" %}</option>
|
|
<option value="positive" {% if sentiment_filter == 'positive' %}selected{% endif %}>{% trans "Positive" %}</option>
|
|
<option value="neutral" {% if sentiment_filter == 'neutral' %}selected{% endif %}>{% trans "Neutral" %}</option>
|
|
<option value="negative" {% if sentiment_filter == 'negative' %}selected{% endif %}>{% trans "Negative" %}</option>
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs font-bold text-slate uppercase mb-1.5">{% trans "Source" %}</label>
|
|
<select name="sync_via_webhook" class="px-4 py-2 border-2 border-slate-200 rounded-xl text-sm bg-white focus:border-navy focus:ring-2 focus:ring-navy/20 outline-none transition">
|
|
<option value="">{% trans "All" %}</option>
|
|
<option value="true" {% if sync_filter == 'true' %}selected{% endif %}>{% trans "Webhook" %}</option>
|
|
<option value="false" {% if sync_filter == 'false' %}selected{% endif %}>{% trans "Synced" %}</option>
|
|
</select>
|
|
</div>
|
|
<button type="submit" class="px-5 py-2 bg-navy text-white rounded-xl text-sm font-bold hover:bg-blue transition flex items-center gap-2">
|
|
<i data-lucide="filter" class="w-4 h-4"></i>
|
|
{% trans "Filter" %}
|
|
</button>
|
|
{% if search_query or sentiment_filter or sync_filter %}
|
|
<a href="{% url 'social:comments_list' platform_type=platform_type %}" class="px-4 py-2 bg-slate-100 text-slate-600 rounded-xl text-sm font-bold hover:bg-slate-200 transition flex items-center gap-1">
|
|
<i data-lucide="x" class="w-4 h-4"></i>
|
|
{% trans "Clear" %}
|
|
</a>
|
|
{% endif %}
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Comments Table -->
|
|
<div class="section-card">
|
|
<div class="overflow-x-auto">
|
|
<table class="w-full text-sm">
|
|
<thead class="bg-slate-50 border-b-2 border-slate-100">
|
|
<tr>
|
|
<th class="px-6 py-4 text-left text-xs font-bold text-slate uppercase whitespace-nowrap">{% trans "Author" %}</th>
|
|
<th class="px-6 py-4 text-left text-xs font-bold text-slate uppercase">{% trans "Comment" %}</th>
|
|
<th class="px-6 py-4 text-center text-xs font-bold text-slate uppercase whitespace-nowrap">{% trans "Sentiment" %}</th>
|
|
<th class="px-6 py-4 text-center text-xs font-bold text-slate uppercase whitespace-nowrap">{% trans "Rating" %}</th>
|
|
<th class="px-6 py-4 text-center text-xs font-bold text-slate uppercase whitespace-nowrap">{% trans "Likes" %}</th>
|
|
<th class="px-6 py-4 text-left text-xs font-bold text-slate uppercase whitespace-nowrap">{% trans "Date" %}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-slate-100">
|
|
{% for comment in page_obj.object_list %}
|
|
<tr class="hover:bg-blue-50/30 transition cursor-pointer" onclick="window.location.href='{% url 'social:comment_detail' platform_type=platform_type comment_id=comment.comment_id %}'">
|
|
<td class="px-6 py-4">
|
|
<div class="flex items-center gap-2">
|
|
<div class="w-8 h-8 rounded-full bg-navy/10 flex items-center justify-center flex-shrink-0">
|
|
<span class="text-xs font-bold text-navy">{{ comment.author_name|first|upper|default:"?" }}</span>
|
|
</div>
|
|
<span class="font-semibold text-navy text-xs">{{ comment.author_name|truncatechars:25 }}</span>
|
|
</div>
|
|
</td>
|
|
<td class="px-6 py-4 max-w-md">
|
|
<p class="text-slate-700 text-xs leading-relaxed line-clamp-2">{{ comment.text|truncatewords:25 }}</p>
|
|
</td>
|
|
<td class="px-6 py-4 text-center">
|
|
{% if comment.is_analyzed %}
|
|
{% with sentiment=comment.ai_analysis.sentiment.classification.en %}
|
|
{% if sentiment == 'positive' %}
|
|
<span class="inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-[10px] font-bold bg-green-100 text-green-700 uppercase">
|
|
<i data-lucide="smile" class="w-3 h-3"></i> {% trans "Positive" %}
|
|
</span>
|
|
{% elif sentiment == 'negative' %}
|
|
<span class="inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-[10px] font-bold bg-red-100 text-red-700 uppercase">
|
|
<i data-lucide="frown" class="w-3 h-3"></i> {% trans "Negative" %}
|
|
</span>
|
|
{% elif sentiment == 'neutral' %}
|
|
<span class="inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-[10px] font-bold bg-slate-100 text-slate-600 uppercase">
|
|
<i data-lucide="meh" class="w-3 h-3"></i> {% trans "Neutral" %}
|
|
</span>
|
|
{% else %}
|
|
<span class="text-slate text-xs">-</span>
|
|
{% endif %}
|
|
{% endwith %}
|
|
{% else %}
|
|
<span class="text-slate-400 text-xs italic">{% trans "Pending" %}</span>
|
|
{% endif %}
|
|
</td>
|
|
<td class="px-6 py-4 text-center">
|
|
{% if comment.rating %}
|
|
<span class="inline-flex items-center gap-0.5 text-yellow-500 font-bold text-xs">
|
|
<i data-lucide="star" class="w-3.5 h-3.5 fill-current"></i>
|
|
{{ comment.rating }}
|
|
</span>
|
|
{% else %}
|
|
<span class="text-slate text-xs">-</span>
|
|
{% endif %}
|
|
</td>
|
|
<td class="px-6 py-4 text-center">
|
|
{% if comment.like_count > 0 %}
|
|
<span class="inline-flex items-center gap-1 text-slate text-xs">
|
|
<i data-lucide="thumbs-up" class="w-3.5 h-3.5"></i>
|
|
{{ comment.like_count }}
|
|
</span>
|
|
{% else %}
|
|
<span class="text-slate text-xs">-</span>
|
|
{% endif %}
|
|
</td>
|
|
<td class="px-6 py-4 text-xs text-slate whitespace-nowrap">
|
|
{{ comment.created_at|date:"M d, Y" }}
|
|
</td>
|
|
</tr>
|
|
{% empty %}
|
|
<tr>
|
|
<td colspan="6" class="px-6 py-12 text-center">
|
|
<div class="inline-flex items-center justify-center w-16 h-16 bg-slate-100 rounded-full mb-3">
|
|
<i data-lucide="inbox" class="w-8 h-8 text-slate-400"></i>
|
|
</div>
|
|
<p class="text-slate font-medium mb-1">{% trans "No comments found" %}</p>
|
|
<p class="text-slate text-sm">{% trans "Try adjusting your filters or sync new comments" %}</p>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
{% if page_obj.has_other_pages %}
|
|
<!-- Pagination -->
|
|
<div class="px-6 py-4 border-t-2 border-slate-100 bg-slate-50 flex items-center justify-between">
|
|
<div class="text-sm text-slate">
|
|
{% blocktrans with start=page_obj.start_index end=page_obj.end_index total=page_obj.paginator.count %}
|
|
Showing {{ start }}-{{ end }} of {{ total }}
|
|
{% endblocktrans %}
|
|
</div>
|
|
<div class="flex gap-1">
|
|
{% if page_obj.has_previous %}
|
|
<a href="?page={{ page_obj.previous_page_number }}{% if search_query %}&search={{ search_query }}{% endif %}{% if sentiment_filter %}&sentiment={{ sentiment_filter }}{% endif %}{% if sync_filter %}&sync_via_webhook={{ sync_filter }}{% endif %}"
|
|
class="px-3 py-2 bg-white border border-slate-200 rounded-lg text-sm font-semibold text-navy hover:bg-navy hover:text-white transition">
|
|
<i data-lucide="chevron-left" class="w-4 h-4"></i>
|
|
</a>
|
|
{% endif %}
|
|
<span class="px-4 py-2 bg-navy text-white rounded-lg text-sm font-bold">
|
|
{{ page_obj.number }} / {{ page_obj.paginator.num_pages }}
|
|
</span>
|
|
{% if page_obj.has_next %}
|
|
<a href="?page={{ page_obj.next_page_number }}{% if search_query %}&search={{ search_query }}{% endif %}{% if sentiment_filter %}&sentiment={{ sentiment_filter }}{% endif %}{% if sync_filter %}&sync_via_webhook={{ sync_filter }}{% endif %}"
|
|
class="px-3 py-2 bg-white border border-slate-200 rounded-lg text-sm font-semibold text-navy hover:bg-navy hover:text-white transition">
|
|
<i data-lucide="chevron-right" class="w-4 h-4"></i>
|
|
</a>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block extra_js %}
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
lucide.createIcons();
|
|
});
|
|
</script>
|
|
{% endblock %}
|