Background color: light or dark

This commit is contained in:
aceberg 2023-06-04 23:01:49 +07:00
parent b3a891772e
commit 21f71fa567
8 changed files with 22 additions and 5 deletions

View file

@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/) The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/). and this project adheres to [Semantic Versioning](http://semver.org/).
## [v0.9.3] - 2023-06-04
### Added
- Background color: light or dark
## [v0.9.2] - 2023-05-05 ## [v0.9.2] - 2023-05-05
### Added ### Added
- Choose log level in config - Choose log level in config

View file

@ -22,7 +22,7 @@ fmt:
go fmt ./... go fmt ./...
lint: lint:
# golangci-lint run golangci-lint run
golint ./... golint ./...
check: fmt lint check: fmt lint

View file

@ -16,6 +16,7 @@ func Get(path string) (config models.Conf) {
viper.SetDefault("TIMEOUT", "60") viper.SetDefault("TIMEOUT", "60")
viper.SetDefault("SHOUTRRR_URL", "") viper.SetDefault("SHOUTRRR_URL", "")
viper.SetDefault("THEME", "solar") viper.SetDefault("THEME", "solar")
viper.SetDefault("COLOR", "light")
viper.SetDefault("IGNOREIP", "no") viper.SetDefault("IGNOREIP", "no")
viper.SetDefault("LOGLEVEL", "verbose") viper.SetDefault("LOGLEVEL", "verbose")
@ -33,6 +34,7 @@ func Get(path string) (config models.Conf) {
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) config.Theme = viper.Get("THEME").(string)
config.Color = viper.Get("COLOR").(string)
config.IgnoreIP = viper.Get("IGNOREIP").(string) config.IgnoreIP = viper.Get("IGNOREIP").(string)
config.LogLevel = viper.Get("LOGLEVEL").(string) config.LogLevel = viper.Get("LOGLEVEL").(string)
@ -52,6 +54,7 @@ func Write(path string, config models.Conf) {
viper.Set("TIMEOUT", config.Timeout) viper.Set("TIMEOUT", config.Timeout)
viper.Set("SHOUTRRR_URL", config.ShoutURL) viper.Set("SHOUTRRR_URL", config.ShoutURL)
viper.Set("THEME", config.Theme) viper.Set("THEME", config.Theme)
viper.Set("COLOR", config.Color)
viper.Set("IGNOREIP", config.IgnoreIP) viper.Set("IGNOREIP", config.IgnoreIP)
viper.Set("LOGLEVEL", config.LogLevel) viper.Set("LOGLEVEL", config.LogLevel)

View file

@ -21,6 +21,7 @@ type Conf struct {
Timeout int Timeout int
ShoutURL string ShoutURL string
Theme string Theme string
Color string
IgnoreIP string IgnoreIP string
LogLevel string LogLevel string
BootPath string BootPath string

View file

@ -54,6 +54,7 @@ func saveConfigHandler(w http.ResponseWriter, r *http.Request) {
AppConfig.GuiPort = r.FormValue("port") AppConfig.GuiPort = r.FormValue("port")
AppConfig.ShoutURL = r.FormValue("shout") AppConfig.ShoutURL = r.FormValue("shout")
AppConfig.Theme = r.FormValue("theme") AppConfig.Theme = r.FormValue("theme")
AppConfig.Color = r.FormValue("color")
AppConfig.IgnoreIP = r.FormValue("ignoreip") AppConfig.IgnoreIP = r.FormValue("ignoreip")
AppConfig.LogLevel = r.FormValue("loglevel") AppConfig.LogLevel = r.FormValue("loglevel")

View file

@ -41,6 +41,14 @@
{{ end }} {{ end }}
</select></td> </select></td>
</tr> </tr>
<tr>
<td>Color mode</td>
<td><select name="color" class="form-select">
<option selected>{{ .Config.Color }}</option>
<option value="light">light</option>
<option value="dark">dark</option>
</select></td>
</tr>
<tr> <tr>
<td>Ignore IP</td> <td>Ignore IP</td>
<td> <td>

View file

@ -1,5 +1,5 @@
{{ define "header"}} {{ define "header"}}
<html> <html lang="en" data-bs-theme="{{ .Config.Color }}">
<head> <head>
<title>Watch Your LAN</title> <title>Watch Your LAN</title>
<meta charset="utf-8"> <meta charset="utf-8">
@ -7,9 +7,9 @@
<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.BootPath "" }}
<!-- Bootstrap and theme --> <!-- Bootstrap and theme -->
<link href="https://cdn.jsdelivr.net/npm/bootswatch@5.2.3/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.9.1/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 --> <!-- Bootstrap and theme -->
<link href="/css/bootswatch/dist/{{ .Config.Theme }}/bootstrap.min.css" rel="stylesheet"> <link href="/css/bootswatch/dist/{{ .Config.Theme }}/bootstrap.min.css" rel="stylesheet">

View file

@ -1 +1 @@
VERSION=0.9.2 VERSION=0.9.3