diff --git a/.gitignore b/.gitignore index 0e7c768..ac35f8c 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,4 @@ config.toml miniwol !example/** +__debug_bin diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..7b0bafa --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Launch Package", + "type": "go", + "request": "launch", + "mode": "auto", + "program": "${workspaceFolder}" + } + ] +} \ No newline at end of file diff --git a/web/device.go b/web/device.go index f78dcf4..fa6336a 100644 --- a/web/device.go +++ b/web/device.go @@ -3,6 +3,7 @@ package web import ( "errors" "net/http" + "strconv" "strings" "git.ulra.eu/adro/miniwol/config" @@ -27,13 +28,12 @@ func add(c echo.Context) error { } func wake(c echo.Context) error { - _device := config.Device{} - err := c.Bind(&_device) + index, err := strconv.Atoi(c.FormValue("Index")) if err != nil { return err } - for _, device := range config.Config.Devices { - if device == _device { + for i, device := range config.Config.Devices { + if i == index { if !strings.Contains(device.IP, ":") { device.IP += ":9" } @@ -49,13 +49,12 @@ func wake(c echo.Context) error { } func remove(c echo.Context) error { - _device := config.Device{} - err := c.Bind(&_device) + index, err := strconv.Atoi(c.FormValue("Index")) if err != nil { return err } - for i, device := range config.Config.Devices { - if device == _device { + for i := range config.Config.Devices { + if i == index { config.Config.Devices = append(config.Config.Devices[:i], config.Config.Devices[i+1:]...) err := config.Save() if err != nil { diff --git a/web/template/device.html b/web/template/device.html index 8d969ac..758bd31 100644 --- a/web/template/device.html +++ b/web/template/device.html @@ -27,16 +27,12 @@
- - - - + +
- - - - + +
diff --git a/web/template/page.html b/web/template/page.html index ac16454..dea9b74 100644 --- a/web/template/page.html +++ b/web/template/page.html @@ -14,7 +14,7 @@
{{ if .Auth }}
- +
{{ end }}