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
|
||||
DBPATH=/data/hosts.db
|
||||
SHOUTRRR_URL=gotify://192.168.2.1:8083/AwQqpAae.rrl5Ob/?title=Unknown host detected&DisableTLS=yes
|
||||
THEME=darkly
|
||||
|
||||
mod:
|
||||
rm go.mod || true && \
|
||||
|
|
@ -16,7 +15,7 @@ run:
|
|||
cd cmd/WatchYourLAN/ && \
|
||||
sudo \
|
||||
env IFACE=$(IFACE) DBPATH=$(DBPATH) THEME=$(THEME) \
|
||||
go run .
|
||||
go run . #-n http://192.168.2.3:8850
|
||||
|
||||
fmt:
|
||||
go fmt ./...
|
||||
|
|
|
|||
|
|
@ -8,15 +8,14 @@ import (
|
|||
)
|
||||
|
||||
const configPath = "/data/config"
|
||||
|
||||
const bootPath = ""
|
||||
const nodePath = ""
|
||||
|
||||
func main() {
|
||||
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()
|
||||
|
||||
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
|
||||
IgnoreIP string
|
||||
LogLevel string
|
||||
BootPath string
|
||||
NodePath string
|
||||
Icon string
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,10 @@
|
|||
package web
|
||||
|
||||
import (
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/tidwall/gjson"
|
||||
|
||||
"github.com/aceberg/WatchYourLAN/internal/check"
|
||||
"github.com/aceberg/WatchYourLAN/internal/conf"
|
||||
"github.com/aceberg/WatchYourLAN/internal/db"
|
||||
|
|
@ -27,19 +24,6 @@ func configHandler(w http.ResponseWriter, r *http.Request) {
|
|||
version := string(file)
|
||||
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"}
|
||||
|
||||
execTemplate(w, "config", guiData)
|
||||
|
|
|
|||
|
|
@ -79,10 +79,7 @@
|
|||
</table>
|
||||
</div>
|
||||
<div class="col">
|
||||
<p>Current version: {{ .Version }}; Latest version: {{ .Release }}</p>
|
||||
{{ if ne .Version .Release }}
|
||||
<p><b>Update available!</b></p>
|
||||
{{ end }}
|
||||
<p>Current version: {{ .Version }}</p>
|
||||
<div class="alert alert-info" role="alert">
|
||||
<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>
|
||||
|
|
|
|||
|
|
@ -5,16 +5,14 @@
|
|||
<meta charset="utf-8">
|
||||
<!--Favicon-->
|
||||
<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 -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootswatch@5.3.0/dist/{{ .Config.Theme }}/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- Font for icons -->
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
|
||||
{{ else }}
|
||||
<!-- Bootstrap and theme -->
|
||||
<link href="/css/bootswatch/dist/{{ .Config.Theme }}/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- Font for icons -->
|
||||
<link rel="stylesheet" href="/css/bootstrap-icons/font/bootstrap-icons.css">
|
||||
<link rel="stylesheet" href="{{ .Config.NodePath }}/node_modules/bootstrap-icons/font/bootstrap-icons.css">
|
||||
<link href="{{ .Config.NodePath }}/node_modules/bootswatch/dist/{{ .Config.Theme }}/bootstrap.min.css" rel="stylesheet">
|
||||
{{ end }}
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@ import (
|
|||
)
|
||||
|
||||
// Gui - start web GUI
|
||||
func Gui(configPath, bootPath string) {
|
||||
func Gui(configPath, nodePath string) {
|
||||
|
||||
ConfigPath = configPath
|
||||
AppConfig = conf.Get(ConfigPath)
|
||||
AppConfig.BootPath = bootPath
|
||||
AppConfig.NodePath = nodePath
|
||||
AppConfig.Icon = Icon
|
||||
|
||||
address := AppConfig.GuiIP + ":" + AppConfig.GuiPort
|
||||
|
|
@ -28,12 +28,6 @@ func Gui(configPath, bootPath string) {
|
|||
|
||||
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.Printf("Web GUI at http://%s", address)
|
||||
log.Println("=================================== ")
|
||||
|
|
|
|||
Loading…
Reference in a new issue