HH/templates/social/social_comment_list.html
2026-03-09 16:10:24 +03:00

279 lines
16 KiB
HTML

{% extends "layouts/base.html" %}
{% load i18n %}
{% load static %}
{% load social_filters %}
{% load star_rating %}
{% load social_icons %}
{% block title %}{% trans "Social Media Monitoring" %} - PX360{% endblock %}
{% block content %}
<div class="p-6 md:p-8 bg-gradient-to-br from-light to-blue-50 min-h-screen">
<!-- Page Header -->
<div class="flex flex-col md:flex-row justify-between items-start md:items-center gap-4 mb-8">
<div class="flex items-center gap-3">
<div class="flex items-center justify-center w-14 h-14 bg-gradient-to-br from-purple-500 to-indigo-500 rounded-2xl shadow-lg shadow-purple-200">
<i data-lucide="message-circle" class="w-8 h-8 text-white"></i>
</div>
<div>
<h1 class="text-2xl font-bold text-navy">
{% trans "Social Media Monitoring" %}
</h1>
<p class="text-slate text-sm">
{% trans "Track social media mentions and sentiment across all platforms" %}
</p>
</div>
</div>
<div class="flex gap-3">
<a href="{% url 'social:social_analytics' %}" class="inline-flex items-center gap-2 px-5 py-2.5 bg-gradient-to-r from-blue to-navy text-white rounded-xl font-semibold hover:from-navy hover:to-blue transition shadow-lg shadow-blue-200">
<i data-lucide="bar-chart-3" class="w-4 h-4"></i>
{% trans "Analytics" %}
</a>
<a href="{% url 'social:social_export_csv' %}" class="inline-flex items-center gap-2 px-5 py-2.5 bg-white border-2 border-emerald-200 text-emerald-700 rounded-xl font-semibold hover:bg-emerald-50 transition">
<i data-lucide="file-spreadsheet" class="w-4 h-4"></i> CSV
</a>
<a href="{% url 'social:social_export_excel' %}" class="inline-flex items-center gap-2 px-5 py-2.5 bg-white border-2 border-emerald-200 text-emerald-700 rounded-xl font-semibold hover:bg-emerald-50 transition">
<i data-lucide="file-spreadsheet" class="w-4 h-4"></i> Excel
</a>
</div>
</div>
<!-- Platform Cards -->
<div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4 mb-8">
{% for platform_code, platform_name in platforms %}
<a href="{% url 'social:social_platform' platform_code %}" class="group">
<div class="bg-white p-6 rounded-2xl shadow-sm border-2 border-blue-100 hover:border-purple hover:shadow-lg hover:-translate-y-1 transition-all duration-200">
<div class="text-center">
<div class="w-14 h-14 bg-gradient-to-br from-blue-100 to-purple-100 rounded-2xl flex items-center justify-center mx-auto mb-3 group-hover:shadow-lg transition">
{% social_icon platform_code %}
</div>
<h6 class="font-bold text-navy mb-1">{{ platform_name }}</h6>
<p class="text-xs text-slate">
{{ stats|lookup:platform_code }} {% trans "comments" %}
</p>
</div>
</div>
</a>
{% endfor %}
</div>
<!-- Statistics Cards -->
<div class="grid grid-cols-1 md:grid-cols-4 gap-6 mb-8">
<div class="bg-white rounded-2xl shadow-sm border border-blue-100 p-6 hover:shadow-md transition">
<div class="flex items-center gap-3 mb-3">
<div class="w-12 h-12 bg-gradient-to-br from-blue to-navy rounded-xl flex items-center justify-center">
<i data-lucide="message-square" class="w-6 h-6 text-white"></i>
</div>
<div>
<p class="text-xs font-semibold text-slate uppercase">{% trans "Total Comments" %}</p>
<p class="text-2xl font-bold text-navy">{{ stats.total }}</p>
</div>
</div>
</div>
<div class="bg-white rounded-2xl shadow-sm border border-emerald-100 p-6 hover:shadow-md transition">
<div class="flex items-center gap-3 mb-3">
<div class="w-12 h-12 bg-gradient-to-br from-emerald-500 to-green-500 rounded-xl flex items-center justify-center">
<i data-lucide="smile" class="w-6 h-6 text-white"></i>
</div>
<div>
<p class="text-xs font-semibold text-slate uppercase">{% trans "Positive" %}</p>
<p class="text-2xl font-bold text-navy">{{ stats.positive }}</p>
<p class="text-xs text-slate">{% widthratio stats.positive stats.total 100 %}% {% trans "of total" %}</p>
</div>
</div>
</div>
<div class="bg-white rounded-2xl shadow-sm border border-slate-200 p-6 hover:shadow-md transition">
<div class="flex items-center gap-3 mb-3">
<div class="w-12 h-12 bg-gradient-to-br from-slate-400 to-slate-500 rounded-xl flex items-center justify-center">
<i data-lucide="meh" class="w-6 h-6 text-white"></i>
</div>
<div>
<p class="text-xs font-semibold text-slate uppercase">{% trans "Neutral" %}</p>
<p class="text-2xl font-bold text-navy">{{ stats.neutral }}</p>
<p class="text-xs text-slate">{% widthratio stats.neutral stats.total 100 %}% {% trans "of total" %}</p>
</div>
</div>
</div>
<div class="bg-white rounded-2xl shadow-sm border border-red-100 p-6 hover:shadow-md transition">
<div class="flex items-center gap-3 mb-3">
<div class="w-12 h-12 bg-gradient-to-br from-red-500 to-rose-500 rounded-xl flex items-center justify-center">
<i data-lucide="frown" class="w-6 h-6 text-white"></i>
</div>
<div>
<p class="text-xs font-semibold text-slate uppercase">{% trans "Negative" %}</p>
<p class="text-2xl font-bold text-navy">{{ stats.negative }}</p>
<p class="text-xs text-slate">{% widthratio stats.negative stats.total 100 %}% {% trans "of total" %}</p>
</div>
</div>
</div>
</div>
<!-- Filters -->
<div class="bg-white rounded-2xl shadow-sm border border-blue-100 overflow-hidden mb-8">
<details class="group">
<summary class="flex items-center justify-between p-6 cursor-pointer list-none">
<h3 class="text-lg font-bold text-navy flex items-center gap-2">
<i data-lucide="filter" class="w-5 h-5 text-blue"></i>
{% trans "Advanced Filters" %}
</h3>
<i data-lucide="chevron-down" class="w-5 h-5 text-slate group-open:rotate-180 transition-transform"></i>
</summary>
<div class="px-6 pb-6">
<form method="get" class="grid grid-cols-1 md:grid-cols-5 gap-4">
<div>
<label class="block text-sm font-bold text-navy mb-2">{% trans "Platform" %}</label>
<select name="platform" class="w-full px-4 py-2.5 border-2 border-blue-100 rounded-xl text-navy focus:ring-2 focus:ring-blue focus:border-transparent transition bg-white">
<option value="">{% trans "All Platforms" %}</option>
{% for platform_code, platform_name in platforms %}
<option value="{{ platform_code }}" {% if filters.platform == platform_code %}selected{% endif %}>
{{ platform_name }}
</option>
{% endfor %}
</select>
</div>
<div>
<label class="block text-sm font-bold text-navy mb-2">{% trans "Sentiment" %}</label>
<select name="sentiment" class="w-full px-4 py-2.5 border-2 border-blue-100 rounded-xl text-navy focus:ring-2 focus:ring-blue focus:border-transparent transition bg-white">
<option value="">{% trans "All Sentiments" %}</option>
<option value="positive" {% if filters.sentiment == 'positive' %}selected{% endif %}>{% trans "Positive" %}</option>
<option value="neutral" {% if filters.sentiment == 'neutral' %}selected{% endif %}>{% trans "Neutral" %}</option>
<option value="negative" {% if filters.sentiment == 'negative' %}selected{% endif %}>{% trans "Negative" %}</option>
</select>
</div>
<div>
<label class="block text-sm font-bold text-navy mb-2">{% trans "Date From" %}</label>
<input type="date" name="date_from" class="w-full px-4 py-2.5 border-2 border-blue-100 rounded-xl text-navy focus:ring-2 focus:ring-blue focus:border-transparent transition" value="{{ filters.date_from|default:'' }}">
</div>
<div>
<label class="block text-sm font-bold text-navy mb-2">{% trans "Date To" %}</label>
<input type="date" name="date_to" class="w-full px-4 py-2.5 border-2 border-blue-100 rounded-xl text-navy focus:ring-2 focus:ring-blue focus:border-transparent transition" value="{{ filters.date_to|default:'' }}">
</div>
<div class="flex items-end">
<button type="submit" class="w-full inline-flex items-center justify-center gap-2 px-4 py-2.5 bg-gradient-to-r from-blue to-navy text-white rounded-xl font-semibold hover:from-navy hover:to-blue transition shadow-lg shadow-blue-200">
<i data-lucide="search" class="w-4 h-4"></i> {% trans "Filter" %}
</button>
</div>
</form>
</div>
</details>
</div>
<!-- Comments Feed -->
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
{% for comment in comments %}
<div class="bg-white rounded-2xl shadow-sm border border-blue-100 hover:shadow-lg hover:-translate-y-1 transition-all duration-200 overflow-hidden">
<div class="p-6">
<div class="flex flex-wrap gap-2 mb-4">
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-bold bg-gradient-to-r from-blue to-navy text-white">
{{ comment.get_platform_display }}
</span>
{% if comment.rating %}
<span class="inline-flex items-center gap-1 px-3 py-1 rounded-full text-xs font-bold bg-yellow-100 text-yellow-700">
<i data-lucide="star" class="w-3 h-3 fill-current"></i> {{ comment.rating }}/5
</span>
{% endif %}
{% if comment.ai_analysis %}
{% with sentiment=comment.ai_analysis.sentiment.classification.en %}
{% if sentiment == 'positive' %}
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-bold bg-emerald-100 text-emerald-700">
<i data-lucide="smile" class="w-3 h-3"></i> {% trans "Positive" %}
</span>
{% elif sentiment == 'negative' %}
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-bold bg-red-100 text-red-700">
<i data-lucide="frown" class="w-3 h-3"></i> {% trans "Negative" %}
</span>
{% else %}
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-bold bg-slate-100 text-slate-700">
<i data-lucide="meh" class="w-3 h-3"></i> {% trans "Neutral" %}
</span>
{% endif %}
{% endwith %}
{% else %}
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-bold bg-slate-100 text-slate-700">
{% trans "Not Analyzed" %}
</span>
{% endif %}
</div>
{% if comment.author %}
<p class="text-sm font-bold text-navy mb-3">@{{ comment.author }}</p>
{% endif %}
<p class="text-slate mb-4 line-clamp-3">{{ comment.comments|truncatewords:30 }}</p>
<div class="flex items-center justify-between pt-4 border-t border-blue-50">
<div class="flex items-center gap-4">
<div class="flex items-center gap-2 text-slate text-sm">
<i data-lucide="heart" class="w-4 h-4 text-red-500"></i>
<span class="font-medium">{{ comment.like_count }}</span>
</div>
<div class="flex items-center gap-2 text-slate text-sm">
<i data-lucide="message-square" class="w-4 h-4 text-blue-500"></i>
<span class="font-medium">{{ comment.reply_count }}</span>
</div>
</div>
<div class="text-right">
<a href="{% url 'social:social_comment_detail' comment.pk %}" class="inline-flex items-center gap-2 px-4 py-2 bg-blue-50 text-blue-700 rounded-xl font-semibold hover:bg-blue-100 transition text-sm">
{% trans "View Details" %}
<i data-lucide="arrow-right" class="w-4 h-4"></i>
</a>
</div>
</div>
<div class="mt-3 text-right">
<p class="text-xs text-slate">
{% if comment.published_at %}
{{ comment.published_at|date:"M d, Y H:i" }}
{% else %}
{{ comment.scraped_at|date:"M d, Y H:i" }}
{% endif %}
</p>
</div>
</div>
</div>
{% empty %}
<div class="col-span-full">
<div class="bg-white rounded-2xl shadow-sm border border-blue-100 p-12 text-center">
<div class="w-20 h-20 bg-gradient-to-br from-blue-100 to-purple-100 rounded-full flex items-center justify-center mx-auto mb-4">
<i data-lucide="message-circle" class="w-10 h-10 text-blue-500"></i>
</div>
<p class="text-slate font-medium">{% trans "No comments found" %}</p>
</div>
</div>
{% endfor %}
</div>
<!-- Pagination -->
{% if page_obj.has_other_pages %}
<div class="flex items-center justify-center gap-2 mt-8">
{% if page_obj.has_previous %}
<a href="?page={{ page_obj.previous_page_number }}{% for key, value in filters.items %}&{{ key }}={{ value }}{% endfor %}"
class="inline-flex items-center gap-2 px-4 py-2 bg-white border-2 border-blue-200 text-blue-700 rounded-xl font-semibold hover:bg-blue-50 transition">
<i data-lucide="chevron-left" class="w-4 h-4"></i>
</a>
{% endif %}
<span class="inline-flex items-center px-4 py-2 bg-gradient-to-r from-blue to-navy text-white rounded-xl font-semibold">
{{ page_obj.number }} / {{ page_obj.paginator.num_pages }}
</span>
{% if page_obj.has_next %}
<a href="?page={{ page_obj.next_page_number }}{% for key, value in filters.items %}&{{ key }}={{ value }}{% endfor %}"
class="inline-flex items-center gap-2 px-4 py-2 bg-white border-2 border-blue-200 text-blue-700 rounded-xl font-semibold hover:bg-blue-50 transition">
<i data-lucide="chevron-right" class="w-4 h-4"></i>
</a>
{% endif %}
</div>
{% endif %}
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
lucide.createIcons();
});
</script>
{% endblock %}