ATS/templates/recruitment/source_list.html
2026-02-01 13:38:06 +03:00

273 lines
16 KiB
HTML

{% extends "base.html" %}
{% load static i18n %}
{% block title %}{% trans "Sources" %} - University ATS{% endblock %}
{% block content %}
<div class="space-y-6">
<!-- Mobile Header -->
<div class="lg:hidden mb-4">
<div class="flex items-center justify-between mb-4">
<h1 class="text-2xl font-bold text-gray-900 flex items-center gap-2">
<div class="bg-temple-red/10 p-2 rounded-lg">
<i data-lucide="database" class="w-6 h-6 text-temple-red"></i>
</div>
{% trans "Integration Sources" %}
</h1>
<a href="{% url 'source_create' %}" class="inline-flex items-center gap-2 bg-temple-red hover:bg-[#7a1a29] text-white font-semibold px-4 py-2.5 rounded-xl text-sm transition shadow-sm">
<i data-lucide="plus" class="w-4 h-4"></i> {% trans "Add Source" %}
</a>
</div>
<!-- Mobile Filters -->
<div class="space-y-3">
<form method="get" class="flex gap-2">
<div class="flex-1">
<div class="relative">
<i data-lucide="search" class="w-5 h-5 text-gray-400 absolute left-3 top-1/2 -translate-y-1/2"></i>
<input type="text" name="q"
placeholder="{% trans 'Search sources...' %}"
value="{{ search_query }}"
class="w-full pl-10 pr-4 py-2.5 bg-white border border-gray-200 rounded-xl text-sm focus:ring-2 focus:ring-temple-red/20 focus:border-temple-red outline-none transition">
</div>
</div>
<button type="submit" class="bg-temple-red hover:bg-[#7a1a29] text-white px-4 py-2.5 rounded-xl transition">
<i data-lucide="search" class="w-4 h-4"></i>
</button>
{% if search_query %}
<a href="{% url 'source_list' %}" class="bg-gray-100 hover:bg-gray-200 text-gray-600 px-4 py-2.5 rounded-xl transition">
<i data-lucide="x" class="w-4 h-4"></i>
</a>
{% endif %}
</form>
</div>
</div>
<!-- Desktop Header -->
<div class="hidden lg:block">
<!-- Breadcrumb -->
<nav class="mb-6" aria-label="breadcrumb">
<ol class="flex items-center gap-2 text-sm flex-wrap">
<li><a href="{% url 'settings' %}" class="text-gray-500 hover:text-temple-red transition flex items-center gap-1">
<i data-lucide="settings" class="w-4 h-4"></i> {% trans "Settings" %}
</a></li>
<li class="text-gray-400">/</li>
<li class="text-temple-red font-semibold">{% trans "Sources Settings" %}</li>
</ol>
</nav>
<div class="flex justify-between items-start mb-6">
<h1 class="text-3xl font-bold text-gray-900 flex items-center gap-3">
<div class="bg-temple-red/10 p-3 rounded-xl">
<i data-lucide="database" class="w-8 h-8 text-temple-red"></i>
</div>
{% trans "Integration Sources" %}
</h1>
<a href="{% url 'source_create' %}" class="inline-flex items-center gap-2 bg-temple-red hover:bg-[#7a1a29] text-white font-semibold px-6 py-2.5 rounded-xl transition shadow-sm hover:shadow-md">
<i data-lucide="plus" class="w-4 h-4"></i> {% trans "Create New Source" %}
</a>
</div>
<!-- Desktop Filters -->
<div class="bg-white rounded-2xl shadow-sm border border-gray-100 overflow-hidden">
<div class="bg-gradient-to-br from-temple-red to-[#7a1a29] text-white p-4">
<h5 class="text-lg font-bold flex items-center gap-2">
<i data-lucide="filter" class="w-5 h-5"></i>
{% trans "Search Sources" %}
</h5>
</div>
<div class="p-6">
<form method="get" class="flex gap-3">
<div class="flex-1">
<div class="relative">
<i data-lucide="search" class="w-5 h-5 text-gray-400 absolute left-4 top-1/2 -translate-y-1/2"></i>
<input type="text" name="q"
placeholder="{% trans 'Search by name or type...' %}"
value="{{ search_query }}"
class="w-full pl-11 pr-4 py-2.5 bg-white border border-gray-200 rounded-xl text-sm focus:ring-2 focus:ring-temple-red/20 focus:border-temple-red outline-none transition">
</div>
</div>
<button type="submit" class="inline-flex items-center gap-2 bg-temple-red hover:bg-[#7a1a29] text-white font-medium px-5 py-2.5 rounded-xl text-sm transition">
<i data-lucide="search" class="w-4 h-4"></i> {% trans "Search" %}
</button>
{% if search_query %}
<a href="{% url 'source_list' %}" class="inline-flex items-center gap-2 border border-gray-300 text-gray-600 hover:bg-gray-100 px-4 py-2.5 rounded-xl text-sm transition">
<i data-lucide="x" class="w-4 h-4"></i> {% trans "Clear" %}
</a>
{% endif %}
</form>
</div>
</div>
</div>
<!-- Results Summary -->
{% if search_query %}
<div class="bg-blue-50 border border-blue-200 rounded-xl p-4 flex items-center gap-3">
<i data-lucide="info" class="w-5 h-5 text-blue-600"></i>
<p class="text-sm text-blue-800">
{% blocktrans %}Found {{ count }} source{{ count|pluralize }} matching "{{ search_query }}"{% endblocktrans %}
</p>
</div>
{% endif %}
{# --- MOBILE CARD VIEW --- #}
<div class="lg:hidden grid grid-cols-1 gap-4">
{% for source in page_obj %}
<div class="bg-white rounded-2xl shadow-sm border border-gray-100 overflow-hidden">
<div class="bg-gradient-to-br from-temple-red to-[#7a1a29] text-white p-4">
<div class="flex justify-between items-start">
<h5 class="font-bold text-lg">
<a href="{% url 'source_detail' source.pk %}" class="hover:text-white/80 transition-colors">{{ source.name }}</a>
</h5>
<span class="inline-block text-[10px] font-bold uppercase tracking-wide px-2.5 py-1 rounded-full bg-white/20 backdrop-blur-sm border border-white/30">
{{ source.source_type }}
</span>
</div>
<p class="text-xs text-white/80 mt-1">ID: {{ source.pk }}</p>
</div>
<div class="p-4 space-y-3">
<div class="flex items-center gap-2 text-sm text-gray-600">
<i data-lucide="key" class="w-4 h-4 text-temple-red"></i>
<code class="text-xs bg-gray-100 px-2 py-1 rounded">{{ source.api_key|truncatechars:20 }}</code>
</div>
<div class="flex items-center gap-2 text-sm text-gray-600">
<i data-lucide="calendar" class="w-4 h-4 text-temple-red"></i>
<span>{% trans "Created" %}: {{ source.created_at|date:"M d, Y" }}</span>
</div>
<div class="flex items-center gap-2 text-sm">
<i data-lucide="activity" class="w-4 h-4 text-temple-red"></i>
{% if source.is_active %}
<span class="text-emerald-600 font-semibold">{% trans "Active" %}</span>
{% else %}
<span class="text-gray-500 font-semibold">{% trans "Inactive" %}</span>
{% endif %}
</div>
<!-- Actions -->
<div class="flex gap-2 pt-3 border-t border-gray-100">
<a href="{% url 'source_detail' source.pk %}" class="flex-1 inline-flex items-center justify-center gap-2 bg-temple-red hover:bg-[#7a1a29] text-white font-medium px-4 py-2.5 rounded-xl text-sm transition">
<i data-lucide="eye" class="w-4 h-4"></i> {% trans "View Details" %}
</a>
<a href="{% url 'source_update' source.pk %}" class="inline-flex items-center justify-center gap-2 border border-gray-300 text-gray-600 hover:bg-gray-50 px-4 py-2.5 rounded-xl text-sm transition">
<i data-lucide="edit-2" class="w-4 h-4"></i>
</a>
</div>
</div>
</div>
{% empty %}
<div class="bg-white rounded-2xl shadow-sm border border-gray-100 overflow-hidden text-center p-8">
<i data-lucide="database" class="w-16 h-16 text-temple-red mx-auto mb-4"></i>
<h3 class="text-xl font-semibold text-gray-900 mb-2">{% trans "No sources found" %}</h3>
<p class="text-gray-500 mb-4">
{% if search_query %}
{% blocktrans %}No sources match your search criteria "{{ search_query }}".{% endblocktrans %}
{% else %}
{% trans "Get started by creating your first source." %}
{% endif %}
</p>
<a href="{% url 'source_create' %}" class="inline-flex items-center gap-2 bg-temple-red hover:bg-[#7a1a29] text-white font-semibold px-5 py-2.5 rounded-xl transition shadow-sm">
<i data-lucide="plus" class="w-4 h-4"></i> {% trans "Create Source" %}
</a>
</div>
{% endfor %}
</div>
{# --- DESKTOP TABLE VIEW --- #}
<div class="hidden lg:block bg-white rounded-2xl shadow-sm border border-gray-100 overflow-hidden">
<div class="bg-gradient-to-br from-temple-red to-[#7a1a29] text-white p-4">
<h5 class="text-lg font-bold flex items-center gap-2">
<i data-lucide="list" class="w-5 h-5"></i>
{% trans "Source Listings" %}
</h5>
</div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col" class="px-6 py-3 text-left text-xs font-bold text-gray-700 tracking-wider whitespace-nowrap">{% trans "Name" %}</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-bold text-gray-700 tracking-wider whitespace-nowrap">{% trans "Type" %}</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-bold text-gray-700 tracking-wider whitespace-nowrap">{% trans "Status" %}</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-bold text-gray-700 tracking-wider whitespace-nowrap">{% trans "API Key" %}</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-bold text-gray-700 tracking-wider whitespace-nowrap">{% trans "Created" %}</th>
<th scope="col" class="px-6 py-3 text-center text-xs font-bold text-gray-700 tracking-wider whitespace-nowrap">{% trans "Actions" %}</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-100">
{% for source in page_obj %}
<tr class="hover:bg-gray-50 transition-colors">
<td class="px-6 py-4">
<a href="{% url 'source_detail' source.pk %}" class="text-temple-red font-semibold hover:text-[#7a1a29] transition-colors">{{ source.name }}</a>
<br>
<span class="text-xs text-gray-500">ID: {{ source.pk }}</span>
</td>
<td class="px-6 py-4">
<span class="inline-block text-[10px] font-bold uppercase tracking-wide px-2.5 py-1 rounded-full bg-temple-red/10 text-temple-red border border-temple-red">
{{ source.source_type }}
</span>
</td>
<td class="px-6 py-4">
{% if source.is_active %}
<span class="inline-flex items-center gap-1.5 text-sm font-semibold text-emerald-600">
<i data-lucide="check-circle-2" class="w-4 h-4"></i> {% trans "Active" %}
</span>
{% else %}
<span class="inline-flex items-center gap-1.5 text-sm font-semibold text-gray-500">
<i data-lucide="x-circle" class="w-4 h-4"></i> {% trans "Inactive" %}
</span>
{% endif %}
</td>
<td class="px-6 py-4">
<code class="text-xs bg-gray-100 px-2 py-1 rounded text-temple-red">{{ source.api_key|truncatechars:20 }}</code>
</td>
<td class="px-6 py-4 text-sm text-gray-700">{{ source.created_at|date:"M d, Y" }}</td>
<td class="px-6 py-4">
<div class="flex items-center gap-2 justify-center">
<a href="{% url 'source_detail' source.pk %}" class="inline-flex items-center justify-center w-9 h-9 rounded-lg bg-temple-red hover:bg-[#7a1a29] text-white transition" title="{% trans 'View' %}">
<i data-lucide="eye" class="w-4 h-4"></i>
</a>
<a href="{% url 'source_update' source.pk %}" class="inline-flex items-center justify-center w-9 h-9 rounded-lg border border-gray-300 hover:bg-gray-100 text-gray-600 transition" title="{% trans 'Edit' %}">
<i data-lucide="edit-2" class="w-4 h-4"></i>
</a>
</div>
</td>
</tr>
{% empty %}
<tr>
<td colspan="6" class="px-6 py-12 text-center">
<i data-lucide="database" class="w-16 h-16 text-temple-red mx-auto mb-4"></i>
<h3 class="text-xl font-semibold text-gray-900 mb-2">{% trans "No sources found" %}</h3>
<p class="text-gray-500 mb-4">
{% if search_query %}
{% blocktrans %}No sources match your search criteria "{{ search_query }}".{% endblocktrans %}
{% else %}
{% trans "Get started by creating your first source." %}
{% endif %}
</p>
<a href="{% url 'source_create' %}" class="inline-flex items-center gap-2 bg-temple-red hover:bg-[#7a1a29] text-white font-semibold px-5 py-2.5 rounded-xl transition shadow-sm">
<i data-lucide="plus" class="w-4 h-4"></i> {% trans "Create Source" %}
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% include "includes/paginator.html" %}
</div>
<script>
lucide.createIcons();
// Auto-refresh after status toggle (for HTMX)
document.body.addEventListener('htmx:afterRequest', function(evt) {
if (evt.detail.successful) {
setTimeout(() => {
window.location.reload();
}, 500);
}
});
</script>
{% endblock %}