Icons, identify device by index, launch.json
This commit is contained in:
parent
c56ba425c7
commit
ed9d9474e3
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -26,3 +26,4 @@ config.toml
|
|||
miniwol
|
||||
|
||||
!example/**
|
||||
__debug_bin
|
||||
|
|
15
.vscode/launch.json
vendored
Normal file
15
.vscode/launch.json
vendored
Normal 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}"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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 {
|
||||
|
|
|
@ -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="⏻" 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="🗑" title="Delete">
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
|
|
|
@ -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="⏻">
|
||||
</form>
|
||||
{{ end }}
|
||||
</nav>
|
||||
|
|
Loading…
Reference in New Issue
Block a user