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:
|
||||
IMAGE_NAME: watchyourlan
|
||||
TAGS: latest, v0.7.1
|
||||
TAGS: latest, v0.7.2
|
||||
|
||||
|
||||
jobs:
|
||||
|
|
|
|||
3
Makefile
3
Makefile
|
|
@ -4,6 +4,7 @@ DNAME=watchyourlan
|
|||
IFACE=virbr-bw
|
||||
DBPATH=data/hosts.db
|
||||
SHOUTRRR_URL=gotify://192.168.2.1:8083/AwQqpAae.rrl5Ob/?title=Unknown host detected&DisableTLS=yes
|
||||
THEME=darkly
|
||||
|
||||
mod:
|
||||
cd src && \
|
||||
|
|
@ -14,7 +15,7 @@ mod:
|
|||
run:
|
||||
cd src && \
|
||||
sudo \
|
||||
env IFACE=$(IFACE) DBPATH=$(DBPATH) \
|
||||
env IFACE=$(IFACE) DBPATH=$(DBPATH) THEME=$(THEME) \
|
||||
go run .
|
||||
|
||||
go-build:
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ Configuration can be done through config file or environment variables
|
|||
| GUIPORT | Port for web GUI | 8840 |
|
||||
| TIMEOUT | Time between scans (seconds) | 60 (1 minute) |
|
||||
| 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
|
||||
|
||||
|
|
@ -57,4 +58,5 @@ GUIIP="192.168.2.1" # To access from LAN
|
|||
GUIPORT="8840"
|
||||
TIMEOUT="300" # 5 minutes
|
||||
SHOUTRRR_URL="gotify://192.168.2.1:8083/AwQqpAae.rrl5Ob/?title=Unknown host detected&DisableTLS=yes" # Url to notify
|
||||
THEME="darkly"
|
||||
```
|
||||
|
|
@ -13,4 +13,5 @@ services:
|
|||
GUIIP: "0.0.0.0" # optional, default: localhost
|
||||
GUIPORT: "8840" # optional, default: 8840
|
||||
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("TIMEOUT", "60")
|
||||
viper.SetDefault("SHOUTRRR_URL", "")
|
||||
viper.SetDefault("THEME", "solar")
|
||||
|
||||
viper.SetConfigFile(path)
|
||||
viper.SetConfigType("env")
|
||||
|
|
@ -24,6 +25,7 @@ func get_config(path string) (config Conf) {
|
|||
config.GuiPort = viper.Get("GUIPORT").(string)
|
||||
config.Timeout = viper.GetInt("TIMEOUT")
|
||||
config.ShoutUrl = viper.Get("SHOUTRRR_URL").(string)
|
||||
config.Theme = viper.Get("THEME").(string)
|
||||
|
||||
return config
|
||||
}
|
||||
|
|
@ -16,7 +16,7 @@ func index(w http.ResponseWriter, r *http.Request) {
|
|||
guiData.Config = AppConfig
|
||||
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)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ type Conf struct {
|
|||
GuiPort string
|
||||
Timeout int
|
||||
ShoutUrl string
|
||||
Theme string
|
||||
}
|
||||
|
||||
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>
|
||||
<title>Watch Your LAN</title>
|
||||
<meta charset="utf-8">
|
||||
<!--Auto refresh (seconds)-->
|
||||
<meta http-equiv="refresh" content="60">
|
||||
<!--Favicon-->
|
||||
<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 }}
|
||||
|
|
@ -1,7 +1,11 @@
|
|||
{{ define "index"}}
|
||||
|
||||
{{ 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>
|
||||
<div class="container mt-3">
|
||||
<h2>Online</h2>
|
||||
|
|
@ -65,6 +69,6 @@
|
|||
{{ end }}
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
{{ template "footer" }}
|
||||
{{ end }}
|
||||
Loading…
Reference in a new issue