Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version number to Web UI and fix page scrolling behaviour #385

Merged
merged 2 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .air.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ tmp_dir = "tmp" # Temporary directory for build artifacts
export CGO_CFLAGS="-I${HOME}/src/tensorflow"
export CGO_LDFLAGS="-L/usr/lib -ltensorflowlite_c"

# Build the Go application
go build -v -x -ldflags "-s -w -X main.buildDate=$(date -u +%Y-%m-%dT%H:%M:%SZ)" -o ./tmp/main .
# Build the Go application with version and build date
go build -v -x -ldflags "-s -w \
-X 'main.buildDate=$(date -u +%Y-%m-%dT%H:%M:%SZ)' \
-X 'main.version=$(git describe --tags --always)'" \
-o ./tmp/main .
"""

bin = "./tmp/main" # Path to the compiled binary
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ TFLITE_VERSION := v2.17.1

# Common flags
CGO_FLAGS := CGO_ENABLED=1 CGO_CFLAGS="-I$(HOME)/src/tensorflow"
LDFLAGS := -ldflags "-s -w -X 'main.buildDate=$(shell date -u +%Y-%m-%dT%H:%M:%SZ)'"
LDFLAGS := -ldflags "-s -w \
-X 'main.buildDate=$(shell date -u +%Y-%m-%dT%H:%M:%SZ)' \
-X 'main.version=$(shell git describe --tags --always)'"

# Detect host OS and architecture
UNAME_S := $(shell uname -s)
Expand Down
19 changes: 0 additions & 19 deletions assets/custom.css
Original file line number Diff line number Diff line change
@@ -1,28 +1,9 @@
/* Ensure scrollbar gutter is stable */
html {
scrollbar-gutter: stable !important;
}

/* Force page scrolling behavior */
html, body {
height: 100%;
overflow-y: auto;
}

/* Ensure drawer content can scroll */
.drawer-content {
height: auto !important;
min-height: 100vh;
overflow-y: auto;
scrollbar-gutter: stable;
}

/* Override any DaisyUI overflow constraints */
.drawer.drawer-open {
overflow-y: auto;
scrollbar-gutter: stable;
}

.audio-control {
width: 100%;
height: 25px;
Expand Down
6 changes: 5 additions & 1 deletion internal/conf/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,10 @@ type Security struct {
type Settings struct {
Debug bool // true to enable debug mode

// Runtime values, not stored in config file
Version string `yaml:"-"` // Version from build
BuildDate string `yaml:"-"` // Build date from build

Main struct {
Name string // name of BirdNET-Go node, can be used to identify source of notes
TimeAs24h bool // true 24-hour time format, false 12-hour time format
Expand Down Expand Up @@ -493,7 +497,7 @@ func SaveSettings() error {
return nil
}

// Settings returns the current settings instance, initializing it if necessary
// Setting returns the current settings instance, initializing it if necessary
func Setting() *Settings {
once.Do(func() {
if settingsInstance == nil {
Expand Down
10 changes: 9 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import (
// buildTime is the time when the binary was built.
var buildDate string

// version holds the Git version tag
var version string

//go:embed assets/*
var assetsFs embed.FS

Expand Down Expand Up @@ -55,7 +58,12 @@ func main() {
os.Exit(1)
}

fmt.Printf("🐦 \033[37mBirdNET-Go build date: %s, using config file: %s\033[0m\n", buildDate, viper.ConfigFileUsed())
// Set runtime values
settings.Version = version
settings.BuildDate = buildDate

fmt.Printf("🐦 \033[37mBirdNET-Go v%s (built: %s), using config file: %s\033[0m\n",
settings.Version, settings.BuildDate, viper.ConfigFileUsed())

// Execute the root command
rootCmd := cmd.RootCommand(settings)
Expand Down
13 changes: 12 additions & 1 deletion views/elements/sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@

{{/* Footer section */}}
<div class="flex-none border-base-200">
<div class="p-4">
<div class="p-4 flex flex-col gap-4">
{{if .Security.Enabled}}
{{if .Security.AccessAllowed}}
{{/* Logout section */}}
Expand Down Expand Up @@ -107,6 +107,17 @@
</button>
{{end}}
{{end}}

{{/* Version number */}}
<div class="text-center text-sm text-base-content/60" role="contentinfo">
<span class="inline-flex items-center gap-1">
{{if .Settings.Version}}
{{.Settings.Version}}
{{else}}
Development Build
{{end}}
</span>
</div>
</div>
</div>
</nav>
Expand Down
Loading