Compare commits
6 Commits
918b9a6b74
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
26b363fc34
|
|||
|
4700faf03c
|
|||
|
79f3692ad2
|
|||
|
5485fd135d
|
|||
|
5558d42bdb
|
|||
|
b74df36bda
|
24
.gitea/ISSUE_TEMPLATE/bug_report.md
Normal file
24
.gitea/ISSUE_TEMPLATE/bug_report.md
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
name: "Bug Report"
|
||||||
|
about: Report an error or unexpected behavior in MiauInv
|
||||||
|
title: "[BUG] "
|
||||||
|
labels: ["Kind/Bug"]
|
||||||
|
---
|
||||||
|
|
||||||
|
### Description
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
### Steps to Reproduce
|
||||||
|
1. Go to '...'
|
||||||
|
2. Click on '...'
|
||||||
|
3. Scroll down to '...'
|
||||||
|
4. See error
|
||||||
|
|
||||||
|
### Expected Behavior
|
||||||
|
A clear and concise description of what you expected to happen.
|
||||||
|
|
||||||
|
### Logs and Error Messages
|
||||||
|
If applicable, add server logs or browser console outputs here:
|
||||||
|
```text
|
||||||
|
Insert logs here
|
||||||
|
```
|
||||||
18
.gitea/ISSUE_TEMPLATE/feature_request.md
Normal file
18
.gitea/ISSUE_TEMPLATE/feature_request.md
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
---
|
||||||
|
name: "Feature Request"
|
||||||
|
about: Suggest an idea or enhancement for MiauInv
|
||||||
|
title: "[FEATURE] "
|
||||||
|
labels: ["Kind/Feature"]
|
||||||
|
---
|
||||||
|
|
||||||
|
### Problem Statement
|
||||||
|
Is your feature request related to a problem? Please describe. (e.g., I am frustrated when...)
|
||||||
|
|
||||||
|
### Proposed Solution
|
||||||
|
A clear and concise description of what you want to happen.
|
||||||
|
|
||||||
|
### Alternative Solutions
|
||||||
|
A clear and concise description of any alternative solutions or features you have considered.
|
||||||
|
|
||||||
|
### Additional Context
|
||||||
|
Add any other context, screenshots, or mockup ideas about the feature request here.
|
||||||
14
.gitea/pull_request_template.md
Normal file
14
.gitea/pull_request_template.md
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
## Description
|
||||||
|
Please include a summary of the changes and which issue is fixed.
|
||||||
|
|
||||||
|
Closes # (Issue Number)
|
||||||
|
|
||||||
|
## Type of Change
|
||||||
|
- [ ] Bug fix (non-breaking change which fixes an issue)
|
||||||
|
- [ ] New feature (non-breaking change which adds functionality)
|
||||||
|
- [ ] Chore / Refactoring (code cleanup or configuration updates)
|
||||||
|
|
||||||
|
## Testing Environment
|
||||||
|
- [ ] Verified via local development server
|
||||||
|
- [ ] Verified compilation inside the Docker container
|
||||||
|
- [ ] All unit tests passing successfully
|
||||||
36
.gitea/workflows/release-docker.yaml
Normal file
36
.gitea/workflows/release-docker.yaml
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
name: Build and Push Docker Image on Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: actions/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: actions/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Log in to Gitea Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: git.miaurizius.de
|
||||||
|
username: ${{ gitea.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
push: true
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
tags: |
|
||||||
|
git.miaurizius.de/${{ gitea.repository }}:latest
|
||||||
|
git.miaurizius.de/${{ gitea.repository }}:${{ gitea.event.release.tag_name }}
|
||||||
30
.gitea/workflows/test-and-lint.yaml
Normal file
30
.gitea/workflows/test-and-lint.yaml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
name: Code Quality and Testing
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main, 'feature/**', 'bugfix/**', 'chore/**', 'refactor/**' ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ main ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test-and-lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: '1.22'
|
||||||
|
|
||||||
|
- name: Check Go Formatting (gofmt)
|
||||||
|
run: |
|
||||||
|
if [ -n "$(gofmt -l .)" ]; then
|
||||||
|
echo "The following files are not properly formatted. Please run 'gofmt -w .'"
|
||||||
|
gofmt -l .
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Run Unit Tests
|
||||||
|
run: go test -v ./...
|
||||||
@@ -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