Theme config
This commit is contained in:
parent
47a15cdb2a
commit
760f7e4d2c
10 changed files with 27 additions and 12 deletions
2
.github/workflows/docker-publish.yml
vendored
2
.github/workflows/docker-publish.yml
vendored
|
|
@ -14,7 +14,7 @@ on:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
IMAGE_NAME: watchyourlan
|
IMAGE_NAME: watchyourlan
|
||||||
TAGS: latest, v0.7.1
|
TAGS: latest, v0.7.2
|
||||||
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
|
||||||
3
Makefile
3
Makefile
|
|
@ -4,6 +4,7 @@ DNAME=watchyourlan
|
||||||
IFACE=virbr-bw
|
IFACE=virbr-bw
|
||||||
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:
|
||||||
cd src && \
|
cd src && \
|
||||||
|
|
@ -14,7 +15,7 @@ mod:
|
||||||
run:
|
run:
|
||||||
cd src && \
|
cd src && \
|
||||||
sudo \
|
sudo \
|
||||||
env IFACE=$(IFACE) DBPATH=$(DBPATH) \
|
env IFACE=$(IFACE) DBPATH=$(DBPATH) THEME=$(THEME) \
|
||||||
go run .
|
go run .
|
||||||
|
|
||||||
go-build:
|
go-build:
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ Configuration can be done through config file or environment variables
|
||||||
| GUIPORT | Port for web GUI | 8840 |
|
| GUIPORT | Port for web GUI | 8840 |
|
||||||
| TIMEOUT | Time between scans (seconds) | 60 (1 minute) |
|
| TIMEOUT | Time between scans (seconds) | 60 (1 minute) |
|
||||||
| SHOUTRRR_URL | Url to any notification service supported by https://github.com/containrrr/shoutrrr | "" |
|
| SHOUTRRR_URL | Url to any notification service supported by https://github.com/containrrr/shoutrrr | "" |
|
||||||
|
| THEME | Any theme name from https://bootswatch.com in lowcase | solar |
|
||||||
|
|
||||||
## Config file
|
## Config file
|
||||||
|
|
||||||
|
|
@ -57,4 +58,5 @@ GUIIP="192.168.2.1" # To access from LAN
|
||||||
GUIPORT="8840"
|
GUIPORT="8840"
|
||||||
TIMEOUT="300" # 5 minutes
|
TIMEOUT="300" # 5 minutes
|
||||||
SHOUTRRR_URL="gotify://192.168.2.1:8083/AwQqpAae.rrl5Ob/?title=Unknown host detected&DisableTLS=yes" # Url to notify
|
SHOUTRRR_URL="gotify://192.168.2.1:8083/AwQqpAae.rrl5Ob/?title=Unknown host detected&DisableTLS=yes" # Url to notify
|
||||||
|
THEME="darkly"
|
||||||
```
|
```
|
||||||
|
|
@ -14,3 +14,4 @@ services:
|
||||||
GUIPORT: "8840" # optional, default: 8840
|
GUIPORT: "8840" # optional, default: 8840
|
||||||
TIMEOUT: "120" # optional, time in seconds, default: 60
|
TIMEOUT: "120" # optional, time in seconds, default: 60
|
||||||
SHOUTRRR_URL: "" # optional, set url to notify
|
SHOUTRRR_URL: "" # optional, set url to notify
|
||||||
|
THEME: "darkly" # optional
|
||||||
|
|
@ -11,6 +11,7 @@ func get_config(path string) (config Conf) {
|
||||||
viper.SetDefault("GUIPORT", "8840")
|
viper.SetDefault("GUIPORT", "8840")
|
||||||
viper.SetDefault("TIMEOUT", "60")
|
viper.SetDefault("TIMEOUT", "60")
|
||||||
viper.SetDefault("SHOUTRRR_URL", "")
|
viper.SetDefault("SHOUTRRR_URL", "")
|
||||||
|
viper.SetDefault("THEME", "solar")
|
||||||
|
|
||||||
viper.SetConfigFile(path)
|
viper.SetConfigFile(path)
|
||||||
viper.SetConfigType("env")
|
viper.SetConfigType("env")
|
||||||
|
|
@ -24,6 +25,7 @@ func get_config(path string) (config Conf) {
|
||||||
config.GuiPort = viper.Get("GUIPORT").(string)
|
config.GuiPort = viper.Get("GUIPORT").(string)
|
||||||
config.Timeout = viper.GetInt("TIMEOUT")
|
config.Timeout = viper.GetInt("TIMEOUT")
|
||||||
config.ShoutUrl = viper.Get("SHOUTRRR_URL").(string)
|
config.ShoutUrl = viper.Get("SHOUTRRR_URL").(string)
|
||||||
|
config.Theme = viper.Get("THEME").(string)
|
||||||
|
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|
@ -16,7 +16,7 @@ func index(w http.ResponseWriter, r *http.Request) {
|
||||||
guiData.Config = AppConfig
|
guiData.Config = AppConfig
|
||||||
guiData.Hosts = AllHosts
|
guiData.Hosts = AllHosts
|
||||||
|
|
||||||
tmpl, _ := template.ParseFiles("templates/index.html", "templates/header.html")
|
tmpl, _ := template.ParseFiles("templates/index.html", "templates/header.html", "templates/footer.html")
|
||||||
tmpl.ExecuteTemplate(w, "index", guiData)
|
tmpl.ExecuteTemplate(w, "index", guiData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ type Conf struct {
|
||||||
GuiPort string
|
GuiPort string
|
||||||
Timeout int
|
Timeout int
|
||||||
ShoutUrl string
|
ShoutUrl string
|
||||||
|
Theme string
|
||||||
}
|
}
|
||||||
|
|
||||||
var AppConfig Conf
|
var AppConfig Conf
|
||||||
|
|
|
||||||
9
src/templates/footer.html
Normal file
9
src/templates/footer.html
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
{{ define "footer"}}
|
||||||
|
<div class="navbar fixed-bottom">
|
||||||
|
<div class="container">
|
||||||
|
<a href="https://github.com/aceberg/WatchYourLAN">Github</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
{{ end }}
|
||||||
|
|
@ -3,12 +3,7 @@
|
||||||
<head>
|
<head>
|
||||||
<title>Watch Your LAN</title>
|
<title>Watch Your LAN</title>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<!--Auto refresh (seconds)-->
|
|
||||||
<meta http-equiv="refresh" content="60">
|
|
||||||
<!--Favicon-->
|
<!--Favicon-->
|
||||||
<link href="data:image/x-icon;base64,AAABAAEAEBAQAAEABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAA/6k7AP+uSQD/z50A7urjAD85MgAAOO8AWlpaAADIawAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADEREQAAAAAzEREREQAAAzEREREREAAzFxEREVERADN3d3VVVREDM3d3dYVlERMzd3d1VVUREzM3ERESERETMzcRESERERMzNxESMREREzM3ESNEQREwMzcSMxEREwAzNyM0REQzAAMzMzMzMzAAADMzMzMzAAAAADMzMwAAD4HwAA4AcAAMADAACAAQAAgAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIABAACAAQAAwAMAAOAHAAD4HwAA" rel="icon" type="image/x-icon" />
|
<link href="data:image/x-icon;base64,AAABAAEAEBAQAAEABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAA/6k7AP+uSQD/z50A7urjAD85MgAAOO8AWlpaAADIawAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADEREQAAAAAzEREREQAAAzEREREREAAzFxEREVERADN3d3VVVREDM3d3dYVlERMzd3d1VVUREzM3ERESERETMzcRESERERMzNxESMREREzM3ESNEQREwMzcSMxEREwAzNyM0REQzAAMzMzMzMzAAADMzMzMzAAAAADMzMwAAD4HwAA4AcAAMADAACAAQAAgAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIABAACAAQAAwAMAAOAHAAD4HwAA" rel="icon" type="image/x-icon" />
|
||||||
<!--Bootstrap theme-->
|
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootswatch@5.2.0/dist/solar/bootstrap.min.css" rel="stylesheet">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
{{ define "index"}}
|
{{ define "index"}}
|
||||||
|
|
||||||
{{ template "header" }}
|
{{ template "header" }}
|
||||||
|
<!--Auto refresh (seconds)-->
|
||||||
|
<meta http-equiv="refresh" content="{{ .Config.Timeout }}">
|
||||||
|
<!--Bootstrap theme-->
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootswatch@5.2.0/dist/{{ .Config.Theme }}/bootstrap.min.css" rel="stylesheet">
|
||||||
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container mt-3">
|
<div class="container mt-3">
|
||||||
<h2>Online</h2>
|
<h2>Online</h2>
|
||||||
|
|
@ -65,6 +69,6 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
|
||||||
</html>
|
{{ template "footer" }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
Loading…
Reference in a new issue