77 Commits

Author SHA1 Message Date
Gregory Ballantine d09c306c6b Adding when:event tag to woodpecker pipeline per Woodpecker's Docs' recommendation
ci/woodpecker/push/woodpecker Pipeline was successful
2026-07-24 14:50:10 -04:00
Gregory Ballantine b9a0cfb993 Fixed more style issues
ci/woodpecker/push/woodpecker Pipeline was successful
2026-07-24 14:46:16 -04:00
Gregory Ballantine 73d0bec16a Updated some styles 2026-07-24 12:29:44 -04:00
Gregory Ballantine 2d62d1d18b Fixed timestamps; added info to dashboard
ci/woodpecker/push/woodpecker Pipeline was successful
2026-07-24 12:18:22 -04:00
Gregory Ballantine 4e0223052e Updated Docker configs to use Air for auto-reloading
ci/woodpecker/push/woodpecker Pipeline was successful
2026-07-24 12:01:20 -04:00
Gregory Ballantine 58dd358acb Added Docker container and compose definitions to make development easier
ci/woodpecker/push/woodpecker Pipeline was successful
2026-07-24 11:00:35 -04:00
gballan 6ac189a72c [Issue #11] - reworked the benchmark profile add page to be more sensible; added links for editing and deleting settings profiles
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/manual/woodpecker Pipeline was successful
2025-10-22 18:48:09 -04:00
gballan 008a6a5c72 [Issue #11] - added ability to create new benchmark settings profiles
ci/woodpecker/push/woodpecker Pipeline was successful
2025-10-22 00:58:32 -04:00
gballan 431d94660d Added ability to edit benchmark parameters
ci/woodpecker/tag/woodpecker Pipeline was successful
ci/woodpecker/release/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
2025-10-04 12:23:06 -04:00
Gregory Ballantine fd66449c28 Added ability to edit tests and hardware
ci/woodpecker/push/woodpecker Pipeline was successful
2025-10-02 16:18:40 -04:00
Gregory Ballantine cb55a19ada Switching from air to fresh for auto-reloading
ci/woodpecker/push/woodpecker Pipeline is pending
2025-10-02 14:42:14 -04:00
Gregory Ballantine 352950467c Finishing the test/edit route
ci/woodpecker/push/woodpecker Pipeline is pending
2025-10-02 11:28:56 -04:00
Gregory Ballantine abc4abe80e Updating Woodpecker CI config 2025-10-02 11:25:14 -04:00
Gregory Ballantine ff8acd493b [Issue #2] - Added .air.toml for using air with some sane defaults; added README to document how to use it (plus some info on the app) 2025-10-02 11:22:21 -04:00
Gregory Ballantine 4b98322022 Continued work on the test/edit post routet
ci/woodpecker/push/woodpecker Pipeline failed
2025-08-12 11:40:56 -04:00
gballan 60d8554cf1 Updated the test edit page (still need to do the post page)
ci/woodpecker/push/woodpecker Pipeline failed
2025-08-10 01:44:33 -04:00
gballan c19bb2108c Adding local tmp directory to git ignore
ci/woodpecker/push/woodpecker Pipeline was successful
2025-07-28 08:00:21 -04:00
gballan 27cff3e79b Adding event: tag to the asset packaging step
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline failed
2025-07-14 14:17:12 -04:00
gballan 03ef5cc905 Updating Grunt commands 2025-07-14 14:17:11 -04:00
gballan f81879302d Started working on test edit page; removed nodemon because it wasn't working 2025-07-14 14:17:11 -04:00
gballan 9ecff3a25d Added nodemon to dev dependencies to automatially reload the app on changes 2025-07-14 14:17:10 -04:00
gballan bef17b5a59 Fixed typo in Gruntfile; added Make tasks to compile frontend assets; Modernized the gathering of benchmark result data for the test view 2025-07-14 14:17:10 -04:00
gballan 82f42ecbed Improved some styles 2025-07-14 14:17:09 -04:00
gballan 673e2e9634 [Issue #8] - Licensing project under the BSD 2-Clause license (#10)
Adding license to project

Co-authored-by: Gregory Ballantine <gballantine@bitgoblin.tech>
Reviewed-on: #10
2025-07-14 14:17:07 -04:00
gballan 178894a360 3-add-gruntjs (#9)
Adding Grunt.js to compile SASS and CoffeeScript assets

Co-authored-by: Gregory Ballantine <gballantine555@gmail.com>
Reviewed-on: #9
2025-07-14 14:16:58 -04:00
gballan 5fc381c4b9 Updated some styles for tables and links 2025-07-14 13:53:50 -04:00
gballan c9d2f7114a Added tests to hardware page 2025-07-14 13:53:50 -04:00
gballan bce063c5f4 Updated some styles 2025-07-14 13:53:50 -04:00
gballan b54d31213b Updated some styles 2025-07-14 13:53:50 -04:00
gballan ae4198f3cc Fixed results table in test view 2025-07-14 13:53:50 -04:00
gballan 9fdf6e2b99 Fixed results table in test view 2025-07-14 13:53:50 -04:00
gballan 8f0cce7550 Fixed results table in test view 2025-07-14 13:53:50 -04:00
gballan d97fee0911 Fixed results table in test view 2025-07-14 13:53:50 -04:00
gballan de107761eb Added back reference associations for result; added table of results to test view 2025-07-14 13:53:50 -04:00
gballan 26ad420436 added missing import 2025-07-14 13:53:50 -04:00
gballan 47f3dcdbd1 Fixed result form stuff 2025-07-14 13:53:50 -04:00
gballan 6bb06205b0 Fixed float variable types 2025-07-14 13:53:50 -04:00
gballan b508efd5a8 Added result creation route 2025-07-14 13:53:50 -04:00
gballan e5a18f77f2 Added result model; added form to submit results 2025-07-14 13:53:50 -04:00
gballan db41f0d6bd Added result model; added form to submit results 2025-07-14 13:53:50 -04:00
gballan b93c8a5319 Added result model; added form to submit results 2025-07-14 13:53:50 -04:00
gballan 346b9e3911 Cleaned up runtime version 2025-07-14 13:53:50 -04:00
gballan 446590acb1 Added Go runtime version to the layout footer 2025-07-14 13:53:50 -04:00
gballan a38ede5187 Added Go runtime version to the layout footer 2025-07-14 13:53:50 -04:00
gballan 2b3f24ee5c Fixed associating benchmarks to test 2025-07-14 13:53:50 -04:00
gballan 9104125de7 Fixed creating new test 2025-07-14 13:53:50 -04:00
gballan 5ad0810d81 Fixed creating new test 2025-07-14 13:53:50 -04:00
gballan e27fd8d214 Added more information to the test view page 2025-07-14 13:53:50 -04:00
gballan 3910c4dc9c Fixed typo in test view route 2025-07-14 13:53:50 -04:00
gballan 3b8a30c7f8 Fixed typos in benchmark list view 2025-07-14 13:53:50 -04:00
gballan 293098e173 Fixed typos in model searches 2025-07-14 13:53:50 -04:00
gballan 10298cbf7c Fixed typo in benchmark list view 2025-07-14 13:53:50 -04:00
gballan 743a108add Fixed benchmark form submission error 2025-07-14 13:53:50 -04:00
gballan c8a47b270a Fixed mix up between benchmark and hardware routes files 2025-07-14 13:53:50 -04:00
gballan fde8d1dee4 Added benchmarks routes and views 2025-07-14 13:53:50 -04:00
gballan bee64576bc Slight tweak to create test view 2025-07-14 13:53:50 -04:00
gballan 3c1d48a9ed Fixed form select field styling 2025-07-14 13:53:50 -04:00
gballan 633fc4ac02 Fixed variable capitalization in create test view 2025-07-14 13:53:50 -04:00
gballan 79924cd978 Added description field to Test model 2025-07-14 13:53:50 -04:00
gballan e5443fb644 Passed hardware components and benchmarks to create test view 2025-07-14 13:53:50 -04:00
gballan 81a87e2761 Added route to view test 2025-07-14 13:53:50 -04:00
gballan 65550c983c Added route to view test 2025-07-14 13:53:50 -04:00
gballan f3a2376c19 Added route to view test 2025-07-14 13:53:50 -04:00
gballan 99f45b3b3a Added route to view hardware component 2025-07-14 13:53:50 -04:00
gballan 4718aeaccd Added route to view hardware component 2025-07-14 13:53:50 -04:00
gballan 62654b9a3e Added route to view hardware component 2025-07-14 13:53:50 -04:00
gballan 93778274c2 Added hardware routes and views 2025-07-14 13:53:50 -04:00
gballan 7c13b1f209 Lots of changes 2025-07-14 13:53:50 -04:00
gballan e09d399c98 Added ability to create projects 2025-07-14 13:53:50 -04:00
gballan c9ad5df2ed Refactored models code to follow a better approach for opening and closing the database connection 2025-07-14 13:53:50 -04:00
gballan 0f89087134 Added models; started working on project routes 2025-07-14 13:53:50 -04:00
gballan 819baeb0c3 Added Gorm to project 2025-07-14 13:53:50 -04:00
gballan fe303cb778 Copied some styles from Leviathan 2025-07-14 13:53:50 -04:00
gballan 98bd1f7eca Started working on the layout of the app 2025-07-14 13:53:50 -04:00
gballan 09a2667fc5 Updated Makefile to auto-define version 2025-07-14 13:53:50 -04:00
gballan 4020812549 Added templating, versioning, middleware, etc 2025-07-14 13:53:50 -04:00
gballan 8bc9849776 Better start for Flamego 2025-07-14 13:53:50 -04:00
46 changed files with 3090 additions and 249 deletions
+21
View File
@@ -0,0 +1,21 @@
[build]
# Tell Air to use your Makefile build target directly!
cmd = "make build BUILD_DIR=/tmp"
# Tell Air where your compiled binary ends up
bin = "/tmp/blt"
# Watch these extensions and ignore these paths
include_ext = ["go", "tpl", "tmpl", "html"]
exclude_dir = ["assets", "tmp", "bin", "node_modules", "public"]
# Delay before rebuilding after a file save (ms)
delay = 500
[log]
time = false
[color]
main = "magenta"
build = "yellow"
runner = "green"
+8
View File
@@ -3,4 +3,12 @@ blt
# Local data files
data/
tmp/
# Compiled assets
public/css/
public/js/
# Node modules
node_modules/
+35
View File
@@ -0,0 +1,35 @@
when:
event: push
steps:
build:
image: golang:1.22
commands:
- go mod vendor
- GOOS=linux GOARCH=amd64 go build -o "dist/blt-linux-amd64-${CI_COMMIT_TAG}.bin"
- GOOS=windows GOARCH=amd64 go build -o "dist/blt-windows-amd64-${CI_COMMIT_TAG}.exe"
assets:
image: node:24
commands:
- npm install
- npm run grunt build
package:
image: alpine
commands:
- tar -cvzf "dist/blt-assets-${CI_COMMIT_TAG}.tar.gz" public/
when:
event: tag
gitea_release:
image: plugins/gitea-release
settings:
api_key:
from_secret: gitea_api_key
base_url: https://git.metaunix.net
title: "${CI_COMMIT_TAG}"
files:
- dist/blt-*
when:
event: tag
+21
View File
@@ -0,0 +1,21 @@
FROM golang:1.26
WORKDIR /app
RUN apt install -y make gcc
# Make sure /app is safe regardless of who owns it
RUN git config --global --add safe.directory /app
ENV CGO_ENABLED=1
# Install Air for auto-reloading
RUN go install github.com/air-verse/air@latest
# Copy dependency definitions first (caching optimization)
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN make build BUILD_DIR=/tmp
+11
View File
@@ -0,0 +1,11 @@
# Node.js runtime
FROM node:24
WORKDIR /var/www/html/
COPY package.* /var/www/html/
RUN npm install
# Run the app
CMD [ "npm", "run", "grunt" ]
+67
View File
@@ -0,0 +1,67 @@
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
dist: {
options: {
style: 'compressed'
},
files: [{
expand: true,
cwd: 'assets/styles',
src: ['**/*.sass'],
dest: 'public/css',
ext: '.css'
}]
}
},
coffee: {
options: {
sourceMap: true,
style: 'compressed'
},
files: {
expand: true,
flatten: true,
cwd: 'assets/scripts',
src: ['*.coffee'],
dest: 'public/js',
ext: '.js'
}
},
watch: {
css: {
files: ['assets/styles/**/*.sass'],
tasks: ['sass'],
options: {
atBegin: true,
spawn: false
}
},
js: {
files: ['assets/scripts/**/*.coffee'],
tasks: ['coffee'],
options: {
atBegin: true,
spawn: false
}
}
}
});
// Load plugins.
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-coffee');
// CLI tasks.
grunt.registerTask('build', ['sass', 'coffee']);
grunt.registerTask('dev', ['watch']);
grunt.registerTask('default', ['build']);
};
+9
View File
@@ -0,0 +1,9 @@
Copyright (c) 2023 Bit Goblin
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+19 -26
View File
@@ -1,35 +1,28 @@
NAME=blt
VERSION=`git describe --tags`
.PHONY: build
## build: Compile the packages.
# used for changing the output directory within docker containers
BUILD_DIR ?= .
dev-up:
docker compose -f docker-dev.yml up -d
dev-down:
docker compose -f docker-dev.yml down
dev-build:
docker compose -f docker-dev.yml build
build:
@go build -o $(NAME) -ldflags "-X git.metaunix.net/bitgoblin/blt/app.AppVersion=$(VERSION)"
@echo "Building Go binary..."
@go build -o $(BUILD_DIR)/$(NAME) -ldflags "-X git.metaunix.net/bitgoblin/blt/app.AppVersion=$(VERSION)"
.PHONY: run
## run: Build and Run in development mode.
run: build
@./$(NAME) -e development
run:
$(BUILD_DIR)/$(NAME)
.PHONY: run-prod
## run-prod: Build and Run in production mode.
run-prod: build
@./$(NAME) -e production
.PHONY: clean
## clean: Clean project and previous builds.
clean:
@rm -f $(NAME)
.PHONY: deps
## deps: Download modules
deps:
@go mod download
.PHONY: test
## test: Run tests with verbose mode
test:
@go test -v ./tests/*
watch:
@echo "Starting hot-reload watcher..."
@air
.PHONY: help
all: help
+54
View File
@@ -0,0 +1,54 @@
# Benchmark Logging Tool (BLT)
![Build badge](https://builds.metaunix.net/api/badges/87/status.svg)
Web-based tool to store and organize PC hardware benchmarks.
## Project Goals
The goals of this project are to:
* Record benchmarking results from multiple devices - e.g. log from a laptop or a phone.
* Group results into tests to keep track of different testing configurations.
* Encourage running tests multiple times - it's good practice to run a benchmark multiple times for accuracy.
* Create comparisons of hardware tests to compare performance.
* Generate graphs of hardware comparisons for usage in videos and articles.
## Requirements
BLT runs on Go. It uses the built-in `go mod` tool to manage dependencies, thus there is no external tooling to install to build/run BLT.
Debian/Ubuntu: `apt install -y golang`
RedHat and clones: `dnf install -y golang`
## Production Deployment
**TODO**
## Development
### Via Docker
**TODO**
### Local/Native Development
BLT uses [fresh](https://github.com/gravityblast/fresh) to auto-reload the app. While this is not strictly necessary, it used to make development more convenient. If you wish to forego installing it, you may simply build and run the app with the standard `go run main.go`.
1. Install dependencies:
`go mod download`
2. Install fresh to auto-reload the app:
`go install github.com/gravityblast/fresh@latest`
3. Run the app via air:
`fresh`
4. If everything is running successfully you can open your browser and go to http://localhost:2830.
## License
This project is available under the BSD 2-Clause license.
+7
View File
@@ -0,0 +1,7 @@
root = if typeof window isnt 'undefined' then window else global
root.roundDecimal = (value) ->
return Math.round(value * 100) / 100
$ ->
console.log('DOM is ready.')
+62
View File
@@ -0,0 +1,62 @@
testId = $('#results-table').data('test-id')
$ ->
$('#result-form').on 'submit', (e) ->
e.preventDefault()
form = $(this)
formData = $(this).serialize()
benchmarkId = $(this).find('[name="result_benchmark"]').val()
$.post '/api/v1/result/add', formData, (response) ->
if response == 'success'
fetchTestBenchmarkResults(testId, benchmarkId)
form[0].reset()
fetchTestBenchmarkResults = (testId, benchmarkId) ->
try
benchmarkSearchParams = new URLSearchParams
benchmark_id: benchmarkId
benchmarkRes = await fetch("/api/v1/benchmark/details?#{benchmarkSearchParams}")
benchmarkData = await benchmarkRes.json()
resultSearchParams = new URLSearchParams
test_id: testId
benchmark_id: benchmarkId
resultRes = await fetch("/api/v1/result/list?#{resultSearchParams}")
resultData = await resultRes.json()
avg_total = 0
min_total = 0
max_total = 0
for result in resultData
avg_total += result.AverageScore
min_total += result.MinimumScore if result.MinimumScore
max_total += result.MaximumScore if result.MaximumScore
tableRow = $("#results-table tr[data-benchmark-id=#{benchmarkId}]")
tableRow.empty()
tableRow.append('<td><a href="/benchmark/' + benchmarkData.ID + '">' + benchmarkData.Name + '</a></td>')
tableRow.append('<td>' + benchmarkData.ScoringType + '</td>')
tableRow.append('<td>' + resultData.length + '</td>')
if resultData.length != 0
tableRow.append('<td>' + roundDecimal(avg_total / resultData.length) + '</td>')
else
tableRow.append('<td>N/a</td>')
if min_total != 0
tableRow.append('<td>' + roundDecimal(min_total / resultData.length) + '</td>')
tableRow.append('<td>' + roundDecimal(max_total / resultData.length) + '</td>')
else
tableRow.append('<td>N/a</td>')
tableRow.append('<td>N/a</td>')
catch error
console.error 'An error occurred while fetching benchmark results.', error
$('#results-table tbody tr').each (index, tr) ->
benchmarkId = $(tr).data('benchmark-id')
console.log("Fetching results for benchmark id: " + benchmarkId)
fetchTestBenchmarkResults(testId, benchmarkId)
+122
View File
@@ -0,0 +1,122 @@
$primary-color: #ff3300
$primary-color-dark: darken($primary-color, 10%)
@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100..900;1,100..900&display=swap')
html,
body
width: 100%
height: 100%
margin: 0
padding: 0
body
height: auto
min-height: 100%
box-sizing: border-box
padding-top: 80px
padding-bottom: 100px
background: #eee
font-family: "Roboto", sans-serif
font-optical-sizing: auto
a
color: $primary-color
transition: color 180ms ease-in-out
&:hover
color: $primary-color-dark
button.button-primary,
input[type=button].button-primary,
input[type=submit].button-primary
background: $primary-color
transition: background 180ms ease-in-out
&:hover
background: $primary-color-dark
textarea
max-width: 100%
min-width: 100%
height: 100px
form select[multiple]
min-height: 100px
table
border: 1px solid #ddd
border-radius: 8px
border-spacing: 0
overflow: hidden
table th,
table td,
table th:first-child,
table td:first-child
border: none
padding: 7px 12px
table thead tr
border-radius: 8px 8px 0 0
&:last-child
border-radius: 0 0 8px 8px
table thead tr,
table tr:nth-child(even)
background: #eee
table tbody tr
transition: background 180ms ease-in-out
&:hover
background: #d8d8d8
.container
max-width: 1200px
#main-nav
position: fixed
top: 0
left: 0
width: 100%
height: 64px
background: $primary-color
color: white
z-index: 20
ul
list-style: none
display: inline-block
li
display: inline-block
margin-left: 15px
h4
display: inline-block
margin-left: 25px
line-height: 64px
a
color: white
text-decoration: none
font-size: 2.25rem
line-height: 64px
transition: all 200ms ease-in-out
&:hover
color: #eee
#main-content
padding: 15px 25px
background: white
border-radius: 8px
z-index: 10
#main-footer
position: fixed
bottom: 0
left: 0
width: 100%
height: 64px
p
margin-bottom: 5px
text-align: center
+32
View File
@@ -0,0 +1,32 @@
services:
app:
build:
context: .
dockerfile: Dockerfile.dev
command: make watch
ports:
- "2830:2830"
volumes:
- .:/app # Mounts local directory for hot-reloading/live edits
- go-modules:/go/pkg/mod # Caches Go modules on host
# Mount the compiled static assets generated by Grunt
- static-assets:/app/public
environment:
- APP_ENV=development
assets:
build:
context: .
dockerfile: Dockerfile.grunt
# Override CMD to run watch mode during local dev
command: npm run grunt watch
volumes:
# Mount host code so Grunt detects file changes in real time
- .:/var/www/html
# Preserve container node_modules from being overwritten by host
- /var/www/html/node_modules
# Output compiled assets into the shared volume
- static-assets:/var/www/html/public
volumes:
go-modules:
static-assets:
+15 -2
View File
@@ -1,6 +1,7 @@
package main
import (
gotemplate "html/template"
"log"
"net/http"
@@ -21,8 +22,20 @@ func main() {
// initialize database
models.Open()
// initialize base renderer
f.Use(flamego.Renderer())
// initialize templating engine
f.Use(template.Templater())
f.Use(template.Templater(template.Options{
FuncMaps: []gotemplate.FuncMap{
{
"contains": web.Contains,
},
},
Directory: "templates",
Extensions: []string{".tmpl", ".html"},
},
))
// inject custom middleware
f.Use(middleware.CustomVars)
@@ -31,6 +44,6 @@ func main() {
web.RegisterRoutes(f)
// alert the user and start the server
log.Println("Server is running...")
log.Println("Server is listening on 0.0.0.0:2830.")
log.Println(http.ListenAndServe("0.0.0.0:2830", f))
}
+27
View File
@@ -0,0 +1,27 @@
package models
import (
"strconv"
"gorm.io/gorm"
)
type BenchmarkProfile struct {
gorm.Model
Label string
Settings string
// belongs to Benchmark
BenchmarkID int
Benchmark Benchmark
// many-to-many with tests
Tests []Test `gorm:"many2many:tests_benchmark_profiles;"`
// has many results
Results []Result
}
func (b *BenchmarkProfile) StringID() string {
return strconv.Itoa(int(b.ID))
}
+8 -5
View File
@@ -1,6 +1,8 @@
package models
import (
"strconv"
"gorm.io/gorm"
)
@@ -10,9 +12,10 @@ type Benchmark struct {
ScoringType string
Description string
// many-to-many test
Tests []Test `gorm:"many2many:tests_benchmarks;"`
// has many results
Results []Result
// one-to-many BenchmarkProfiles
BenchmarkProfiles []BenchmarkProfile
}
func (b *Benchmark) StringID() string {
return strconv.Itoa(int(b.ID))
}
-3
View File
@@ -11,7 +11,4 @@ type Hardware struct {
// has many tests
Tests []Test
// has many results
Results []Result
}
+2 -6
View File
@@ -10,13 +10,9 @@ type Result struct {
MinimumScore float32
MaximumScore float32
// belongs to Hardware
HardwareID int
Hardware Hardware
// belongs to Benchmark
BenchmarkID int
Benchmark Benchmark
BenchmarkProfileID int
BenchmarkProfile BenchmarkProfile
// belongs to Test
TestID int
+25 -2
View File
@@ -1,6 +1,8 @@
package models
import (
"strconv"
"gorm.io/gorm"
)
@@ -13,9 +15,30 @@ type Test struct {
HardwareID int
Hardware Hardware
// many-to-many benchmarks
Benchmarks []Benchmark `gorm:"many2many:tests_benchmarks;"`
// many-to-many benchmark profiles
BenchmarkProfiles []Benchmark `gorm:"many2many:tests_benchmark_profiles;"`
// has many results
Results []Result
}
func (t *Test) SelectedBenchmarks() []string {
benchmarks := t.BenchmarkProfiles
ids := make([]string, len(benchmarks))
for i, b := range benchmarks {
ids[i] = strconv.Itoa(int(b.ID))
}
return ids
}
func (t *Test) IsBenchmarkSelected(benchmarkID uint) bool {
benchmarkUint := uint(benchmarkID)
for _, b := range t.BenchmarkProfiles {
if b.ID == benchmarkUint {
return true
}
}
return false
}
+1853
View File
File diff suppressed because it is too large Load Diff
+36
View File
@@ -0,0 +1,36 @@
{
"name": "blt",
"version": "0.1.0",
"description": "Self-hosted PC hardware benchmark logging tool",
"main": "index.js",
"scripts": {
"grunt": "grunt",
"nodemon": "nodemon"
},
"repository": {
"type": "git",
"url": "gitea@git.metaunix.net:BitGoblin/blt.git"
},
"keywords": [
"hardware",
"benchmark",
"testing",
"PC"
],
"author": "Gregory Ballanine <gballantine@bitgoblin.tech>",
"uploaders": [
{
"name": "Gregory Ballantine",
"email": "gballantine@bitgoblin.tech"
}
],
"license": "BSD-2-Clause",
"devDependencies": {
"grunt": "^1.5.3",
"grunt-cli": "^1.4.3",
"grunt-contrib-coffee": "^2.1.0",
"grunt-contrib-sass": "^2.0.0",
"grunt-contrib-watch": "^1.1.0",
"sass": "^1.55.0"
}
}
-156
View File
@@ -1,156 +0,0 @@
html,
body{
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
body{
height: auto;
min-height: 100%;
box-sizing: border-box;
padding-top: 80px;
padding-bottom: 100px;
background: #eee;
}
a{
color: teal;
transition: color 180ms ease-in-out;
}
a:hover{
color: darkcyan;
}
button.button-primary{
background: teal;
transition: background 180ms ease-in-out;
}
button.button-primary:hover{
background: darkcyan;
}
textarea{
max-width: 100%;
min-width: 100%;
height: 100px;
}
form select[multiple]{
min-height: 100px;
}
table{
border: 1px solid #ddd;
border-radius: 8px;
border-spacing: 0;
overflow: hidden;
}
table th,
table td,
table th:first-child,
table td:first-child{
border: none;
padding: 7px 12px;
}
table thead tr{
border-radius: 8px 8px 0 0;
}
table tbody tr:last-child{
border-radius: 0 0 8px 8px;
}
table thead tr,
table tr:nth-child(even){
background: #eee;
}
/* Material card styles */
.card-1 {
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
transition: all 0.3s cubic-bezier(.25,.8,.25,1);
}
.card-1:hover {
box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
}
.card-2 {
box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
}
.card-3 {
box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
}
.card-4 {
box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
}
.card-5 {
box-shadow: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22);
}
.container{
max-width: 1200px;
}
#main-nav{
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 64px;
background: teal;
color: white;
z-index: 20;
}
#main-nav ul{
list-style: none;
display: inline-block;
}
#main-nav h4{
display: inline-block;
margin-left: 25px;
line-height: 64px;
}
#main-nav ul li{
display: inline-block;
margin-left: 15px;
}
#main-nav a{
color: white;
font-size: 2.25rem;
line-height: 64px;
transition: all 200ms ease-in-out;
}
#main-nav a:hover{
color: #eee;
font-size: 2.5rem;
}
#main-content{
padding: 15px 25px;
background: white;
border-radius: 8px;
z-index: 10;
}
#main-footer{
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height: 64px;
}
#main-footer p{
margin-bottom: 5px;
text-align: center;
}
+38
View File
@@ -0,0 +1,38 @@
{{ template "header" . }}
<div class="row">
<h2>Editing Benchmark: {{ .benchmark.Name }}</h2>
<form class="twelve columns" action="/benchmark/{{ .benchmark.ID }}/edit" method="POST">
<div class="row">
<div class="nine columns">
<label for="benchmark_name">
Benchmark name:
<input id="benchmark_name" class="u-full-width" type="text" name="benchmark_name" placeholder="Unigine Heaven" value="{{ .benchmark.Name }}">
</label>
</div>
<div class="three columns">
<label for="benchmark_scoring">
Benchmark type:
<select id="benchmark_scoring" class="u-full-width" name="benchmark_scoring">
<option value="fps" {{ if eq .benchmark.ScoringType "fps" }}selected{{ end }}>Frames per second</option>
<option value="ms" {{ if eq .benchmark.ScoringType "ms" }}selected{{ end }}>Frame time</option>
<option value="pts" {{ if eq .benchmark.ScoringType "pts" }}selected{{ end }}>Total points</option>
</select>
</label>
</div>
</div>
<div class="row">
<label for="benchmark_description">
Benchmark description:
<textarea id="benchmark_description" class="twelve columns" cols="30" rows="10" name="benchmark_description">{{ .benchmark.Description }}</textarea>
</label>
</div>
<input class="button-primary u-full-width" type="submit" value="Submit">
</form>
</div>
{{ template "footer" . }}
+4 -4
View File
@@ -1,10 +1,10 @@
{{ template "header" . }}
<div class="row">
<h2>Benchmark</h2>
<h2>List of benchmarks</h2>
<a href="/benchmark/create">Add new benchmark</a>
<table class="twelve columns card-1">
<table class="twelve columns">
<thead>
<tr>
<td>Name</td>
@@ -16,8 +16,8 @@
{{ range $b := .benchmarks }}
<tr>
<td><a href="/benchmark/{{ $b.ID }}">{{ $b.Name }}</a></td>
<td>{{ $b.CreatedAt.Format "01/02/2006 15:04am" }}</td>
<td>{{ $b.UpdatedAt.Format "01/02/2006 15:04am" }}</td>
<td>{{ $b.CreatedAt.Format "01/02/2006 3:04pm" }}</td>
<td>{{ $b.UpdatedAt.Format "01/02/2006 3:04pm" }}</td>
</tr>
{{ end }}
</tbody>
+47
View File
@@ -0,0 +1,47 @@
{{ template "header" . }}
<div class="row">
<h2>Add benchmark settings profile</h2>
<form class="twelve columns" action="/benchmark/profile/add" method="POST">
<div class="row">
<div class="six columns">
<label for="benchmark_profile_benchmark">
Benchmark:
{{ if .benchmark }}
<select id="benchmark_profile_benchmark" class="u-full-width" disabled>
<option value="{{ .benchmark.ID }}">{{ .benchmark.Name }}</option>
</select>
<input type="hidden" name="benchmark_profile_benchmark" value="{{ .benchmark.ID }}">
{{ end }}
{{ if .benchmarks }}
<select id="benchmark_profile_benchmark" class="u-full-width" name="benchmark_profile_benchmark">
{{ range $benchmark := .benchmarks }}
<option value="{{ $benchmark.ID }}">{{ $benchmark.Name }}</option>
{{ end }}
</select>
{{ end }}
</label>
</div>
<div class="six columns">
<label for="benchmark_profile_label">
Profile label:
<input id="benchmark_profile_label" class="u-full-width" type="text" name="benchmark_profile_label" placeholder="My benchmark settings profile">
</label>
</div>
</div>
<div class="row">
<label for="benchmark_description">
Benchmark description:
<textarea id="benchmark_description" class="twelve columns" cols="30" rows="10" name="benchmark_description"></textarea>
</label>
</div>
<input class="button-primary u-full-width" type="submit" value="Submit">
</form>
</div>
{{ template "footer" . }}
+22
View File
@@ -3,8 +3,30 @@
<div class="row">
<h2>{{ .benchmark.Name }}</h2>
<span><a href="/benchmark/{{ .benchmark.ID }}/edit">Edit</a></span>
<p>{{ .benchmark.ScoringType }}</p>
<p>{{ .benchmark.Description }}</p>
<hr>
<h4>Profiles for this Benchmark</h4>
<p><a href="/benchmark/profile/add?benchmark={{ .benchmark.ID }}">Add settings profile</a></p>
<ul class="benchmark-profiles">
{{ range $profile := .benchmark.BenchmarkProfiles }}
<li>
{{ $profile.Label }}
<span>
<a href="/benchmark/profile/{{ $profile.ID }}/edit">Edit</a>
<a href="/benchmark/profile/{{ $profile.ID }}/delete">Delete</a>
</span>
</li>
{{ end }}
</ul>
<hr>
<h4>Latest Benchmark Results:</h4>
+34
View File
@@ -0,0 +1,34 @@
{{ template "header" . }}
<div class="row">
<h2>Add new hardware</h2>
<form class="twelve columns" action="/hardware/{{ .hardware.ID }}/edit" method="POST">
<div class="row">
<div class="nine columns">
<label for="hardware_name">
Hardware name:
<input id="hardware_name" class="u-full-width" type="text" name="hardware_name" placeholder="EVGA RTX 3080 Ti" value="{{ .hardware.Name }}">
</label>
</div>
<div class="three columns">
<label for="hardware_type">
Hardware type:
<select id="hardware_type" class="u-full-width" name="hardware_type">
<option value="cpu" {{ if eq .hardware.Type "cpu" }}selected{{ end }}>Processor</option>
<option value="mem" {{ if eq .hardware.Type "mem" }}selected{{ end }}>Memory</option>
<option value="gpu" {{ if eq .hardware.Type "gpu" }}selected{{ end }}>Graphics Card</option>
<option value="ssd" {{ if eq .hardware.Type "ssd" }}selected{{ end }}>Solid State Drive</option>
<option value="hdd" {{ if eq .hardware.Type "hdd" }}selected{{ end }}>Hard Drive</option>
<option value="nic" {{ if eq .hardware.Type "nic" }}selected{{ end }}>Network Card</option>
</select>
</label>
</div>
</div>
<input class="button-primary u-full-width" type="submit" value="Submit">
</form>
</div>
{{ template "footer" . }}
+4 -4
View File
@@ -1,10 +1,10 @@
{{ template "header" . }}
<div class="row">
<h2>Hardware</h2>
<h2>List of hardware</h2>
<a href="/hardware/create">Add new hardware</a>
<table class="twelve columns card-1">
<table class="twelve columns">
<thead>
<tr>
<td>Name</td>
@@ -16,8 +16,8 @@
{{ range $h := .hardware }}
<tr>
<td><a href="/hardware/{{ $h.ID }}">{{ $h.Name }}</a></td>
<td>{{ $h.CreatedAt.Format "01/02/2006 15:04am" }}</td>
<td>{{ $h.UpdatedAt.Format "01/02/2006 15:04am" }}</td>
<td>{{ $h.CreatedAt.Format "01/02/2006 3:04pm" }}</td>
<td>{{ $h.UpdatedAt.Format "01/02/2006 3:04pm" }}</td>
</tr>
{{ end }}
</tbody>
+4 -2
View File
@@ -3,6 +3,8 @@
<div class="row">
<h2>{{ .hardware.Name }}</h2>
<span><a href="/hardware/{{ .hardware.ID }}/edit">Edit</a></span>
<p>{{ .hardware.Type }}</p>
<hr>
@@ -12,7 +14,7 @@
{{ $length := len .hardware.Tests }} {{ if eq $length 0 }}
<p>There are currently no tests using this hardware component.</p>
{{ else }}
<table class="u-full-width card-1">
<table class="u-full-width">
<thead>
<tr>
<th>Test</th>
@@ -25,7 +27,7 @@
<tr>
<td><a href="/test/{{ $test.ID }}">{{ $test.Name }}</a></td>
<td>{{ len $test.Benchmarks }}</td>
<td>{{ $test.CreatedAt.Format "01/02/2006 15:04am" }}</td>
<td>{{ $test.CreatedAt.Format "01/02/2006 3:04pm" }}</td>
</tr>
{{ end }}
</tbody>
+75
View File
@@ -2,4 +2,79 @@
<p>This is the BLT dashboard.</p>
<section class="row">
<h3>Recently updated tests:</h3>
<table class="twelve columns">
<thead>
<tr>
<td>Title</td>
<td>Created at</td>
<td>Last updated</td>
</tr>
</thead>
<tbody>
{{ range $p := .tests }}
<tr>
<td><a href="/test/{{ $p.ID }}">{{ $p.Name }}</a></td>
<td>{{ $p.CreatedAt.Format "01/02/2006 3:04pm" }}</td>
<td>{{ $p.UpdatedAt.Format "01/02/2006 3:04pm" }}</td>
</tr>
{{ end }}
</tbody>
</table>
<p>Visit the <a href="/test/list">tests</a> page to for more information and actions.</p>
</section>
<hr>
<section class="row">
<div class="six columns">
<h3>Recently updated hardware:</h3>
<table class="u-full-width">
<thead>
<tr>
<td>Name</td>
<td>Created at</td>
<td>Last updated</td>
</tr>
</thead>
<tbody>
{{ range $h := .hardware }}
<tr>
<td><a href="/hardware/{{ $h.ID }}">{{ $h.Name }}</a></td>
<td>{{ $h.CreatedAt.Format "01/02/2006 3:04pm" }}</td>
<td>{{ $h.UpdatedAt.Format "01/02/2006 3:04pm" }}</td>
</tr>
{{ end }}
</tbody>
</table>
</div>
<div class="six columns">
<h3>Recently updated benchmarks:</h3>
<table class="u-full-width">
<thead>
<tr>
<td>Name</td>
<td>Created at</td>
<td>Last updated</td>
</tr>
</thead>
<tbody>
{{ range $b := .benchmarks }}
<tr>
<td><a href="/benchmark/{{ $b.ID }}">{{ $b.Name }}</a></td>
<td>{{ $b.CreatedAt.Format "01/02/2006 3:04pm" }}</td>
<td>{{ $b.UpdatedAt.Format "01/02/2006 3:04pm" }}</td>
</tr>
{{ end }}
</tbody>
</table>
</div>
</section>
{{ template "footer" . }}
+2 -1
View File
@@ -9,6 +9,7 @@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css">
<link rel="stylesheet" href="/css/kourend.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js" charset="utf-8"></script>
<script src="/js/kebos.js" charset="utf-8"></script>
</head>
<body>
@@ -16,5 +17,5 @@
{{ template "navbar" . }}
<!-- main content -->
<div id="main-content" class="container card-5">
<div id="main-content" class="container">
{{ end }}
+1 -1
View File
@@ -1,5 +1,5 @@
{{ define "navbar" }}
<nav id="main-nav" class="card-2">
<nav id="main-nav">
<div class="nav-left">
<h4>BLT</h4>
<ul>
+53
View File
@@ -0,0 +1,53 @@
{{ template "header" . }}
<div class="row">
<h2>{{ .title }}</h2>
<form class="twelve columns" action="/test/{{ .test.ID }}/edit" method="POST">
<div class="row">
<div class="columns four">
<label for="test_hardware">
Hardware Component:
<select id="test_hardware" class="u-full-width" name="test_hardware">
{{ $testHardwareID := .test.Hardware.ID }}
{{ range $hw := .hardware }}
<option value="{{ $hw.ID }}" {{ if eq $testHardwareID $hw.ID }}selected{{ end }}>{{ $hw.Name }}</option>
{{ end }}
</select>
</label>
</div>
<div class="columns eight">
<label for="test_name">
Test name:
<input id="test_name" class="u-full-width" type="text" name="test_name" placeholder="My hardware benchmarking test" value="{{ .test.Name }}">
</label>
</div>
</div>
<div class="row">
<div class="columns twelve">
<label for="test_benchmarks">
Benchmarks to Test:
<select id="test_benchmarks" class="u-full-width" name="test_benchmarks" multiple>
{{ $selectedBenchmarks := .selectedBenchmarks }}
{{ range $bm := .benchmarks }}
<option value="{{ $bm.ID }}" {{ if contains $selectedBenchmarks $bm.StringID }}selected{{ end }}>{{ $bm.Name }}</option>
{{ end }}
</select>
</label>
</div>
</div>
<div class="row">
<label for="test_description">
Test description:
<textarea id="test_description" class="twelve columns" cols="30" rows="10" name="test_description"></textarea>
</label>
</div>
<input class="button-primary u-full-width" type="submit" value="Submit">
</form>
</div>
{{ template "footer" . }}
+4 -4
View File
@@ -1,10 +1,10 @@
{{ template "header" . }}
<div class="row">
<h2>Tests</h2>
<h2>List of tests</h2>
<a href="/test/create">Create a new test</a>
<table class="twelve columns card-1">
<table class="twelve columns">
<thead>
<tr>
<td>Title</td>
@@ -16,8 +16,8 @@
{{ range $p := .tests }}
<tr>
<td><a href="/test/{{ $p.ID }}">{{ $p.Name }}</a></td>
<td>{{ $p.CreatedAt.Format "01/02/2006 15:04am" }}</td>
<td>{{ $p.UpdatedAt.Format "01/02/2006 15:04am" }}</td>
<td>{{ $p.CreatedAt.Format "01/02/2006 3:04pm" }}</td>
<td>{{ $p.UpdatedAt.Format "01/02/2006 3:04pm" }}</td>
</tr>
{{ end }}
</tbody>
+19 -17
View File
@@ -3,11 +3,15 @@
<div class="row">
<h2>{{ .test.Name }}</h2>
<p><a href="/hardware/{{ .test.Hardware.ID }}">link to hardware tested.</a></p>
<span><a href="/test/{{ .test.ID }}/edit">Edit</a></span>
<p>{{ .test.Description }}</p>
<h4>Benchmarks used:</h4>
<h4>Test Info:</h4>
<p>Hardware tested: <a href="/hardware/{{ .test.Hardware.ID }}">{{ .test.Hardware.Name }}</a></p>
<p>Benchmarks used:</p>
<ul>
{{ range $bm := .test.Benchmarks }}
@@ -19,7 +23,7 @@
<h4>Add new result:</h4>
<form class="u-full-width" action="/result/add" method="POST">
<form id="result-form" class="u-full-width" action="/result/add" method="POST">
<div class="row">
<div class="columns four">
<label for="result_benchmark">
@@ -35,21 +39,21 @@
<div class="columns two">
<label for="result_avg">
Average score:
<input id="result_avg" class="u-full-width" type="number" name="result_avg" value="0">
<input id="result_avg" class="u-full-width" type="number" name="result_avg" step="0.01" placeholder="0.00">
</label>
</div>
<div class="columns two">
<label for="result_min">
Minimum score:
<input id="result_min" class="u-full-width" type="number" name="result_min" value="0">
<input id="result_min" class="u-full-width" type="number" name="result_min" step="0.01" placeholder="0.00">
</label>
</div>
<div class="columns two">
<label for="result_max">
Maximum score:
<input id="result_max" class="u-full-width" type="number" name="result_max" value="0">
<input id="result_max" class="u-full-width" type="number" name="result_max" step="0.01" placeholder="0.00">
</label>
</div>
@@ -58,34 +62,30 @@
</div>
<input type="hidden" name="result_test" value="{{ .test.ID }}">
<input type="hidden" name="result_hardware" value="{{ .test.Hardware.ID }}">
</div>
</form>
<hr>
<h4>Latest Benchmark Results:</h4>
<h4>Benchmark Results:</h4>
{{ $length := len .test.Results }} {{ if eq $length 0 }}
{{ $length := len .test.Benchmarks }} {{ if eq $length 0 }}
<p>There are currently no benchmarks recorded in this test.</p>
{{ else }}
<table class="u-full-width card-1">
<table id="results-table" class="u-full-width card-2" data-test-id="{{ .test.ID }}">
<thead>
<tr>
<th>Benchmark</th>
<th>Scoring Type</th>
<th># of Results</th>
<th>Average</th>
<th>Minimum</th>
<th>Maximum</th>
</tr>
</thead>
<tbody>
{{ range $res := .test.Results }}
<tr>
<td>{{ $res.Benchmark.Name }}</td>
<td>{{ $res.AverageScore }}</td>
<td>{{ if eq $res.MinimumScore 0.0 }}N/a{{ else }}{{ $res.MinimumScore }}{{ end }}</td>
<td>{{ if eq $res.MaximumScore 0.0 }}N/a{{ else }}{{ $res.MaximumScore }}{{ end }}</td>
</tr>
{{ range $benchmark := .test.Benchmarks }}
<tr data-benchmark-id="{{ $benchmark.ID }}"></tr>
{{ end }}
</tbody>
</table>
@@ -96,4 +96,6 @@
<p><a href="/test">Back</a></p>
</div>
<script src="/js/test.js"></script>
{{ template "footer" . }}
+7
View File
@@ -0,0 +1,7 @@
package forms
type BenchmarkProfileForm struct {
BenchmarkID int `form:"benchmark_profile_benchmark" validate:"required"`
Label string `form:"benchmark_profile_label" validate:"required"`
Settings string `form:"benchmark_profile_settings" validate:"required"`
}
+1 -2
View File
@@ -2,8 +2,7 @@ package forms
type ResultForm struct {
Test int `form:"result_test" validate:"required"`
Hardware int `form:"result_hardware" validate:"required"`
Benchmark int `form:"result_benchmark" validate:"required"`
BenchmarkProfile int `form:"result_benchmark" validate:"required"`
AverageScore float32 `form:"result_avg" validate:"required"`
MinimumScore float32 `form:"result_min"`
MaximumScore float32 `form:"result_max"`
+11 -1
View File
@@ -4,5 +4,15 @@ type TestForm struct {
Name string `form:"test_name" validate:"required"`
Description string `form:"test_description"`
Hardware int `form:"test_hardware" validate:"required"`
Benchmarks []string `form:"test_benchmarks" validate:"required"`
BenchmarkProfiles []uint `form:"test_benchmarks" validate:"required"`
}
func (t *TestForm) IsBenchmarkSelected(checkID uint) bool {
for _, selectedID := range t.BenchmarkProfiles {
if checkID == selectedID {
return true
}
}
return false
}
+10
View File
@@ -0,0 +1,10 @@
package web
func Contains(slice []string, val string) bool {
for _, v := range slice {
if v == val {
return true
}
}
return false
}
+34 -1
View File
@@ -24,6 +24,9 @@ func RegisterRoutes(f *flamego.Flame) {
f.Post("/create", binding.Form(forms.HardwareForm{}), routes.HardwarePostCreate)
f.Get("/{hardware_id}", routes.HardwareGetView)
f.Get("/{hardware_id}/edit", routes.HardwareGetEdit)
f.Post("/{hardware_id}/edit", binding.Form(forms.HardwareForm{}), routes.HardwarePostEdit)
})
// benchmark routes
@@ -38,6 +41,14 @@ func RegisterRoutes(f *flamego.Flame) {
f.Post("/create", binding.Form(forms.BenchmarkForm{}), routes.BenchmarkPostCreate)
f.Get("/{benchmark_id}", routes.BenchmarkGetView)
f.Get("/{benchmark_id}/edit", routes.BenchmarkGetEdit)
f.Post("/{benchmark_id}/edit", binding.Form(forms.BenchmarkForm{}), routes.BenchmarkPostEdit)
f.Group("/profile", func() {
f.Get("/add", routes.BenchmarkGetProfileAdd)
f.Post("/add", binding.Form(forms.BenchmarkProfileForm{}), routes.BenchmarkPostProfileAdd)
})
})
// test routes
@@ -51,11 +62,33 @@ func RegisterRoutes(f *flamego.Flame) {
f.Get("/create", routes.TestGetCreate)
f.Post("/create", binding.Form(forms.TestForm{}), routes.TestPostCreate)
f.Get("/{test_id}", routes.TestGetView)
f.Group("/{test_id}", func() {
f.Get("", routes.TestGetView)
f.Get("/edit", routes.TestGetEdit)
f.Post("/edit", binding.Form(forms.TestForm{}), routes.TestPostEdit)
})
})
// result routes
f.Group("/result", func() {
f.Post("/add", binding.Form(forms.ResultForm{}), routes.ResultPostCreate)
})
// API v1 routes
f.Group("/api", func () {
f.Group("/v1", func() {
f.Group("/benchmark", func() {
f.Get("/details", routes.ApiV1BenchmarkDetails)
})
f.Group("/benchmark_profile", func() {
f.Get("/details", routes.ApiV1BenchmarkProfileDetails)
})
f.Group("/result", func() {
f.Post("/add", binding.Form(forms.ResultForm{}), routes.ApiV1ResultAdd)
f.Get("/list", routes.ApiV1ResultList)
})
})
})
}
+74
View File
@@ -0,0 +1,74 @@
package routes
import (
"log"
"github.com/flamego/binding"
"github.com/flamego/flamego"
"github.com/flamego/validator"
"git.metaunix.net/bitgoblin/blt/models"
"git.metaunix.net/bitgoblin/blt/web/forms"
)
func ApiV1BenchmarkDetails(c flamego.Context, r flamego.Render) {
// find benchmark ID from request
benchmarkID := c.Query("benchmark_id")
// find benchmark from DB
var benchmark models.Benchmark
models.DB.First(&benchmark, benchmarkID)
// return JSON response
r.JSON(200, benchmark)
}
func ApiV1BenchmarkProfileDetails(c flamego.Context, r flamego.Render) {
// find benchmark ID from request
benchmarkProfileID := c.Query("benchmark_profile_id")
// find benchmark from DB
var benchmarkProfile models.BenchmarkProfile
models.DB.Preload("BenchmarkProfiles").First(&benchmarkProfile, benchmarkProfileID)
// return JSON response
r.JSON(200, benchmarkProfile)
}
func ApiV1ResultAdd(c flamego.Context, form forms.ResultForm, errs binding.Errors, r flamego.Render) {
if len(errs) > 0 {
var err error
switch errs[0].Category {
case binding.ErrorCategoryValidation:
err = errs[0].Err.(validator.ValidationErrors)[0]
default:
err = errs[0].Err
}
log.Fatal(err)
}
result := models.Result{
TestID: form.Test,
BenchmarkProfileID: form.BenchmarkProfile,
AverageScore: form.AverageScore,
MinimumScore: form.MinimumScore,
MaximumScore: form.MaximumScore,
}
_ = models.DB.Create(&result)
r.JSON(200, "success")
}
func ApiV1ResultList(c flamego.Context, r flamego.Render) {
// find benchmark and test IDs from request
benchmarkProfileID := c.Query("benchmark_id")
testID := c.Query("test_id")
// find results from the DB that match the benchmark and test
var results []models.Result
models.DB.Where("test_id = ? AND benchmark_profile_id = ?", testID, benchmarkProfileID).Find(&results)
// return JSON response
r.JSON(200, results)
}
+75 -1
View File
@@ -30,7 +30,7 @@ func BenchmarkGetView(c flamego.Context, t template.Template, data template.Data
// find benchmark from DB
var benchmark models.Benchmark
models.DB.First(&benchmark, benchmarkID)
models.DB.Preload("BenchmarkProfiles").First(&benchmark, benchmarkID)
data["benchmark"] = benchmark
data["title"] = benchmark.Name
@@ -64,3 +64,77 @@ func BenchmarkPostCreate(c flamego.Context, form forms.BenchmarkForm, errs bindi
c.Redirect(fmt.Sprintf("/benchmark/%d", benchmark.ID))
}
func BenchmarkGetEdit(c flamego.Context, t template.Template, data template.Data) {
// find benchmark ID from request
benchmarkID := c.Param("benchmark_id")
// find benchmark from DB
var benchmark models.Benchmark
models.DB.First(&benchmark, benchmarkID)
data["benchmark"] = benchmark
data["title"] = "Editing Benchmark"
t.HTML(http.StatusOK, "benchmark/edit")
}
func BenchmarkPostEdit(c flamego.Context, form forms.BenchmarkForm, errs binding.Errors) {
if len(errs) > 0 {
var err error
switch errs[0].Category {
case binding.ErrorCategoryValidation:
err = errs[0].Err.(validator.ValidationErrors)[0]
default:
err = errs[0].Err
}
log.Fatal(err)
}
// find benchmark ID from request
benchmarkID := c.Param("benchmark_id")
// find benchmark from DB
var benchmark models.Benchmark
models.DB.First(&benchmark, benchmarkID)
benchmark.Name = form.Name
benchmark.ScoringType = form.ScoringType
benchmark.Description = form.Description
models.DB.Save(&benchmark)
c.Redirect(fmt.Sprintf("/benchmark/%d", benchmark.ID))
}
func BenchmarkGetProfileAdd(c flamego.Context, t template.Template, data template.Data) {
// find benchmark ID from GET parameters
benchmarkID := c.Query("benchmark")
// check if the query parameter was used
if benchmarkID != "" {
// find benchmark from DB
var benchmark models.Benchmark
models.DB.First(&benchmark, benchmarkID)
data["benchmark"] = benchmark
} else {
// find all benchmarks from DB
var benchmarks []models.Benchmark
models.DB.Find(&benchmarks)
data["benchmarks"] = benchmarks
}
data["title"] = "Add new benchmark settings profile"
t.HTML(http.StatusOK, "benchmark/profile/add")
}
func BenchmarkPostProfileAdd(c flamego.Context, form forms.BenchmarkProfileForm, errs binding.Errors) {
benchmarkProfile := models.BenchmarkProfile{
BenchmarkID: form.BenchmarkID,
Label: form.Label,
Settings: form.Settings,
}
_ = models.DB.Create(&benchmarkProfile)
c.Redirect(fmt.Sprintf("/benchmark/%d", form.BenchmarkID))
}
+40
View File
@@ -63,3 +63,43 @@ func HardwarePostCreate(c flamego.Context, form forms.HardwareForm, errs binding
c.Redirect(fmt.Sprintf("/hardware/%d", hardware.ID))
}
func HardwareGetEdit(c flamego.Context, t template.Template, data template.Data) {
// find hardware ID from request
hardwareID := c.Param("hardware_id")
// find hardware from DB
var hardware models.Hardware
models.DB.Preload("Tests.Benchmarks").First(&hardware, hardwareID)
data["hardware"] = hardware
data["title"] = "Edit Hardware"
t.HTML(http.StatusOK, "hardware/edit")
}
func HardwarePostEdit(c flamego.Context, form forms.HardwareForm, errs binding.Errors) {
if len(errs) > 0 {
var err error
switch errs[0].Category {
case binding.ErrorCategoryValidation:
err = errs[0].Err.(validator.ValidationErrors)[0]
default:
err = errs[0].Err
}
log.Fatal(err)
}
// find hardware ID from request
hardwareID := c.Param("hardware_id")
// find hardware from DB
var hardware models.Hardware
models.DB.Preload("Tests.Benchmarks").First(&hardware, hardwareID)
hardware.Name = form.Name
hardware.Type = form.Type
models.DB.Save(&hardware)
c.Redirect(fmt.Sprintf("/hardware/%d", hardware.ID))
}
+16
View File
@@ -4,9 +4,25 @@ import (
"net/http"
"github.com/flamego/template"
"git.metaunix.net/bitgoblin/blt/models"
)
func GetDashboard(t template.Template, data template.Data) {
// add tests to template; limited to 10 most recent
var tests []models.Test
models.DB.Order("updated_at desc").Limit(10).Find(&tests)
data["tests"] = tests
// add hardwares to template; limited to 5 most recent
var hardware []models.Hardware
models.DB.Order("updated_at desc").Limit(5).Find(&hardware)
data["hardware"] = hardware
// add benchmarks to template; limited to 5 most recent
var benchmarks []models.Benchmark
models.DB.Order("updated_at desc").Limit(5).Find(&benchmarks)
data["benchmarks"] = benchmarks
data["title"] = "Dashboard"
t.HTML(http.StatusOK, "index/dashboard")
}
+1 -2
View File
@@ -26,8 +26,7 @@ func ResultPostCreate(c flamego.Context, form forms.ResultForm, errs binding.Err
result := models.Result{
TestID: form.Test,
HardwareID: form.Hardware,
BenchmarkID: form.Benchmark,
BenchmarkProfileID: form.BenchmarkProfile,
AverageScore: form.AverageScore,
MinimumScore: form.MinimumScore,
MaximumScore: form.MaximumScore,
+73 -2
View File
@@ -73,11 +73,82 @@ func TestPostCreate(c flamego.Context, form forms.TestForm, errs binding.Errors)
_ = models.DB.Create(&test)
// bind benchmarks to test
for _, v := range form.Benchmarks {
for _, v := range form.BenchmarkProfiles {
var benchmark models.Benchmark
models.DB.First(&benchmark, v) // find benchmark
models.DB.Model(&test).Association("Benchmarks").Append(&benchmark)
models.DB.Model(&test).Association("BenchmarkProfiles").Append(&benchmark)
}
c.Redirect(fmt.Sprintf("/test/%d", test.ID))
}
func TestGetEdit(c flamego.Context, t template.Template, data template.Data) {
// find test in DB
testID := c.Param("test_id")
var test models.Test
models.DB.Preload("Hardware").Preload("BenchmarkProfiles").First(&test, testID)
data["test"] = test
// add hardware components to template
var hardware []models.Hardware
models.DB.Find(&hardware)
data["hardware"] = hardware
// add benchmarks to template
var benchmarks []models.Benchmark
models.DB.Find(&benchmarks)
data["benchmarks"] = benchmarks
// determine which benchmarks are selected in a test
selectedBenchmarks := test.SelectedBenchmarks()
data["selectedBenchmarks"] = selectedBenchmarks
data["title"] = fmt.Sprintf("Editing Test: %s", test.Name)
t.HTML(http.StatusOK, "test/edit")
}
func TestPostEdit(c flamego.Context, form forms.TestForm, errs binding.Errors) {
if len(errs) > 0 {
var err error
switch errs[0].Category {
case binding.ErrorCategoryValidation:
err = errs[0].Err.(validator.ValidationErrors)[0]
default:
err = errs[0].Err
}
log.Fatal(err)
}
// find test ID from request
testID := c.Param("test_id")
// find hardware from DB
var test models.Test
models.DB.Preload("Hardware").Preload("BenchmarkProfiles").First(&test, testID)
test.Name = form.Name
test.Description = form.Description
test.HardwareID = form.Hardware
// bind benchmarks to test that aren't already associated
for _, b := range form.BenchmarkProfiles {
if ! test.IsBenchmarkSelected(b) {
var benchmark models.BenchmarkProfile
models.DB.First(&benchmark, b) // find benchmark
models.DB.Model(&test).Association("BenchmarkProfiles").Append(&benchmark)
}
}
// removed associated benchmarks that weren't in the form
for _, b := range test.BenchmarkProfiles {
if ! form.IsBenchmarkSelected(b.ID) {
var benchmark models.BenchmarkProfile
models.DB.First(&benchmark, b) // find benchmark
models.DB.Model(&test).Association("BenchmarkProfiles").Delete(&benchmark)
}
}
models.DB.Save(&test)
c.Redirect(fmt.Sprintf("/test/%d", test.ID))
}