diff options
| author | Fuwn <[email protected]> | 2026-01-20 16:34:01 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-01-20 16:34:01 -0800 |
| commit | d21e767ec97826beb878a501936bc03f1cb5d33b (patch) | |
| tree | 7ee6f279222991ee42f0705a544ac6d68a40edf4 /internal/config | |
| parent | feat: Add API access control (public/private/authenticated) (diff) | |
| download | kaze-d21e767ec97826beb878a501936bc03f1cb5d33b.tar.xz kaze-d21e767ec97826beb878a501936bc03f1cb5d33b.zip | |
feat: Add API-based refresh mode for smoother updates
Add display.refresh_mode option:
- 'page' (default): Full page refresh via meta refresh
- 'api': Fetch /api/status and update DOM without reload
Also add display.refresh_interval (default: 30s, min: 5s)
API mode updates: status indicators, response times, uptimes,
errors, overall status banner, and page title counts.
History bars remain static until full page refresh.
Diffstat (limited to 'internal/config')
| -rw-r--r-- | internal/config/config.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/internal/config/config.go b/internal/config/config.go index 5f05b96..0c8b430 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -44,6 +44,12 @@ type DisplayConfig struct { Timezone string `yaml:"timezone"` // Scale adjusts the overall UI scale (default: 1.0, range: 0.5-2.0) Scale float64 `yaml:"scale"` + // RefreshMode controls how the page updates: + // "page" - Full page refresh via meta refresh (default) + // "api" - Fetch updates via API without page reload + RefreshMode string `yaml:"refresh_mode"` + // RefreshInterval is how often to refresh in seconds (default: 30) + RefreshInterval int `yaml:"refresh_interval"` } // SiteConfig contains site metadata @@ -252,6 +258,12 @@ func (c *Config) applyDefaults() { } else if c.Display.Scale > 2.0 { c.Display.Scale = 2.0 } + if c.Display.RefreshMode == "" { + c.Display.RefreshMode = "page" + } + if c.Display.RefreshInterval == 0 { + c.Display.RefreshInterval = 30 + } // Apply API defaults if c.API.Access == "" { @@ -485,6 +497,18 @@ func (c *Config) validate() error { return fmt.Errorf("api.access is 'authenticated' but no api.keys provided") } + // Validate refresh mode + switch c.Display.RefreshMode { + case "page", "api": + // Valid modes + default: + return fmt.Errorf("invalid display.refresh_mode %q (must be page or api)", c.Display.RefreshMode) + } + + if c.Display.RefreshInterval < 5 { + return fmt.Errorf("display.refresh_interval must be at least 5 seconds, got %d", c.Display.RefreshInterval) + } + return nil } |