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
|
miniwol
|
||||||
|
|
||||||
!example/**
|
!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 (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.ulra.eu/adro/miniwol/config"
|
"git.ulra.eu/adro/miniwol/config"
|
||||||
|
@ -27,13 +28,12 @@ func add(c echo.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func wake(c echo.Context) error {
|
func wake(c echo.Context) error {
|
||||||
_device := config.Device{}
|
index, err := strconv.Atoi(c.FormValue("Index"))
|
||||||
err := c.Bind(&_device)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, device := range config.Config.Devices {
|
for i, device := range config.Config.Devices {
|
||||||
if device == _device {
|
if i == index {
|
||||||
if !strings.Contains(device.IP, ":") {
|
if !strings.Contains(device.IP, ":") {
|
||||||
device.IP += ":9"
|
device.IP += ":9"
|
||||||
}
|
}
|
||||||
|
@ -49,13 +49,12 @@ func wake(c echo.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func remove(c echo.Context) error {
|
func remove(c echo.Context) error {
|
||||||
_device := config.Device{}
|
index, err := strconv.Atoi(c.FormValue("Index"))
|
||||||
err := c.Bind(&_device)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for i, device := range config.Config.Devices {
|
for i := range config.Config.Devices {
|
||||||
if device == _device {
|
if i == index {
|
||||||
config.Config.Devices = append(config.Config.Devices[:i], config.Config.Devices[i+1:]...)
|
config.Config.Devices = append(config.Config.Devices[:i], config.Config.Devices[i+1:]...)
|
||||||
err := config.Save()
|
err := config.Save()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -27,16 +27,12 @@
|
||||||
<td>
|
<td>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<form action="/wake" method="post">
|
<form action="/wake" method="post">
|
||||||
<input type="text" name="Alias" value="{{$d.Alias}}" hidden>
|
<input type="number" name="Index" value="{{$i}}" hidden>
|
||||||
<input type="text" name="MAC" value="{{$d.MAC}}" hidden>
|
<input type="submit" value="⏻" title="Wake">
|
||||||
<input type="text" name="IP" value="{{$d.IP}}" hidden>
|
|
||||||
<input type="submit" value="Wake">
|
|
||||||
</form>
|
</form>
|
||||||
<form action="/remove" method="post">
|
<form action="/remove" method="post">
|
||||||
<input type="text" name="Alias" value="{{$d.Alias}}" hidden>
|
<input type="number" name="Index" value="{{$i}}" hidden>
|
||||||
<input type="text" name="MAC" value="{{$d.MAC}}" hidden>
|
<input type="submit" value="🗑" title="Delete">
|
||||||
<input type="text" name="IP" value="{{$d.IP}}" hidden>
|
|
||||||
<input type="submit" value="Remove">
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<div style="flex-grow: 1;"></div>
|
<div style="flex-grow: 1;"></div>
|
||||||
{{ if .Auth }}
|
{{ if .Auth }}
|
||||||
<form action="/deauth" method="post">
|
<form action="/deauth" method="post">
|
||||||
<input type="submit" value="Logout">
|
<input type="submit" value="⏻">
|
||||||
</form>
|
</form>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</nav>
|
</nav>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user