local node modules option
This commit is contained in:
parent
5535dadd9c
commit
79866698f1
7 changed files with 11 additions and 40 deletions
3
Makefile
3
Makefile
|
|
@ -4,7 +4,6 @@ DNAME=watchyourlan
|
||||||
IFACE=enp4s0
|
IFACE=enp4s0
|
||||||
DBPATH=/data/hosts.db
|
DBPATH=/data/hosts.db
|
||||||
SHOUTRRR_URL=gotify://192.168.2.1:8083/AwQqpAae.rrl5Ob/?title=Unknown host detected&DisableTLS=yes
|
SHOUTRRR_URL=gotify://192.168.2.1:8083/AwQqpAae.rrl5Ob/?title=Unknown host detected&DisableTLS=yes
|
||||||
THEME=darkly
|
|
||||||
|
|
||||||
mod:
|
mod:
|
||||||
rm go.mod || true && \
|
rm go.mod || true && \
|
||||||
|
|
@ -16,7 +15,7 @@ run:
|
||||||
cd cmd/WatchYourLAN/ && \
|
cd cmd/WatchYourLAN/ && \
|
||||||
sudo \
|
sudo \
|
||||||
env IFACE=$(IFACE) DBPATH=$(DBPATH) THEME=$(THEME) \
|
env IFACE=$(IFACE) DBPATH=$(DBPATH) THEME=$(THEME) \
|
||||||
go run .
|
go run . #-n http://192.168.2.3:8850
|
||||||
|
|
||||||
fmt:
|
fmt:
|
||||||
go fmt ./...
|
go fmt ./...
|
||||||
|
|
|
||||||
|
|
@ -8,15 +8,14 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const configPath = "/data/config"
|
const configPath = "/data/config"
|
||||||
|
const nodePath = ""
|
||||||
const bootPath = ""
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
confPtr := flag.String("c", configPath, "Path to config file")
|
confPtr := flag.String("c", configPath, "Path to config file")
|
||||||
bootPtr := flag.String("b", bootPath, "Path to local Bootswatch")
|
nodePtr := flag.String("n", nodePath, "Path to node modules")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
check.Path(*confPtr)
|
check.Path(*confPtr)
|
||||||
|
|
||||||
web.Gui(*confPtr, *bootPtr) // Start web GUI
|
web.Gui(*confPtr, *nodePtr) // Start web GUI
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ type Conf struct {
|
||||||
Color string
|
Color string
|
||||||
IgnoreIP string
|
IgnoreIP string
|
||||||
LogLevel string
|
LogLevel string
|
||||||
BootPath string
|
NodePath string
|
||||||
Icon string
|
Icon string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,10 @@
|
||||||
package web
|
package web
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/tidwall/gjson"
|
|
||||||
|
|
||||||
"github.com/aceberg/WatchYourLAN/internal/check"
|
"github.com/aceberg/WatchYourLAN/internal/check"
|
||||||
"github.com/aceberg/WatchYourLAN/internal/conf"
|
"github.com/aceberg/WatchYourLAN/internal/conf"
|
||||||
"github.com/aceberg/WatchYourLAN/internal/db"
|
"github.com/aceberg/WatchYourLAN/internal/db"
|
||||||
|
|
@ -27,19 +24,6 @@ func configHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
version := string(file)
|
version := string(file)
|
||||||
guiData.Version = version[8:]
|
guiData.Version = version[8:]
|
||||||
|
|
||||||
url := "https://api.github.com/repos/aceberg/WatchYourLAN/releases/latest"
|
|
||||||
req, err := http.Get(url)
|
|
||||||
check.IfError(err)
|
|
||||||
|
|
||||||
defer req.Body.Close()
|
|
||||||
|
|
||||||
body, err := io.ReadAll(req.Body)
|
|
||||||
check.IfError(err)
|
|
||||||
|
|
||||||
bodyStr := string(body)
|
|
||||||
release := gjson.Get(bodyStr, "tag_name")
|
|
||||||
guiData.Release = release.String()
|
|
||||||
|
|
||||||
guiData.Themes = []string{"cerulean", "cosmo", "cyborg", "darkly", "flatly", "journal", "litera", "lumen", "lux", "materia", "minty", "morph", "pulse", "quartz", "sandstone", "simplex", "sketchy", "slate", "solar", "spacelab", "superhero", "united", "vapor", "yeti", "zephyr"}
|
guiData.Themes = []string{"cerulean", "cosmo", "cyborg", "darkly", "flatly", "journal", "litera", "lumen", "lux", "materia", "minty", "morph", "pulse", "quartz", "sandstone", "simplex", "sketchy", "slate", "solar", "spacelab", "superhero", "united", "vapor", "yeti", "zephyr"}
|
||||||
|
|
||||||
execTemplate(w, "config", guiData)
|
execTemplate(w, "config", guiData)
|
||||||
|
|
|
||||||
|
|
@ -79,10 +79,7 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<p>Current version: {{ .Version }}; Latest version: {{ .Release }}</p>
|
<p>Current version: {{ .Version }}</p>
|
||||||
{{ if ne .Version .Release }}
|
|
||||||
<p><b>Update available!</b></p>
|
|
||||||
{{ end }}
|
|
||||||
<div class="alert alert-info" role="alert">
|
<div class="alert alert-info" role="alert">
|
||||||
<p>● There can be one or more <b>Interfaces</b>, space separated</p>
|
<p>● There can be one or more <b>Interfaces</b>, space separated</p>
|
||||||
<p>● After changing <b>Host</b>, <b>Port</b> or <b>Path to DB</b> you need to restart the app</p>
|
<p>● After changing <b>Host</b>, <b>Port</b> or <b>Path to DB</b> you need to restart the app</p>
|
||||||
|
|
|
||||||
|
|
@ -5,16 +5,14 @@
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<!--Favicon-->
|
<!--Favicon-->
|
||||||
<link href="data:image/x-icon;base64,{{ .Config.Icon }}" rel="icon" type="image/x-icon" />
|
<link href="data:image/x-icon;base64,{{ .Config.Icon }}" rel="icon" type="image/x-icon" />
|
||||||
{{ if eq .Config.BootPath "" }}
|
{{ if eq .Config.NodePath "" }}
|
||||||
<!-- Bootstrap and theme -->
|
<!-- Bootstrap and theme -->
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootswatch@5.3.0/dist/{{ .Config.Theme }}/bootstrap.min.css" rel="stylesheet">
|
<link href="https://cdn.jsdelivr.net/npm/bootswatch@5.3.0/dist/{{ .Config.Theme }}/bootstrap.min.css" rel="stylesheet">
|
||||||
<!-- Font for icons -->
|
<!-- Font for icons -->
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<!-- Bootstrap and theme -->
|
<link rel="stylesheet" href="{{ .Config.NodePath }}/node_modules/bootstrap-icons/font/bootstrap-icons.css">
|
||||||
<link href="/css/bootswatch/dist/{{ .Config.Theme }}/bootstrap.min.css" rel="stylesheet">
|
<link href="{{ .Config.NodePath }}/node_modules/bootswatch/dist/{{ .Config.Theme }}/bootstrap.min.css" rel="stylesheet">
|
||||||
<!-- Font for icons -->
|
|
||||||
<link rel="stylesheet" href="/css/bootstrap-icons/font/bootstrap-icons.css">
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
||||||
|
|
@ -11,11 +11,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Gui - start web GUI
|
// Gui - start web GUI
|
||||||
func Gui(configPath, bootPath string) {
|
func Gui(configPath, nodePath string) {
|
||||||
|
|
||||||
ConfigPath = configPath
|
ConfigPath = configPath
|
||||||
AppConfig = conf.Get(ConfigPath)
|
AppConfig = conf.Get(ConfigPath)
|
||||||
AppConfig.BootPath = bootPath
|
AppConfig.NodePath = nodePath
|
||||||
AppConfig.Icon = Icon
|
AppConfig.Icon = Icon
|
||||||
|
|
||||||
address := AppConfig.GuiIP + ":" + AppConfig.GuiPort
|
address := AppConfig.GuiIP + ":" + AppConfig.GuiPort
|
||||||
|
|
@ -28,12 +28,6 @@ func Gui(configPath, bootPath string) {
|
||||||
|
|
||||||
AllHosts = db.Select(AppConfig.DbPath)
|
AllHosts = db.Select(AppConfig.DbPath)
|
||||||
|
|
||||||
if AppConfig.BootPath != "" {
|
|
||||||
fs := http.FileServer(http.Dir(AppConfig.BootPath))
|
|
||||||
http.Handle("/css/", http.StripPrefix("/css", fs))
|
|
||||||
// http.Handle("/css/", http.FileServer(http.Dir(AppConfig.BootPath)))
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Println("=================================== ")
|
log.Println("=================================== ")
|
||||||
log.Printf("Web GUI at http://%s", address)
|
log.Printf("Web GUI at http://%s", address)
|
||||||
log.Println("=================================== ")
|
log.Println("=================================== ")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue