add ui, new config opts

This commit is contained in:
2026-07-16 16:32:44 -04:00
parent 8effff311b
commit df01e060e4
33 changed files with 1104 additions and 37 deletions
+19
View File
@@ -34,6 +34,19 @@ type ServiceConfig struct {
// usage are re-fetched over REST.
PollInterval time.Duration `yaml:"pollInterval" json:"pollInterval,omitempty" env:"ECONET_POLL_INTERVAL"`
// EnableWebUI toggles the admin UI served at /. It defaults to enabled:
// a pointer so an unset value (nil) is distinguishable from an explicit
// false, which is what makes the default actually true at runtime —
// LoadEnv's plain env.Parse does not apply the `default` tag (that tag
// only feeds the JSON schema). Use WebUIEnabled to read it.
EnableWebUI *bool `yaml:"enableWebUI" json:"enableWebUI,omitempty" env:"ECONET_ENABLE_WEB_UI" default:"true"`
// DisableWaterUsage skips the per-device water-usage REST call on each
// refresh. Handy for units that don't report water usage, where the call is
// wasted work and just produces debug-log noise. Zero value (false) keeps
// water usage enabled, so unlike EnableWebUI this needs no pointer.
DisableWaterUsage bool `yaml:"disableWaterUsage" json:"disableWaterUsage,omitempty" env:"ECONET_DISABLE_WATER_USAGE" default:"false"`
// Embeds go-app config, used by go-app to
// merge custom config into go-app config, and to produce
// a complete configuration json schema
@@ -51,6 +64,12 @@ func (c *ServiceConfig) LoadEnv() error {
return env.Parse(c)
}
// WebUIEnabled reports whether the admin UI should be served. Unset defaults to
// true; set enableWebUI: false (or ECONET_ENABLE_WEB_UI=false) to disable it.
func (c *ServiceConfig) WebUIEnabled() bool {
return c.EnableWebUI == nil || *c.EnableWebUI
}
// GetPollInterval returns the configured poll interval or the default.
func (c *ServiceConfig) GetPollInterval() time.Duration {
if c.PollInterval <= 0 {