ups reconfiguration

This commit is contained in:
Paolo Asperti 2022-06-03 15:56:56 +02:00
parent ee7d2697ee
commit e2d92daf31
Signed by: paspo
GPG Key ID: 06D46905D19D5182
2 changed files with 6 additions and 3 deletions

View File

@ -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() {

View File

@ -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)
}