Skip to content

Commit

Permalink
Background color: light or dark
Browse files Browse the repository at this point in the history
  • Loading branch information
aceberg committed Jun 4, 2023
1 parent b3a8917 commit 21f71fa
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
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
### Added
- Choose log level in config
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fmt:
go fmt ./...

lint:
# golangci-lint run
golangci-lint run
golint ./...

check: fmt lint
Expand Down
3 changes: 3 additions & 0 deletions internal/conf/get-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func Get(path string) (config models.Conf) {
viper.SetDefault("TIMEOUT", "60")
viper.SetDefault("SHOUTRRR_URL", "")
viper.SetDefault("THEME", "solar")
viper.SetDefault("COLOR", "light")
viper.SetDefault("IGNOREIP", "no")
viper.SetDefault("LOGLEVEL", "verbose")

Expand All @@ -33,6 +34,7 @@ func Get(path string) (config models.Conf) {
config.Timeout = viper.GetInt("TIMEOUT")
config.ShoutURL = viper.Get("SHOUTRRR_URL").(string)
config.Theme = viper.Get("THEME").(string)
config.Color = viper.Get("COLOR").(string)
config.IgnoreIP = viper.Get("IGNOREIP").(string)
config.LogLevel = viper.Get("LOGLEVEL").(string)

Expand All @@ -52,6 +54,7 @@ func Write(path string, config models.Conf) {
viper.Set("TIMEOUT", config.Timeout)
viper.Set("SHOUTRRR_URL", config.ShoutURL)
viper.Set("THEME", config.Theme)
viper.Set("COLOR", config.Color)
viper.Set("IGNOREIP", config.IgnoreIP)
viper.Set("LOGLEVEL", config.LogLevel)

Expand Down
1 change: 1 addition & 0 deletions internal/models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type Conf struct {
Timeout int
ShoutURL string
Theme string
Color string
IgnoreIP string
LogLevel string
BootPath string
Expand Down
1 change: 1 addition & 0 deletions internal/web/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func saveConfigHandler(w http.ResponseWriter, r *http.Request) {
AppConfig.GuiPort = r.FormValue("port")
AppConfig.ShoutURL = r.FormValue("shout")
AppConfig.Theme = r.FormValue("theme")
AppConfig.Color = r.FormValue("color")
AppConfig.IgnoreIP = r.FormValue("ignoreip")
AppConfig.LogLevel = r.FormValue("loglevel")

Expand Down
8 changes: 8 additions & 0 deletions internal/web/templates/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@
{{ end }}
</select></td>
</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>
<td>Ignore IP</td>
<td>
Expand Down
6 changes: 3 additions & 3 deletions internal/web/templates/header.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{{ define "header"}}
<html>
<html lang="en" data-bs-theme="{{ .Config.Color }}">
<head>
<title>Watch Your LAN</title>
<meta charset="utf-8">
<!--Favicon-->
<link href="data:image/x-icon;base64,{{ .Config.Icon }}" rel="icon" type="image/x-icon" />
{{ if eq .Config.BootPath "" }}
<!-- 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 -->
<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 }}
<!-- Bootstrap and theme -->
<link href="/css/bootswatch/dist/{{ .Config.Theme }}/bootstrap.min.css" rel="stylesheet">
Expand Down
2 changes: 1 addition & 1 deletion internal/web/templates/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION=0.9.2
VERSION=0.9.3

0 comments on commit 21f71fa

Please sign in to comment.