Expensive bee
This commit is contained in:
18
db/db.go
18
db/db.go
@@ -201,6 +201,12 @@ type Settings struct {
|
||||
ColorClock string
|
||||
ColorAlarm string
|
||||
ShowSeconds bool
|
||||
|
||||
// Client/server mode
|
||||
ServerURL string // If set, run as client connecting to this URL
|
||||
ServerPassword string // Password for authenticating to remote server
|
||||
APIPassword string // Password required for incoming API requests (host mode)
|
||||
PollSeconds int // How often to poll server in client mode
|
||||
}
|
||||
|
||||
func DefaultSettings() Settings {
|
||||
@@ -213,6 +219,10 @@ func DefaultSettings() Settings {
|
||||
ColorClock: "#00FF88",
|
||||
ColorAlarm: "#FF4444",
|
||||
ShowSeconds: true,
|
||||
ServerURL: "",
|
||||
ServerPassword: "",
|
||||
APIPassword: "",
|
||||
PollSeconds: 5,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,6 +236,10 @@ func (s *Store) LoadSettings() Settings {
|
||||
cfg.ColorClock = s.GetSetting("color_clock", cfg.ColorClock)
|
||||
cfg.ColorAlarm = s.GetSetting("color_alarm", cfg.ColorAlarm)
|
||||
cfg.ShowSeconds = s.GetSetting("show_seconds", "true") == "true"
|
||||
cfg.ServerURL = s.GetSetting("server_url", cfg.ServerURL)
|
||||
cfg.ServerPassword = s.GetSetting("server_password", cfg.ServerPassword)
|
||||
cfg.APIPassword = s.GetSetting("api_password", cfg.APIPassword)
|
||||
cfg.PollSeconds = s.getSettingInt("poll_seconds", cfg.PollSeconds)
|
||||
return cfg
|
||||
}
|
||||
|
||||
@@ -239,6 +253,10 @@ func (s *Store) SaveSettings(cfg Settings) error {
|
||||
"color_clock": cfg.ColorClock,
|
||||
"color_alarm": cfg.ColorAlarm,
|
||||
"show_seconds": fmt.Sprintf("%t", cfg.ShowSeconds),
|
||||
"server_url": cfg.ServerURL,
|
||||
"server_password": cfg.ServerPassword,
|
||||
"api_password": cfg.APIPassword,
|
||||
"poll_seconds": fmt.Sprintf("%d", cfg.PollSeconds),
|
||||
}
|
||||
for k, v := range pairs {
|
||||
if err := s.SetSetting(k, v); err != nil {
|
||||
|
||||
13
db/interface.go
Normal file
13
db/interface.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package db
|
||||
|
||||
// AlarmStore defines the interface for alarm CRUD operations.
|
||||
// Implemented by *Store (local SQLite) and api.Client (remote HTTP).
|
||||
type AlarmStore interface {
|
||||
ListAlarms() ([]Alarm, error)
|
||||
GetAlarm(id int) (Alarm, error)
|
||||
CreateAlarm(a Alarm) (int, error)
|
||||
UpdateAlarm(a Alarm) error
|
||||
DeleteAlarm(id int) error
|
||||
ToggleAlarm(id int) error
|
||||
MarkTriggered(id int) error
|
||||
}
|
||||
Reference in New Issue
Block a user