mirror of
https://github.com/wahyd4/links.git
synced 2026-08-09 05:06:16 +10:00
180 lines
9.8 KiB
HTML
180 lines
9.8 KiB
HTML
{% extends "base.html" %}
|
|
{% load i18n %}
|
|
|
|
{% block title %}{% trans "Price Monitor" %}{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="max-w-7xl mx-auto px-4 py-6">
|
|
|
|
<!-- Header -->
|
|
<div class="flex items-center justify-between mb-6">
|
|
<div>
|
|
<h1 class="text-2xl font-bold text-gray-900">{% trans "Price Monitor" %}</h1>
|
|
<p class="text-sm text-gray-500 mt-0.5">{% trans "Track product prices and get notified on drops" %}</p>
|
|
</div>
|
|
<a href="{% url 'pricemon-add' %}"
|
|
class="inline-flex items-center px-4 py-2 bg-indigo-600 text-white text-sm font-medium rounded-lg hover:bg-indigo-700 transition">
|
|
<svg class="w-4 h-4 mr-1.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/>
|
|
</svg>
|
|
{% trans "Add Watcher" %}
|
|
</a>
|
|
<a href="{% url 'site-settings' %}"
|
|
class="inline-flex items-center px-3 py-2 bg-white border border-gray-200 text-gray-600 text-sm font-medium rounded-lg hover:bg-gray-50 transition" title="Settings (Telegram, etc.)">
|
|
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"/>
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/>
|
|
</svg>
|
|
</a>
|
|
</div>
|
|
|
|
<!-- Stat cards -->
|
|
<div class="grid grid-cols-2 sm:grid-cols-3 gap-4 mb-6">
|
|
<div class="bg-white rounded-lg shadow-sm border border-gray-100 p-4">
|
|
<div class="text-xs text-gray-400 font-medium uppercase tracking-wide mb-1">{% trans "Watchers" %}</div>
|
|
<div class="text-2xl font-bold text-gray-900">{{ total_watchers }}</div>
|
|
</div>
|
|
<div class="bg-white rounded-lg shadow-sm border border-gray-100 p-4">
|
|
<div class="text-xs text-gray-400 font-medium uppercase tracking-wide mb-1">{% trans "Active Alerts" %}</div>
|
|
<div class="text-2xl font-bold {% if active_alerts_count %}text-red-600{% else %}text-gray-900{% endif %}">
|
|
{{ active_alerts_count }}
|
|
</div>
|
|
</div>
|
|
<div class="bg-white rounded-lg shadow-sm border border-gray-100 p-4">
|
|
<div class="text-xs text-gray-400 font-medium uppercase tracking-wide mb-1">{% trans "Enabled" %}</div>
|
|
<div class="text-2xl font-bold text-gray-900">
|
|
{% with watchers|length as total %}
|
|
{% for w in watchers %}{% if w.enabled %}{% endif %}{% endfor %}
|
|
{{ watchers|length }}
|
|
{% endwith %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Active Alerts Panel -->
|
|
{% if active_alerts %}
|
|
<div id="alerts-container"
|
|
hx-get="{% url 'pricemon-alerts-partial' %}"
|
|
hx-trigger="every 30s"
|
|
hx-swap="innerHTML">
|
|
{% include 'pricemon/_alerts.html' %}
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Watchers Table -->
|
|
<div class="bg-white rounded-lg shadow-sm border border-gray-100 overflow-hidden">
|
|
{% if watchers %}
|
|
<table class="min-w-full divide-y divide-gray-200 text-sm">
|
|
<thead class="bg-gray-50">
|
|
<tr>
|
|
<th class="px-4 py-3 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider">{% trans "Product" %}</th>
|
|
<th class="px-4 py-3 text-right text-xs font-semibold text-gray-500 uppercase tracking-wider">{% trans "Current Price" %}</th>
|
|
<th class="px-4 py-3 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider hidden sm:table-cell">{% trans "Last Checked" %}</th>
|
|
<th class="px-4 py-3 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider hidden md:table-cell">{% trans "Interval" %}</th>
|
|
<th class="px-4 py-3 text-center text-xs font-semibold text-gray-500 uppercase tracking-wider">{% trans "Status" %}</th>
|
|
<th class="px-4 py-3 text-right text-xs font-semibold text-gray-500 uppercase tracking-wider">{% trans "Actions" %}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-gray-100">
|
|
{% for watcher in watchers %}
|
|
<tr class="hover:bg-gray-50" id="watcher-row-{{ watcher.pk }}">
|
|
<td class="px-4 py-3">
|
|
<div class="font-medium text-gray-900">{{ watcher.name }}</div>
|
|
<a href="{{ watcher.url }}" target="_blank" rel="noopener"
|
|
class="text-xs text-indigo-500 hover:underline truncate block max-w-xs">
|
|
{{ watcher.url|truncatechars:60 }}
|
|
</a>
|
|
</td>
|
|
<td class="px-4 py-3 text-right">
|
|
{% if watcher.last_price %}
|
|
<span class="text-lg font-bold text-gray-900">${{ watcher.last_price }}</span>
|
|
{% else %}
|
|
<span class="text-gray-400">—</span>
|
|
{% endif %}
|
|
</td>
|
|
<td class="px-4 py-3 text-gray-500 hidden sm:table-cell">
|
|
{% if watcher.last_checked_at %}
|
|
{{ watcher.last_checked_at|timesince }} {% trans "ago" %}
|
|
{% else %}
|
|
<span class="text-gray-300">{% trans "Never" %}</span>
|
|
{% endif %}
|
|
</td>
|
|
<td class="px-4 py-3 text-gray-500 hidden md:table-cell">
|
|
{{ watcher.get_check_interval_hours_display }}
|
|
</td>
|
|
<td class="px-4 py-3 text-center">
|
|
{% if watcher.enabled %}
|
|
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-700">{% trans "Active" %}</span>
|
|
{% else %}
|
|
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-500">{% trans "Paused" %}</span>
|
|
{% endif %}
|
|
</td>
|
|
<td class="px-4 py-3 text-right">
|
|
<div class="flex items-center justify-end gap-1">
|
|
<!-- Check Now -->
|
|
<button
|
|
hx-post="{% url 'pricemon-check-now' watcher.pk %}"
|
|
hx-confirm="Run a price check now for {{ watcher.name }}?"
|
|
hx-swap="none"
|
|
hx-on::after-request="if(event.detail.successful) window.location.reload()"
|
|
title="Check Now"
|
|
class="p-1.5 rounded text-gray-400 hover:text-indigo-600 hover:bg-indigo-50 transition">
|
|
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/>
|
|
</svg>
|
|
</button>
|
|
<!-- History -->
|
|
<a href="{% url 'pricemon-history' watcher.pk %}"
|
|
title="Price History"
|
|
class="p-1.5 rounded text-gray-400 hover:text-indigo-600 hover:bg-indigo-50 transition">
|
|
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"/>
|
|
</svg>
|
|
</a>
|
|
<!-- Edit -->
|
|
<a href="{% url 'pricemon-edit' watcher.pk %}"
|
|
title="Edit"
|
|
class="p-1.5 rounded text-gray-400 hover:text-indigo-600 hover:bg-indigo-50 transition">
|
|
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"/>
|
|
</svg>
|
|
</a>
|
|
<!-- Delete -->
|
|
<form method="post" action="{% url 'pricemon-delete' watcher.pk %}" class="inline"
|
|
onsubmit="return confirm('Delete watcher {{ watcher.name }}?')">
|
|
{% csrf_token %}
|
|
<button type="submit" title="Delete"
|
|
class="p-1.5 rounded text-gray-400 hover:text-red-600 hover:bg-red-50 transition">
|
|
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/>
|
|
</svg>
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
{% else %}
|
|
<div class="text-center py-16 text-gray-400">
|
|
<svg class="w-12 h-12 mx-auto mb-3 text-gray-300" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"
|
|
d="M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A1.994 1.994 0 013 12V7a4 4 0 014-4z"/>
|
|
</svg>
|
|
<p class="font-medium">{% trans "No watchers yet" %}</p>
|
|
<p class="text-sm mt-1">
|
|
<a href="{% url 'pricemon-add' %}" class="text-indigo-500 hover:underline">{% trans "Add your first price watcher" %}</a>
|
|
</p>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
</div>
|
|
{% endblock %}
|