172 lines
9.5 KiB
HTML
172 lines
9.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Admin Panel — Thor's Hammer Electrical</title>
|
|
<script src="https://cdn.tailwindcss.com"></script>
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=Oswald:wght@400;600;700&display=swap" rel="stylesheet">
|
|
<link rel="icon" href="{{ url_for('static', filename='images/Logo.png') }}">
|
|
<style>
|
|
body { font-family: system-ui, sans-serif; background-color: #080808; }
|
|
.font-oswald { font-family: 'Oswald', sans-serif; }
|
|
</style>
|
|
</head>
|
|
<body class="text-white min-h-screen" style="background-color: #080808;">
|
|
|
|
<!-- Header bar -->
|
|
<header style="background-color: #0f0f0f; border-bottom: 1px solid rgba(250,204,21,0.15);" class="sticky top-0 z-10">
|
|
<div class="max-w-7xl mx-auto px-4 py-4 flex items-center justify-between gap-4 flex-wrap">
|
|
<div class="flex items-center gap-3">
|
|
<img src="{{ url_for('static', filename='images/Logo.png') }}" alt="Logo"
|
|
class="h-8 w-8 rounded-full ring-1 ring-yellow-400/30">
|
|
<h1 class="font-oswald text-lg font-bold tracking-wide">
|
|
<span class="text-yellow-400">Thor's Hammer</span>
|
|
<span class="text-gray-400 font-light"> · Admin Panel</span>
|
|
</h1>
|
|
</div>
|
|
<div class="flex items-center gap-3">
|
|
<a href="{{ url_for('completed_jobs') }}"
|
|
class="px-4 py-2 text-sm rounded-lg border border-white/10 text-gray-300
|
|
hover:bg-white/5 hover:text-white transition-all font-medium">
|
|
Completed Jobs
|
|
</a>
|
|
<form action="{{ url_for('logout') }}" method="POST" class="inline">
|
|
<button type="submit"
|
|
class="px-4 py-2 text-sm rounded-lg bg-red-900/50 border border-red-500/30
|
|
text-red-300 hover:bg-red-900 transition-all font-medium">
|
|
Logout
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<main class="max-w-7xl mx-auto px-4 py-8">
|
|
|
|
<!-- Flash messages -->
|
|
{% with messages = get_flashed_messages(with_categories=true) %}
|
|
{% if messages %}
|
|
<div class="mb-6 space-y-2">
|
|
{% for category, message in messages %}
|
|
<div class="px-4 py-3 rounded-lg border text-sm
|
|
{% if category == 'success' %}bg-green-950 border-green-500/50 text-green-300
|
|
{% elif category == 'danger' %}bg-red-950 border-red-500/50 text-red-300
|
|
{% else %}bg-yellow-950 border-yellow-500/50 text-yellow-300{% endif %}">
|
|
{{ message }}
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
{% endwith %}
|
|
|
|
<!-- Analytics Cards -->
|
|
<div class="grid grid-cols-1 sm:grid-cols-3 gap-4 mb-8">
|
|
<div class="rounded-xl p-5 border border-blue-500/20" style="background-color: #111111;">
|
|
<p class="text-gray-400 text-xs uppercase tracking-widest mb-2">Total Visitors (7d)</p>
|
|
<p id="total-visitors" class="font-oswald text-3xl font-bold text-blue-400">—</p>
|
|
</div>
|
|
<div class="rounded-xl p-5 border border-green-500/20" style="background-color: #111111;">
|
|
<p class="text-gray-400 text-xs uppercase tracking-widest mb-2">Page Views (7d)</p>
|
|
<p id="page-views" class="font-oswald text-3xl font-bold text-green-400">—</p>
|
|
</div>
|
|
<div class="rounded-xl p-5 border border-yellow-500/20" style="background-color: #111111;">
|
|
<p class="text-gray-400 text-xs uppercase tracking-widest mb-2">Top Page (7d)</p>
|
|
<p id="top-page" class="font-oswald text-3xl font-bold text-yellow-400 truncate">—</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Work Orders -->
|
|
<div class="rounded-2xl border border-white/8 overflow-hidden" style="background-color: #111111;">
|
|
<div class="px-6 py-5 border-b border-white/8 flex items-center justify-between">
|
|
<div>
|
|
<h2 class="font-oswald text-xl font-bold text-white">Active Work Orders</h2>
|
|
<p class="text-gray-500 text-xs mt-0.5">{{ work_orders | length }} order(s) pending</p>
|
|
</div>
|
|
</div>
|
|
|
|
{% if work_orders %}
|
|
<div class="overflow-x-auto">
|
|
<table class="w-full text-sm">
|
|
<thead>
|
|
<tr style="background-color: #161616; border-bottom: 1px solid rgba(255,255,255,0.06);">
|
|
<th class="px-4 py-3 text-left text-xs text-gray-500 uppercase tracking-wider font-medium">ID</th>
|
|
<th class="px-4 py-3 text-left text-xs text-gray-500 uppercase tracking-wider font-medium">Name</th>
|
|
<th class="px-4 py-3 text-left text-xs text-gray-500 uppercase tracking-wider font-medium">Job</th>
|
|
<th class="px-4 py-3 text-left text-xs text-gray-500 uppercase tracking-wider font-medium">Address</th>
|
|
<th class="px-4 py-3 text-left text-xs text-gray-500 uppercase tracking-wider font-medium">Phone</th>
|
|
<th class="px-4 py-3 text-left text-xs text-gray-500 uppercase tracking-wider font-medium">Submitted</th>
|
|
<th class="px-4 py-3 text-left text-xs text-gray-500 uppercase tracking-wider font-medium">Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for order in work_orders %}
|
|
<tr class="border-b border-white/5 hover:bg-white/2 transition-colors">
|
|
<td class="px-4 py-4 text-gray-500 text-xs font-mono">#{{ order[0] }}</td>
|
|
<td class="px-4 py-4 text-white font-medium">{{ order[1] }}</td>
|
|
<td class="px-4 py-4 text-gray-300 max-w-xs">
|
|
<span class="block truncate" title="{{ order[2] }}">{{ order[2] }}</span>
|
|
</td>
|
|
<td class="px-4 py-4 text-gray-400 text-xs">
|
|
{{ order[3] }}, {{ order[4] }}, {{ order[5] }} {{ order[6] }}
|
|
</td>
|
|
<td class="px-4 py-4 text-gray-400 text-xs">{{ order[7] }}</td>
|
|
<td class="px-4 py-4 text-gray-500 text-xs">{{ order[8] }}</td>
|
|
<td class="px-4 py-4">
|
|
<div class="flex items-center gap-2">
|
|
<form action="{{ url_for('mark_complete', order_id=order[0]) }}" method="POST">
|
|
<button type="submit"
|
|
class="px-3 py-1.5 text-xs rounded-md bg-green-900/60 border border-green-500/30
|
|
text-green-300 hover:bg-green-900 transition-all font-medium whitespace-nowrap">
|
|
✓ Complete
|
|
</button>
|
|
</form>
|
|
<form action="{{ url_for('delete_order', order_id=order[0]) }}" method="POST"
|
|
onsubmit="return confirm('Delete this work order?');">
|
|
<button type="submit"
|
|
class="px-3 py-1.5 text-xs rounded-md bg-red-900/60 border border-red-500/30
|
|
text-red-300 hover:bg-red-900 transition-all font-medium">
|
|
Delete
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{% else %}
|
|
<div class="py-16 text-center">
|
|
<i class="fa-solid fa-clipboard-list text-gray-600 text-4xl mb-3 block"></i>
|
|
<p class="text-gray-400 font-medium">No active work orders</p>
|
|
<p class="text-gray-600 text-sm mt-1">New orders will appear here</p>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
</main>
|
|
|
|
<script>
|
|
async function fetchAnalytics() {
|
|
try {
|
|
const res = await fetch('/analytics');
|
|
const data = await res.json();
|
|
document.getElementById('total-visitors').textContent = data.error ? 'Error' : data.total_users;
|
|
document.getElementById('page-views').textContent = data.error ? 'Error' : data.total_pageviews;
|
|
document.getElementById('top-page').textContent = data.error ? 'Error' : data.top_page;
|
|
} catch (e) {
|
|
['total-visitors','page-views','top-page'].forEach(id => {
|
|
document.getElementById(id).textContent = 'N/A';
|
|
});
|
|
}
|
|
}
|
|
fetchAnalytics();
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|