Parcourir la source

fix shutdown button visibility

tuanchris il y a 3 mois
Parent
commit
f0ced92457
2 fichiers modifiés avec 11 ajouts et 31 suppressions
  1. 1 9
      main.py
  2. 10 22
      templates/base.html

+ 1 - 9
main.py

@@ -1687,16 +1687,8 @@ async def check_pi():
 
 @app.post("/api/system/shutdown")
 async def shutdown_system():
-    """Shutdown the Raspberry Pi system"""
+    """Shutdown the system"""
     try:
-        # Double-check it's a Pi before allowing shutdown
-        check_result = await check_pi()
-        if not check_result["is_pi"]:
-            return JSONResponse(
-                content={"success": False, "message": "Shutdown only available on Raspberry Pi"},
-                status_code=403
-            )
-
         logger.warning("Shutdown initiated via API")
 
         # Run docker compose down in background

+ 10 - 22
templates/base.html

@@ -269,14 +269,6 @@
             </a>
           </div>
           <div class="flex items-center gap-2">
-            <button
-              id="shutdown-button"
-              class="p-1.5 flex rounded-lg hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-red-500 hidden"
-              aria-label="Shutdown system"
-              title="Shutdown Raspberry Pi"
-            >
-              <span class="material-icons text-red-600">power_settings_new</span>
-            </button>
             <button
               id="theme-toggle"
               class="p-1.5 flex rounded-lg hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500"
@@ -284,6 +276,14 @@
             >
               <span class="material-icons" id="theme-toggle-icon">dark_mode</span>
             </button>
+            <button
+              id="shutdown-button"
+              class="p-1.5 flex rounded-lg hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-red-500"
+              aria-label="Shutdown system"
+              title="Shutdown System (Raspberry Pi only)"
+            >
+              <span class="material-icons text-red-600">power_settings_new</span>
+            </button>
           </div>
         </header>
         <main class="flex flex-1 justify-center px-4 sm:px-6 lg:px-8 pt-16 sm:pt-20">
@@ -694,24 +694,12 @@
       });
 
       // Shutdown button functionality
-      document.addEventListener('DOMContentLoaded', async function() {
+      document.addEventListener('DOMContentLoaded', function() {
         const shutdownButton = document.getElementById('shutdown-button');
 
-        // Check if system is a Raspberry Pi
-        try {
-          const response = await fetch('/api/system/check_pi');
-          const data = await response.json();
-
-          if (data.is_pi) {
-            shutdownButton.classList.remove('hidden');
-          }
-        } catch (error) {
-          console.error('Error checking Pi status:', error);
-        }
-
         // Shutdown button click handler
         shutdownButton.addEventListener('click', async () => {
-          const confirmed = confirm('Are you sure you want to shutdown the Raspberry Pi?\n\nThis will:\n1. Stop Docker containers\n2. Shut down the system\n\nYou will need physical access to restart it.');
+          const confirmed = confirm('Are you sure you want to shutdown the system?\n\nNote: This only works on Raspberry Pi.\n\nThis will:\n1. Stop Docker containers\n2. Shut down the system\n\nYou will need physical access to restart it.');
 
           if (!confirmed) return;