Add shutdown machine feature with configurable command

Backend:
- New migration: add shutdown_command TEXT column to machines table
- Machine model updated with ShutdownCommand field (Create/GetAll/GetByID/Update)
- MachineRequest/MachineResponse DTOs updated with shutdown_command field
- New ShutdownResponse DTO
- New POST /api/machines/{id}/shutdown handler via SSH
- Refactor sshmanager/testconn.go: extract dialSSH() helper shared with shutdown.go
- New sshmanager/shutdown.go: RunRemoteCommand with 15s timeout

Frontend:
- New shutdownMachine() API helper and ShutdownResponse type in client.ts
- New shutdown_command field in MachineForm
- Power button (amber) in machines table actions
- Shutdown confirmation modal with WoL warning notice
- shutdown_command input field in machine edit/create form
- Machine interface updated with shutdown_command and last_seen_at fields
This commit is contained in:
2026-07-13 10:02:18 -04:00
parent bf9bcccde2
commit bc3bc44c4a
11 changed files with 282 additions and 32 deletions
+12 -4
View File
@@ -11,6 +11,7 @@ type MachineRequest struct {
BroadcastAddr *string `json:"broadcast_addr"`
WakeTimeoutSeconds int `json:"wake_timeout_seconds"`
WakeCheckIntervalSeconds int `json:"wake_check_interval_seconds"`
ShutdownCommand string `json:"shutdown_command,omitempty"`
}
type MachineResponse struct {
@@ -30,13 +31,20 @@ type MachineResponse struct {
Status string `json:"status"`
LastSeenAt *string `json:"last_seen_at"`
CreatedAt string `json:"created_at"`
ShutdownCommand string `json:"shutdown_command"`
}
type TestConnectionResponse struct {
Success bool `json:"success"`
Output string `json:"output,omitempty"`
Error string `json:"error,omitempty"`
Fingerprint string `json:"fingerprint,omitempty"`
Success bool `json:"success"`
Output string `json:"output,omitempty"`
Error string `json:"error,omitempty"`
Fingerprint string `json:"fingerprint,omitempty"`
}
type ShutdownResponse struct {
Success bool `json:"success"`
Output string `json:"output,omitempty"`
Error string `json:"error,omitempty"`
}
type SyncPairRequest struct {