diff --git a/frontend/lock-code-edit.html b/frontend/lock-code-edit.html index 6cecbe6..4faa47c 100644 --- a/frontend/lock-code-edit.html +++ b/frontend/lock-code-edit.html @@ -1,9 +1,10 @@ {{ template "header.html" . }} -
{{ if eq .Data.Name "" }}Lock #{{ .Data.ID }}{{ else }}{{ .Data.Name }}{{ end }}
+
{{ if eq .Data.lock.Name "" }}Lock #{{ .Data.lock.ID }}{{ else }}{{ .Data.lock.Name }}{{ end }} Slot #{{ .Data.code.Slot }}
+
- Code:
- Name:
- Enabled:
+ Code:
+ Name:
+ Enabled:

diff --git a/frontend/lock-edit.html b/frontend/lock-edit.html index 65e1707..d379cc4 100644 --- a/frontend/lock-edit.html +++ b/frontend/lock-edit.html @@ -1,5 +1,6 @@ {{ template "header.html" . }}
Rename {{ if eq .Data.Name "" }}Lock #{{ .Data.ID }}{{ else }}{{ .Data.Name }}{{ end }}
+
Name:
diff --git a/httpserver/lock.go b/httpserver/lock.go index 736aac7..8b337ba 100644 --- a/httpserver/lock.go +++ b/httpserver/lock.go @@ -102,15 +102,18 @@ func lockCodeEditHandler(c echo.Context) error { return err } - if c.Request().Method == http.MethodGet { - return c.Render(http.StatusFound, "lock-code-edit.html", code) - } - lock, err := queries.GetLock(ctx, lockID) if err != nil { return err } + if c.Request().Method == http.MethodGet { + return c.Render(http.StatusFound, "lock-code-edit.html", map[string]interface{}{ + "lock": lock, + "code": code, + }) + } + zwaveClient := c.Get(contextKeyZWaveClient).(*zwavejs.Client) enabled := c.FormValue("enabled") == "on" @@ -133,7 +136,7 @@ func lockCodeEditHandler(c echo.Context) error { newCode := "0000" if enabled { - newCode := c.FormValue("code") + newCode = c.FormValue("code") err = zwaveClient.SetNodeValue(ctx, int(lock.ZwaveDeviceID), zwavejs.NodeValue{ CCVersion: 1, CommandClassName: zwavejs.CommandClassNameUserCode,