Compare commits
3 Commits
d7200de452
...
7dc27290fb
| Author | SHA1 | Date | |
|---|---|---|---|
| 7dc27290fb | |||
| fd24a0c548 | |||
| c332f4f48d |
@@ -1,8 +1,8 @@
|
||||
@ECHO OFF
|
||||
REM One-time deployment script for DOS Update System
|
||||
REM Usage: T:\COMMON\ProdSW\DEPLOY.BAT machine-name
|
||||
REM Version: 2.3 - Removed 2>NUL (DOS 6.22 only supports >NUL)
|
||||
REM Last modified: 2026-01-20
|
||||
REM Version: 2.4 - Use COPY instead of XCOPY (DOS 6.22 compatibility)
|
||||
REM Last modified: 2026-01-21
|
||||
|
||||
CLS
|
||||
|
||||
@@ -27,13 +27,13 @@ MD C:\BAT >NUL
|
||||
MD T:\%MACHINE% >NUL
|
||||
|
||||
ECHO [1/2] Copying batch files to C:\BAT...
|
||||
XCOPY T:\COMMON\ProdSW\NWTOC.BAT C:\BAT /Y >NUL
|
||||
XCOPY T:\COMMON\ProdSW\CTONW.BAT C:\BAT /Y >NUL
|
||||
XCOPY T:\COMMON\ProdSW\UPDATE.BAT C:\BAT /Y >NUL
|
||||
XCOPY T:\COMMON\ProdSW\CHECKUPD.BAT C:\BAT /Y >NUL
|
||||
XCOPY T:\COMMON\ProdSW\STAGE.BAT C:\BAT /Y >NUL
|
||||
XCOPY T:\COMMON\ProdSW\REBOOT.BAT C:\BAT /Y >NUL
|
||||
ECHO [OK] Batch files installed
|
||||
COPY T:\COMMON\ProdSW\NWTOC.BAT C:\BAT >NUL
|
||||
COPY T:\COMMON\ProdSW\CTONW.BAT C:\BAT >NUL
|
||||
COPY T:\COMMON\ProdSW\UPDATE.BAT C:\BAT >NUL
|
||||
COPY T:\COMMON\ProdSW\CHECKUPD.BAT C:\BAT >NUL
|
||||
COPY T:\COMMON\ProdSW\STAGE.BAT C:\BAT >NUL
|
||||
COPY T:\COMMON\ProdSW\REBOOT.BAT C:\BAT >NUL
|
||||
ECHO Batch files installed
|
||||
ECHO.
|
||||
|
||||
ECHO [2/2] Installing AUTOEXEC.BAT...
|
||||
@@ -63,7 +63,7 @@ ECHO ECHO System Ready >> C:\AUTOEXEC.BAT
|
||||
ECHO ECHO. >> C:\AUTOEXEC.BAT
|
||||
ECHO CD \ATE >> C:\AUTOEXEC.BAT
|
||||
ECHO menux >> C:\AUTOEXEC.BAT
|
||||
ECHO [OK] AUTOEXEC.BAT installed with MACHINE=%MACHINE%
|
||||
ECHO AUTOEXEC.BAT installed with MACHINE=%MACHINE%
|
||||
ECHO.
|
||||
|
||||
ECHO ==============================================================
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
@ECHO OFF
|
||||
REM Network to Computer - Download software updates from network to local C: drive
|
||||
REM Version: 2.8 - Added /I flag, removed 2>NUL (DOS 6.22)
|
||||
REM Last modified: 2026-01-20
|
||||
|
||||
REM Check MACHINE variable
|
||||
IF "%MACHINE%"=="" GOTO NO_MACHINE
|
||||
REM Version: 3.5 - Use COPY, no NUL redirects
|
||||
REM Last modified: 2026-01-21
|
||||
|
||||
REM Check T: drive
|
||||
IF NOT EXIST T:\*.* GOTO NO_DRIVE
|
||||
@@ -12,51 +9,54 @@ IF NOT EXIST T:\*.* GOTO NO_DRIVE
|
||||
REM Display banner
|
||||
ECHO.
|
||||
ECHO ==============================================================
|
||||
ECHO Download Updates: %MACHINE% from Network
|
||||
ECHO Download Updates from Network
|
||||
ECHO ==============================================================
|
||||
ECHO.
|
||||
|
||||
REM Create local directories (ignore errors with >NUL)
|
||||
MD C:\BAT >NUL
|
||||
MD C:\ATE >NUL
|
||||
MD C:\NET >NUL
|
||||
REM Create local directories (errors ignored)
|
||||
IF NOT EXIST C:\BAT\*.* MD C:\BAT
|
||||
IF NOT EXIST C:\ATE\*.* MD C:\ATE
|
||||
IF NOT EXIST C:\ATE\5BDATA\*.* MD C:\ATE\5BDATA
|
||||
IF NOT EXIST C:\ATE\7BDATA\*.* MD C:\ATE\7BDATA
|
||||
IF NOT EXIST C:\ATE\8BDATA\*.* MD C:\ATE\8BDATA
|
||||
IF NOT EXIST C:\ATE\DSCDATA\*.* MD C:\ATE\DSCDATA
|
||||
IF NOT EXIST C:\ATE\HVDATA\*.* MD C:\ATE\HVDATA
|
||||
IF NOT EXIST C:\ATE\PWRDATA\*.* MD C:\ATE\PWRDATA
|
||||
IF NOT EXIST C:\ATE\RMSDATA\*.* MD C:\ATE\RMSDATA
|
||||
IF NOT EXIST C:\ATE\SCTDATA\*.* MD C:\ATE\SCTDATA
|
||||
IF NOT EXIST C:\NET\*.* MD C:\NET
|
||||
|
||||
REM Check for COMMON updates
|
||||
IF NOT EXIST T:\COMMON\ProdSW\*.* GOTO NO_COMMON
|
||||
|
||||
ECHO [1/3] Copying from T:\COMMON\ProdSW to C:\BAT...
|
||||
XCOPY T:\COMMON\ProdSW\*.BAT C:\BAT /Y /I >NUL
|
||||
ECHO [OK] Common batch files updated
|
||||
ECHO [1/3] Copying batch files to C:\BAT...
|
||||
COPY T:\COMMON\ProdSW\*.BAT C:\BAT
|
||||
ECHO Done
|
||||
ECHO.
|
||||
|
||||
REM Check for machine-specific updates
|
||||
IF NOT EXIST T:\%MACHINE%\ProdSW\*.* GOTO SKIP_MACHINE
|
||||
|
||||
ECHO [2/3] Copying from T:\%MACHINE%\ProdSW...
|
||||
IF EXIST T:\%MACHINE%\ProdSW\*.BAT XCOPY T:\%MACHINE%\ProdSW\*.BAT C:\BAT /Y /I >NUL
|
||||
IF EXIST T:\%MACHINE%\ProdSW\*.EXE XCOPY T:\%MACHINE%\ProdSW\*.EXE C:\ATE /Y /I >NUL
|
||||
IF EXIST T:\%MACHINE%\ProdSW\*.DAT XCOPY T:\%MACHINE%\ProdSW\*.DAT C:\ATE /Y /I >NUL
|
||||
IF EXIST T:\%MACHINE%\ProdSW\*.CFG XCOPY T:\%MACHINE%\ProdSW\*.CFG C:\ATE /Y /I >NUL
|
||||
ECHO [OK] Machine-specific files updated
|
||||
ECHO.
|
||||
GOTO CHECK_NET
|
||||
|
||||
:SKIP_MACHINE
|
||||
ECHO [2/3] No machine-specific updates (T:\%MACHINE%\ProdSW not found)
|
||||
ECHO [2/3] Copying ATE data folders to C:\ATE...
|
||||
IF EXIST T:\Ate\ProdSW\5BDATA\*.* COPY T:\Ate\ProdSW\5BDATA\*.* C:\ATE\5BDATA
|
||||
IF EXIST T:\Ate\ProdSW\7BDATA\*.* COPY T:\Ate\ProdSW\7BDATA\*.* C:\ATE\7BDATA
|
||||
IF EXIST T:\Ate\ProdSW\8BDATA\*.* COPY T:\Ate\ProdSW\8BDATA\*.* C:\ATE\8BDATA
|
||||
IF EXIST T:\Ate\ProdSW\DSCDATA\*.* COPY T:\Ate\ProdSW\DSCDATA\*.* C:\ATE\DSCDATA
|
||||
IF EXIST T:\Ate\ProdSW\HVDATA\*.* COPY T:\Ate\ProdSW\HVDATA\*.* C:\ATE\HVDATA
|
||||
IF EXIST T:\Ate\ProdSW\PWRDATA\*.* COPY T:\Ate\ProdSW\PWRDATA\*.* C:\ATE\PWRDATA
|
||||
IF EXIST T:\Ate\ProdSW\RMSDATA\*.* COPY T:\Ate\ProdSW\RMSDATA\*.* C:\ATE\RMSDATA
|
||||
IF EXIST T:\Ate\ProdSW\SCTDATA\*.* COPY T:\Ate\ProdSW\SCTDATA\*.* C:\ATE\SCTDATA
|
||||
ECHO Done
|
||||
ECHO.
|
||||
|
||||
:CHECK_NET
|
||||
REM Check for network client updates
|
||||
IF NOT EXIST T:\COMMON\NET\*.* GOTO SKIP_NET
|
||||
|
||||
ECHO [3/3] Copying from T:\COMMON\NET to C:\NET...
|
||||
XCOPY T:\COMMON\NET\*.* C:\NET /Y /I >NUL
|
||||
ECHO [OK] Network files updated
|
||||
ECHO [3/3] Copying network files to C:\NET...
|
||||
COPY T:\COMMON\NET\*.* C:\NET
|
||||
ECHO Done
|
||||
ECHO.
|
||||
GOTO DONE
|
||||
|
||||
:SKIP_NET
|
||||
ECHO [3/3] No network updates (T:\COMMON\NET not found)
|
||||
ECHO [3/3] No network updates
|
||||
ECHO.
|
||||
|
||||
:DONE
|
||||
@@ -71,12 +71,6 @@ ECHO [ERROR] T:\COMMON\ProdSW not found
|
||||
PAUSE
|
||||
GOTO END
|
||||
|
||||
:NO_MACHINE
|
||||
ECHO [ERROR] MACHINE variable not set
|
||||
ECHO Run DEPLOY.BAT first
|
||||
PAUSE
|
||||
GOTO END
|
||||
|
||||
:NO_DRIVE
|
||||
ECHO [ERROR] T: drive not available
|
||||
ECHO Run C:\STARTNET.BAT first
|
||||
|
||||
281
projects/dataforth-dos/session-logs/2026-01-21-session.md
Normal file
281
projects/dataforth-dos/session-logs/2026-01-21-session.md
Normal file
@@ -0,0 +1,281 @@
|
||||
# Dataforth DOS - Session Log: 2026-01-21
|
||||
|
||||
**Project:** Dataforth DOS Update System
|
||||
**Client:** Dataforth
|
||||
**Duration:** ~2 hours
|
||||
**Status:** DSCDATA sync issue fixed, batch files updated
|
||||
|
||||
---
|
||||
|
||||
## Session Summary
|
||||
|
||||
### What Was Accomplished
|
||||
|
||||
1. **Diagnosed DSCDATA Sync Issue**
|
||||
- DOS machines were getting wrong/outdated DSCDATA files
|
||||
- AD2 had newer files (Jan 2026, DSCMAIN4.DAT 65,508 bytes)
|
||||
- NAS had old files (Dec 2025, DSCMAIN4.DAT 64,395 bytes)
|
||||
- Root cause: Ate/ProdSW folder was NOT in AD2->NAS sync script
|
||||
|
||||
2. **Fixed DSCDATA Sync**
|
||||
- Manually copied correct files from AD2 to NAS via SCP
|
||||
- Updated Sync-FromNAS.ps1 on AD2 to include Ate/ProdSW folder
|
||||
- All 8 ATE subfolders now sync automatically
|
||||
|
||||
3. **Updated Batch Files**
|
||||
- NWTOC.BAT v3.5: Uses COPY instead of XCOPY, no >NUL redirects
|
||||
- DEPLOY.BAT v2.4: Uses COPY instead of XCOPY
|
||||
|
||||
4. **Git Checkpoint Created**
|
||||
- Commit: fd24a0c - "fix(dataforth-dos): DOS 6.22 batch file improvements and sync fix"
|
||||
|
||||
### Key Decisions Made
|
||||
|
||||
1. **Use COPY instead of XCOPY for all operations**
|
||||
- Rationale: XCOPY has unpredictable behavior in DOS 6.22
|
||||
- XCOPY can hang waiting for input even with /Y flag
|
||||
- COPY is simpler and more reliable
|
||||
|
||||
2. **Add IF NOT EXIST checks before MD commands**
|
||||
- Rationale: Avoids "Directory already exists" error messages
|
||||
- Cleaner output for users
|
||||
|
||||
3. **Update sync script to include Ate/ProdSW**
|
||||
- Rationale: This folder contains shared ATE data for all machines
|
||||
- Was overlooked in original sync script design
|
||||
|
||||
### Problems Encountered and Solutions
|
||||
|
||||
**Problem 1: DOS machines getting wrong DSCDATA files**
|
||||
- Symptom: DSCMAIN4.DAT was 64,395 bytes instead of 65,508 bytes
|
||||
- Investigation: Compared AD2 vs NAS file sizes and dates
|
||||
- Root cause: Ate/ProdSW folder not in sync script
|
||||
- Solution: Added Ate/ProdSW to Sync-FromNAS.ps1, manually synced files
|
||||
|
||||
**Problem 2: AD2 network connectivity intermittent**
|
||||
- Symptom: SSH and SMB connections timing out
|
||||
- Solution: Used multiple connection methods, eventually mounted via Finder
|
||||
|
||||
---
|
||||
|
||||
## Credentials
|
||||
|
||||
### AD2 (Production Server - 192.168.0.6)
|
||||
- **Host:** 192.168.0.6
|
||||
- **Domain:** INTRANET
|
||||
- **User:** INTRANET\sysadmin
|
||||
- **Password:** Paper123!@#
|
||||
- **Share Access:** \\192.168.0.6\C$ (admin share)
|
||||
- **Local Path:** C:\Shares\test
|
||||
|
||||
### D2TESTNAS (SMB1 Proxy - 192.168.0.9)
|
||||
- **Host:** 192.168.0.9
|
||||
- **SSH User:** root
|
||||
- **SSH Auth:** ED25519 key (passwordless from Mac)
|
||||
- **Web Admin:** admin / Paper123!@#-nas
|
||||
- **Share Path:** /data/test (maps to T:\ on DOS machines)
|
||||
|
||||
### ClaudeTools (for reference)
|
||||
- **Database:** 172.16.3.30:3306
|
||||
- **Database Name:** claudetools
|
||||
- **Database User:** claudetools
|
||||
- **Database Password:** CT_e8fcd5a3952030a79ed6debae6c954ed
|
||||
- **API:** http://172.16.3.30:8001
|
||||
|
||||
---
|
||||
|
||||
## Infrastructure & Servers
|
||||
|
||||
### AD2 File Locations
|
||||
- **Software Updates:** C:\Shares\test\COMMON\ProdSW\
|
||||
- **ATE Data Folders:** C:\Shares\test\Ate\ProdSW\
|
||||
- 5BDATA, 7BDATA, 8BDATA, DSCDATA, HVDATA, PWRDATA, RMSDATA, SCTDATA
|
||||
- **Sync Script:** C:\Shares\test\scripts\Sync-FromNAS.ps1
|
||||
- **Sync Schedule:** Every 15 minutes via Windows Task Scheduler
|
||||
|
||||
### NAS File Locations
|
||||
- **Software Updates:** /data/test/COMMON/ProdSW/
|
||||
- **ATE Data Folders:** /data/test/Ate/ProdSW/
|
||||
- **Machine Folders:** /data/test/TS-XX/
|
||||
|
||||
### DOS Machine Paths
|
||||
- **Network Drive T:** \\D2TESTNAS\test (SMB1)
|
||||
- **Local Batch Files:** C:\BAT\
|
||||
- **Local ATE Data:** C:\ATE\
|
||||
- **ATE Subfolders:** C:\ATE\5BDATA, C:\ATE\7BDATA, C:\ATE\8BDATA, C:\ATE\DSCDATA, etc.
|
||||
|
||||
---
|
||||
|
||||
## Commands & Outputs
|
||||
|
||||
### Check DSCDATA on NAS
|
||||
```bash
|
||||
ssh root@192.168.0.9 "ls -la /data/test/Ate/ProdSW/DSCDATA/"
|
||||
```
|
||||
Output (before fix):
|
||||
```
|
||||
-rw-r--r--+ 1 root root 64395 Dec 14 20:03 DSCMAIN4.DAT
|
||||
```
|
||||
|
||||
### Check DSCDATA on AD2
|
||||
```bash
|
||||
ls -la "/Volumes/C$/Shares/test/Ate/ProdSW/DSCDATA/"
|
||||
```
|
||||
Output:
|
||||
```
|
||||
-rwx------ 1 azcomputerguru staff 65508 Jan 16 12:35 DSCMAIN4.DAT
|
||||
```
|
||||
|
||||
### Sync DSCDATA to NAS
|
||||
```bash
|
||||
scp "/Volumes/C$/Shares/test/Ate/ProdSW/DSCDATA/"* root@192.168.0.9:/data/test/Ate/ProdSW/DSCDATA/
|
||||
```
|
||||
|
||||
### Verify after sync
|
||||
```bash
|
||||
ssh root@192.168.0.9 "ls -la /data/test/Ate/ProdSW/DSCDATA/"
|
||||
```
|
||||
Output (after fix):
|
||||
```
|
||||
-rw-r--r--+ 1 root root 65508 Jan 21 13:42 DSCMAIN4.DAT
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Configuration Changes
|
||||
|
||||
### Files Modified
|
||||
|
||||
**NWTOC.BAT (v3.5)**
|
||||
- Path: `/Users/azcomputerguru/ClaudeTools/projects/dataforth-dos/batch-files/NWTOC.BAT`
|
||||
- Deployed to: NAS `/data/test/COMMON/ProdSW/NWTOC.BAT`
|
||||
- Deployed to: AD2 `C:\Shares\test\COMMON\ProdSW\NWTOC.BAT`
|
||||
- Changes:
|
||||
- Switched from XCOPY to COPY
|
||||
- Removed all >NUL redirects
|
||||
- Added IF NOT EXIST checks before MD
|
||||
- Added 8 ATE data folder copies (DSCDATA, 5BDATA, 7BDATA, etc.)
|
||||
- Removed machine-specific section
|
||||
- Removed MACHINE variable requirement
|
||||
|
||||
**DEPLOY.BAT (v2.4)**
|
||||
- Path: `/Users/azcomputerguru/ClaudeTools/projects/dataforth-dos/batch-files/DEPLOY.BAT`
|
||||
- Deployed to: NAS and AD2
|
||||
- Changes:
|
||||
- Switched all XCOPY to COPY
|
||||
- Simplified output messages
|
||||
|
||||
**Sync-FromNAS.ps1 (on AD2)**
|
||||
- Path: `C:\Shares\test\scripts\Sync-FromNAS.ps1`
|
||||
- Changes: Added new section to sync Ate/ProdSW folder:
|
||||
```powershell
|
||||
# Sync Ate/ProdSW (shared ATE data folders - 5BDATA, 7BDATA, 8BDATA, DSCDATA, etc.)
|
||||
Write-Log "Syncing Ate/ProdSW data folders..."
|
||||
$ateProdSwPath = "$AD2_TEST_PATH\Ate\ProdSW"
|
||||
if (Test-Path $ateProdSwPath) {
|
||||
$ateFiles = Get-ChildItem -Path $ateProdSwPath -File -Recurse -ErrorAction SilentlyContinue
|
||||
foreach ($file in $ateFiles) {
|
||||
$relativePath = $file.FullName.Substring($ateProdSwPath.Length + 1).Replace('\', '/')
|
||||
$remotePath = "$NAS_DATA_PATH/Ate/ProdSW/$relativePath"
|
||||
# ... copy logic ...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## DOS 6.22 Compatibility Notes (Updated)
|
||||
|
||||
### Commands That DON'T Work
|
||||
- XCOPY /I flag - "Invalid switch"
|
||||
- XCOPY /D without date - "Invalid number of parameters"
|
||||
- 2>NUL (stderr redirect) - "Too many parameters"
|
||||
- >NUL sometimes causes hanging
|
||||
|
||||
### Commands That Work Reliably
|
||||
- COPY (simple file copy)
|
||||
- MD directory (create directory)
|
||||
- IF NOT EXIST path\*.* (check if directory has files)
|
||||
- IF EXIST file\*.* (check if files exist)
|
||||
|
||||
### Best Practices
|
||||
- Use COPY instead of XCOPY for flat files
|
||||
- Use IF NOT EXIST checks before MD to avoid errors
|
||||
- Don't redirect to NUL unless necessary
|
||||
- Don't use 2>NUL (DOS 6.22 doesn't support it)
|
||||
|
||||
---
|
||||
|
||||
## Pending/Incomplete Tasks
|
||||
|
||||
### Immediate
|
||||
- [x] DSCDATA files synced to NAS (completed)
|
||||
- [x] Sync script updated to include Ate/ProdSW (completed)
|
||||
- [ ] Test on a DOS machine to verify files copy correctly
|
||||
|
||||
### Future
|
||||
- [ ] Investigate test data database on AD2 port 3000 (user mentioned, couldn't access)
|
||||
- [ ] Document the testdatadb application if found
|
||||
|
||||
---
|
||||
|
||||
## Reference Information
|
||||
|
||||
### File Versions (Current)
|
||||
| File | Version | Date |
|
||||
|------|---------|------|
|
||||
| NWTOC.BAT | 3.5 | 2026-01-21 |
|
||||
| DEPLOY.BAT | 2.4 | 2026-01-21 |
|
||||
| CTONW.BAT | 2.5 | 2026-01-20 |
|
||||
| UPDATE.BAT | 2.3 | 2026-01-20 |
|
||||
| CHECKUPD.BAT | 1.3 | 2026-01-20 |
|
||||
|
||||
### ATE Data Folders (9 total)
|
||||
1. 5BDATA
|
||||
2. 7BDATA
|
||||
3. 8BDATA
|
||||
4. DSCDATA
|
||||
5. HVDATA
|
||||
6. PWRDATA
|
||||
7. RMSDATA
|
||||
8. SCTDATA
|
||||
9. (root files in Ate/ProdSW/)
|
||||
|
||||
### Git Commits This Session
|
||||
- `fd24a0c` - fix(dataforth-dos): DOS 6.22 batch file improvements and sync fix
|
||||
|
||||
### Network Topology
|
||||
```
|
||||
Admin deposits files on AD2
|
||||
|
|
||||
v
|
||||
[AD2 Server]
|
||||
192.168.0.6
|
||||
C:\Shares\test\
|
||||
|
|
||||
| (Sync-FromNAS.ps1 every 15 min)
|
||||
v
|
||||
[D2TESTNAS]
|
||||
192.168.0.9
|
||||
/data/test/
|
||||
|
|
||||
| (SMB1 protocol)
|
||||
v
|
||||
[DOS Machines]
|
||||
TS-1L through TS-27
|
||||
T:\ = \\D2TESTNAS\test
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Session Metrics
|
||||
|
||||
- **Session Duration:** ~2 hours
|
||||
- **Issues Fixed:** 1 major (DSCDATA sync)
|
||||
- **Files Modified:** 3 (NWTOC.BAT, DEPLOY.BAT, Sync-FromNAS.ps1)
|
||||
- **Git Commits:** 1
|
||||
|
||||
---
|
||||
|
||||
**Session End:** 2026-01-21 13:50
|
||||
**Next Session:** Test NWTOC on DOS machine, investigate testdatadb
|
||||
@@ -9,7 +9,7 @@ import { Clients } from "./pages/Clients";
|
||||
import { Sites } from "./pages/Sites";
|
||||
import { Agents } from "./pages/Agents";
|
||||
import { AgentDetail } from "./pages/AgentDetail";
|
||||
import { Commands } from "./pages/Commands";
|
||||
import { History, HistoryDetail } from "./pages/History";
|
||||
import { Settings } from "./pages/Settings";
|
||||
import "./index.css";
|
||||
|
||||
@@ -118,10 +118,18 @@ function AppRoutes() {
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="/commands"
|
||||
path="/history"
|
||||
element={
|
||||
<ProtectedRoute>
|
||||
<Commands />
|
||||
<History />
|
||||
</ProtectedRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="/history/:id"
|
||||
element={
|
||||
<ProtectedRoute>
|
||||
<HistoryDetail />
|
||||
</ProtectedRoute>
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -1,17 +1,22 @@
|
||||
import { ReactNode } from "react";
|
||||
import { ReactNode, useState } from "react";
|
||||
import { Link, useLocation, useNavigate } from "react-router-dom";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { commandsApi, Command } from "../api/client";
|
||||
import {
|
||||
LayoutDashboard,
|
||||
Server,
|
||||
Terminal,
|
||||
Settings,
|
||||
LogOut,
|
||||
Menu,
|
||||
X,
|
||||
Building2,
|
||||
MapPin,
|
||||
History,
|
||||
CheckCircle,
|
||||
XCircle,
|
||||
Clock,
|
||||
Loader2,
|
||||
} from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { useAuth } from "../hooks/useAuth";
|
||||
import { Button } from "./Button";
|
||||
|
||||
@@ -24,16 +29,37 @@ const navItems = [
|
||||
{ path: "/clients", label: "Clients", icon: Building2 },
|
||||
{ path: "/sites", label: "Sites", icon: MapPin },
|
||||
{ path: "/agents", label: "Agents", icon: Server },
|
||||
{ path: "/commands", label: "Commands", icon: Terminal },
|
||||
{ path: "/settings", label: "Settings", icon: Settings },
|
||||
];
|
||||
|
||||
const APP_VERSION = "0.2.0";
|
||||
const SERVER_VERSION = "0.1.0";
|
||||
|
||||
function CommandStatusIcon({ status }: { status: Command["status"] }) {
|
||||
const config = {
|
||||
pending: { icon: Clock, color: "text-amber-500" },
|
||||
running: { icon: Loader2, color: "text-cyan-500 animate-spin" },
|
||||
completed: { icon: CheckCircle, color: "text-emerald-500" },
|
||||
failed: { icon: XCircle, color: "text-rose-500" },
|
||||
};
|
||||
const { icon: Icon, color } = config[status];
|
||||
return <Icon className={`h-3 w-3 ${color}`} />;
|
||||
}
|
||||
|
||||
export function Layout({ children }: LayoutProps) {
|
||||
const [sidebarOpen, setSidebarOpen] = useState(false);
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
const { user, logout } = useAuth();
|
||||
|
||||
const { data: commands = [] } = useQuery({
|
||||
queryKey: ["commands"],
|
||||
queryFn: () => commandsApi.list().then((res) => res.data),
|
||||
refetchInterval: 15000,
|
||||
});
|
||||
|
||||
const recentCommands = commands.slice(0, 4);
|
||||
|
||||
const handleLogout = () => {
|
||||
logout();
|
||||
navigate("/login");
|
||||
@@ -85,7 +111,7 @@ export function Layout({ children }: LayoutProps) {
|
||||
<div className="flex relative">
|
||||
{/* Sidebar - Mission Control Aesthetic */}
|
||||
<aside
|
||||
className={`fixed inset-y-0 left-0 z-50 w-72 transform transition-all duration-300 ease-out lg:translate-x-0 lg:static ${
|
||||
className={`fixed inset-y-0 left-0 z-50 w-60 transform transition-all duration-300 ease-out lg:translate-x-0 lg:static ${
|
||||
sidebarOpen ? "translate-x-0" : "-translate-x-full"
|
||||
}`}
|
||||
>
|
||||
@@ -95,18 +121,18 @@ export function Layout({ children }: LayoutProps) {
|
||||
<div className="absolute left-0 top-0 bottom-0 w-[2px] bg-gradient-to-b from-transparent via-cyan-500/50 to-transparent" />
|
||||
|
||||
{/* Logo section */}
|
||||
<div className="p-6 hidden lg:block">
|
||||
<div className="p-4 hidden lg:block">
|
||||
<div className="flex items-center gap-3">
|
||||
{/* Logo icon with glow */}
|
||||
<div className="relative">
|
||||
<div className="absolute inset-0 bg-cyan-500/30 blur-lg rounded-lg" />
|
||||
<div className="relative h-10 w-10 rounded-lg bg-gradient-to-br from-cyan-500 to-blue-600 flex items-center justify-center shadow-lg shadow-cyan-500/20">
|
||||
<LayoutDashboard className="h-5 w-5 text-white" />
|
||||
<div className="relative h-8 w-8 rounded-lg bg-gradient-to-br from-cyan-500 to-blue-600 flex items-center justify-center shadow-lg shadow-cyan-500/20">
|
||||
<LayoutDashboard className="h-4 w-4 text-white" />
|
||||
</div>
|
||||
</div>
|
||||
{/* Logo text with gradient */}
|
||||
<div>
|
||||
<h1 className="text-xl font-bold tracking-wider">
|
||||
<h1 className="text-lg font-bold tracking-wider">
|
||||
<span className="bg-gradient-to-r from-cyan-400 via-cyan-300 to-blue-400 bg-clip-text text-transparent">
|
||||
GURU
|
||||
</span>
|
||||
@@ -120,7 +146,7 @@ export function Layout({ children }: LayoutProps) {
|
||||
</div>
|
||||
|
||||
{/* Navigation */}
|
||||
<nav className="flex-1 px-3 space-y-1 mt-4 lg:mt-2 pt-16 lg:pt-0">
|
||||
<nav className="flex-1 px-2 space-y-0.5 mt-4 lg:mt-2 pt-16 lg:pt-0">
|
||||
{navItems.map((item) => {
|
||||
const isActive = location.pathname === item.path;
|
||||
return (
|
||||
@@ -128,7 +154,7 @@ export function Layout({ children }: LayoutProps) {
|
||||
key={item.path}
|
||||
to={item.path}
|
||||
onClick={() => setSidebarOpen(false)}
|
||||
className={`group relative flex items-center gap-3 px-4 py-3 rounded-lg text-xs font-semibold uppercase tracking-wider transition-all duration-300 ${
|
||||
className={`group relative flex items-center gap-2 px-3 py-2 rounded-lg text-xs font-semibold uppercase tracking-wider transition-all duration-300 ${
|
||||
isActive
|
||||
? "text-cyan-400"
|
||||
: "text-slate-400 hover:text-slate-200"
|
||||
@@ -155,7 +181,7 @@ export function Layout({ children }: LayoutProps) {
|
||||
{/* Icon with conditional glow */}
|
||||
<div className="relative z-10">
|
||||
<item.icon
|
||||
className={`h-5 w-5 transition-all duration-300 ${
|
||||
className={`h-4 w-4 transition-all duration-300 ${
|
||||
isActive
|
||||
? "text-cyan-400 drop-shadow-[0_0_8px_rgba(6,182,212,0.8)]"
|
||||
: "text-slate-500 group-hover:text-slate-300"
|
||||
@@ -176,14 +202,14 @@ export function Layout({ children }: LayoutProps) {
|
||||
</nav>
|
||||
|
||||
{/* User profile section */}
|
||||
<div className="p-4 border-t border-cyan-500/10">
|
||||
<div className="flex items-center gap-3 mb-4 p-3 rounded-lg bg-slate-800/30">
|
||||
<div className="p-3 border-t border-cyan-500/10">
|
||||
<div className="flex items-center gap-2 mb-3 p-2 rounded-lg bg-slate-800/30">
|
||||
{/* Avatar with cyan ring glow */}
|
||||
<div className="relative">
|
||||
{/* Glow ring */}
|
||||
<div className="absolute -inset-1 bg-gradient-to-r from-cyan-500 to-blue-500 rounded-full opacity-50 blur-sm" />
|
||||
{/* Avatar */}
|
||||
<div className="relative h-10 w-10 rounded-full bg-gradient-to-br from-slate-700 to-slate-800 ring-2 ring-cyan-500/50 flex items-center justify-center text-cyan-400 text-sm font-bold shadow-lg">
|
||||
<div className="relative h-8 w-8 rounded-full bg-gradient-to-br from-slate-700 to-slate-800 ring-2 ring-cyan-500/50 flex items-center justify-center text-cyan-400 text-sm font-bold shadow-lg">
|
||||
{user?.name?.[0] || user?.email?.[0] || "U"}
|
||||
</div>
|
||||
{/* Online indicator */}
|
||||
@@ -204,19 +230,58 @@ export function Layout({ children }: LayoutProps) {
|
||||
{/* Sign out button */}
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="w-full justify-start gap-3 px-4 py-3 text-xs font-semibold uppercase tracking-wider text-slate-400 hover:text-red-400 hover:bg-red-500/10 rounded-lg transition-all duration-300 group"
|
||||
className="w-full justify-start gap-2 px-3 py-2 text-xs font-semibold uppercase tracking-wider text-slate-400 hover:text-red-400 hover:bg-red-500/10 rounded-lg transition-all duration-300 group"
|
||||
onClick={handleLogout}
|
||||
>
|
||||
<LogOut className="h-4 w-4 transition-all duration-300 group-hover:text-red-400 group-hover:drop-shadow-[0_0_6px_rgba(239,68,68,0.6)]" />
|
||||
Sign Out
|
||||
</Button>
|
||||
|
||||
{/* History log */}
|
||||
<div className="mt-2 pt-2 border-t border-slate-800/50">
|
||||
<Link
|
||||
to="/history"
|
||||
className="flex items-center gap-1.5 px-1 py-1 text-[10px] font-mono text-slate-500 hover:text-cyan-400 transition-colors"
|
||||
>
|
||||
<History className="h-3 w-3" />
|
||||
<span>History</span>
|
||||
</Link>
|
||||
|
||||
<div className="mt-1 space-y-0.5">
|
||||
{recentCommands.length === 0 ? (
|
||||
<p className="text-[10px] text-slate-600 px-1">No recent activity</p>
|
||||
) : (
|
||||
recentCommands.map((cmd: Command) => (
|
||||
<Link
|
||||
key={cmd.id}
|
||||
to={`/history/${cmd.id}`}
|
||||
className="flex items-center gap-1.5 px-1 py-0.5 rounded text-[10px] hover:bg-slate-800/50 transition-colors"
|
||||
title={cmd.command_text}
|
||||
>
|
||||
<CommandStatusIcon status={cmd.status} />
|
||||
<span className="text-slate-500 hover:text-slate-400 truncate flex-1 font-mono">
|
||||
{cmd.command_text.length > 18
|
||||
? cmd.command_text.slice(0, 18) + "..."
|
||||
: cmd.command_text}
|
||||
</span>
|
||||
</Link>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Version info */}
|
||||
<div className="mt-2 pt-2 border-t border-slate-800/50 text-[10px] font-mono text-slate-600 flex justify-between px-1">
|
||||
<span>UI v{APP_VERSION}</span>
|
||||
<span>API v{SERVER_VERSION}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
{/* Main content area */}
|
||||
<main className="flex-1 min-h-screen pt-16 lg:pt-0">
|
||||
<div className="p-6 lg:p-8 transition-all duration-300">
|
||||
<div className="p-4 lg:p-6 transition-all duration-300">
|
||||
{children}
|
||||
</div>
|
||||
</main>
|
||||
|
||||
@@ -395,7 +395,7 @@ code, pre, .mono {
|
||||
border: 1px solid var(--glass-border);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-lg);
|
||||
padding: 1.5rem;
|
||||
padding: 1rem;
|
||||
transition: all var(--transition-base);
|
||||
}
|
||||
|
||||
@@ -669,7 +669,7 @@ code, pre, .mono {
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-lg);
|
||||
padding: 1.5rem;
|
||||
padding: 1rem;
|
||||
transition: all var(--transition-base);
|
||||
}
|
||||
|
||||
@@ -683,8 +683,8 @@ code, pre, .mono {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 1rem;
|
||||
padding-bottom: 1rem;
|
||||
margin-bottom: 0.75rem;
|
||||
padding-bottom: 0.75rem;
|
||||
border-bottom: 1px solid var(--border-secondary);
|
||||
}
|
||||
|
||||
@@ -703,10 +703,10 @@ code, pre, .mono {
|
||||
backdrop-filter: blur(var(--glass-blur));
|
||||
border: 1px solid var(--glass-border);
|
||||
border-radius: var(--radius-lg);
|
||||
padding: 1.25rem;
|
||||
padding: 1rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
gap: 0.375rem;
|
||||
}
|
||||
|
||||
.metric-label {
|
||||
@@ -719,7 +719,7 @@ code, pre, .mono {
|
||||
|
||||
.metric-value {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 2rem;
|
||||
font-size: 1.75rem;
|
||||
font-weight: 700;
|
||||
color: var(--text-primary);
|
||||
line-height: 1;
|
||||
@@ -761,13 +761,13 @@ code, pre, .mono {
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
font-size: 0.75rem;
|
||||
padding: 0.75rem 1rem;
|
||||
padding: 0.5rem 0.75rem;
|
||||
text-align: left;
|
||||
border-bottom: 1px solid var(--border-primary);
|
||||
}
|
||||
|
||||
.data-grid td {
|
||||
padding: 0.75rem 1rem;
|
||||
padding: 0.5rem 0.75rem;
|
||||
color: var(--text-secondary);
|
||||
border-bottom: 1px solid var(--border-secondary);
|
||||
transition: background var(--transition-fast);
|
||||
@@ -790,7 +790,7 @@ code, pre, .mono {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0.625rem 1.25rem;
|
||||
padding: 0.5rem 1rem;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
@@ -954,9 +954,9 @@ code, pre, .mono {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0.5rem 1rem;
|
||||
padding: 0.375rem 0.75rem;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.875rem;
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 500;
|
||||
color: var(--text-muted);
|
||||
background: transparent;
|
||||
@@ -987,7 +987,7 @@ code, pre, .mono {
|
||||
border-right: 1px solid var(--glass-border);
|
||||
height: 100vh;
|
||||
position: fixed;
|
||||
width: 260px;
|
||||
width: 240px;
|
||||
overflow-y: auto;
|
||||
z-index: 100;
|
||||
}
|
||||
@@ -1238,6 +1238,15 @@ code, pre, .mono {
|
||||
letter-spacing: 0.2em;
|
||||
}
|
||||
|
||||
/* Compact spacing utilities */
|
||||
.space-y-compact > * + * {
|
||||
margin-top: 0.75rem;
|
||||
}
|
||||
|
||||
.gap-compact {
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
SCROLLBAR STYLING
|
||||
============================================================ */
|
||||
|
||||
@@ -1,21 +1,36 @@
|
||||
import { useState } from "react";
|
||||
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { Link } from "react-router-dom";
|
||||
import { Trash2, Terminal, RefreshCw, MoveRight, Building2, MapPin } from "lucide-react";
|
||||
import { Link, useSearchParams } from "react-router-dom";
|
||||
import { Trash2, Terminal, RefreshCw, MoveRight, X } from "lucide-react";
|
||||
import { agentsApi, sitesApi, Agent, Site } from "../api/client";
|
||||
import { Card, CardHeader, CardTitle, CardContent } from "../components/Card";
|
||||
import { Card, CardContent } from "../components/Card";
|
||||
import { Button } from "../components/Button";
|
||||
import { Input } from "../components/Input";
|
||||
|
||||
function AgentStatusBadge({ status }: { status: Agent["status"] }) {
|
||||
const colors = {
|
||||
online: "bg-green-100 text-green-800",
|
||||
offline: "bg-gray-100 text-gray-800",
|
||||
error: "bg-red-100 text-red-800",
|
||||
const statusConfig = {
|
||||
online: {
|
||||
dotClass: "bg-[var(--accent-green)] shadow-[0_0_8px_var(--accent-green)]",
|
||||
badgeClass: "bg-[var(--accent-green-muted)] text-[var(--accent-green-light)] border border-[rgba(16,185,129,0.3)]",
|
||||
animate: true,
|
||||
},
|
||||
offline: {
|
||||
dotClass: "bg-[var(--text-muted)]",
|
||||
badgeClass: "bg-[rgba(100,116,139,0.2)] text-[var(--text-muted)] border border-[rgba(100,116,139,0.3)]",
|
||||
animate: false,
|
||||
},
|
||||
error: {
|
||||
dotClass: "bg-[var(--accent-rose)] shadow-[0_0_8px_var(--accent-rose)]",
|
||||
badgeClass: "bg-[var(--accent-rose-muted)] text-[var(--accent-rose-light)] border border-[rgba(244,63,94,0.3)]",
|
||||
animate: true,
|
||||
},
|
||||
};
|
||||
|
||||
const config = statusConfig[status];
|
||||
|
||||
return (
|
||||
<span className={`px-2 py-1 rounded-full text-xs font-medium ${colors[status]}`}>
|
||||
<span className={`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full font-mono text-xs font-semibold uppercase tracking-wider ${config.badgeClass}`}>
|
||||
<span className={`w-2 h-2 rounded-full ${config.dotClass} ${config.animate ? "animate-pulse" : ""}`} />
|
||||
{status}
|
||||
</span>
|
||||
);
|
||||
@@ -37,36 +52,39 @@ function MoveAgentModal({
|
||||
const [selectedSiteId, setSelectedSiteId] = useState<string>(agent.site_id || "");
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 bg-black/50 flex items-center justify-center z-50">
|
||||
<div className="bg-[hsl(var(--card))] rounded-lg p-6 w-full max-w-md">
|
||||
<h2 className="text-xl font-bold mb-4">Move Agent</h2>
|
||||
<p className="text-[hsl(var(--muted-foreground))] mb-4">
|
||||
Move <strong>{agent.hostname}</strong> to a different site
|
||||
<div className="fixed inset-0 bg-black/70 backdrop-blur-sm flex items-center justify-center z-50">
|
||||
<div className="glass-card bg-[var(--glass-bg)] border border-[var(--glass-border)] rounded-xl p-6 w-full max-w-md shadow-xl">
|
||||
<h2 className="text-xl font-mono font-bold text-[var(--text-primary)] mb-2">Move Agent</h2>
|
||||
<p className="text-[var(--text-secondary)] mb-6">
|
||||
Move <strong className="text-[var(--accent-cyan)]">{agent.hostname}</strong> to a different site
|
||||
</p>
|
||||
|
||||
<div className="mb-4">
|
||||
<label className="block text-sm font-medium mb-2">Select Site</label>
|
||||
<div className="mb-6">
|
||||
<label className="block text-xs font-mono font-semibold text-[var(--text-muted)] uppercase tracking-wider mb-2">
|
||||
Select Site
|
||||
</label>
|
||||
<select
|
||||
value={selectedSiteId}
|
||||
onChange={(e) => setSelectedSiteId(e.target.value)}
|
||||
className="w-full px-3 py-2 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--background))] text-sm"
|
||||
className="w-full px-3 py-2.5 rounded-lg border border-[var(--border-primary)] bg-[var(--bg-secondary)] text-[var(--text-primary)] font-mono text-sm focus:border-[var(--accent-cyan)] focus:outline-none focus:ring-2 focus:ring-[var(--accent-cyan-muted)] transition-all"
|
||||
>
|
||||
<option value="">-- Unassigned --</option>
|
||||
{sites.map((site) => (
|
||||
<option key={site.id} value={site.id}>
|
||||
{site.client_name} → {site.name} ({site.site_code})
|
||||
{site.client_name} → {site.name} ({site.site_code})
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-end gap-2 pt-4">
|
||||
<div className="flex justify-end gap-3 pt-4 border-t border-[var(--border-secondary)]">
|
||||
<Button type="button" variant="ghost" onClick={onClose}>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => onMove(selectedSiteId || null)}
|
||||
disabled={isLoading || selectedSiteId === (agent.site_id || "")}
|
||||
className="btn-mission-control"
|
||||
>
|
||||
{isLoading ? "Moving..." : "Move Agent"}
|
||||
</Button>
|
||||
@@ -82,6 +100,8 @@ export function Agents() {
|
||||
const [movingAgent, setMovingAgent] = useState<Agent | null>(null);
|
||||
const [filterClient, setFilterClient] = useState<string>("");
|
||||
const [filterSite, setFilterSite] = useState<string>("");
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
const statusFilter = searchParams.get("status") || "";
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const { data: agents = [], isLoading, refetch } = useQuery({
|
||||
@@ -144,43 +164,56 @@ export function Agents() {
|
||||
}
|
||||
|
||||
const matchesSite = !filterSite || agent.site_id === filterSite;
|
||||
const matchesStatus = !statusFilter || agent.status === statusFilter;
|
||||
|
||||
return matchesSearch && matchesClient && matchesSite;
|
||||
return matchesSearch && matchesClient && matchesSite && matchesStatus;
|
||||
});
|
||||
|
||||
// Group agents by client > site for display
|
||||
const groupedAgents = filteredAgents.reduce((acc: Record<string, Record<string, Agent[]>>, agent: Agent) => {
|
||||
const clientKey = agent.client_name || "Unassigned";
|
||||
const siteKey = agent.site_name || "No Site";
|
||||
|
||||
if (!acc[clientKey]) acc[clientKey] = {};
|
||||
if (!acc[clientKey][siteKey]) acc[clientKey][siteKey] = [];
|
||||
acc[clientKey][siteKey].push(agent);
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
const clearStatusFilter = () => {
|
||||
searchParams.delete("status");
|
||||
setSearchParams(searchParams);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* Header */}
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold">Agents</h1>
|
||||
<p className="text-[hsl(var(--muted-foreground))]">
|
||||
<div className="flex items-center gap-3">
|
||||
<h1 className="text-3xl font-mono font-bold text-[var(--text-primary)]">Agents</h1>
|
||||
{statusFilter && (
|
||||
<button
|
||||
onClick={clearStatusFilter}
|
||||
className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-mono font-semibold bg-[var(--accent-cyan-muted)] text-[var(--accent-cyan)] border border-[var(--border-accent)] hover:bg-[var(--accent-cyan)] hover:text-[var(--bg-primary)] transition-all"
|
||||
>
|
||||
Status: {statusFilter}
|
||||
<X className="h-3 w-3" />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<p className="text-[var(--text-secondary)] mt-1">
|
||||
Manage your monitored endpoints
|
||||
</p>
|
||||
</div>
|
||||
<Button variant="outline" size="sm" onClick={() => refetch()}>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => refetch()}
|
||||
className="border-[var(--border-accent)] text-[var(--accent-cyan)] hover:bg-[var(--accent-cyan-muted)] hover:shadow-[var(--glow-cyan)] transition-all"
|
||||
>
|
||||
<RefreshCw className="h-4 w-4 mr-2" />
|
||||
Refresh
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{/* Filters */}
|
||||
<div className="glass-card bg-[var(--glass-bg)] border border-[var(--glass-border)] rounded-xl p-4">
|
||||
<div className="flex flex-wrap items-center gap-4">
|
||||
<Input
|
||||
placeholder="Search agents..."
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
className="max-w-sm"
|
||||
className="max-w-sm bg-[var(--bg-secondary)] border-[var(--border-primary)] text-[var(--text-primary)] font-mono placeholder:text-[var(--text-muted)] focus:border-[var(--accent-cyan)] focus:ring-[var(--accent-cyan-muted)]"
|
||||
/>
|
||||
<select
|
||||
value={filterClient}
|
||||
@@ -188,7 +221,7 @@ export function Agents() {
|
||||
setFilterClient(e.target.value);
|
||||
setFilterSite("");
|
||||
}}
|
||||
className="px-3 py-2 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--background))] text-sm"
|
||||
className="px-3 py-2 rounded-lg border border-[var(--border-primary)] bg-[var(--bg-secondary)] text-[var(--text-primary)] font-mono text-sm focus:border-[var(--accent-cyan)] focus:outline-none focus:ring-2 focus:ring-[var(--accent-cyan-muted)] transition-all"
|
||||
>
|
||||
<option value="">All Clients</option>
|
||||
<option value="__unassigned__">Unassigned Only</option>
|
||||
@@ -198,11 +231,11 @@ export function Agents() {
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
{filterClient && (
|
||||
{filterClient && filterClient !== "__unassigned__" && (
|
||||
<select
|
||||
value={filterSite}
|
||||
onChange={(e) => setFilterSite(e.target.value)}
|
||||
className="px-3 py-2 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--background))] text-sm"
|
||||
className="px-3 py-2 rounded-lg border border-[var(--border-primary)] bg-[var(--bg-secondary)] text-[var(--text-primary)] font-mono text-sm focus:border-[var(--accent-cyan)] focus:outline-none focus:ring-2 focus:ring-[var(--accent-cyan-muted)] transition-all"
|
||||
>
|
||||
<option value="">All Sites</option>
|
||||
{sites
|
||||
@@ -214,58 +247,68 @@ export function Agents() {
|
||||
))}
|
||||
</select>
|
||||
)}
|
||||
<select
|
||||
value={statusFilter}
|
||||
onChange={(e) => {
|
||||
if (e.target.value) {
|
||||
searchParams.set("status", e.target.value);
|
||||
} else {
|
||||
searchParams.delete("status");
|
||||
}
|
||||
setSearchParams(searchParams);
|
||||
}}
|
||||
className="px-3 py-2 rounded-lg border border-[var(--border-primary)] bg-[var(--bg-secondary)] text-[var(--text-primary)] font-mono text-sm focus:border-[var(--accent-cyan)] focus:outline-none focus:ring-2 focus:ring-[var(--accent-cyan-muted)] transition-all"
|
||||
>
|
||||
<option value="">All Statuses</option>
|
||||
<option value="online">Online</option>
|
||||
<option value="offline">Offline</option>
|
||||
<option value="error">Error</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Grouped View */}
|
||||
{Object.entries(groupedAgents).map(([clientName, siteGroups]) => (
|
||||
<Card key={clientName}>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center gap-2">
|
||||
<Building2 className="h-5 w-5" />
|
||||
{clientName}
|
||||
<span className="text-sm font-normal text-[hsl(var(--muted-foreground))]">
|
||||
({Object.values(siteGroups).flat().length} agents)
|
||||
</span>
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{Object.entries(siteGroups).map(([siteName, siteAgents]) => (
|
||||
<div key={siteName} className="mb-6 last:mb-0">
|
||||
<div className="flex items-center gap-2 mb-3 text-sm font-medium text-[hsl(var(--muted-foreground))]">
|
||||
<MapPin className="h-4 w-4" />
|
||||
{siteName}
|
||||
<span className="text-xs">({siteAgents.length} agents)</span>
|
||||
</div>
|
||||
{/* Flat Table View */}
|
||||
{filteredAgents.length > 0 && (
|
||||
<Card className="glass-card bg-[var(--glass-bg)] border border-[var(--glass-border)] rounded-xl overflow-hidden">
|
||||
<CardContent className="p-0">
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full">
|
||||
<table className="w-full data-grid">
|
||||
<thead>
|
||||
<tr className="border-b border-[hsl(var(--border))]">
|
||||
<th className="text-left py-2 px-4 font-medium text-sm">Hostname</th>
|
||||
<th className="text-left py-2 px-4 font-medium text-sm">OS</th>
|
||||
<th className="text-left py-2 px-4 font-medium text-sm">Status</th>
|
||||
<th className="text-left py-2 px-4 font-medium text-sm">Last Seen</th>
|
||||
<th className="text-left py-2 px-4 font-medium text-sm">Version</th>
|
||||
<th className="text-right py-2 px-4 font-medium text-sm">Actions</th>
|
||||
<tr className="border-b border-[var(--border-primary)]">
|
||||
<th className="text-left py-2 px-4 font-mono text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider bg-[var(--bg-tertiary)]">Hostname</th>
|
||||
<th className="text-left py-2 px-4 font-mono text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider bg-[var(--bg-tertiary)]">Client</th>
|
||||
<th className="text-left py-2 px-4 font-mono text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider bg-[var(--bg-tertiary)]">Site</th>
|
||||
<th className="text-left py-2 px-4 font-mono text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider bg-[var(--bg-tertiary)]">OS</th>
|
||||
<th className="text-left py-2 px-4 font-mono text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider bg-[var(--bg-tertiary)]">Status</th>
|
||||
<th className="text-left py-2 px-4 font-mono text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider bg-[var(--bg-tertiary)]">Last Seen</th>
|
||||
<th className="text-left py-2 px-4 font-mono text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider bg-[var(--bg-tertiary)]">Version</th>
|
||||
<th className="text-right py-2 px-4 font-mono text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider bg-[var(--bg-tertiary)]">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{siteAgents.map((agent: Agent) => (
|
||||
{filteredAgents.map((agent: Agent) => (
|
||||
<tr
|
||||
key={agent.id}
|
||||
className="border-b border-[hsl(var(--border))] hover:bg-[hsl(var(--muted))]/50"
|
||||
className="border-b border-[var(--border-secondary)] hover:bg-[rgba(6,182,212,0.05)] transition-colors"
|
||||
>
|
||||
<td className="py-2 px-4">
|
||||
<Link
|
||||
to={`/agents/${agent.id}`}
|
||||
className="font-medium hover:underline text-[hsl(var(--primary))]"
|
||||
className="font-mono font-medium text-[var(--accent-cyan)] hover:text-[var(--accent-cyan-light)] hover:underline transition-colors"
|
||||
>
|
||||
{agent.hostname}
|
||||
</Link>
|
||||
</td>
|
||||
<td className="py-2 px-4 text-sm">
|
||||
<td className="py-2 px-4 font-mono text-sm text-[var(--text-secondary)]">
|
||||
{agent.client_name || <span className="text-[var(--text-muted)]">-</span>}
|
||||
</td>
|
||||
<td className="py-2 px-4 font-mono text-sm text-[var(--text-secondary)]">
|
||||
{agent.site_name || <span className="text-[var(--text-muted)]">-</span>}
|
||||
</td>
|
||||
<td className="py-2 px-4 font-mono text-sm text-[var(--text-secondary)]">
|
||||
{agent.os_type}
|
||||
{agent.os_version && (
|
||||
<span className="text-[hsl(var(--muted-foreground))]">
|
||||
<span className="text-[var(--text-muted)]">
|
||||
{" "}({agent.os_version})
|
||||
</span>
|
||||
)}
|
||||
@@ -273,12 +316,12 @@ export function Agents() {
|
||||
<td className="py-2 px-4">
|
||||
<AgentStatusBadge status={agent.status} />
|
||||
</td>
|
||||
<td className="py-2 px-4 text-sm text-[hsl(var(--muted-foreground))]">
|
||||
<td className="py-2 px-4 font-mono text-sm text-[var(--text-muted)]">
|
||||
{agent.last_seen
|
||||
? new Date(agent.last_seen).toLocaleString()
|
||||
: "Never"}
|
||||
</td>
|
||||
<td className="py-2 px-4 text-sm text-[hsl(var(--muted-foreground))]">
|
||||
<td className="py-2 px-4 font-mono text-sm text-[var(--text-muted)]">
|
||||
{agent.agent_version || "-"}
|
||||
</td>
|
||||
<td className="py-2 px-4">
|
||||
@@ -288,11 +331,17 @@ export function Agents() {
|
||||
size="icon"
|
||||
title="Move to different site"
|
||||
onClick={() => setMovingAgent(agent)}
|
||||
className="text-[var(--text-muted)] hover:text-[var(--accent-cyan)] hover:bg-[var(--accent-cyan-muted)] transition-all"
|
||||
>
|
||||
<MoveRight className="h-4 w-4" />
|
||||
</Button>
|
||||
<Link to={`/agents/${agent.id}`}>
|
||||
<Button variant="ghost" size="icon" title="Open terminal">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
title="Open terminal"
|
||||
className="text-[var(--text-muted)] hover:text-[var(--accent-green)] hover:bg-[var(--accent-green-muted)] transition-all"
|
||||
>
|
||||
<Terminal className="h-4 w-4" />
|
||||
</Button>
|
||||
</Link>
|
||||
@@ -303,6 +352,7 @@ export function Agents() {
|
||||
size="sm"
|
||||
onClick={() => deleteMutation.mutate(agent.id)}
|
||||
disabled={deleteMutation.isPending}
|
||||
className="bg-[var(--accent-rose)] hover:bg-[var(--accent-rose-light)] hover:shadow-[var(--glow-rose)]"
|
||||
>
|
||||
Confirm
|
||||
</Button>
|
||||
@@ -310,6 +360,7 @@ export function Agents() {
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => setDeleteConfirm(null)}
|
||||
className="text-[var(--text-muted)] hover:text-[var(--text-primary)]"
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
@@ -320,6 +371,7 @@ export function Agents() {
|
||||
size="icon"
|
||||
title="Delete agent"
|
||||
onClick={() => setDeleteConfirm(agent.id)}
|
||||
className="text-[var(--text-muted)] hover:text-[var(--accent-rose)] hover:bg-[var(--accent-rose-muted)] transition-all"
|
||||
>
|
||||
<Trash2 className="h-4 w-4" />
|
||||
</Button>
|
||||
@@ -331,22 +383,40 @@ export function Agents() {
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</CardContent>
|
||||
</Card>
|
||||
))}
|
||||
)}
|
||||
|
||||
{isLoading && (
|
||||
<p className="text-[hsl(var(--muted-foreground))]">Loading agents...</p>
|
||||
<div className="glass-card bg-[var(--glass-bg)] border border-[var(--glass-border)] rounded-xl p-8 text-center">
|
||||
<div className="inline-flex items-center gap-3 text-[var(--text-secondary)]">
|
||||
<RefreshCw className="h-5 w-5 animate-spin text-[var(--accent-cyan)]" />
|
||||
<span className="font-mono">Loading agents...</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!isLoading && filteredAgents.length === 0 && (
|
||||
<Card>
|
||||
<CardContent className="py-8 text-center">
|
||||
<p className="text-[hsl(var(--muted-foreground))]">
|
||||
{search || filterClient ? "No agents match your filters." : "No agents registered yet."}
|
||||
<Card className="glass-card bg-[var(--glass-bg)] border border-[var(--glass-border)] rounded-xl">
|
||||
<CardContent className="py-12 text-center">
|
||||
<p className="text-[var(--text-muted)] font-mono">
|
||||
{search || filterClient || statusFilter
|
||||
? "No agents match your filters."
|
||||
: "No agents registered yet."}
|
||||
</p>
|
||||
{(search || filterClient || statusFilter) && (
|
||||
<button
|
||||
onClick={() => {
|
||||
setSearch("");
|
||||
setFilterClient("");
|
||||
setFilterSite("");
|
||||
clearStatusFilter();
|
||||
}}
|
||||
className="mt-4 text-[var(--accent-cyan)] hover:text-[var(--accent-cyan-light)] font-mono text-sm underline transition-colors"
|
||||
>
|
||||
Clear all filters
|
||||
</button>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { RefreshCw, CheckCircle, XCircle, Clock, Play } from "lucide-react";
|
||||
import { commandsApi, Command } from "../api/client";
|
||||
import { Card, CardHeader, CardTitle, CardContent } from "../components/Card";
|
||||
import { Button } from "../components/Button";
|
||||
|
||||
function StatusIcon({ status }: { status: Command["status"] }) {
|
||||
const icons = {
|
||||
pending: <Clock className="h-4 w-4 text-yellow-500" />,
|
||||
running: <Play className="h-4 w-4 text-blue-500" />,
|
||||
completed: <CheckCircle className="h-4 w-4 text-green-500" />,
|
||||
failed: <XCircle className="h-4 w-4 text-red-500" />,
|
||||
};
|
||||
return icons[status];
|
||||
}
|
||||
|
||||
export function Commands() {
|
||||
const { data: commands = [], isLoading, refetch } = useQuery({
|
||||
queryKey: ["commands"],
|
||||
queryFn: () => commandsApi.list().then((res) => res.data),
|
||||
refetchInterval: 10000,
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold">Commands</h1>
|
||||
<p className="text-[hsl(var(--muted-foreground))]">
|
||||
View command history and results
|
||||
</p>
|
||||
</div>
|
||||
<Button variant="outline" size="sm" onClick={() => refetch()}>
|
||||
<RefreshCw className="h-4 w-4 mr-2" />
|
||||
Refresh
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Command History</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{isLoading ? (
|
||||
<p className="text-[hsl(var(--muted-foreground))]">Loading commands...</p>
|
||||
) : commands.length === 0 ? (
|
||||
<p className="text-[hsl(var(--muted-foreground))]">
|
||||
No commands have been executed yet.
|
||||
</p>
|
||||
) : (
|
||||
<div className="space-y-4">
|
||||
{commands.map((cmd: Command) => (
|
||||
<div
|
||||
key={cmd.id}
|
||||
className="border border-[hsl(var(--border))] rounded-lg p-4"
|
||||
>
|
||||
<div className="flex items-start justify-between">
|
||||
<div className="flex items-center gap-3">
|
||||
<StatusIcon status={cmd.status} />
|
||||
<div>
|
||||
<p className="font-mono text-sm">{cmd.command_text}</p>
|
||||
<p className="text-xs text-[hsl(var(--muted-foreground))] mt-1">
|
||||
{cmd.command_type} • Agent: {cmd.agent_id.slice(0, 8)}... •{" "}
|
||||
{new Date(cmd.created_at).toLocaleString()}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<span
|
||||
className={`px-2 py-1 rounded text-xs font-medium ${
|
||||
cmd.status === "completed"
|
||||
? "bg-green-100 text-green-800"
|
||||
: cmd.status === "failed"
|
||||
? "bg-red-100 text-red-800"
|
||||
: cmd.status === "running"
|
||||
? "bg-blue-100 text-blue-800"
|
||||
: "bg-yellow-100 text-yellow-800"
|
||||
}`}
|
||||
>
|
||||
{cmd.status}
|
||||
{cmd.exit_code !== null && ` (${cmd.exit_code})`}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{(cmd.stdout || cmd.stderr) && (
|
||||
<div className="mt-3 space-y-2">
|
||||
{cmd.stdout && (
|
||||
<div>
|
||||
<p className="text-xs font-medium text-[hsl(var(--muted-foreground))] mb-1">
|
||||
Output:
|
||||
</p>
|
||||
<pre className="text-xs bg-[hsl(var(--muted))] p-2 rounded overflow-x-auto">
|
||||
{cmd.stdout}
|
||||
</pre>
|
||||
</div>
|
||||
)}
|
||||
{cmd.stderr && (
|
||||
<div>
|
||||
<p className="text-xs font-medium text-red-600 mb-1">Error:</p>
|
||||
<pre className="text-xs bg-red-50 text-red-800 p-2 rounded overflow-x-auto">
|
||||
{cmd.stderr}
|
||||
</pre>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { Link } from "react-router-dom";
|
||||
import {
|
||||
Activity,
|
||||
Server,
|
||||
@@ -9,6 +11,7 @@ import {
|
||||
RefreshCw,
|
||||
Shield,
|
||||
Zap,
|
||||
ArrowRight,
|
||||
} from "lucide-react";
|
||||
import { agentsApi, Agent } from "../api/client";
|
||||
|
||||
@@ -60,7 +63,7 @@ function StatCardSkeleton({ delay }: { delay: number }) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Stat card component with Mission Control styling
|
||||
* Stat card component with Mission Control styling - navigates to filtered agents page on click
|
||||
*/
|
||||
function StatCard({
|
||||
title,
|
||||
@@ -69,6 +72,7 @@ function StatCard({
|
||||
description,
|
||||
accentColor,
|
||||
delay,
|
||||
linkTo,
|
||||
}: {
|
||||
title: string;
|
||||
value: string | number;
|
||||
@@ -76,47 +80,59 @@ function StatCard({
|
||||
description?: string;
|
||||
accentColor: "cyan" | "green" | "amber" | "rose";
|
||||
delay: number;
|
||||
linkTo: string;
|
||||
}) {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const colorClasses = {
|
||||
cyan: {
|
||||
icon: "text-cyan",
|
||||
glow: "glow-cyan",
|
||||
bg: "bg-[var(--accent-cyan-muted)]",
|
||||
border: "border-l-[var(--accent-cyan)]",
|
||||
value: "text-cyan",
|
||||
},
|
||||
green: {
|
||||
icon: "text-green",
|
||||
glow: "glow-green",
|
||||
bg: "bg-[var(--accent-green-muted)]",
|
||||
border: "border-l-[var(--accent-green)]",
|
||||
value: "text-green",
|
||||
},
|
||||
amber: {
|
||||
icon: "text-amber",
|
||||
glow: "glow-amber",
|
||||
bg: "bg-[var(--accent-amber-muted)]",
|
||||
border: "border-l-[var(--accent-amber)]",
|
||||
value: "text-amber",
|
||||
},
|
||||
rose: {
|
||||
icon: "text-rose",
|
||||
glow: "glow-rose",
|
||||
bg: "bg-[var(--accent-rose-muted)]",
|
||||
border: "border-l-[var(--accent-rose)]",
|
||||
value: "text-rose",
|
||||
},
|
||||
};
|
||||
|
||||
const colors = colorClasses[accentColor];
|
||||
|
||||
const handleClick = () => {
|
||||
navigate(linkTo);
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
className="glass-card relative overflow-hidden opacity-0 border-l-4 group cursor-default"
|
||||
className="glass-card relative overflow-hidden opacity-0 border-l-4 group cursor-pointer transition-transform duration-200 hover:scale-[1.02]"
|
||||
style={{
|
||||
animation: `fadeInUp 0.4s ease-out ${delay}s forwards`,
|
||||
borderLeftColor: `var(--accent-${accentColor})`,
|
||||
}}
|
||||
onClick={handleClick}
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter" || e.key === " ") {
|
||||
e.preventDefault();
|
||||
handleClick();
|
||||
}
|
||||
}}
|
||||
>
|
||||
{/* Subtle gradient overlay on hover */}
|
||||
<div
|
||||
@@ -126,24 +142,34 @@ function StatCard({
|
||||
}}
|
||||
/>
|
||||
|
||||
<div className="relative flex items-start justify-between">
|
||||
<div className="space-y-1">
|
||||
<div className="relative">
|
||||
<div className="flex items-start justify-between">
|
||||
<div>
|
||||
<p className="text-muted font-mono text-xs uppercase tracking-widest-custom">
|
||||
{title}
|
||||
</p>
|
||||
<p className={`font-mono text-4xl font-bold ${colors.value}`}>
|
||||
<p className={`font-mono text-3xl font-bold ${colors.value} mt-1`}>
|
||||
{value}
|
||||
</p>
|
||||
{description && (
|
||||
<p className="text-muted text-sm">{description}</p>
|
||||
<p className="text-muted text-xs mt-0.5">{description}</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Icon with glow effect */}
|
||||
{/* Icon - smaller padding */}
|
||||
<div
|
||||
className={`p-3 rounded-lg ${colors.bg} ${colors.glow} transition-all duration-300 group-hover:scale-110`}
|
||||
className={`p-2 rounded-lg ${colors.bg} ${colors.glow} transition-all duration-300 group-hover:scale-110`}
|
||||
>
|
||||
<Icon className={`h-6 w-6 ${colors.icon}`} />
|
||||
<Icon className={`h-5 w-5 ${colors.icon}`} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Simplified view all - no border */}
|
||||
<div className="mt-3 flex items-center justify-between opacity-60 group-hover:opacity-100 transition-opacity">
|
||||
<span className="text-muted text-xs font-mono">View all</span>
|
||||
<ArrowRight
|
||||
className={`h-3 w-3 ${colors.icon} group-hover:translate-x-1 transition-transform`}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -168,12 +194,15 @@ function StatusDot({ status }: { status: string }) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Activity list item with hover effects
|
||||
* Activity list item with hover effects - clickable with Link
|
||||
*/
|
||||
function ActivityItem({ agent }: { agent: Agent }) {
|
||||
return (
|
||||
<div className="flex items-center justify-between p-3 rounded-lg transition-all duration-200 hover:bg-[rgba(6,182,212,0.05)] group cursor-default">
|
||||
<div className="flex items-center gap-4">
|
||||
<Link
|
||||
to={`/agents/${agent.id}`}
|
||||
className="flex items-center justify-between p-2 rounded-lg transition-all duration-200 hover:bg-[rgba(6,182,212,0.08)] group cursor-pointer"
|
||||
>
|
||||
<div className="flex items-center gap-3">
|
||||
<StatusDot status={agent.status} />
|
||||
<div>
|
||||
<p className="font-mono text-sm font-medium text-primary group-hover:text-cyan transition-colors">
|
||||
@@ -184,10 +213,13 @@ function ActivityItem({ agent }: { agent: Agent }) {
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
<span className="font-mono text-xs text-muted tabular-nums">
|
||||
{formatRelativeTime(agent.last_seen)}
|
||||
</span>
|
||||
<ArrowRight className="h-4 w-4 text-muted opacity-0 group-hover:opacity-100 group-hover:text-cyan transition-all duration-200 transform group-hover:translate-x-1" />
|
||||
</div>
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -243,6 +275,10 @@ function ActivityListSkeleton() {
|
||||
|
||||
/**
|
||||
* Main Dashboard component with Mission Control aesthetic
|
||||
*
|
||||
* Stat cards navigate to the Agents page with status filters.
|
||||
* This approach scales better for large agent counts (1000+) since
|
||||
* the Agents page handles pagination, search, and sorting.
|
||||
*/
|
||||
export function Dashboard() {
|
||||
const { data: agents = [], isLoading } = useQuery({
|
||||
@@ -270,12 +306,12 @@ export function Dashboard() {
|
||||
: "status-online";
|
||||
|
||||
return (
|
||||
<div className="space-y-8">
|
||||
<div className="space-y-5">
|
||||
{/* Page Header */}
|
||||
<header className="space-y-2 animate-fade-in">
|
||||
<header className="space-y-1 animate-fade-in">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 className="text-gradient font-mono text-4xl font-bold tracking-tight">
|
||||
<h1 className="text-gradient font-mono text-3xl font-bold tracking-tight">
|
||||
DASHBOARD
|
||||
</h1>
|
||||
<p className="text-muted text-sm uppercase tracking-widest-custom mt-1">
|
||||
@@ -294,7 +330,7 @@ export function Dashboard() {
|
||||
</header>
|
||||
|
||||
{/* Stat Cards Grid */}
|
||||
<section className="grid gap-4 md:grid-cols-2 lg:grid-cols-4">
|
||||
<section className="grid gap-3 md:grid-cols-2 lg:grid-cols-4">
|
||||
{isLoading ? (
|
||||
<>
|
||||
<StatCardSkeleton delay={0.1} />
|
||||
@@ -311,6 +347,7 @@ export function Dashboard() {
|
||||
description="Registered endpoints"
|
||||
accentColor="cyan"
|
||||
delay={0.1}
|
||||
linkTo="/agents"
|
||||
/>
|
||||
<StatCard
|
||||
title="Online"
|
||||
@@ -319,6 +356,7 @@ export function Dashboard() {
|
||||
description="Currently connected"
|
||||
accentColor="green"
|
||||
delay={0.2}
|
||||
linkTo="/agents?status=online"
|
||||
/>
|
||||
<StatCard
|
||||
title="Offline"
|
||||
@@ -327,6 +365,7 @@ export function Dashboard() {
|
||||
description="Not responding"
|
||||
accentColor="amber"
|
||||
delay={0.3}
|
||||
linkTo="/agents?status=offline"
|
||||
/>
|
||||
<StatCard
|
||||
title="Errors"
|
||||
@@ -335,13 +374,14 @@ export function Dashboard() {
|
||||
description="Requires attention"
|
||||
accentColor="rose"
|
||||
delay={0.4}
|
||||
linkTo="/agents?status=error"
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</section>
|
||||
|
||||
{/* Bottom Grid: Activity + Quick Actions */}
|
||||
<section className="grid gap-6 md:grid-cols-2">
|
||||
<section className="grid gap-4 md:grid-cols-2">
|
||||
{/* Recent Activity Card */}
|
||||
<div
|
||||
className="glass-card opacity-0"
|
||||
@@ -349,7 +389,7 @@ export function Dashboard() {
|
||||
animation: "fadeInUp 0.4s ease-out 0.5s forwards",
|
||||
}}
|
||||
>
|
||||
<div className="flex items-center justify-between mb-4 pb-4 border-b border-[var(--border-secondary)]">
|
||||
<div className="flex items-center justify-between mb-3 pb-3 border-b border-[var(--border-secondary)]">
|
||||
<h2 className="card-title flex items-center gap-2">
|
||||
<Activity className="h-4 w-4 text-cyan" />
|
||||
Recent Activity
|
||||
@@ -374,7 +414,7 @@ export function Dashboard() {
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-1 -mx-3">
|
||||
<div className="space-y-0.5 -mx-2">
|
||||
{agents.slice(0, 5).map((agent: Agent) => (
|
||||
<ActivityItem key={agent.id} agent={agent} />
|
||||
))}
|
||||
@@ -389,12 +429,12 @@ export function Dashboard() {
|
||||
animation: "fadeInUp 0.4s ease-out 0.6s forwards",
|
||||
}}
|
||||
>
|
||||
<div className="flex items-center gap-2 mb-4 pb-4 border-b border-[var(--border-secondary)]">
|
||||
<div className="flex items-center gap-2 mb-3 pb-3 border-b border-[var(--border-secondary)]">
|
||||
<Zap className="h-4 w-4 text-cyan" />
|
||||
<h2 className="card-title">Quick Actions</h2>
|
||||
</div>
|
||||
|
||||
<div className="space-y-3">
|
||||
<div className="space-y-2">
|
||||
<QuickActionButton
|
||||
icon={Terminal}
|
||||
label="Deploy Agent"
|
||||
@@ -413,7 +453,7 @@ export function Dashboard() {
|
||||
</div>
|
||||
|
||||
{/* Terminal-style hint */}
|
||||
<div className="mt-6 p-3 rounded-lg bg-[var(--bg-primary)] border border-[var(--border-secondary)]">
|
||||
<div className="mt-4 p-2 rounded-lg bg-[var(--bg-primary)] border border-[var(--border-secondary)]">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="font-mono text-xs text-cyan">$</span>
|
||||
<span className="font-mono text-xs text-muted">
|
||||
|
||||
281
projects/msp-tools/guru-rmm/dashboard/src/pages/History.tsx
Normal file
281
projects/msp-tools/guru-rmm/dashboard/src/pages/History.tsx
Normal file
@@ -0,0 +1,281 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { Link, useParams, useNavigate } from "react-router-dom";
|
||||
import { RefreshCw, CheckCircle, XCircle, Clock, Loader2, ArrowLeft, Terminal } from "lucide-react";
|
||||
import { commandsApi, Command } from "../api/client";
|
||||
import { Card, CardContent } from "../components/Card";
|
||||
import { Button } from "../components/Button";
|
||||
|
||||
function StatusBadge({ status }: { status: Command["status"] }) {
|
||||
const config = {
|
||||
pending: {
|
||||
icon: Clock,
|
||||
label: "Pending",
|
||||
className: "bg-amber-500/10 text-amber-400 border-amber-500/30",
|
||||
},
|
||||
running: {
|
||||
icon: Loader2,
|
||||
label: "Running",
|
||||
className: "bg-cyan-500/10 text-cyan-400 border-cyan-500/30",
|
||||
spin: true,
|
||||
},
|
||||
completed: {
|
||||
icon: CheckCircle,
|
||||
label: "Completed",
|
||||
className: "bg-emerald-500/10 text-emerald-400 border-emerald-500/30",
|
||||
},
|
||||
failed: {
|
||||
icon: XCircle,
|
||||
label: "Failed",
|
||||
className: "bg-rose-500/10 text-rose-400 border-rose-500/30",
|
||||
},
|
||||
};
|
||||
|
||||
const { icon: Icon, label, className, spin } = config[status] as {
|
||||
icon: typeof Clock;
|
||||
label: string;
|
||||
className: string;
|
||||
spin?: boolean;
|
||||
};
|
||||
|
||||
return (
|
||||
<span className={`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-mono font-medium border ${className}`}>
|
||||
<Icon className={`h-3 w-3 ${spin ? "animate-spin" : ""}`} />
|
||||
{label}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
function formatDate(dateString: string): string {
|
||||
const date = new Date(dateString);
|
||||
return date.toLocaleString();
|
||||
}
|
||||
|
||||
function formatRelativeTime(dateString: string): string {
|
||||
const date = new Date(dateString);
|
||||
const now = new Date();
|
||||
const diffInSeconds = Math.floor((now.getTime() - date.getTime()) / 1000);
|
||||
|
||||
if (diffInSeconds < 60) return "Just now";
|
||||
if (diffInSeconds < 3600) return `${Math.floor(diffInSeconds / 60)}m ago`;
|
||||
if (diffInSeconds < 86400) return `${Math.floor(diffInSeconds / 3600)}h ago`;
|
||||
return `${Math.floor(diffInSeconds / 86400)}d ago`;
|
||||
}
|
||||
|
||||
export function History() {
|
||||
const { data: commands = [], isLoading, refetch } = useQuery({
|
||||
queryKey: ["commands"],
|
||||
queryFn: () => commandsApi.list().then((res) => res.data),
|
||||
refetchInterval: 10000,
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
{/* Header */}
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 className="text-2xl font-mono font-bold text-[var(--text-primary)]">History</h1>
|
||||
<p className="text-[var(--text-muted)] text-sm">Command execution log</p>
|
||||
</div>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => refetch()}
|
||||
className="border-[var(--border-accent)] text-[var(--accent-cyan)] hover:bg-[var(--accent-cyan-muted)]"
|
||||
>
|
||||
<RefreshCw className="h-4 w-4 mr-2" />
|
||||
Refresh
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{/* History List */}
|
||||
<Card className="glass-card bg-[var(--glass-bg)] border border-[var(--glass-border)] rounded-xl overflow-hidden">
|
||||
<CardContent className="p-0">
|
||||
{isLoading ? (
|
||||
<div className="p-8 text-center">
|
||||
<Loader2 className="h-6 w-6 animate-spin text-[var(--accent-cyan)] mx-auto mb-2" />
|
||||
<p className="text-[var(--text-muted)] font-mono text-sm">Loading history...</p>
|
||||
</div>
|
||||
) : commands.length === 0 ? (
|
||||
<div className="p-8 text-center">
|
||||
<Terminal className="h-8 w-8 text-[var(--text-muted)] mx-auto mb-2 opacity-50" />
|
||||
<p className="text-[var(--text-muted)] font-mono text-sm">No commands executed yet</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="divide-y divide-[var(--border-secondary)]">
|
||||
{commands.map((cmd: Command) => (
|
||||
<Link
|
||||
key={cmd.id}
|
||||
to={`/history/${cmd.id}`}
|
||||
className="flex items-center justify-between p-3 hover:bg-[rgba(6,182,212,0.05)] transition-colors group"
|
||||
>
|
||||
<div className="flex items-center gap-3 min-w-0 flex-1">
|
||||
<StatusBadge status={cmd.status} />
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="font-mono text-sm text-[var(--text-primary)] truncate group-hover:text-[var(--accent-cyan)] transition-colors">
|
||||
{cmd.command_text}
|
||||
</p>
|
||||
<p className="text-xs text-[var(--text-muted)] mt-0.5">
|
||||
{cmd.command_type} | Agent: {cmd.agent_id.slice(0, 8)}...
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="text-right pl-4 shrink-0">
|
||||
<p className="font-mono text-xs text-[var(--text-muted)]">
|
||||
{formatRelativeTime(cmd.created_at)}
|
||||
</p>
|
||||
{cmd.exit_code !== null && (
|
||||
<p className={`text-xs font-mono ${cmd.exit_code === 0 ? "text-emerald-500" : "text-rose-500"}`}>
|
||||
exit: {cmd.exit_code}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function HistoryDetail() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const { data: commands = [], isLoading } = useQuery({
|
||||
queryKey: ["commands"],
|
||||
queryFn: () => commandsApi.list().then((res) => res.data),
|
||||
});
|
||||
|
||||
const command = commands.find((cmd: Command) => cmd.id === id);
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center min-h-[50vh]">
|
||||
<Loader2 className="h-8 w-8 animate-spin text-[var(--accent-cyan)]" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!command) {
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<Button
|
||||
variant="ghost"
|
||||
onClick={() => navigate("/history")}
|
||||
className="text-[var(--text-muted)] hover:text-[var(--accent-cyan)]"
|
||||
>
|
||||
<ArrowLeft className="h-4 w-4 mr-2" />
|
||||
Back to History
|
||||
</Button>
|
||||
<Card className="glass-card">
|
||||
<CardContent className="p-8 text-center">
|
||||
<p className="text-[var(--text-muted)]">Command not found</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
{/* Header */}
|
||||
<div className="flex items-center gap-4">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={() => navigate("/history")}
|
||||
className="text-[var(--text-muted)] hover:text-[var(--accent-cyan)] hover:bg-[var(--accent-cyan-muted)]"
|
||||
>
|
||||
<ArrowLeft className="h-5 w-5" />
|
||||
</Button>
|
||||
<div className="flex-1">
|
||||
<div className="flex items-center gap-3">
|
||||
<h1 className="text-xl font-mono font-bold text-[var(--text-primary)]">Command Detail</h1>
|
||||
<StatusBadge status={command.status} />
|
||||
</div>
|
||||
<p className="text-[var(--text-muted)] text-sm mt-0.5">
|
||||
{formatDate(command.created_at)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Command Info */}
|
||||
<Card className="glass-card bg-[var(--glass-bg)] border border-[var(--glass-border)] rounded-xl">
|
||||
<CardContent className="p-4 space-y-4">
|
||||
{/* Command */}
|
||||
<div>
|
||||
<label className="text-xs font-mono font-semibold text-[var(--text-muted)] uppercase tracking-wider">
|
||||
Command
|
||||
</label>
|
||||
<div className="mt-1 p-3 rounded-lg bg-[var(--bg-primary)] border border-[var(--border-secondary)] font-mono text-sm text-[var(--accent-cyan)]">
|
||||
{command.command_text}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Meta info */}
|
||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
|
||||
<div>
|
||||
<label className="text-xs font-mono font-semibold text-[var(--text-muted)] uppercase tracking-wider">
|
||||
Type
|
||||
</label>
|
||||
<p className="mt-1 font-mono text-sm text-[var(--text-secondary)]">{command.command_type}</p>
|
||||
</div>
|
||||
<div>
|
||||
<label className="text-xs font-mono font-semibold text-[var(--text-muted)] uppercase tracking-wider">
|
||||
Agent
|
||||
</label>
|
||||
<Link
|
||||
to={`/agents/${command.agent_id}`}
|
||||
className="mt-1 block font-mono text-sm text-[var(--accent-cyan)] hover:underline"
|
||||
>
|
||||
{command.agent_id.slice(0, 12)}...
|
||||
</Link>
|
||||
</div>
|
||||
<div>
|
||||
<label className="text-xs font-mono font-semibold text-[var(--text-muted)] uppercase tracking-wider">
|
||||
Exit Code
|
||||
</label>
|
||||
<p className={`mt-1 font-mono text-sm ${command.exit_code === 0 ? "text-emerald-400" : command.exit_code !== null ? "text-rose-400" : "text-[var(--text-muted)]"}`}>
|
||||
{command.exit_code !== null ? command.exit_code : "-"}
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<label className="text-xs font-mono font-semibold text-[var(--text-muted)] uppercase tracking-wider">
|
||||
Executed
|
||||
</label>
|
||||
<p className="mt-1 font-mono text-sm text-[var(--text-secondary)]">
|
||||
{formatRelativeTime(command.created_at)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Output */}
|
||||
{command.stdout && (
|
||||
<div>
|
||||
<label className="text-xs font-mono font-semibold text-[var(--text-muted)] uppercase tracking-wider">
|
||||
Output
|
||||
</label>
|
||||
<pre className="mt-1 p-3 rounded-lg bg-[var(--bg-primary)] border border-[var(--border-secondary)] font-mono text-xs text-[var(--text-secondary)] overflow-x-auto max-h-64 overflow-y-auto">
|
||||
{command.stdout}
|
||||
</pre>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Error */}
|
||||
{command.stderr && (
|
||||
<div>
|
||||
<label className="text-xs font-mono font-semibold text-rose-400 uppercase tracking-wider">
|
||||
Error Output
|
||||
</label>
|
||||
<pre className="mt-1 p-3 rounded-lg bg-rose-500/5 border border-rose-500/20 font-mono text-xs text-rose-300 overflow-x-auto max-h-64 overflow-y-auto">
|
||||
{command.stderr}
|
||||
</pre>
|
||||
</div>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user