Production- und Test-Umgebung implementiert. Monatsstatistik an Pos.2 verschoben.
All checks were successful
release-tag / release-image (push) Successful in 2m13s

This commit is contained in:
2025-07-23 22:46:39 +02:00
parent 9711ddd4da
commit 308505a588
2 changed files with 39 additions and 25 deletions

BIN
data.db

Binary file not shown.

62
main.go
View File

@@ -33,7 +33,8 @@ func Enabled(k string, def bool) bool {
var ( var (
username = GetENV("KT_USERNAME", "root") username = GetENV("KT_USERNAME", "root")
password = GetENV("KT_PASSWORD", "root") password = GetENV("KT_PASSWORD", "root")
membername = GetENV("KT_MEMBER", "guest") membername = GetENV("KT_MEMBER", "demo")
productive = Enabled("KT_PRODUCTIVE", false)
) )
type Entry struct { type Entry struct {
@@ -107,7 +108,16 @@ func isAuthenticated(r *http.Request) bool {
} }
func main() { func main() {
db, err := sql.Open("sqlite", "/data/data.db") var (
db *sql.DB
err error
)
if productive {
db, err = sql.Open("sqlite", "/data/data.db")
} else {
db, err = sql.Open("sqlite", "./data.db")
}
//
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
@@ -115,7 +125,11 @@ func main() {
createTable(db) createTable(db)
if productive {
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("/data/static")))) http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("/data/static"))))
} else {
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("./static"))))
}
http.HandleFunc("/login", func(w http.ResponseWriter, r *http.Request) { http.HandleFunc("/login", func(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodPost { if r.Method == http.MethodPost {
@@ -453,6 +467,28 @@ const htmlTemplate = `
</form> </form>
{{end}} {{end}}
<h4 class="mt-4">Monatliche Übersicht</h4>
<table class="table table-bordered">
<thead>
<tr>
<th>Monat</th>
<th>Abgaben verteilt</th>
<th>Abgaben offen</th>
</tr>
</thead>
<tbody>
{{range .Monatsstatistik}}
<tr>
<td>{{.Monat}}</td>
<td>{{formatNumber .Summe}} UEC</td>
<td>{{formatNumber .SummeOffen}} UEC</td>
</tr>
{{end}}
</tbody>
</table>
<hr />
<h2 class="mb-3">Gespeicherte Einträge</h2> <h2 class="mb-3">Gespeicherte Einträge</h2>
<table class="table table-striped table-bordered"> <table class="table table-striped table-bordered">
<thead> <thead>
@@ -507,28 +543,6 @@ const htmlTemplate = `
<hr /> <hr />
<h4 class="mt-4">Monatliche Übersicht</h4>
<table class="table table-bordered">
<thead>
<tr>
<th>Monat</th>
<th>Abgaben verteilt</th>
<th>Abgaben offen</th>
</tr>
</thead>
<tbody>
{{range .Monatsstatistik}}
<tr>
<td>{{.Monat}}</td>
<td>{{formatNumber .Summe}} UEC</td>
<td>{{formatNumber .SummeOffen}} UEC</td>
</tr>
{{end}}
</tbody>
</table>
<hr />
<div class="alert alert-info"> <div class="alert alert-info">
<strong>Die tatsächlichen Werte können abweichen.</strong> Die dargestellten Werte sind meine Vorstellung einer sinnvollen Verteilung.<br> <strong>Die tatsächlichen Werte können abweichen.</strong> Die dargestellten Werte sind meine Vorstellung einer sinnvollen Verteilung.<br>
Die Summe wird an die Orga-Leitung entrichtet. Die entgültige Entscheidung über die Verteilung obliegt der Orga-Leitung. Die Summe wird an die Orga-Leitung entrichtet. Die entgültige Entscheidung über die Verteilung obliegt der Orga-Leitung.