BootPath, Icon in Config
This commit is contained in:
parent
17f7f1fb04
commit
0e15f81758
10 changed files with 19 additions and 11 deletions
|
|
@ -8,12 +8,15 @@ import (
|
|||
)
|
||||
|
||||
const configPath = "/data/config"
|
||||
const bootPath = "https://cdn.jsdelivr.net/npm/bootswatch@5.2.3/dist"
|
||||
// const bootPath = "file://data/node_modules/bootswatch/dist"
|
||||
|
||||
func main() {
|
||||
confPtr := flag.String("c", configPath, "Path to config file")
|
||||
bootPtr := flag.String("b", bootPath, "Path to Bootswatch")
|
||||
flag.Parse()
|
||||
|
||||
check.Path(*confPtr)
|
||||
|
||||
web.Gui(*confPtr) // Start web GUI
|
||||
web.Gui(*confPtr, *bootPtr) // Start web GUI
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ func Write(path string, config models.Conf) {
|
|||
viper.SetConfigType("env")
|
||||
|
||||
viper.Set("IFACE", config.Iface)
|
||||
viper.Set("DBPATH", config.DbPath)
|
||||
viper.Set("GUIIP", config.GuiIP)
|
||||
viper.Set("GUIPORT", config.GuiPort)
|
||||
viper.Set("TIMEOUT", config.Timeout)
|
||||
|
|
|
|||
|
|
@ -22,13 +22,14 @@ type Conf struct {
|
|||
ShoutURL string
|
||||
Theme string
|
||||
IgnoreIP string
|
||||
BootPath string
|
||||
Icon string
|
||||
}
|
||||
|
||||
// GuiData - all data sent to html page
|
||||
type GuiData struct {
|
||||
Config Conf
|
||||
Hosts []Host
|
||||
Icon string
|
||||
Themes []string
|
||||
Version string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ func configHandler(w http.ResponseWriter, r *http.Request) {
|
|||
var guiData models.GuiData
|
||||
|
||||
guiData.Config = AppConfig
|
||||
guiData.Icon = Icon
|
||||
|
||||
file, err := TemplHTML.ReadFile(TemplPath + "version")
|
||||
check.IfError(err)
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ func hostHandler(w http.ResponseWriter, r *http.Request) {
|
|||
var host models.Host
|
||||
|
||||
guiData.Config = AppConfig
|
||||
guiData.Icon = Icon
|
||||
|
||||
idStr := r.URL.Query().Get("id")
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ func indexHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
guiData.Config = AppConfig
|
||||
guiData.Hosts = AllHosts
|
||||
guiData.Icon = Icon
|
||||
|
||||
execTemplate(w, "index", guiData)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ func lineHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
guiData.Config = AppConfig
|
||||
guiData.Hosts = []models.Host{}
|
||||
guiData.Icon = Icon
|
||||
|
||||
state := r.URL.Query().Get("state")
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ func portHandler(w http.ResponseWriter, r *http.Request) {
|
|||
var guiData models.GuiData
|
||||
|
||||
guiData.Config = AppConfig
|
||||
guiData.Icon = Icon
|
||||
|
||||
ip := r.FormValue("ip")
|
||||
beginStr := r.FormValue("begin")
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@
|
|||
<title>Watch Your LAN</title>
|
||||
<meta charset="utf-8">
|
||||
<!--Favicon-->
|
||||
<link href="data:image/x-icon;base64,{{ .Icon }}" rel="icon" type="image/x-icon" />
|
||||
<link href="data:image/x-icon;base64,{{ .Config.Icon }}" rel="icon" type="image/x-icon" />
|
||||
<!-- Bootstrap and theme -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootswatch@5.2.0/dist/{{ .Config.Theme }}/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="{{ .Config.BootPath }}/{{ .Config.Theme }}/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- Font for icons -->
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.9.1/font/bootstrap-icons.css">
|
||||
</head>
|
||||
|
|
@ -34,8 +34,14 @@
|
|||
<button type="submit" class="btn btn-primary">Search</button>
|
||||
</li>
|
||||
</form>
|
||||
<li class="nav-item"><a class="nav-link active" target="_blank" href="https://github.com/aceberg/WatchYourLAN">
|
||||
<!-- <li class="nav-item"><a class="nav-link active" target="_blank" href="https://github.com/aceberg/WatchYourLAN">
|
||||
<h3> <i class="bi bi-github"></i></h3>
|
||||
</a></li> -->
|
||||
|
||||
<li class="nav-item"><a class="nav-link active" target="_blank" href="https://github.com/aceberg/WatchYourLAN">
|
||||
<h3><svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" fill="currentColor" class="bi bi-github" viewBox="0 0 16 16">
|
||||
<path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8z"/>
|
||||
</svg></h3>
|
||||
</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -11,10 +11,12 @@ import (
|
|||
)
|
||||
|
||||
// Gui - start web GUI
|
||||
func Gui(configPath string) {
|
||||
func Gui(configPath, bootPath string) {
|
||||
|
||||
ConfigPath = configPath
|
||||
AppConfig = conf.Get(ConfigPath)
|
||||
AppConfig.BootPath = bootPath
|
||||
AppConfig.Icon = Icon
|
||||
|
||||
address := AppConfig.GuiIP + ":" + AppConfig.GuiPort
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue