421 lines
22 KiB
HTML
421 lines
22 KiB
HTML
{% extends "layouts/base.html" %}
|
|
{% load i18n %}
|
|
{% load static %}
|
|
|
|
{% block title %}{% trans "Observations Console" %} - PX360{% endblock %}
|
|
|
|
{% block extra_css %}
|
|
<style>
|
|
.status-badge {
|
|
padding: 4px 12px;
|
|
border-radius: 12px;
|
|
font-size: 0.85rem;
|
|
font-weight: 500;
|
|
}
|
|
.status-new { background: #e0f2fe; color: #075985; }
|
|
.status-triaged { background: #ccfbf1; color: #0f766e; }
|
|
.status-assigned { background: #ccfbf1; color: #0f766e; }
|
|
.status-in_progress { background: #fef9c3; color: #854d0e; }
|
|
.status-resolved { background: #dcfce7; color: #166534; }
|
|
.status-closed { background: #f3f4f6; color: #6b7280; }
|
|
.status-rejected { background: #fee2e2; color: #991b1b; }
|
|
.status-duplicate { background: #f3f4f6; color: #6b7280; }
|
|
|
|
.severity-badge {
|
|
padding: 4px 12px;
|
|
border-radius: 12px;
|
|
font-size: 0.85rem;
|
|
font-weight: 500;
|
|
}
|
|
.severity-low { background: #dcfce7; color: #166534; }
|
|
.severity-medium { background: #fef9c3; color: #854d0e; }
|
|
.severity-high { background: #fee2e2; color: #991b1b; }
|
|
.severity-critical { background: #991b1b; color: #fff; }
|
|
|
|
.anonymous-badge {
|
|
background: #f3f4f6;
|
|
color: #6b7280;
|
|
padding: 2px 8px;
|
|
border-radius: 10px;
|
|
font-size: 0.75rem;
|
|
font-style: italic;
|
|
}
|
|
|
|
.observation-row:hover {
|
|
background: #f8fafc;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.stat-card {
|
|
border-left: 4px solid;
|
|
transition: transform 0.2s;
|
|
}
|
|
.stat-card:hover {
|
|
transform: translateY(-2px);
|
|
}
|
|
|
|
.tracking-code {
|
|
font-family: 'Courier New', monospace;
|
|
font-weight: 600;
|
|
color: #005696;
|
|
}
|
|
</style>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<!-- Header -->
|
|
<header class="mb-6">
|
|
<div class="flex justify-between items-start">
|
|
<div>
|
|
<h1 class="text-2xl font-bold text-navy flex items-center gap-3">
|
|
<i data-lucide="eye" class="w-7 h-7 text-green-500"></i>
|
|
{% trans "Observations Console" %}
|
|
</h1>
|
|
<p class="text-sm text-slate mt-1">{% trans "Manage and triage staff-reported observations" %}</p>
|
|
</div>
|
|
<div class="flex gap-3">
|
|
<a href="{% url 'observations:category_list' %}" class="bg-white text-navy border-2 border-navy/30 px-5 py-2.5 rounded-xl text-sm font-bold hover:bg-navy hover:text-white flex items-center gap-2 transition">
|
|
<i data-lucide="tags" class="w-4 h-4"></i> {% trans "Categories" %}
|
|
</a>
|
|
<a href="{% url 'core:public_submit_landing' %}" class="bg-navy text-white px-5 py-2.5 rounded-xl text-sm font-bold shadow-lg shadow-navy/20 hover:bg-blue flex items-center gap-2 transition" target="_blank">
|
|
<i data-lucide="plus" class="w-4 h-4"></i> {% trans "Public Form" %}
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<!-- Statistics Cards -->
|
|
<div class="grid grid-cols-1 md:grid-cols-4 gap-4 mb-6">
|
|
<div class="bg-white p-5 rounded-2xl shadow-sm border border-slate-100 border-l-4 border-l-blue-500">
|
|
<div class="flex justify-between items-center">
|
|
<div>
|
|
<p class="text-xs font-bold text-slate uppercase tracking-wider mb-1">{% trans "Total" %}</p>
|
|
<p class="text-2xl font-black text-navy">{{ stats.total }}</p>
|
|
</div>
|
|
<div class="p-3 bg-blue-50 rounded-xl">
|
|
<i data-lucide="list" class="w-6 h-6 text-blue-500"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="bg-white p-5 rounded-2xl shadow-sm border border-slate-100 border-l-4 border-l-cyan-500">
|
|
<div class="flex justify-between items-center">
|
|
<div>
|
|
<p class="text-xs font-bold text-slate uppercase tracking-wider mb-1">{% trans "New" %}</p>
|
|
<p class="text-2xl font-black text-navy">{{ stats.new }}</p>
|
|
</div>
|
|
<div class="p-3 bg-cyan-50 rounded-xl">
|
|
<i data-lucide="inbox" class="w-6 h-6 text-cyan-500"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="bg-white p-5 rounded-2xl shadow-sm border border-slate-100 border-l-4 border-l-amber-500">
|
|
<div class="flex justify-between items-center">
|
|
<div>
|
|
<p class="text-xs font-bold text-slate uppercase tracking-wider mb-1">{% trans "In Progress" %}</p>
|
|
<p class="text-2xl font-black text-navy">{{ stats.in_progress }}</p>
|
|
</div>
|
|
<div class="p-3 bg-amber-50 rounded-xl">
|
|
<i data-lucide="clock" class="w-6 h-6 text-amber-500"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="bg-white p-5 rounded-2xl shadow-sm border border-slate-100 border-l-4 border-l-slate-400">
|
|
<div class="flex justify-between items-center">
|
|
<div>
|
|
<p class="text-xs font-bold text-slate uppercase tracking-wider mb-1">{% trans "Anonymous" %}</p>
|
|
<p class="text-2xl font-black text-navy">{{ stats.anonymous_count }}</p>
|
|
</div>
|
|
<div class="p-3 bg-slate-100 rounded-xl">
|
|
<i data-lucide="user-x" class="w-6 h-6 text-slate-500"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Filter Panel -->
|
|
<div class="bg-white rounded-2xl shadow-sm border-2 border-slate-200 mb-6" id="filterPanel">
|
|
<div class="px-6 py-4 border-b-2 border-slate-200 flex justify-between items-center bg-gradient-to-r from-slate-50 to-slate-100">
|
|
<h3 class="font-bold text-navy flex items-center gap-2">
|
|
<i data-lucide="filter" class="w-5 h-5 text-navy"></i>
|
|
{% trans "Filters" %}
|
|
</h3>
|
|
<button onclick="toggleFilters()" class="text-slate hover:text-navy transition p-2 rounded-lg hover:bg-white">
|
|
<i data-lucide="chevron-up" id="filterToggleIcon" class="w-5 h-5"></i>
|
|
</button>
|
|
</div>
|
|
|
|
<div class="filter-body px-6 py-4 bg-slate-50">
|
|
<form method="get" action="{% url 'observations:observation_list' %}" id="filterForm">
|
|
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
|
<!-- Search -->
|
|
<div>
|
|
<label class="block text-xs font-bold text-slate uppercase mb-2">{% trans "Search" %}</label>
|
|
<input type="text" name="search"
|
|
placeholder="{% trans 'Tracking code, description...' %}"
|
|
value="{{ filters.search }}"
|
|
class="w-full px-4 py-2.5 border border-slate-200 rounded-xl text-sm focus:ring-2 focus:ring-navy focus:border-transparent transition">
|
|
</div>
|
|
|
|
<!-- Status -->
|
|
<div>
|
|
<label class="block text-xs font-bold text-slate uppercase mb-2">{% trans "Status" %}</label>
|
|
<select name="status" class="w-full px-4 py-2.5 border border-slate-200 rounded-xl text-sm focus:ring-2 focus:ring-navy focus:border-transparent transition">
|
|
<option value="">{% trans "All Statuses" %}</option>
|
|
{% for value, label in status_choices %}
|
|
<option value="{{ value }}" {% if filters.status == value %}selected{% endif %}>
|
|
{{ label }}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
|
|
<!-- Severity -->
|
|
<div>
|
|
<label class="block text-xs font-bold text-slate uppercase mb-2">{% trans "Severity" %}</label>
|
|
<select name="severity" class="w-full px-4 py-2.5 border border-slate-200 rounded-xl text-sm focus:ring-2 focus:ring-navy focus:border-transparent transition">
|
|
<option value="">{% trans "All Severities" %}</option>
|
|
<option value="low" {% if filters.severity == 'low' %}selected{% endif %}>{% trans "Low" %}</option>
|
|
<option value="medium" {% if filters.severity == 'medium' %}selected{% endif %}>{% trans "Medium" %}</option>
|
|
<option value="high" {% if filters.severity == 'high' %}selected{% endif %}>{% trans "High" %}</option>
|
|
<option value="critical" {% if filters.severity == 'critical' %}selected{% endif %}>{% trans "Critical" %}</option>
|
|
</select>
|
|
</div>
|
|
|
|
<!-- Category -->
|
|
<div>
|
|
<label class="block text-xs font-bold text-slate uppercase mb-2">{% trans "Category" %}</label>
|
|
<select name="category" class="w-full px-4 py-2.5 border border-slate-200 rounded-xl text-sm focus:ring-2 focus:ring-navy focus:border-transparent transition">
|
|
<option value="">{% trans "All Categories" %}</option>
|
|
{% for cat in categories %}
|
|
<option value="{{ cat.id }}" {% if filters.category == cat.id|stringformat:"s" %}selected{% endif %}>
|
|
{{ cat.name_en }}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
|
|
<!-- Department -->
|
|
<div>
|
|
<label class="block text-xs font-bold text-slate uppercase mb-2">{% trans "Department" %}</label>
|
|
<select name="assigned_department" class="w-full px-4 py-2.5 border border-slate-200 rounded-xl text-sm focus:ring-2 focus:ring-navy focus:border-transparent transition">
|
|
<option value="">{% trans "All Departments" %}</option>
|
|
{% for dept in departments %}
|
|
<option value="{{ dept.id }}" {% if filters.assigned_department == dept.id|stringformat:"s" %}selected{% endif %}>
|
|
{{ dept.name }}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
|
|
<!-- Assigned To -->
|
|
<div>
|
|
<label class="block text-xs font-bold text-slate uppercase mb-2">{% trans "Assigned To" %}</label>
|
|
<select name="assigned_to" class="w-full px-4 py-2.5 border border-slate-200 rounded-xl text-sm focus:ring-2 focus:ring-navy focus:border-transparent transition">
|
|
<option value="">{% trans "All Users" %}</option>
|
|
{% for user_obj in assignable_users %}
|
|
<option value="{{ user_obj.id }}" {% if filters.assigned_to == user_obj.id|stringformat:"s" %}selected{% endif %}>
|
|
{{ user_obj.get_full_name }}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
|
|
<!-- Anonymous Filter -->
|
|
<div>
|
|
<label class="block text-xs font-bold text-slate uppercase mb-2">{% trans "Reporter Type" %}</label>
|
|
<select name="is_anonymous" class="w-full px-4 py-2.5 border border-slate-200 rounded-xl text-sm focus:ring-2 focus:ring-navy focus:border-transparent transition">
|
|
<option value="">{% trans "All" %}</option>
|
|
<option value="yes" {% if filters.is_anonymous == 'yes' %}selected{% endif %}>{% trans "Anonymous Only" %}</option>
|
|
<option value="no" {% if filters.is_anonymous == 'no' %}selected{% endif %}>{% trans "Identified Only" %}</option>
|
|
</select>
|
|
</div>
|
|
|
|
<!-- Date Range -->
|
|
<div>
|
|
<label class="block text-xs font-bold text-slate uppercase mb-2">{% trans "Date From" %}</label>
|
|
<input type="date" name="date_from" value="{{ filters.date_from }}"
|
|
class="w-full px-4 py-2.5 border border-slate-200 rounded-xl text-sm focus:ring-2 focus:ring-navy focus:border-transparent transition">
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs font-bold text-slate uppercase mb-2">{% trans "Date To" %}</label>
|
|
<input type="date" name="date_to" value="{{ filters.date_to }}"
|
|
class="w-full px-4 py-2.5 border border-slate-200 rounded-xl text-sm focus:ring-2 focus:ring-navy focus:border-transparent transition">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mt-4 flex gap-3">
|
|
<button type="submit" class="bg-navy text-white px-5 py-2.5 rounded-xl text-sm font-bold hover:bg-blue transition flex items-center gap-2">
|
|
<i data-lucide="search" class="w-4 h-4"></i> {% trans "Apply Filters" %}
|
|
</button>
|
|
<a href="{% url 'observations:observation_list' %}" class="border-2 border-slate-200 text-slate px-5 py-2.5 rounded-xl text-sm font-bold hover:bg-white transition flex items-center gap-2">
|
|
<i data-lucide="x-circle" class="w-4 h-4"></i> {% trans "Clear" %}
|
|
</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Table Toolbar -->
|
|
<div class="bg-white px-6 py-4 rounded-t-2xl border-2 border-slate-200 border-b-0 flex justify-between items-center bg-gradient-to-r from-slate-50 to-slate-100">
|
|
<div class="text-sm text-slate">
|
|
{% trans "Showing" %} <span class="font-bold text-navy">{{ page_obj.start_index }}</span> {% trans "to" %} <span class="font-bold text-navy">{{ page_obj.end_index }}</span> {% trans "of" %} <span class="font-bold text-navy">{{ page_obj.paginator.count }}</span> {% trans "observations" %}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Observations Table -->
|
|
<div class="bg-white rounded-b-2xl shadow-sm border-2 border-slate-200 overflow-hidden mb-6 border-t-0">
|
|
<div class="overflow-x-auto">
|
|
<table class="w-full">
|
|
<thead class="bg-gray-50">
|
|
<tr>
|
|
<th class="px-6 py-4 text-left text-xs font-bold text-gray-500 uppercase tracking-wider">{% trans "Reference" %}</th>
|
|
<th class="px-6 py-4 text-left text-xs font-bold text-gray-500 uppercase tracking-wider">{% trans "Date" %}</th>
|
|
<th class="px-6 py-4 text-left text-xs font-bold text-gray-500 uppercase tracking-wider">{% trans "Category" %}</th>
|
|
<th class="px-6 py-4 text-left text-xs font-bold text-gray-500 uppercase tracking-wider">{% trans "Description" %}</th>
|
|
<th class="px-6 py-4 text-left text-xs font-bold text-gray-500 uppercase tracking-wider">{% trans "Severity" %}</th>
|
|
<th class="px-6 py-4 text-left text-xs font-bold text-gray-500 uppercase tracking-wider">{% trans "Status" %}</th>
|
|
<th class="px-6 py-4 text-left text-xs font-bold text-gray-500 uppercase tracking-wider">{% trans "Reporter" %}</th>
|
|
<th class="px-6 py-4 text-left text-xs font-bold text-gray-500 uppercase tracking-wider">{% trans "Department" %}</th>
|
|
<th class="px-6 py-4 text-left text-xs font-bold text-gray-500 uppercase tracking-wider">{% trans "Assigned" %}</th>
|
|
<th class="px-6 py-4 text-left text-xs font-bold text-gray-500 uppercase tracking-wider">{% trans "Actions" %}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-gray-100">
|
|
{% for observation in observations %}
|
|
{% url 'observations:observation_detail' observation.id as observation_detail_url %}
|
|
<tr class="observation-row" onclick="window.location='{{ observation_detail_url }}'">
|
|
<td class="px-6 py-4">
|
|
<span class="tracking-code text-sm">{{ observation.tracking_code }}</span>
|
|
</td>
|
|
<td class="px-6 py-4">
|
|
<small class="text-gray-600">{{ observation.created_at|date:"M d, Y" }}</small><br>
|
|
<small class="text-gray-400">{{ observation.created_at|time:"H:i" }}</small>
|
|
</td>
|
|
<td class="px-6 py-4">
|
|
{% if observation.category %}
|
|
<span class="inline-flex items-center px-2.5 py-1 rounded-lg text-xs font-bold bg-slate-100 text-slate">
|
|
{{ observation.category.name_en }}
|
|
</span>
|
|
{% else %}
|
|
<span class="text-gray-400">-</span>
|
|
{% endif %}
|
|
</td>
|
|
<td class="px-6 py-4">
|
|
<div class="max-w-[200px]">
|
|
{% if observation.title %}
|
|
<strong class="text-gray-800 text-sm block">{{ observation.title|truncatewords:5 }}</strong>
|
|
{% endif %}
|
|
<small class="text-gray-400">{{ observation.description|truncatewords:10 }}</small>
|
|
</div>
|
|
</td>
|
|
<td class="px-6 py-4">
|
|
<span class="severity-badge severity-{{ observation.severity }}">
|
|
{{ observation.get_severity_display }}
|
|
</span>
|
|
</td>
|
|
<td class="px-6 py-4">
|
|
<span class="status-badge status-{{ observation.status }}">
|
|
{{ observation.get_status_display }}
|
|
</span>
|
|
</td>
|
|
<td class="px-6 py-4">
|
|
{% if observation.is_anonymous %}
|
|
<span class="anonymous-badge">{% trans "Anonymous" %}</span>
|
|
{% else %}
|
|
<small class="text-gray-600">{{ observation.reporter_display }}</small>
|
|
{% endif %}
|
|
</td>
|
|
<td class="px-6 py-4">
|
|
{% if observation.assigned_department %}
|
|
<small class="text-gray-600">{{ observation.assigned_department.name|truncatewords:3 }}</small>
|
|
{% else %}
|
|
<span class="text-gray-400">-</span>
|
|
{% endif %}
|
|
</td>
|
|
<td class="px-6 py-4">
|
|
{% if observation.assigned_to %}
|
|
<small class="text-gray-600">{{ observation.assigned_to.get_full_name }}</small>
|
|
{% else %}
|
|
<span class="text-gray-400 italic">{% trans "Unassigned" %}</span>
|
|
{% endif %}
|
|
</td>
|
|
<td class="px-6 py-4" onclick="event.stopPropagation();">
|
|
<a href="{% url 'observations:observation_detail' observation.id %}"
|
|
class="inline-flex items-center gap-1 px-3 py-2 text-navy bg-light rounded-lg hover:bg-light transition font-medium text-sm">
|
|
<i data-lucide="eye" class="w-4 h-4"></i>
|
|
</a>
|
|
</td>
|
|
</tr>
|
|
{% empty %}
|
|
<tr>
|
|
<td colspan="10" class="text-center py-8 text-gray-500">
|
|
<i data-lucide="inbox" class="w-12 h-12 mx-auto mb-3 text-gray-300"></i>
|
|
<p>{% trans "No observations found" %}</p>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Pagination -->
|
|
{% if page_obj.has_other_pages %}
|
|
<div class="flex justify-center">
|
|
<div class="flex items-center gap-2">
|
|
{% if page_obj.has_previous %}
|
|
<a href="?page=1{% for key, value in filters.items %}&{{ key }}={{ value }}{% endfor %}"
|
|
class="px-3 py-2 rounded-lg border border-slate-200 text-slate hover:bg-light transition">
|
|
<i data-lucide="chevrons-left" class="w-4 h-4"></i>
|
|
</a>
|
|
<a href="?page={{ page_obj.previous_page_number }}{% for key, value in filters.items %}&{{ key }}={{ value }}{% endfor %}"
|
|
class="px-3 py-2 rounded-lg border border-slate-200 text-slate hover:bg-light transition">
|
|
<i data-lucide="chevron-left" class="w-4 h-4"></i>
|
|
</a>
|
|
{% endif %}
|
|
|
|
{% for num in page_obj.paginator.page_range %}
|
|
{% if page_obj.number == num %}
|
|
<span class="px-4 py-2 rounded-lg bg-navy text-white font-bold">{{ num }}</span>
|
|
{% elif num > page_obj.number|add:'-3' and num < page_obj.number|add:'3' %}
|
|
<a href="?page={{ num }}{% for key, value in filters.items %}&{{ key }}={{ value }}{% endfor %}"
|
|
class="px-4 py-2 rounded-lg border border-slate-200 text-slate hover:bg-light transition">
|
|
{{ num }}
|
|
</a>
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
{% if page_obj.has_next %}
|
|
<a href="?page={{ page_obj.next_page_number }}{% for key, value in filters.items %}&{{ key }}={{ value }}{% endfor %}"
|
|
class="px-3 py-2 rounded-lg border border-slate-200 text-slate hover:bg-light transition">
|
|
<i data-lucide="chevron-right" class="w-4 h-4"></i>
|
|
</a>
|
|
<a href="?page={{ page_obj.paginator.num_pages }}{% for key, value in filters.items %}&{{ key }}={{ value }}{% endfor %}"
|
|
class="px-3 py-2 rounded-lg border border-slate-200 text-slate hover:bg-light transition">
|
|
<i data-lucide="chevrons-right" class="w-4 h-4"></i>
|
|
</a>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
{% endblock %}
|
|
|
|
{% block extra_js %}
|
|
<script>
|
|
function toggleFilters() {
|
|
const panel = document.getElementById('filterPanel');
|
|
const body = panel.querySelector('.filter-body');
|
|
const icon = document.getElementById('filterToggleIcon');
|
|
|
|
if (body.style.display === 'none') {
|
|
body.style.display = 'block';
|
|
icon.setAttribute('data-lucide', 'chevron-up');
|
|
} else {
|
|
body.style.display = 'none';
|
|
icon.setAttribute('data-lucide', 'chevron-down');
|
|
}
|
|
lucide.createIcons();
|
|
}
|
|
</script>
|
|
{% endblock %}
|