9d32ef7fd6
Backend: - Migration 0003_job_error: adds error_message and error_code columns to jobs table - models/job.go: add ErrorMessage, ErrorCode fields to Job struct; SetError method; update all SELECT queries - models/job_log.go: GetAllFiltered also reads error_message and error_code (via Job embed) - syncengine/engine.go: setJobError() helper; capture errors at Wol timeout (wol_timeout), rsync error (rsync_error), and exit_code failure points - api/dto.go: add ErrorMessage and ErrorCode to JobResponse - api/handlers_jobs.go: jobToResp propagates error fields Frontend: - api/client.ts: add error_message? and error_code? to Job interface - lib/status.ts: add ERROR_CODES map with friendly titles/hints; getErrorCodeInfo() - components/ErrorDetailsModal.tsx: new modal showing error title, hint, full message, job metadata, and stderr log; copy-all and download-log buttons - pages/JobDetail.tsx: error banner for failed jobs with title/hint; View error button opens ErrorDetailsModal; SSE updates error_message in real-time
98 lines
3.6 KiB
Go
98 lines
3.6 KiB
Go
package api
|
|
|
|
type MachineRequest struct {
|
|
Name string `json:"name"`
|
|
Host string `json:"host"`
|
|
Port int `json:"port"`
|
|
SSHUser string `json:"ssh_user"`
|
|
SSHKeyID *int64 `json:"ssh_key_id"`
|
|
MACAddress *string `json:"mac_address"`
|
|
WoLEnabled bool `json:"wol_enabled"`
|
|
BroadcastAddr *string `json:"broadcast_addr"`
|
|
WakeTimeoutSeconds int `json:"wake_timeout_seconds"`
|
|
WakeCheckIntervalSeconds int `json:"wake_check_interval_seconds"`
|
|
}
|
|
|
|
type MachineResponse struct {
|
|
ID int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
Host string `json:"host"`
|
|
Port int `json:"port"`
|
|
SSHUser string `json:"ssh_user"`
|
|
SSHKeyID *int64 `json:"ssh_key_id"`
|
|
MACAddress *string `json:"mac_address"`
|
|
WoLEnabled bool `json:"wol_enabled"`
|
|
BroadcastAddr *string `json:"broadcast_addr"`
|
|
WakeTimeoutSeconds int `json:"wake_timeout_seconds"`
|
|
WakeCheckIntervalSeconds int `json:"wake_check_interval_seconds"`
|
|
FingerprintConfirmed bool `json:"fingerprint_confirmed"`
|
|
Status string `json:"status"`
|
|
}
|
|
|
|
type SyncPairRequest struct {
|
|
Name string `json:"name"`
|
|
SourceMachineID *int64 `json:"source_machine_id"`
|
|
SourcePath string `json:"source_path"`
|
|
DestMachineID *int64 `json:"dest_machine_id"`
|
|
DestPath string `json:"dest_path"`
|
|
Direction string `json:"direction"`
|
|
RsyncFlags string `json:"rsync_flags"`
|
|
ExcludePatterns string `json:"exclude_patterns"`
|
|
Enabled bool `json:"enabled"`
|
|
}
|
|
|
|
type SyncPairResponse struct {
|
|
ID int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
SourceMachineID *int64 `json:"source_machine_id"`
|
|
SourcePath string `json:"source_path"`
|
|
DestMachineID *int64 `json:"dest_machine_id"`
|
|
DestPath string `json:"dest_path"`
|
|
Direction string `json:"direction"`
|
|
RsyncFlags string `json:"rsync_flags"`
|
|
ExcludePatterns string `json:"exclude_patterns"`
|
|
Enabled bool `json:"enabled"`
|
|
}
|
|
|
|
type JobResponse struct {
|
|
ID int64 `json:"id"`
|
|
SyncPairID int64 `json:"sync_pair_id"`
|
|
TriggerType string `json:"trigger_type"`
|
|
Status string `json:"status"`
|
|
StartedAt *string `json:"started_at"`
|
|
FinishedAt *string `json:"finished_at"`
|
|
LogFile *string `json:"log_file"`
|
|
ErrorMessage *string `json:"error_message,omitempty"`
|
|
ErrorCode *string `json:"error_code,omitempty"`
|
|
DurationSeconds *int64 `json:"duration_seconds,omitempty"`
|
|
LogLineCount *int64 `json:"log_line_count,omitempty"`
|
|
}
|
|
|
|
type LogLineResponse struct {
|
|
ID int64 `json:"id"`
|
|
JobID int64 `json:"job_id"`
|
|
Stream string `json:"stream"`
|
|
Content string `json:"content"`
|
|
Timestamp string `json:"timestamp"`
|
|
}
|
|
|
|
type SSHKeyRequest struct {
|
|
Label string `json:"label"`
|
|
Generate bool `json:"generate"`
|
|
PublicKey string `json:"public_key"`
|
|
}
|
|
|
|
type SSHKeyResponse struct {
|
|
ID int64 `json:"id"`
|
|
Label string `json:"label"`
|
|
PublicKey string `json:"public_key"`
|
|
Fingerprint string `json:"fingerprint"`
|
|
InUse bool `json:"in_use"`
|
|
HasPrivateKey bool `json:"has_private_key"`
|
|
CreatedAt string `json:"created_at"`
|
|
}
|
|
|
|
type ErrorResponse struct {
|
|
Error string `json:"error"`
|
|
}
|