watchyourlan/internal/web/line.go
2023-10-06 22:37:01 +07:00

27 lines
544 B
Go

package web
import (
"net/http"
"github.com/aceberg/WatchYourLAN/internal/models"
)
func lineHandler(w http.ResponseWriter, r *http.Request) {
var guiData models.GuiData
guiData.Config = AppConfig
guiData.Hosts = []models.Host{}
state := r.URL.Query().Get("state")
for _, oneHost := range AllHosts {
if state == "off" && oneHost.Now == 0 {
guiData.Hosts = append(guiData.Hosts, oneHost)
}
if state == "on" && oneHost.Now == 1 {
guiData.Hosts = append(guiData.Hosts, oneHost)
}
}
execTemplate(w, "line", guiData)
}