From e2d92daf31ad77007a176caaed04169634b81398 Mon Sep 17 00:00:00 2001 From: Paolo Asperti Date: Fri, 3 Jun 2022 15:56:56 +0200 Subject: [PATCH] ups reconfiguration --- src/ups/ups.go | 2 +- src/webui/ups_ui.go | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ups/ups.go b/src/ups/ups.go index c6f9e78..c4307fa 100644 --- a/src/ups/ups.go +++ b/src/ups/ups.go @@ -25,7 +25,7 @@ func init() { config.SetDefault(k, v) } Connected = false - events.AddListener("config_changed", Reconfigure) + events.AddListener("ups_config_changed", Reconfigure) } func UpsConnect() { diff --git a/src/webui/ups_ui.go b/src/webui/ups_ui.go index b6df1d9..fe2c816 100644 --- a/src/webui/ups_ui.go +++ b/src/webui/ups_ui.go @@ -4,6 +4,7 @@ import ( "strings" "git.openpdu.org/OpenPDU/openpdu/config" + "git.openpdu.org/OpenPDU/openpdu/events" "git.openpdu.org/OpenPDU/openpdu/ups" "gopkg.in/macaron.v1" ) @@ -35,8 +36,8 @@ type UPSPostForm struct { Host string `form:"host" binding:"Required"` Port int `form:"port" binding:"Required"` UpsName string `form:"upsname" binding:"Required"` - Username string `form:"username" binding:"Required"` - Password string `form:"password" binding:"Required"` + Username string `form:"username"` + Password string `form:"password"` } func upsPost(ctx *macaron.Context, f UPSPostForm) { @@ -47,5 +48,7 @@ func upsPost(ctx *macaron.Context, f UPSPostForm) { config.Set("Ups.Password", f.Password) config.WriteConfig() + events.FireEvent("ups_config_changed") + upsPage(ctx) }