Files
baby-nas/internal/db/models.go
T
darroyo 428056e1be feat: show disk usage of mover source with configurable warning threshold
GET /api/storage/disk-usage returns source path stats (total/used/free bytes, %).
Polls every 30s while Storage page is open.

Backend:
- migration 0009: adds mover_warning_threshold (1-99, default 80) to storage_config
- StatPath moved to internal/storage package for testability
- handleStorageDiskUsage returns {source: PathStat}

Frontend:
- DiskUsageBar component in Mergerfs Mover card: usage bar with color
  green < threshold, amber >= threshold, red >= 95%
- Warning message when threshold reached or exceeded
- New input in config form: Umbral de aviso (%)
- storageDiskUsage() API method

Tests: StatPath unit tests (empty/nonexistent/valid paths)

Version: 0.7.3
2026-07-07 00:30:32 -04:00

127 lines
4.0 KiB
Go

package db
import "time"
type User struct {
ID int64 `json:"id"`
Username string `json:"username"`
UID *int64 `json:"uid,omitempty"`
GID *int64 `json:"gid,omitempty"`
Groups []string `json:"groups"`
SMBEnabled bool `json:"smb_enabled"`
Disabled bool `json:"disabled"`
// PendingPassword holds a not-yet-applied password. Never serialized.
PendingPassword string `json:"-"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type Admin struct {
ID int64 `json:"id"`
Username string `json:"username"`
PasswordHash string `json:"-"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type SambaShare struct {
ID int64 `json:"id"`
Name string `json:"name"`
Path string `json:"path"`
Comment string `json:"comment"`
ReadOnly bool `json:"read_only"`
GuestOK bool `json:"guest_ok"`
ValidUsers []string `json:"valid_users"`
ValidGroups []string `json:"valid_groups"`
InvalidUsers []string `json:"invalid_users"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type NFSClient struct {
Host string `json:"host"`
ReadOnly bool `json:"read_only"`
Async bool `json:"async"`
RootSquash bool `json:"root_squash"`
SubtreeCheck bool `json:"subtree_check"`
Advanced NFSAdvanced `json:"advanced"`
}
type NFSExport struct {
ID int64 `json:"id"`
Path string `json:"path"`
Clients []NFSClient `json:"clients"`
ReadOnly bool `json:"read_only"`
Async bool `json:"async"`
RootSquash bool `json:"root_squash"`
SubtreeCheck bool `json:"subtree_check"`
FSID int64 `json:"fsid"`
Advanced string `json:"advanced"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type NFSAdvanced struct {
AllSquash bool `json:"all_squash"`
Secure bool `json:"secure"`
WDelay bool `json:"wdelay"`
Hide bool `json:"hide"`
Crossmnt bool `json:"crossmnt"`
}
type WatchedMount struct {
ID int64 `json:"id"`
Path string `json:"path"`
CreatedAt time.Time `json:"created_at"`
}
type DirtyModule struct {
Module string `json:"module"`
MarkedAt time.Time `json:"marked_at"`
}
type ApplyLogEntry struct {
ID int64 `json:"id"`
Module string `json:"module"`
Message string `json:"message"`
Success bool `json:"success"`
CreatedAt time.Time `json:"created_at"`
}
type StorageConfig struct {
ID int64 `json:"id"`
MoverSource string `json:"mover_source"`
MoverDest string `json:"mover_dest"`
MoverCleanMacOS bool `json:"mover_clean_macos"`
MoverRemoveSource bool `json:"mover_remove_source"`
MoverInplace bool `json:"mover_inplace"`
MoverRsyncOptions string `json:"mover_rsync_options"`
MoverWarningThreshold int `json:"mover_warning_threshold"`
SnapraidContent string `json:"snapraid_content"`
SnapraidDataDirs string `json:"snapraid_data_dirs"`
SnapraidParityDir string `json:"snapraid_parity_dir"`
SnapraidScrubPlan int `json:"snapraid_scrub_plan"`
UpdatedAt string `json:"updated_at"`
}
type StorageJob struct {
ID int64 `json:"id"`
Kind string `json:"kind"`
Status string `json:"status"`
ArgsJSON string `json:"args_json"`
PID int `json:"pid"`
StartedAt *string `json:"started_at,omitempty"`
FinishedAt *string `json:"finished_at,omitempty"`
ExitCode int `json:"exit_code"`
Output string `json:"output"`
Error string `json:"error"`
CreatedAt string `json:"created_at"`
}
type StorageCapabilities struct {
Rsync bool `json:"rsync"`
MergerfsBin bool `json:"mergerfs"`
MergerfsMounted bool `json:"mergerfs_mounted"`
SnapraidBin bool `json:"snapraid"`
}