Просмотр исходного кода

feat: enhance delay pools management with authentication check and user prompts

Manuel 7 месяцев назад
Родитель
Сommit
86f9c31474
3 измененных файлов с 40 добавлено и 19 удалено
  1. 7 2
      routes/admin/delay_pools.py
  2. 6 1
      routes/admin_routes.py
  3. 27 16
      templates/admin/delay_pools.html

+ 7 - 2
routes/admin/delay_pools.py

@@ -2,7 +2,7 @@
 
 
 from flask import render_template, request
 from flask import render_template, request
 
 
-from services.auth.auth_service import admin_required
+from services.auth.auth_service import AuthService, admin_required
 from services.squid.delay_pools_service import (
 from services.squid.delay_pools_service import (
     add_delay_pool as service_add_delay_pool,
     add_delay_pool as service_add_delay_pool,
 )
 )
@@ -22,7 +22,12 @@ def register_routes(bp):
     def manage_delay_pools():
     def manage_delay_pools():
         cm = get_config_manager()
         cm = get_config_manager()
         delay_pools = cm.get_delay_pools()
         delay_pools = cm.get_delay_pools()
-        return render_template("admin/delay_pools.html", delay_pools=delay_pools)
+        authenticated = AuthService.is_authenticated()
+        return render_template(
+            "admin/delay_pools.html",
+            delay_pools=delay_pools,
+            authenticated=authenticated,
+        )
 
 
     @bp.route("/delay-pools/delete", methods=["POST"])
     @bp.route("/delay-pools/delete", methods=["POST"])
     @admin_required
     @admin_required

+ 6 - 1
routes/admin_routes.py

@@ -245,7 +245,12 @@ def delete_acl():
 @admin_required
 @admin_required
 def manage_delay_pools():
 def manage_delay_pools():
     delay_pools = config_manager.get_delay_pools()
     delay_pools = config_manager.get_delay_pools()
-    return render_template("admin/delay_pools.html", delay_pools=delay_pools)
+    authenticated = AuthService.is_authenticated()
+    return render_template(
+        "admin/delay_pools.html",
+        delay_pools=delay_pools,
+        authenticated=authenticated,
+    )
 
 
 
 
 @admin_bp.route("/http-access")
 @admin_bp.route("/http-access")

+ 27 - 16
templates/admin/delay_pools.html

@@ -135,25 +135,36 @@
         {% endfor %}
         {% endfor %}
     </div>
     </div>
     {% else %}
     {% else %}
-    <div class="text-center py-12">
-        <i class="fas fa-clock text-6xl text-gray-300 mb-4"></i>
-        <p class="text-gray-500 text-lg">No hay delay pools configurados</p>
-        
-        <div class="mt-4 bg-blue-50 border border-blue-200 rounded-lg p-4 max-w-md mx-auto">
-            <div class="flex items-start">
-                <i class="fas fa-info-circle text-blue-600 mt-1 mr-3"></i>
-                <div class="text-left text-sm">
-                    <p class="font-semibold text-blue-900 mb-1">¿Ya tienes delay pools configurados?</p>
-                    <p class="text-blue-800 mb-2">Si tu squid.conf aún no está dividido, puedes <a href="{{ url_for('admin.split_config') }}" class="underline hover:text-blue-600 font-semibold">dividir tu configuración</a> para una mejor gestión modular.</p>
-                    <p class="text-blue-800">Si ya está dividido, verifica que los archivos estén en el directorio correcto o edítalos directamente desde <a href="{{ url_for('admin.view_config') }}" class="underline hover:text-blue-600 font-semibold">Configuración</a>.</p>
+        {% if not authenticated %}
+        <div class="text-center py-12">
+            <i class="fas fa-user-lock text-6xl text-gray-300 mb-4"></i>
+            <p class="text-gray-500 text-lg">Para ver los delay pools debes iniciar sesión.</p>
+            <p class="text-gray-500 mt-2">Inicia sesión con una cuenta de administrador para acceder a esta sección.</p>
+            <a href="{{ url_for('auth.login') }}" class="mt-4 inline-flex items-center justify-center bg-blue-600 hover:bg-blue-700 text-white font-semibold px-6 py-2 rounded-lg shadow-md transition-colors">
+                <i class="fas fa-sign-in-alt mr-2"></i> Iniciar sesión
+            </a>
+        </div>
+        {% else %}
+        <div class="text-center py-12">
+            <i class="fas fa-clock text-6xl text-gray-300 mb-4"></i>
+            <p class="text-gray-500 text-lg">No hay delay pools configurados</p>
+            
+            <div class="mt-4 bg-blue-50 border border-blue-200 rounded-lg p-4 max-w-md mx-auto">
+                <div class="flex items-start">
+                    <i class="fas fa-info-circle text-blue-600 mt-1 mr-3"></i>
+                    <div class="text-left text-sm">
+                        <p class="font-semibold text-blue-900 mb-1">¿Ya tienes delay pools configurados?</p>
+                        <p class="text-blue-800 mb-2">Si tu squid.conf aún no está dividido, puedes <a href="{{ url_for('admin.split_config') }}" class="underline hover:text-blue-600 font-semibold">dividir tu configuración</a> para una mejor gestión modular.</p>
+                        <p class="text-blue-800">Si ya está dividido, verifica que los archivos estén en el directorio correcto o edítalos directamente desde <a href="{{ url_for('admin.view_config') }}" class="underline hover:text-blue-600 font-semibold">Configuración</a>.</p>
+                    </div>
                 </div>
                 </div>
             </div>
             </div>
+            
+            <button onclick="showAddModal()" class="mt-4 bg-blue-600 hover:bg-blue-700 text-white font-semibold px-6 py-2 rounded-lg shadow-md transition-colors">
+                <i class="fas fa-plus mr-2"></i>Crear primer Pool
+            </button>
         </div>
         </div>
-        
-        <button onclick="showAddModal()" class="mt-4 bg-blue-600 hover:bg-blue-700 text-white font-semibold px-6 py-2 rounded-lg shadow-md transition-colors">
-            <i class="fas fa-plus mr-2"></i>Crear primer Pool
-        </button>
-    </div>
+        {% endif %}
     {% endif %}
     {% endif %}
 </div>
 </div>