Compare commits
3 Commits
918b9a6b74
...
v1.0.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
5485fd135d
|
|||
|
5558d42bdb
|
|||
|
b74df36bda
|
@@ -1,5 +1,5 @@
|
|||||||
sudo docker buildx build \
|
sudo docker buildx build \
|
||||||
--platform linux/amd64,linux/arm64 \
|
--platform linux/amd64,linux/arm64 \
|
||||||
-t git.miaurizius.de/miaurizius/miauinv:latest \
|
-t git.miaurizius.de/miaurizius/miauinv:latest \
|
||||||
-t git.miaurizius.de/miaurizius/miauinv:v1.0.1 \
|
-t git.miaurizius.de/miaurizius/miauinv:v1.0.2 \
|
||||||
--push .
|
--push .
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package frontend
|
package frontend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"MiauInv/storage"
|
||||||
"html/template"
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@@ -53,7 +54,28 @@ func Home(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
func Dashboard(w http.ResponseWriter, r *http.Request) {
|
func Dashboard(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "text/html")
|
w.Header().Set("Content-Type", "text/html")
|
||||||
err := dashboard.ExecuteTemplate(w, "base.html", struct {
|
|
||||||
|
var itemHive, projectHive, locationHive int
|
||||||
|
|
||||||
|
err := storage.DB.QueryRow("SELECT COUNT(*) FROM items").Scan(&itemHive)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, "Failed to count items", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = storage.DB.QueryRow("SELECT COUNT(*) FROM projects").Scan(&projectHive)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, "Failed to count projects", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = storage.DB.QueryRow("SELECT COUNT(*) FROM locations").Scan(&locationHive)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, "Failed to count locations", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = dashboard.ExecuteTemplate(w, "base.html", struct {
|
||||||
Title string
|
Title string
|
||||||
Stats struct {
|
Stats struct {
|
||||||
Items int
|
Items int
|
||||||
@@ -67,9 +89,9 @@ func Dashboard(w http.ResponseWriter, r *http.Request) {
|
|||||||
Projects int
|
Projects int
|
||||||
Locations int
|
Locations int
|
||||||
}{
|
}{
|
||||||
Items: 1,
|
Items: itemHive,
|
||||||
Projects: 1,
|
Projects: projectHive,
|
||||||
Locations: 3,
|
Locations: locationHive,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -30,6 +30,12 @@ func APIRegister(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(user.Password) > 72 {
|
||||||
|
log.Println("POST [api/register] User password too long")
|
||||||
|
http.Error(w, "Password exceeds the maximum allowed length of 72 characters", http.StatusUnprocessableEntity)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
hashed, err := auth.HashPassword(user.Password)
|
hashed, err := auth.HashPassword(user.Password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("POST [api/register] " + r.RemoteAddr + ": " + err.Error())
|
log.Println("POST [api/register] " + r.RemoteAddr + ": " + err.Error())
|
||||||
|
|||||||
Reference in New Issue
Block a user