Some checks failed
Release / build (push) Failing after 19s
Full Syncthing tray wrapper with: - System tray with 5 icon states (idle/syncing/paused/error/disconnected) - Syncthing REST API client with auto-discovered API key - Long-polling event listener for real-time status - Transfer rate monitoring, folder tracking, recent files, conflict counting - Full context menu with folders, recent files, settings toggles - Embedded admin panel binary (webview, requires CGO) - OS notifications via beeep (per-event configurable) - Syncthing process management with auto-restart - Cross-platform installer with autostart - CI pipeline for Linux (.deb + .tar.gz) and Windows (.zip) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
65 lines
1.3 KiB
Go
65 lines
1.3 KiB
Go
package monitor
|
|
|
|
import (
|
|
"time"
|
|
|
|
"git.davoryn.de/calic/syncwarden/internal/icons"
|
|
)
|
|
|
|
// AggregateStatus holds the full aggregated status for the tray.
|
|
type AggregateStatus struct {
|
|
State icons.State
|
|
DevicesTotal int
|
|
DevicesOnline int
|
|
DownRate float64 // bytes/sec
|
|
UpRate float64 // bytes/sec
|
|
LastSync time.Time
|
|
Paused bool
|
|
RecentFiles []RecentFile
|
|
ConflictCount int
|
|
Folders []FolderInfo
|
|
PendingDevices int
|
|
}
|
|
|
|
// FolderInfo holds per-folder info for the menu.
|
|
type FolderInfo struct {
|
|
ID string
|
|
Label string
|
|
Path string
|
|
State string // "idle", "syncing", "scanning", "error", etc.
|
|
}
|
|
|
|
// RecentFile records a recently synced file.
|
|
type RecentFile struct {
|
|
Name string
|
|
Folder string
|
|
Timestamp time.Time
|
|
}
|
|
|
|
// stateFromFolders determines the aggregate icon state from folder states.
|
|
func stateFromFolders(folders []FolderInfo, paused bool) icons.State {
|
|
if paused {
|
|
return icons.StatePaused
|
|
}
|
|
|
|
hasError := false
|
|
hasSyncing := false
|
|
|
|
for _, f := range folders {
|
|
switch f.State {
|
|
case "error":
|
|
hasError = true
|
|
case "syncing", "sync-preparing", "scanning", "sync-waiting", "scan-waiting":
|
|
hasSyncing = true
|
|
}
|
|
}
|
|
|
|
if hasError {
|
|
return icons.StateError
|
|
}
|
|
if hasSyncing {
|
|
return icons.StateSyncing
|
|
}
|
|
return icons.StateIdle
|
|
}
|