| {% extends "admin/base.html" %}
|
|
|
| {% block title %}Services Management{% endblock %}
|
|
|
| {% block content %}
|
| <div class="min-h-screen bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-900 dark:to-gray-800">
|
|
|
| <nav class="glass-nav sticky top-0 z-50 shadow-lg">
|
| <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
| <div class="flex justify-between h-16">
|
| <div class="flex items-center space-x-3">
|
| <div class="w-10 h-10 bg-gradient-to-br from-blue-500 to-purple-600 rounded-xl flex items-center justify-center shadow-lg">
|
| <svg class="w-6 h-6 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
|
| </svg>
|
| </div>
|
| <h1 class="text-2xl font-bold bg-gradient-to-r from-blue-600 to-purple-600 dark:from-blue-400 dark:to-purple-400 bg-clip-text text-transparent">Arxiver Admin</h1>
|
| </div>
|
| <div class="flex items-center space-x-2">
|
| <a href="/admin/dashboard" class="px-4 py-2 rounded-lg font-medium text-gray-700 dark:text-gray-300 hover:bg-white/50 dark:hover:bg-gray-800/50 transition-all">Dashboard</a>
|
| <a href="/admin/users" class="px-4 py-2 rounded-lg font-medium text-gray-700 dark:text-gray-300 hover:bg-white/50 dark:hover:bg-gray-800/50 transition-all">Users</a>
|
| <a href="/admin/services" class="px-4 py-2 rounded-lg font-medium bg-gradient-to-r from-blue-600 to-blue-700 dark:from-blue-500 dark:to-blue-600 text-white shadow-md hover:shadow-lg transform hover:scale-105 transition-all">Services</a>
|
| <a href="/admin/resources" class="px-4 py-2 rounded-lg font-medium text-gray-700 dark:text-gray-300 hover:bg-white/50 dark:hover:bg-gray-800/50 transition-all">Resources</a>
|
| <button onclick="toggleTheme()" class="p-2 rounded-lg hover:bg-white/50 dark:hover:bg-gray-800/50 transition-all ml-2">
|
| <svg class="w-5 h-5 text-gray-700 dark:text-gray-300" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| <path class="dark:hidden" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"></path>
|
| <path class="hidden dark:block" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"></path>
|
| </svg>
|
| </button>
|
| <a href="/admin/logout" class="px-4 py-2 rounded-lg font-medium bg-gradient-to-r from-red-500 to-red-600 hover:from-red-600 hover:to-red-700 text-white shadow-md hover:shadow-lg transform hover:scale-105 transition-all ml-2">Logout</a>
|
| </div>
|
| </div>
|
| </div>
|
| </nav>
|
|
|
|
|
| <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
|
|
| {% if request.query_params.get('success') == 'added' %}
|
| <div class="mb-6 glass-card border-green-500/30 text-green-700 dark:text-green-400 px-4 py-3 rounded-xl shadow-lg">✓ Service added successfully!</div>
|
| {% elif request.query_params.get('success') == 'deleted' %}
|
| <div class="mb-6 glass-card border-green-500/30 text-green-700 dark:text-green-400 px-4 py-3 rounded-xl shadow-lg">✓ Service deleted successfully!</div>
|
| {% elif request.query_params.get('success') == 'toggled' %}
|
| <div class="mb-6 glass-card border-green-500/30 text-green-700 dark:text-green-400 px-4 py-3 rounded-xl shadow-lg">✓ Service status updated!</div>
|
| {% elif request.query_params.get('error') %}
|
| <div class="mb-6 glass-card border-red-500/30 text-red-700 dark:text-red-400 px-4 py-3 rounded-xl shadow-lg">✗ Error: {{ request.query_params.get('error') }}</div>
|
| {% endif %}
|
|
|
|
|
| <div class="glass-card shadow-xl rounded-2xl p-6 mb-8">
|
| <h2 class="text-2xl font-bold text-gray-900 dark:text-white mb-6 flex items-center space-x-2">
|
| <span class="w-8 h-8 bg-gradient-to-br from-blue-500 to-purple-600 rounded-lg flex items-center justify-center">
|
| <svg class="w-5 h-5 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"></path></svg>
|
| </span>
|
| <span>Add New Service</span>
|
| </h2>
|
| <form method="POST" action="/admin/services/add" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-4">
|
| <div>
|
| <label class="block text-sm font-semibold text-gray-700 dark:text-gray-300 mb-2">Name</label>
|
| <input type="text" name="name" required placeholder="OpenAI"
|
| class="w-full px-4 py-2.5 bg-white/50 dark:bg-gray-800/50 border border-gray-300 dark:border-gray-600 rounded-xl focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400 focus:border-transparent text-gray-900 dark:text-white placeholder-gray-400 dark:placeholder-gray-500 transition">
|
| </div>
|
| <div>
|
| <label class="block text-sm font-semibold text-gray-700 dark:text-gray-300 mb-2">Slug</label>
|
| <input type="text" name="slug" required placeholder="openai"
|
| class="w-full px-4 py-2.5 bg-white/50 dark:bg-gray-800/50 border border-gray-300 dark:border-gray-600 rounded-xl focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400 focus:border-transparent text-gray-900 dark:text-white placeholder-gray-400 dark:placeholder-gray-500 transition font-mono">
|
| </div>
|
| <div>
|
| <label class="block text-sm font-semibold text-gray-700 dark:text-gray-300 mb-2">Type</label>
|
| <select name="service_type" required
|
| class="w-full px-4 py-2.5 bg-white/50 dark:bg-gray-800/50 border border-gray-300 dark:border-gray-600 rounded-xl focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400 focus:border-transparent text-gray-900 dark:text-white transition">
|
| {% for st in service_types %}
|
| <option value="{{ st.value }}">{{ st.value.replace('_', ' ').title() }}</option>
|
| {% endfor %}
|
| </select>
|
| </div>
|
| <div>
|
| <label class="block text-sm font-semibold text-gray-700 dark:text-gray-300 mb-2">Description</label>
|
| <input type="text" name="description" placeholder="Optional description"
|
| class="w-full px-4 py-2.5 bg-white/50 dark:bg-gray-800/50 border border-gray-300 dark:border-gray-600 rounded-xl focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400 focus:border-transparent text-gray-900 dark:text-white placeholder-gray-400 dark:placeholder-gray-500 transition">
|
| </div>
|
| <div class="flex items-end">
|
| <button type="submit"
|
| class="w-full bg-gradient-to-r from-blue-600 to-blue-700 hover:from-blue-700 hover:to-blue-800 dark:from-blue-500 dark:to-blue-600 dark:hover:from-blue-600 dark:hover:to-blue-700 text-white font-semibold py-2.5 px-4 rounded-xl transition shadow-lg hover:shadow-xl transform hover:scale-[1.02]">
|
| Add Service
|
| </button>
|
| </div>
|
| </form>
|
| </div>
|
|
|
|
|
| <div class="glass-card shadow-xl rounded-2xl overflow-hidden">
|
| <div class="px-6 py-4 border-b border-gray-200 dark:border-gray-700 bg-gradient-to-r from-white/50 to-gray-50/50 dark:from-gray-800/50 dark:to-gray-900/50">
|
| <h2 class="text-xl font-bold text-gray-900 dark:text-white">All Services ({{ services|length }})</h2>
|
| </div>
|
| <div class="overflow-x-auto">
|
| <table class="min-w-full divide-y divide-gray-200 dark:divide-gray-700">
|
| <thead class="bg-gray-50/50 dark:bg-gray-800/50">
|
| <tr>
|
| <th class="px-6 py-3 text-left text-xs font-bold text-gray-500 dark:text-gray-400 uppercase tracking-wider">ID</th>
|
| <th class="px-6 py-3 text-left text-xs font-bold text-gray-500 dark:text-gray-400 uppercase tracking-wider">Name</th>
|
| <th class="px-6 py-3 text-left text-xs font-bold text-gray-500 dark:text-gray-400 uppercase tracking-wider">Slug</th>
|
| <th class="px-6 py-3 text-left text-xs font-bold text-gray-500 dark:text-gray-400 uppercase tracking-wider">Type</th>
|
| <th class="px-6 py-3 text-left text-xs font-bold text-gray-500 dark:text-gray-400 uppercase tracking-wider">Description</th>
|
| <th class="px-6 py-3 text-left text-xs font-bold text-gray-500 dark:text-gray-400 uppercase tracking-wider">Status</th>
|
| <th class="px-6 py-3 text-left text-xs font-bold text-gray-500 dark:text-gray-400 uppercase tracking-wider">Actions</th>
|
| </tr>
|
| </thead>
|
| <tbody class="divide-y divide-gray-200 dark:divide-gray-700">
|
| {% for service in services %}
|
| <tr class="hover:bg-white/30 dark:hover:bg-gray-800/30 transition-colors">
|
| <td class="px-6 py-4 whitespace-nowrap text-sm font-semibold text-gray-900 dark:text-white">{{ service.id }}</td>
|
| <td class="px-6 py-4 whitespace-nowrap text-sm font-bold text-gray-900 dark:text-white">{{ service.name }}</td>
|
| <td class="px-6 py-4 whitespace-nowrap">
|
| <span class="text-sm text-blue-600 dark:text-blue-400 font-mono bg-blue-50 dark:bg-blue-900/20 rounded px-2 py-1 inline-block">{{ service.slug }}</span>
|
| </td>
|
| <td class="px-6 py-4 whitespace-nowrap">
|
| <span class="px-3 py-1 inline-flex text-xs leading-5 font-bold rounded-full bg-gradient-to-r from-blue-500 to-cyan-500 text-white shadow-sm">{{ service.service_type.value.replace('_', ' ').title() }}</span>
|
| </td>
|
| <td class="px-6 py-4 text-sm text-gray-600 dark:text-gray-400 max-w-xs truncate">{{ service.description or '-' }}</td>
|
| <td class="px-6 py-4 whitespace-nowrap">
|
| <span class="px-3 py-1 inline-flex text-xs leading-5 font-bold rounded-full {% if service.is_active %}bg-gradient-to-r from-green-500 to-emerald-500 text-white{% else %}bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300{% endif %} shadow-sm">{% if service.is_active %}Active{% else %}Inactive{% endif %}</span>
|
| </td>
|
| <td class="px-6 py-4 whitespace-nowrap text-sm font-medium space-x-2">
|
| <form method="POST" action="/admin/services/toggle/{{ service.id }}" class="inline">
|
| <button type="submit" class="text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300 font-semibold transition" onclick="return confirm('Toggle service status?')">Toggle</button>
|
| </form>
|
| <form method="POST" action="/admin/services/delete/{{ service.id }}" class="inline">
|
| <button type="submit" class="text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300 font-semibold transition" onclick="return confirm('Are you sure you want to delete this service?')">Delete</button>
|
| </form>
|
| </td>
|
| </tr>
|
| {% endfor %}
|
| </tbody>
|
| </table>
|
| </div>
|
| </div>
|
| </div>
|
| </div>
|
| {% endblock %}
|
|
|