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

Added admin link to Tasmota power plugs card

maziggy 8 месяцев назад
Родитель
Сommit
02f437b349
3 измененных файлов с 24 добавлено и 3 удалено
  1. 23 2
      frontend/src/components/SmartPlugCard.tsx
  2. 0 0
      static/assets/index-Bo9Lo1_A.js
  3. 1 1
      static/index.html

+ 23 - 2
frontend/src/components/SmartPlugCard.tsx

@@ -1,6 +1,6 @@
 import { useState } from 'react';
 import { useMutation, useQueryClient, useQuery } from '@tanstack/react-query';
-import { Plug, Power, PowerOff, Loader2, Trash2, Settings2, Thermometer, Clock, Wifi, WifiOff, Edit2, Bell, Calendar, LayoutGrid } from 'lucide-react';
+import { Plug, Power, PowerOff, Loader2, Trash2, Settings2, Thermometer, Clock, Wifi, WifiOff, Edit2, Bell, Calendar, LayoutGrid, ExternalLink } from 'lucide-react';
 import { api } from '../api/client';
 import type { SmartPlug, SmartPlugUpdate } from '../api/client';
 import { Card, CardContent } from './Card';
@@ -66,6 +66,16 @@ export function SmartPlugCard({ plug, onEdit }: SmartPlugCardProps) {
   const isReachable = status?.reachable ?? false;
   const isPending = controlMutation.isPending;
 
+  // Generate admin URL with auto-login credentials
+  const getAdminUrl = () => {
+    const ip = plug.ip_address;
+    if (plug.username && plug.password) {
+      // Use HTTP Basic Auth in URL for auto-login
+      return `http://${encodeURIComponent(plug.username)}:${encodeURIComponent(plug.password)}@${ip}/`;
+    }
+    return `http://${ip}/`;
+  };
+
   return (
     <>
       <Card className="relative">
@@ -83,7 +93,7 @@ export function SmartPlugCard({ plug, onEdit }: SmartPlugCardProps) {
             </div>
 
             {/* Status indicator */}
-            <div className="flex items-center gap-2">
+            <div className="flex flex-col items-end gap-1">
               {statusLoading ? (
                 <Loader2 className="w-4 h-4 text-bambu-gray animate-spin" />
               ) : isReachable ? (
@@ -97,6 +107,17 @@ export function SmartPlugCard({ plug, onEdit }: SmartPlugCardProps) {
                   <span>Offline</span>
                 </div>
               )}
+              {/* Admin page link */}
+              <a
+                href={getAdminUrl()}
+                target="_blank"
+                rel="noopener noreferrer"
+                className="flex items-center gap-1 px-2 py-0.5 bg-bambu-dark hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white text-xs rounded-full transition-colors"
+                title="Open plug admin page"
+              >
+                <ExternalLink className="w-3 h-3" />
+                Admin
+              </a>
             </div>
           </div>
 

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/index-Bo9Lo1_A.js


+ 1 - 1
static/index.html

@@ -23,7 +23,7 @@
 
     <!-- Splash screens for iOS -->
     <link rel="apple-touch-startup-image" href="/img/android-chrome-512x512.png" />
-    <script type="module" crossorigin src="/assets/index-Buplsh8i.js"></script>
+    <script type="module" crossorigin src="/assets/index-Bo9Lo1_A.js"></script>
     <link rel="stylesheet" crossorigin href="/assets/index-j3n1gAEX.css">
   </head>
   <body>

Некоторые файлы не были показаны из-за большого количества измененных файлов