Icons, identify device by index, launch.json

This commit is contained in:
adro 2022-02-23 14:02:46 +01:00
parent c56ba425c7
commit ed9d9474e3
5 changed files with 28 additions and 17 deletions

1
.gitignore vendored
View File

@ -26,3 +26,4 @@ config.toml
miniwol
!example/**
__debug_bin

15
.vscode/launch.json vendored Normal file
View File

@ -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}"
}
]
}

View File

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

View File

@ -27,16 +27,12 @@
<td>
<div class="actions">
<form action="/wake" method="post">
<input type="text" name="Alias" value="{{$d.Alias}}" hidden>
<input type="text" name="MAC" value="{{$d.MAC}}" hidden>
<input type="text" name="IP" value="{{$d.IP}}" hidden>
<input type="submit" value="Wake">
<input type="number" name="Index" value="{{$i}}" hidden>
<input type="submit" value="&#x23FB;" title="Wake">
</form>
<form action="/remove" method="post">
<input type="text" name="Alias" value="{{$d.Alias}}" hidden>
<input type="text" name="MAC" value="{{$d.MAC}}" hidden>
<input type="text" name="IP" value="{{$d.IP}}" hidden>
<input type="submit" value="Remove">
<input type="number" name="Index" value="{{$i}}" hidden>
<input type="submit" value="&#x1F5D1;" title="Delete">
</form>
</div>
</td>

View File

@ -14,7 +14,7 @@
<div style="flex-grow: 1;"></div>
{{ if .Auth }}
<form action="/deauth" method="post">
<input type="submit" value="Logout">
<input type="submit" value="&#x23FB;">
</form>
{{ end }}
</nav>