Expensive bee
This commit is contained in:
27
ui/config.go
27
ui/config.go
@@ -20,6 +20,10 @@ const (
|
||||
cfgColorClock
|
||||
cfgColorAlarm
|
||||
cfgShowSeconds
|
||||
cfgServerURL
|
||||
cfgServerPassword
|
||||
cfgAPIPassword
|
||||
cfgPollSeconds
|
||||
cfgFieldCount
|
||||
)
|
||||
|
||||
@@ -43,6 +47,10 @@ func newConfigModel(cfg db.Settings) *configModel {
|
||||
} else {
|
||||
c.fields[cfgShowSeconds] = "false"
|
||||
}
|
||||
c.fields[cfgServerURL] = cfg.ServerURL
|
||||
c.fields[cfgServerPassword] = cfg.ServerPassword
|
||||
c.fields[cfgAPIPassword] = cfg.APIPassword
|
||||
c.fields[cfgPollSeconds] = strconv.Itoa(cfg.PollSeconds)
|
||||
return c
|
||||
}
|
||||
|
||||
@@ -145,6 +153,12 @@ func (c *configModel) save(m *Model) (tea.Model, tea.Cmd) {
|
||||
return *m, nil
|
||||
}
|
||||
|
||||
pollSeconds, err := strconv.Atoi(strings.TrimSpace(c.fields[cfgPollSeconds]))
|
||||
if err != nil || pollSeconds < 1 || pollSeconds > 60 {
|
||||
c.err = "Poll seconds must be 1-60"
|
||||
return *m, nil
|
||||
}
|
||||
|
||||
cfg := db.Settings{
|
||||
SnoozeMinutes: snooze,
|
||||
TimeoutMinutes: timeout,
|
||||
@@ -158,6 +172,11 @@ func (c *configModel) save(m *Model) (tea.Model, tea.Cmd) {
|
||||
showSec := strings.TrimSpace(c.fields[cfgShowSeconds])
|
||||
cfg.ShowSeconds = showSec == "true"
|
||||
|
||||
cfg.ServerURL = strings.TrimSpace(c.fields[cfgServerURL])
|
||||
cfg.ServerPassword = strings.TrimSpace(c.fields[cfgServerPassword])
|
||||
cfg.APIPassword = strings.TrimSpace(c.fields[cfgAPIPassword])
|
||||
cfg.PollSeconds = pollSeconds
|
||||
|
||||
if cfg.DefaultSound == "" {
|
||||
cfg.DefaultSound = "default"
|
||||
}
|
||||
@@ -185,6 +204,10 @@ func (c *configModel) View() string {
|
||||
"Clock color:",
|
||||
"Alarm color:",
|
||||
"Show seconds:",
|
||||
"Server URL:",
|
||||
"Server pass:",
|
||||
"API password:",
|
||||
"Poll (sec):",
|
||||
}
|
||||
|
||||
hints := [cfgFieldCount]string{
|
||||
@@ -196,6 +219,10 @@ func (c *configModel) View() string {
|
||||
"hex e.g. #00FF88",
|
||||
"hex e.g. #FF4444",
|
||||
"space to toggle",
|
||||
"empty=local, or http://host:9119",
|
||||
"password to auth with server",
|
||||
"password for incoming API requests",
|
||||
"1-60, client poll frequency",
|
||||
}
|
||||
|
||||
var lines []string
|
||||
|
||||
Reference in New Issue
Block a user