Compare commits
51 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
fb76f28643 | ||
|
06262431da | ||
|
e734d4077d | ||
|
9617f4280d | ||
|
3ec5605c53 | ||
|
ed5232371c | ||
|
29d9cbc59c | ||
|
3eca29c2db | ||
|
8df9b7684f | ||
|
7282d0a4b6 | ||
|
0525838f4b | ||
|
958c72ee63 | ||
|
fa92321176 | ||
|
458646ee8e | ||
|
9df8f6c9e1 | ||
|
7e294c8f72 | ||
|
cefa79a8b8 | ||
|
1e87466ccb | ||
|
e3e4e24e56 | ||
|
2be6d216d1 | ||
|
93170d0935 | ||
|
2299ac0a93 | ||
|
3ec465872e | ||
|
52e4d9c420 | ||
|
9ddf7fa928 | ||
|
ab6b94cb5f | ||
|
39185f1144 | ||
|
403ab7f166 | ||
|
ba06a2ea4c | ||
|
95fe5ab400 | ||
|
9ddc3db48d | ||
|
8412163370 | ||
|
86bf4d37f0 | ||
|
6cb2ac0263 | ||
|
dea08d15dd | ||
|
cf7623fbb9 | ||
|
a51c8aa8a4 | ||
|
9fd6ec6b0b | ||
|
5b14721b14 | ||
|
dcfc6e0115 | ||
4ad9a92306 | |||
c5df026d04 | |||
16704aeeb1 | |||
|
bae65994f8 | ||
19670e9abd | |||
49925c6d8f | |||
0ee3d06f89 | |||
9dceaa8119 | |||
cbc816ad70 | |||
92d8e5fa09 | |||
cd7003223a |
8
.gitignore
vendored
8
.gitignore
vendored
@@ -3,12 +3,4 @@ blt
|
|||||||
|
|
||||||
# Local data files
|
# Local data files
|
||||||
data/
|
data/
|
||||||
tmp/
|
|
||||||
|
|
||||||
# Compiled assets
|
|
||||||
public/css/
|
|
||||||
public/js/
|
|
||||||
|
|
||||||
# Node modules
|
|
||||||
node_modules/
|
|
||||||
|
|
||||||
|
@@ -1,32 +0,0 @@
|
|||||||
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
|
|
67
Gruntfile.js
67
Gruntfile.js
@@ -1,67 +0,0 @@
|
|||||||
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
LICENSE
9
LICENSE
@@ -1,9 +0,0 @@
|
|||||||
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.
|
|
10
Makefile
10
Makefile
@@ -6,16 +6,6 @@ VERSION=`git describe --tags`
|
|||||||
build:
|
build:
|
||||||
@go build -o $(NAME) -ldflags "-X git.metaunix.net/bitgoblin/blt/app.AppVersion=$(VERSION)"
|
@go build -o $(NAME) -ldflags "-X git.metaunix.net/bitgoblin/blt/app.AppVersion=$(VERSION)"
|
||||||
|
|
||||||
.PHONY: grunt
|
|
||||||
## grunt: Compile frontend assets.
|
|
||||||
grunt:
|
|
||||||
@npm run grunt
|
|
||||||
|
|
||||||
.PHONY: grunt-watch
|
|
||||||
## grunt-watch: Compile frontend assets while watching for changes.
|
|
||||||
grunt-watch:
|
|
||||||
@npm run grunt watch
|
|
||||||
|
|
||||||
.PHONY: run
|
.PHONY: run
|
||||||
## run: Build and Run in development mode.
|
## run: Build and Run in development mode.
|
||||||
run: build
|
run: build
|
||||||
|
54
README.md
54
README.md
@@ -1,54 +0,0 @@
|
|||||||
# Benchmark Logging Tool (BLT)
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
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.
|
|
@@ -1,7 +0,0 @@
|
|||||||
root = if typeof window isnt 'undefined' then window else global
|
|
||||||
|
|
||||||
root.roundDecimal = (value) ->
|
|
||||||
return Math.round(value * 100) / 100
|
|
||||||
|
|
||||||
$ ->
|
|
||||||
console.log('DOM is ready.')
|
|
@@ -1,62 +0,0 @@
|
|||||||
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)
|
|
@@ -1,133 +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
|
|
||||||
&:hover
|
|
||||||
color: darkcyan
|
|
||||||
|
|
||||||
button.button-primary
|
|
||||||
background: teal
|
|
||||||
transition: background 180ms ease-in-out
|
|
||||||
&: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
|
|
||||||
&: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: lightgrey
|
|
||||||
|
|
||||||
/* 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)
|
|
||||||
&: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
|
|
||||||
|
|
||||||
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
|
|
||||||
font-size: 2.25rem
|
|
||||||
line-height: 64px
|
|
||||||
transition: all 200ms ease-in-out
|
|
||||||
&: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
|
|
||||||
|
|
||||||
p
|
|
||||||
margin-bottom: 5px
|
|
||||||
text-align: center
|
|
15
main.go
15
main.go
@@ -1,7 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
gotemplate "html/template"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
@@ -22,20 +21,8 @@ func main() {
|
|||||||
// initialize database
|
// initialize database
|
||||||
models.Open()
|
models.Open()
|
||||||
|
|
||||||
// initialize base renderer
|
|
||||||
f.Use(flamego.Renderer())
|
|
||||||
|
|
||||||
// initialize templating engine
|
// initialize templating engine
|
||||||
f.Use(template.Templater(template.Options{
|
f.Use(template.Templater())
|
||||||
FuncMaps: []gotemplate.FuncMap{
|
|
||||||
{
|
|
||||||
"contains": web.Contains,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Directory: "templates",
|
|
||||||
Extensions: []string{".tmpl", ".html"},
|
|
||||||
},
|
|
||||||
))
|
|
||||||
|
|
||||||
// inject custom middleware
|
// inject custom middleware
|
||||||
f.Use(middleware.CustomVars)
|
f.Use(middleware.CustomVars)
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -18,7 +16,3 @@ type Benchmark struct {
|
|||||||
// has many results
|
// has many results
|
||||||
Results []Result
|
Results []Result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Benchmark) StringID() string {
|
|
||||||
return strconv.Itoa(int(b.ID))
|
|
||||||
}
|
|
||||||
|
@@ -11,4 +11,7 @@ type Hardware struct {
|
|||||||
|
|
||||||
// has many tests
|
// has many tests
|
||||||
Tests []Test
|
Tests []Test
|
||||||
|
|
||||||
|
// has many results
|
||||||
|
Results []Result
|
||||||
}
|
}
|
||||||
|
@@ -10,6 +10,10 @@ type Result struct {
|
|||||||
MinimumScore float32
|
MinimumScore float32
|
||||||
MaximumScore float32
|
MaximumScore float32
|
||||||
|
|
||||||
|
// belongs to Hardware
|
||||||
|
HardwareID int
|
||||||
|
Hardware Hardware
|
||||||
|
|
||||||
// belongs to Benchmark
|
// belongs to Benchmark
|
||||||
BenchmarkID int
|
BenchmarkID int
|
||||||
Benchmark Benchmark
|
Benchmark Benchmark
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -21,24 +19,3 @@ type Test struct {
|
|||||||
// has many results
|
// has many results
|
||||||
Results []Result
|
Results []Result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Test) SelectedBenchmarks() []string {
|
|
||||||
benchmarks := t.Benchmarks
|
|
||||||
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.Benchmarks {
|
|
||||||
if b.ID == benchmarkUint {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
1853
package-lock.json
generated
1853
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
36
package.json
36
package.json
@@ -1,36 +0,0 @@
|
|||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
|
113
public/css/kourend.css
Normal file
113
public/css/kourend.css
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
textarea{
|
||||||
|
max-width: 100%;
|
||||||
|
min-width: 100%;
|
||||||
|
height: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
form select[multiple]{
|
||||||
|
min-height: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 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: 1024px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#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: 14px 20px;
|
||||||
|
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;
|
||||||
|
}
|
14
runner.conf
14
runner.conf
@@ -1,14 +0,0 @@
|
|||||||
root: .
|
|
||||||
tmp_path: ./tmp
|
|
||||||
build_name: runner-build
|
|
||||||
build_log: runner-build-errors.log
|
|
||||||
valid_ext: .go, .tpl, .tmpl, .html
|
|
||||||
no_rebuild_ext: .tpl, .tmpl, .html
|
|
||||||
ignored: assets, tmp, node_modules, data, vendor
|
|
||||||
build_delay: 600
|
|
||||||
colors: 1
|
|
||||||
log_color_main: cyan
|
|
||||||
log_color_build: yellow
|
|
||||||
log_color_runner: green
|
|
||||||
log_color_watcher: magenta
|
|
||||||
log_color_app:
|
|
@@ -1,38 +0,0 @@
|
|||||||
{{ 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,7 +4,7 @@
|
|||||||
<h2>Benchmark</h2>
|
<h2>Benchmark</h2>
|
||||||
<a href="/benchmark/create">Add new benchmark</a>
|
<a href="/benchmark/create">Add new benchmark</a>
|
||||||
|
|
||||||
<table class="twelve columns card-2">
|
<table class="twelve columns">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Name</td>
|
<td>Name</td>
|
||||||
|
@@ -3,12 +3,8 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<h2>{{ .benchmark.Name }}</h2>
|
<h2>{{ .benchmark.Name }}</h2>
|
||||||
|
|
||||||
<span><a href="/benchmark/{{ .benchmark.ID }}/edit">Edit</a></span>
|
|
||||||
|
|
||||||
<p>{{ .benchmark.ScoringType }}</p>
|
<p>{{ .benchmark.ScoringType }}</p>
|
||||||
|
|
||||||
<p>{{ .benchmark.Description }}</p>
|
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<h4>Latest Benchmark Results:</h4>
|
<h4>Latest Benchmark Results:</h4>
|
||||||
|
@@ -1,34 +0,0 @@
|
|||||||
{{ 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,7 +4,7 @@
|
|||||||
<h2>Hardware</h2>
|
<h2>Hardware</h2>
|
||||||
<a href="/hardware/create">Add new hardware</a>
|
<a href="/hardware/create">Add new hardware</a>
|
||||||
|
|
||||||
<table class="twelve columns card-2">
|
<table class="twelve columns">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Name</td>
|
<td>Name</td>
|
||||||
|
@@ -3,8 +3,6 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<h2>{{ .hardware.Name }}</h2>
|
<h2>{{ .hardware.Name }}</h2>
|
||||||
|
|
||||||
<span><a href="/hardware/{{ .hardware.ID }}/edit">Edit</a></span>
|
|
||||||
|
|
||||||
<p>{{ .hardware.Type }}</p>
|
<p>{{ .hardware.Type }}</p>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
@@ -14,7 +12,7 @@
|
|||||||
{{ $length := len .hardware.Tests }} {{ if eq $length 0 }}
|
{{ $length := len .hardware.Tests }} {{ if eq $length 0 }}
|
||||||
<p>There are currently no tests using this hardware component.</p>
|
<p>There are currently no tests using this hardware component.</p>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<table class="u-full-width card-2">
|
<table class="u-full-width">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Test</th>
|
<th>Test</th>
|
||||||
|
@@ -9,7 +9,6 @@
|
|||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css">
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css">
|
||||||
<link rel="stylesheet" href="/css/kourend.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="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>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
@@ -1,53 +0,0 @@
|
|||||||
{{ 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,7 +4,7 @@
|
|||||||
<h2>Tests</h2>
|
<h2>Tests</h2>
|
||||||
<a href="/test/create">Create a new test</a>
|
<a href="/test/create">Create a new test</a>
|
||||||
|
|
||||||
<table class="twelve columns card-2">
|
<table class="twelve columns">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Title</td>
|
<td>Title</td>
|
||||||
|
@@ -3,15 +3,11 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<h2>{{ .test.Name }}</h2>
|
<h2>{{ .test.Name }}</h2>
|
||||||
|
|
||||||
<span><a href="/test/{{ .test.ID }}/edit">Edit</a></span>
|
<p><a href="/hardware/{{ .test.Hardware.ID }}">link to hardware tested.</a></p>
|
||||||
|
|
||||||
<p>{{ .test.Description }}</p>
|
<p>{{ .test.Description }}</p>
|
||||||
|
|
||||||
<h4>Test Info:</h4>
|
<h4>Benchmarks used:</h4>
|
||||||
|
|
||||||
<p>Hardware tested: <a href="/hardware/{{ .test.Hardware.ID }}">{{ .test.Hardware.Name }}</a></p>
|
|
||||||
|
|
||||||
<p>Benchmarks used:</p>
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
{{ range $bm := .test.Benchmarks }}
|
{{ range $bm := .test.Benchmarks }}
|
||||||
@@ -23,7 +19,7 @@
|
|||||||
|
|
||||||
<h4>Add new result:</h4>
|
<h4>Add new result:</h4>
|
||||||
|
|
||||||
<form id="result-form" class="u-full-width" action="/result/add" method="POST">
|
<form class="u-full-width" action="/result/add" method="POST">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="columns four">
|
<div class="columns four">
|
||||||
<label for="result_benchmark">
|
<label for="result_benchmark">
|
||||||
@@ -39,21 +35,21 @@
|
|||||||
<div class="columns two">
|
<div class="columns two">
|
||||||
<label for="result_avg">
|
<label for="result_avg">
|
||||||
Average score:
|
Average score:
|
||||||
<input id="result_avg" class="u-full-width" type="number" name="result_avg" step="0.01" placeholder="0.00">
|
<input id="result_avg" class="u-full-width" type="number" name="result_avg" value="0">
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="columns two">
|
<div class="columns two">
|
||||||
<label for="result_min">
|
<label for="result_min">
|
||||||
Minimum score:
|
Minimum score:
|
||||||
<input id="result_min" class="u-full-width" type="number" name="result_min" step="0.01" placeholder="0.00">
|
<input id="result_min" class="u-full-width" type="number" name="result_min" value="0">
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="columns two">
|
<div class="columns two">
|
||||||
<label for="result_max">
|
<label for="result_max">
|
||||||
Maximum score:
|
Maximum score:
|
||||||
<input id="result_max" class="u-full-width" type="number" name="result_max" step="0.01" placeholder="0.00">
|
<input id="result_max" class="u-full-width" type="number" name="result_max" value="0">
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -62,30 +58,34 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input type="hidden" name="result_test" value="{{ .test.ID }}">
|
<input type="hidden" name="result_test" value="{{ .test.ID }}">
|
||||||
|
<input type="hidden" name="result_hardware" value="{{ .test.Hardware.ID }}">
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<h4>Benchmark Results:</h4>
|
<h4>Latest Benchmark Results:</h4>
|
||||||
|
|
||||||
{{ $length := len .test.Benchmarks }} {{ if eq $length 0 }}
|
{{ $length := len .test.Results }} {{ if eq $length 0 }}
|
||||||
<p>There are currently no benchmarks recorded in this test.</p>
|
<p>There are currently no benchmarks recorded in this test.</p>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<table id="results-table" class="u-full-width card-2" data-test-id="{{ .test.ID }}">
|
<table class="u-full-width">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Benchmark</th>
|
<th>Benchmark</th>
|
||||||
<th>Scoring Type</th>
|
|
||||||
<th># of Results</th>
|
|
||||||
<th>Average</th>
|
<th>Average</th>
|
||||||
<th>Minimum</th>
|
<th>Minimum</th>
|
||||||
<th>Maximum</th>
|
<th>Maximum</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{{ range $benchmark := .test.Benchmarks }}
|
{{ range $res := .test.Results }}
|
||||||
<tr data-benchmark-id="{{ $benchmark.ID }}"></tr>
|
<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>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@@ -96,6 +96,4 @@
|
|||||||
<p><a href="/test">Back</a></p>
|
<p><a href="/test">Back</a></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/js/test.js"></script>
|
|
||||||
|
|
||||||
{{ template "footer" . }}
|
{{ template "footer" . }}
|
||||||
|
@@ -2,6 +2,7 @@ package forms
|
|||||||
|
|
||||||
type ResultForm struct {
|
type ResultForm struct {
|
||||||
Test int `form:"result_test" validate:"required"`
|
Test int `form:"result_test" validate:"required"`
|
||||||
|
Hardware int `form:"result_hardware" validate:"required"`
|
||||||
Benchmark int `form:"result_benchmark" validate:"required"`
|
Benchmark int `form:"result_benchmark" validate:"required"`
|
||||||
AverageScore float32 `form:"result_avg" validate:"required"`
|
AverageScore float32 `form:"result_avg" validate:"required"`
|
||||||
MinimumScore float32 `form:"result_min"`
|
MinimumScore float32 `form:"result_min"`
|
||||||
|
@@ -4,15 +4,5 @@ type TestForm struct {
|
|||||||
Name string `form:"test_name" validate:"required"`
|
Name string `form:"test_name" validate:"required"`
|
||||||
Description string `form:"test_description"`
|
Description string `form:"test_description"`
|
||||||
Hardware int `form:"test_hardware" validate:"required"`
|
Hardware int `form:"test_hardware" validate:"required"`
|
||||||
Benchmarks []uint `form:"test_benchmarks" validate:"required"`
|
Benchmarks []string `form:"test_benchmarks" validate:"required"`
|
||||||
}
|
|
||||||
|
|
||||||
func (t *TestForm) IsBenchmarkSelected(checkID uint) bool {
|
|
||||||
for _, selectedID := range t.Benchmarks {
|
|
||||||
if checkID == selectedID {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
@@ -1,10 +0,0 @@
|
|||||||
package web
|
|
||||||
|
|
||||||
func Contains(slice []string, val string) bool {
|
|
||||||
for _, v := range slice {
|
|
||||||
if v == val {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
@@ -24,9 +24,6 @@ func RegisterRoutes(f *flamego.Flame) {
|
|||||||
f.Post("/create", binding.Form(forms.HardwareForm{}), routes.HardwarePostCreate)
|
f.Post("/create", binding.Form(forms.HardwareForm{}), routes.HardwarePostCreate)
|
||||||
|
|
||||||
f.Get("/{hardware_id}", routes.HardwareGetView)
|
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
|
// benchmark routes
|
||||||
@@ -41,9 +38,6 @@ func RegisterRoutes(f *flamego.Flame) {
|
|||||||
f.Post("/create", binding.Form(forms.BenchmarkForm{}), routes.BenchmarkPostCreate)
|
f.Post("/create", binding.Form(forms.BenchmarkForm{}), routes.BenchmarkPostCreate)
|
||||||
|
|
||||||
f.Get("/{benchmark_id}", routes.BenchmarkGetView)
|
f.Get("/{benchmark_id}", routes.BenchmarkGetView)
|
||||||
|
|
||||||
f.Get("/{benchmark_id}/edit", routes.BenchmarkGetEdit)
|
|
||||||
f.Post("/{benchmark_id}/edit", binding.Form(forms.BenchmarkForm{}), routes.BenchmarkPostEdit)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// test routes
|
// test routes
|
||||||
@@ -57,29 +51,11 @@ func RegisterRoutes(f *flamego.Flame) {
|
|||||||
f.Get("/create", routes.TestGetCreate)
|
f.Get("/create", routes.TestGetCreate)
|
||||||
f.Post("/create", binding.Form(forms.TestForm{}), routes.TestPostCreate)
|
f.Post("/create", binding.Form(forms.TestForm{}), routes.TestPostCreate)
|
||||||
|
|
||||||
f.Group("/{test_id}", func() {
|
f.Get("/{test_id}", routes.TestGetView)
|
||||||
f.Get("", routes.TestGetView)
|
|
||||||
f.Get("/edit", routes.TestGetEdit)
|
|
||||||
f.Post("/edit", binding.Form(forms.TestForm{}), routes.TestPostEdit)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// result routes
|
// result routes
|
||||||
f.Group("/result", func() {
|
f.Group("/result", func() {
|
||||||
f.Post("/add", binding.Form(forms.ResultForm{}), routes.ResultPostCreate)
|
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("/result", func() {
|
|
||||||
f.Post("/add", binding.Form(forms.ResultForm{}), routes.ApiV1ResultAdd)
|
|
||||||
f.Get("/list", routes.ApiV1ResultList)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
@@ -1,62 +0,0 @@
|
|||||||
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 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,
|
|
||||||
BenchmarkID: form.Benchmark,
|
|
||||||
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
|
|
||||||
benchmarkID := 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_id = ?", testID, benchmarkID).Find(&results)
|
|
||||||
|
|
||||||
// return JSON response
|
|
||||||
r.JSON(200, results)
|
|
||||||
}
|
|
@@ -64,44 +64,3 @@ func BenchmarkPostCreate(c flamego.Context, form forms.BenchmarkForm, errs bindi
|
|||||||
|
|
||||||
c.Redirect(fmt.Sprintf("/benchmark/%d", benchmark.ID))
|
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))
|
|
||||||
}
|
|
||||||
|
@@ -63,43 +63,3 @@ func HardwarePostCreate(c flamego.Context, form forms.HardwareForm, errs binding
|
|||||||
|
|
||||||
c.Redirect(fmt.Sprintf("/hardware/%d", hardware.ID))
|
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))
|
|
||||||
}
|
|
||||||
|
@@ -26,6 +26,7 @@ func ResultPostCreate(c flamego.Context, form forms.ResultForm, errs binding.Err
|
|||||||
|
|
||||||
result := models.Result{
|
result := models.Result{
|
||||||
TestID: form.Test,
|
TestID: form.Test,
|
||||||
|
HardwareID: form.Hardware,
|
||||||
BenchmarkID: form.Benchmark,
|
BenchmarkID: form.Benchmark,
|
||||||
AverageScore: form.AverageScore,
|
AverageScore: form.AverageScore,
|
||||||
MinimumScore: form.MinimumScore,
|
MinimumScore: form.MinimumScore,
|
||||||
|
@@ -81,74 +81,3 @@ func TestPostCreate(c flamego.Context, form forms.TestForm, errs binding.Errors)
|
|||||||
|
|
||||||
c.Redirect(fmt.Sprintf("/test/%d", test.ID))
|
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("Benchmarks").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("Benchmarks").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.Benchmarks {
|
|
||||||
if ! test.IsBenchmarkSelected(b) {
|
|
||||||
var benchmark models.Benchmark
|
|
||||||
models.DB.First(&benchmark, b) // find benchmark
|
|
||||||
models.DB.Model(&test).Association("Benchmarks").Append(&benchmark)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// removed associated benchmarks that weren't in the form
|
|
||||||
for _, b := range test.Benchmarks {
|
|
||||||
if ! form.IsBenchmarkSelected(b.ID) {
|
|
||||||
var benchmark models.Benchmark
|
|
||||||
models.DB.First(&benchmark, b) // find benchmark
|
|
||||||
models.DB.Model(&test).Association("Benchmarks").Delete(&benchmark)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
models.DB.Save(&test)
|
|
||||||
|
|
||||||
c.Redirect(fmt.Sprintf("/test/%d", test.ID))
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user