Compare commits

..

5 Commits

75 changed files with 807 additions and 6205 deletions

21
.fresh.yaml Normal file
View File

@@ -0,0 +1,21 @@
version: "1"
root: .
main_path: ""
tmp_path: ./tmp
build_name: runner-build
build_args: ""
run_args: ""
build_log: runner-build-errors.log
valid_ext: .go, .tpl, .tmpl, .html
no_rebuild_ext: .tpl, .tmpl, .html
ignore: assets/**/*, assets, tmp/*, public/**/*, public, node_modules/**/*, node_modules
build_delay: "600"
colors: true
log_color_main: cyan
log_color_build: yellow
log_color_runner: green
log_color_watcher: magenta
log_color_app: ""
delve: false
delve_args: ""
debug: false

40
.gitignore vendored
View File

@@ -1,13 +1,39 @@
# Composer dependencies # ---> Go
/vendor/ # If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Local data directory # Test binary, built with `go test -c`
data/ *.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# Dependency directories (remove the comment below to include it)
vendor/
# Temporary directory created by fresh
tmp/
# Go workspace file
go.work
# Compiled Go binary
colossus
# Compiled CSS/JS
public/css/
public/js/
# NPM dependencies for Grunt # NPM dependencies for Grunt
node_modules/ node_modules/
# Compiled CSS and JS # Local data
public/css/ data/
public/js/

View File

@@ -1,25 +0,0 @@
# PHP composer to get dependencies
FROM composer:2.5 AS composer
WORKDIR /usr/src/colossus/
COPY composer.* /usr/src/colossus/
# Install dependencies
RUN composer install
RUN composer update
# Actual PHP runtime
FROM php:8.4-cli
WORKDIR /usr/src/colossus/
COPY --from=composer /usr/src/colossus/vendor/ /usr/src/colossus/vendor/
COPY . /usr/src/colossus/
VOLUME /usr/src/colossus/vendor/
EXPOSE 8080
# Run the app
CMD [ "bash", "entrypoints/dev.sh" ]

View File

@@ -1,13 +0,0 @@
# Node.js runtime
FROM node:24
WORKDIR /usr/src/colossus/
COPY package.* /usr/src/colossus/
RUN npm install
VOLUME /usr/src/colossus/node_modules/
# Run the app
CMD [ "npm", "run", "grunt" ]

View File

@@ -1,9 +1,9 @@
module.exports = function(grunt) { module.exports = function(grunt) {
var pkg = grunt.file.readJSON('package.json')
// Project configuration. // Project configuration.
grunt.initConfig({ grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: { sass: {
dist: { dist: {
options: { options: {
@@ -11,8 +11,8 @@ module.exports = function(grunt) {
}, },
files: [{ files: [{
expand: true, expand: true,
cwd: 'assets/styles', cwd: 'assets/sass',
src: ['**/*.scss'], src: ['*.sass'],
dest: 'public/css', dest: 'public/css',
ext: '.css' ext: '.css'
}] }]
@@ -27,7 +27,7 @@ module.exports = function(grunt) {
files: { files: {
expand: true, expand: true,
flatten: true, flatten: true,
cwd: 'assets/scripts', cwd: 'assets/coffee',
src: ['*.coffee'], src: ['*.coffee'],
dest: 'public/js', dest: 'public/js',
ext: '.js' ext: '.js'
@@ -36,15 +36,15 @@ module.exports = function(grunt) {
watch: { watch: {
css: { css: {
files: ['assets/styles/**/*.scss'], files: ['assets/sass/*.sass'],
tasks: ['sass'], tasks: ['sass'],
options: { options: {
atBegin: true, atBegin: true,
spawn: false spawn: false
} }
}, },
coffee: { js: {
files: ['assets/scripts/**/*.coffee'], files: ['assets/coffee/*.coffee'],
tasks: ['coffee'], tasks: ['coffee'],
options: { options: {
atBegin: true, atBegin: true,
@@ -54,12 +54,12 @@ module.exports = function(grunt) {
} }
}); });
// Load plugins. // Load task plugins
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-sass'); grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-coffee'); grunt.loadNpmTasks('grunt-contrib-coffee');
grunt.loadNpmTasks('grunt-contrib-watch');
// CLI tasks. // Default task(s).
grunt.registerTask('default', ['sass', 'coffee']); grunt.registerTask('default', ['sass', 'coffee']);
}; };

View File

@@ -1,26 +1,3 @@
# colossus # colossus
Self-hosted database for organizing PC hardware benchmarking results. Self-hosted database for organizing PC hardware benchmarking results
## 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 - 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.
## Development
The recommended way to run the development server for Colossus is using [Docker](https://docker.com/).
There are some shell and batch scripts in `bin/` to build and run the containers. To build the containers:
`bin/docker-build.sh` or `bin/docker-build.bat`
And then to run the containers:
`bin/docker-run.sh` or `bin/docker-run.bat`
This will build the containers for Apache and Grunt to serve the web pages and build front-end assets, respectively. If everything is running successfully you can open your browser and go to https://localhost:8080.

43
assets/sass/nardah.sass Normal file
View File

@@ -0,0 +1,43 @@
$nav-height: 65px
body
margin: 0
padding: $nav-height 0 0
background: white
#main-nav
position: fixed
top: 0
left: 0
width: 100%
height: $nav-height
background: cornflowerblue
.nav-left,
.nav-right
list-style: none
li
display: inline-block
.nav-left
float: left
.nav-right
float: right
.site-logo,
.nav-link a
display: inline-block
padding: 15px 15px
color: black
font-size: 2rem
transition: all 230ms ease-in-out
&:hover
color: #333
.site-logo
padding-left: 25px
font-weight: bold
#main-wrapper
max-width: 1180px
margin-top: 15px
padding: 20px 27px

View File

@@ -1,23 +0,0 @@
$ ->
console.log('ready.')
$('#report-benchmarks').on 'change', ->
try
benchmarkSearchParams = new URLSearchParams
benchmark_id: $('#report-benchmarks').val()
benchmarkRes = await fetch("/api/v1/benchmark/tests?#{benchmarkSearchParams}")
benchmarkData = await benchmarkRes.json()
# clear old contents from the selector
$('#report-tests').empty()
# add new elements to the selector
addOption(test) for test in benchmarkData
catch error
console.error 'An error occurred while fetching benchmark results.', error
addOption = (test) ->
$('#report-tests').append(
$('<option/>')
.attr('value', test.id)
.text(test.title)
)

View File

@@ -1,110 +0,0 @@
$ ->
chartInstance = null
$('#reports-download').on 'click', ->
canvas = $('#benchmark-chart')[0]
a = document.createElement 'a'
a.href = canvas.toDataURL 'image/png'
a.download = 'chart.png'
a.click()
$('#reports-button').on 'click', (e) ->
$('#reports-download').attr('disabled', true)
chartInstance.destroy() if chartInstance
benchmarkId = $('#report-benchmarks').val()
testIds = $('#report-tests').val()
benchmarkSearchParams = new URLSearchParams
benchmark_id: benchmarkId
benchmarkRes = await fetch("/api/v1/benchmark/details?#{benchmarkSearchParams}")
benchmarkData = await benchmarkRes.json()
data =
labels: []
datasets: []
switch benchmarkData.scoring
when 'pts'
data.datasets.push({
label: 'Average Score'
data: []
})
when 'fps'
data.datasets.push({
label: 'Average FPS'
data: []
})
data.datasets.push({
label: 'Minimum FPS'
data: []
})
when 'ms'
data.datasets.push({
label: 'Average Frame Time'
data: []
})
data.datasets.push({
label: 'Minimum Frame Time'
data: []
})
for testId in testIds
try
testSearchParams = new URLSearchParams
test_id: testId
testRes = await fetch("/api/v1/test/details?#{testSearchParams}")
testData = await testRes.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.average
min_total += result.minimum if result.minimum
max_total += result.maximum if result.maximum
data.labels.push(testData.title)
data.datasets[0].data.push(avg_total / resultData.length)
switch benchmarkData.scoring
when 'fps', 'ms'
data.datasets[1].data.push(min_total / resultData.length)
catch error
console.error 'An error occurred while fetching benchmark results.', error
ctx = $('#benchmark-chart')[0].getContext('2d')
options =
indexAxis: 'y'
plugins:
title:
display: true
text: benchmarkData.name
font:
size: '24'
datalabels:
anchor: 'end'
align: 'left'
color: 'black'
font:
weight: 'bold'
formatter: (value) -> value
scales:
y:
beginAtZero: true
chartInstance = new Chart ctx,
type: 'bar'
data: data
options: options
plugins: [ChartDataLabels]
$('#reports-download').attr('disabled', false)
$('#benchmark-chart').removeClass('disabled')

View File

@@ -1,64 +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.average
min_total += result.minimum if result.minimum
max_total += result.maximum if result.maximum
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.scoring + '</td>')
tableRow.append('<td>' + resultData.length + '</td>')
if resultData.length != 0
tableRow.append('<td>' + (avg_total / resultData.length) + '</td>')
else
tableRow.append('<td>N/a</td>')
if min_total != 0
tableRow.append('<td>' + (min_total / resultData.length) + '</td>')
tableRow.append('<td>' + (max_total / resultData.length) + '</td>')
else
tableRow.append('<td>N/a</td>')
tableRow.append('<td>N/a</td>')
tableRow.append('<td><a href="/test/' + testId + '/results">Details</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)

View File

@@ -1,34 +0,0 @@
$primary-color: navy;
$primary-color-highlight: lighten($primary-color, 10%);
$nav-height: 65px;
$textarea-min-height: 100px;
$shadow-normal: rgba(17, 12, 46, 0.15) 0px 48px 100px 0px;
$shadow-light: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;
$shadow-heavy: rgba(0, 0, 0, 0.25) 0px 54px 55px, rgba(0, 0, 0, 0.12) 0px -12px 30px, rgba(0, 0, 0, 0.12) 0px 4px 6px, rgba(0, 0, 0, 0.17) 0px 12px 13px, rgba(0, 0, 0, 0.09) 0px -3px 5px;
.disabled{
display: none;
}
body{
background: rgb(240, 235, 248);
font-size: 18px;
}
table{
border: 1px solid #eee;
}
a{
transition: color 210ms ease-in-out;
}
#main-wrapper{
padding: 1.5rem 2rem;
background: white;
border: 1px solid #bbb;
border-radius: 8px;
}

View File

@@ -1,4 +0,0 @@
@ECHO OFF
docker build -t colossus-php .
docker build -t colossus-grunt -f Dockerfile.grunt .

View File

@@ -1,4 +0,0 @@
#!/bin/sh
docker build -t colossus-php .
docker build -t colossus-grunt -f Dockerfile.grunt .

View File

@@ -1,3 +0,0 @@
@ECHO OFF
docker run --rm -w "/usr/src/colossus" -v "%cd%:/usr/src/colossus" --name colossus_composer composer "%*"

View File

@@ -1,3 +0,0 @@
#!/bin/sh
docker exec colossus-php ./vendor/bin/phinx $@

View File

@@ -1,4 +0,0 @@
@ECHO OFF
docker run --rm -d -w "/usr/src/colossus" -v "%cd%:/usr/src/colossus" -p 8080:8080 --name colossus-php colossus-php
docker run --rm -d -w "/usr/src/colossus" -v "%cd%:/usr/src/colossus" --name colossus-grunt colossus-grunt npm run grunt watch

View File

@@ -1,4 +0,0 @@
#!/bin/sh
docker run --rm -d -w "/usr/src/colossus" -v "$(pwd):/usr/src/colossus" -p 8080:8080 --name colossus-php colossus-php
docker run --rm -d -w "/usr/src/colossus" -v "$(pwd):/usr/src/colossus" --name colossus-grunt colossus-grunt npm run grunt watch

View File

@@ -1,4 +0,0 @@
#!/bin/sh
# start a local instance of the app using PHP's built-in webserver
php -S localhost:8080 -t public/ public/index.php

34
colossus.go Normal file
View File

@@ -0,0 +1,34 @@
package main
import (
"github.com/flamego/flamego"
"github.com/flamego/template"
"git.metaunix.net/BitGoblin/colossus/models"
"git.metaunix.net/BitGoblin/colossus/routes"
)
func main() {
// initialize database connection
models.InitDB()
// start initialize Flamego router
f := flamego.Classic()
// serve static files from ./public/
f.Use(flamego.Static(
flamego.StaticOptions{
Directory: "public",
},
))
// initialize template engine
f.Use(template.Templater(template.Options{
Directory: "./views",
}))
// register route handlers
routes.InitRoutes(f)
f.Run()
}

View File

@@ -1,31 +0,0 @@
{
"name": "bitgoblin/colossus",
"version": "0.1.0",
"description": "Self-hosted database for organizing PC hardware benchmarking results",
"type": "project",
"license": "BSD-2-Clause",
"autoload": {
"psr-4": {
"BitGoblin\\Colossus\\": "src/"
}
},
"authors": [
{
"name": "Gregory Ballantine",
"email": "gballantine@bitgoblin.tech"
}
],
"minimum-stability": "stable",
"require": {
"slim/slim": "^4.14",
"slim/psr7": "^1.7",
"php-di/php-di": "^7.0",
"slim/twig-view": "^3.4",
"illuminate/database": "^12.19",
"robmorgan/phinx": "^0.16",
"hassankhan/config": "^3.2"
},
"scripts": {
"phinx": "./vendor/bin/phinx"
}
}

3743
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +0,0 @@
{
"database": {
"driver": "sqlite",
"database": "./data/colossus.db"
}
}

View File

@@ -1,27 +0,0 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class AddInitialTables extends AbstractMigration {
public function change(): void {
// hardware components
$components_table = $this->table('components');
$components_table->addColumn('name', 'string', ['null' => false])
->addColumn('type', 'string', ['null' => false])
->addTimestamps()
->addIndex(['name', 'type'])
->create();
// benchmarks
$benchmarks_table = $this->table('benchmarks');
$benchmarks_table->addColumn('name', 'string', ['null' => false])
->addColumn('description', 'string')
->addColumn('scoring', 'string', ['null' => false])
->addTimestamps()
->addIndex(['name', 'scoring'])
->create();
}
}

View File

@@ -1,25 +0,0 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class AddTestsTable extends AbstractMigration {
public function change(): void {
$table = $this->table('tests');
$table->addColumn('title', 'string', ['null' => false])
->addColumn('description', 'string')
->addColumn('component_id', 'integer', ['null' => false])
->addForeignKey('component_id', 'components', 'id', ['delete'=> 'CASCADE', 'update'=> 'CASCADE'])
->addTimestamps()
->create();
$table = $this->table('benchmark_test');
$table->addColumn('test_id', 'integer', ['null' => false])
->addColumn('benchmark_id', 'integer', ['null' => false])
->addForeignKey('test_id', 'tests', 'id', ['delete'=> 'CASCADE', 'update'=> 'CASCADE'])
->addForeignKey('benchmark_id', 'benchmarks', 'id', ['delete'=> 'CASCADE', 'update'=> 'CASCADE'])
->create();
}
}

View File

@@ -1,22 +0,0 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class AddResultsTable extends AbstractMigration {
public function change(): void {
// benchmark test results
$table = $this->table('results');
$table->addColumn('average', 'integer', ['null' => false])
->addColumn('minimum', 'integer')
->addColumn('maximum', 'integer')
->addColumn('test_id', 'integer', ['null' => false])
->addColumn('benchmark_id', 'integer', ['null' => false])
->addForeignKey('test_id', 'tests', 'id', ['delete'=> 'CASCADE', 'update'=> 'CASCADE'])
->addForeignKey('benchmark_id', 'benchmarks', 'id', ['delete'=> 'CASCADE', 'update'=> 'CASCADE'])
->addTimestamps()
->create();
}
}

View File

@@ -1,7 +0,0 @@
#!/bin/sh
# run database migrations before starting
vendor/bin/phinx migrate -e development
# run the app through the PHP built-in dev server
php -S 0.0.0.0:8080 -t public/ public/index.php

19
go.mod Normal file
View File

@@ -0,0 +1,19 @@
module git.metaunix.net/BitGoblin/colossus
go 1.18
require (
github.com/alecthomas/participle/v2 v2.0.0-beta.5 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/flamego/flamego v1.7.0 // indirect
github.com/flamego/template v1.1.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/mattn/go-colorable v0.1.9 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-sqlite3 v1.14.15 // indirect
github.com/pkg/errors v0.9.1 // indirect
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
gorm.io/driver/sqlite v1.4.3 // indirect
gorm.io/gorm v1.24.2 // indirect
)

32
go.sum Normal file
View File

@@ -0,0 +1,32 @@
github.com/alecthomas/participle/v2 v2.0.0-beta.5 h1:y6dsSYVb1G5eK6mgmy+BgI3Mw35a3WghArZ/Hbebrjo=
github.com/alecthomas/participle/v2 v2.0.0-beta.5/go.mod h1:RC764t6n4L8D8ITAJv0qdokritYSNR3wV5cVwmIEaMM=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/flamego/flamego v1.7.0 h1:c1Lu16PBAZKkpsjHw42vwotdoQnMMpUi60ITP41W12w=
github.com/flamego/flamego v1.7.0/go.mod h1:dnVMBJyHKaxjcqRVN93taSK+YB/9p+Op1GdLIuA1hFQ=
github.com/flamego/template v1.1.0 h1:iYtCzY3TeYpsoQiGApFXw2qycKdMzimz2gkO/SlcksM=
github.com/flamego/template v1.1.0/go.mod h1:bgnmEXNumarhQIUzFgn18CDG6u8cM6X09c7UOTwZcxM=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.4 h1:tHnRBy1i5F2Dh8BAFxqFzxKqqvezXrL2OW1TnX+Mlas=
github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/mattn/go-colorable v0.1.9 h1:sqDoxXbdeALODt0DAeJCVp38ps9ZogZEAXjus69YV3U=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI=
github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gorm.io/driver/sqlite v1.4.3 h1:HBBcZSDnWi5BW3B3rwvVTc510KGkBkexlOg0QrmLUuU=
gorm.io/driver/sqlite v1.4.3/go.mod h1:0Aq3iPO+v9ZKbcdiz8gLWRw5VOPcBOPUQJFLq5e2ecI=
gorm.io/gorm v1.24.0/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
gorm.io/gorm v1.24.2 h1:9wR6CFD+G8nOusLdvkZelOEhpJVwwHzpQOUM+REd6U0=
gorm.io/gorm v1.24.2/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=

12
models/component.go Normal file
View File

@@ -0,0 +1,12 @@
package models
import (
"gorm.io/gorm"
)
type Component struct {
gorm.Model
Name string
Manufacturer string
Type string
}

17
models/init.go Normal file
View File

@@ -0,0 +1,17 @@
package models
import (
"gorm.io/gorm"
"gorm.io/driver/sqlite"
)
var (
DB *gorm.DB
)
func InitDB() {
DB, _ = gorm.Open(sqlite.Open("data/colossus.db"), &gorm.Config{})
// Migrate the schema
DB.AutoMigrate(&Component{})
}

952
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{ {
"name": "colossus", "name": "colossus",
"version": "1.0.0", "version": "0.1.0",
"description": "Self-hosted database for organizing PC hardware benchmarking results", "description": "Self-hosted database for organizing PC hardware benchmarking results",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
@@ -9,17 +9,17 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://git.metaunix.net/BitGoblin/colossus" "url": "https://git.metaunix.net/BitGoblin/colossus.git"
}, },
"keywords": [ "keywords": [
"inventory" "benchmarking"
], ],
"author": "Gregory Ballantine <gballantine@bitgoblin.tech>", "author": "Gregory Ballantine <gballantine@bitgoblin.tech>",
"license": "BSD-2-Clause", "license": "BSD-2-Clause",
"dependencies": { "devDependencies": {
"grunt": "^1.5.3", "grunt": "^1.5.3",
"grunt-contrib-sass": "^2.0.0",
"grunt-contrib-coffee": "^2.1.0", "grunt-contrib-coffee": "^2.1.0",
"grunt-contrib-sass": "^2.0.0",
"grunt-contrib-watch": "^1.1.0", "grunt-contrib-watch": "^1.1.0",
"sass": "^1.56.1" "sass": "^1.56.1"
} }

View File

@@ -1,37 +0,0 @@
<?php
return
[
'paths' => [
'migrations' => '%%PHINX_CONFIG_DIR%%/db/migrations',
'seeds' => '%%PHINX_CONFIG_DIR%%/db/seeds'
],
'environments' => [
'default_migration_table' => 'phinxlog',
'default_environment' => 'development',
'production' => [
'adapter' => 'mysql',
'host' => 'localhost',
'name' => 'production_db',
'user' => 'root',
'pass' => '',
'port' => '3306',
'charset' => 'utf8',
],
'development' => [
'adapter' => 'sqlite',
'name' => './data/colossus',
'suffix' => '.db',
],
'testing' => [
'adapter' => 'mysql',
'host' => 'localhost',
'name' => 'testing_db',
'user' => 'root',
'pass' => '',
'port' => '3306',
'charset' => 'utf8',
]
],
'version_order' => 'creation'
];

View File

@@ -1,5 +0,0 @@
# rewrite rules
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]

View File

@@ -1,24 +0,0 @@
<?php
// if we're looking for static files in dev, return false so they can be served.
if (PHP_SAPI == 'cli-server') {
$url = parse_url($_SERVER['REQUEST_URI']);
$file = __DIR__ . $url['path'];
// check the file types, only serve standard files
if (preg_match('/\.(?:png|js|jpg|jpeg|gif|css)$/', $file)) {
// does the file exist? If so, return it
if (is_file($file))
return false;
// file does not exist. return a 404
header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
printf('"%s" does not exist', $_SERVER['REQUEST_URI']);
return false;
}
}
require_once __DIR__ . '/../src/app.php';
$app->run();

16
routes/hardware.go Normal file
View File

@@ -0,0 +1,16 @@
package routes
import (
"github.com/flamego/flamego"
"git.metaunix.net/BitGoblin/colossus/models"
)
func getHardwareAdd(c flamego.Context) {
models.DB.Create(&models.Component{
Name: "PowerColor RX 570 4GB",
Manufacturer: "PowerColor",
Type: "Graphics Card",
})
c.Redirect("/")
}

18
routes/index.go Normal file
View File

@@ -0,0 +1,18 @@
package routes
import (
"net/http"
"github.com/flamego/template"
"git.metaunix.net/BitGoblin/colossus/models"
)
func getIndex(t template.Template, data template.Data) {
var hardware []models.Component
models.DB.Find(&hardware)
data["hardware"] = hardware
data["title"] = "Dashboard"
t.HTML(http.StatusOK, "index")
}

11
routes/init.go Normal file
View File

@@ -0,0 +1,11 @@
package routes
import (
"github.com/flamego/flamego"
)
func InitRoutes(f *flamego.Flame) {
f.Get("/", getIndex)
f.Get("/hardware/add", getHardwareAdd)
}

View File

@@ -1,97 +0,0 @@
<?php
namespace BitGoblin\Colossus\Controllers;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Routing\RouteContext;
use BitGoblin\Colossus\Models\Benchmark;
use BitGoblin\Colossus\Models\Result;
use BitGoblin\Colossus\Models\Test;
class ApiController extends Controller {
public function getBenchmarkDetails(Request $request, Response $response, array $args): Response {
$urlParams = $request->getQueryParams();
$benchmark = Benchmark::where('id', $urlParams['benchmark_id'])->first();
$payload = json_encode($benchmark);
$response->getBody()->write($payload);
return $response
->withHeader('Content-Type', 'application/json');
}
public function getBenchmarkTests(Request $request, Response $response, array $args): Response {
$urlParams = $request->getQueryParams();
$benchmark = Benchmark::where('id', $urlParams['benchmark_id'])->first();
$payload = json_encode($benchmark->tests);
$response->getBody()->write($payload);
return $response
->withHeader('Content-Type', 'application/json');
}
public function getResultList(Request $request, Response $response, array $args): Response {
$urlParams = $request->getQueryParams();
$results = Result::where([
['benchmark_id', '=', $urlParams['benchmark_id']],
['test_id', '=', $urlParams['test_id']],
])->get();
$payload = json_encode($results);
$response->getBody()->write($payload);
return $response
->withHeader('Content-Type', 'application/json');
}
public function postResultAdd(Request $request, Response $response, array $args): Response {
$params = (array)$request->getParsedBody();
$result = new Result;
$result->test_id = $params['result_test'];
$result->benchmark_id = $params['result_benchmark'];
$result->average = $params['result_avg'];
$result->minimum = $params['result_min'] ?? null;
$result->maximum = $params['result_max'] ?? null;
$result->save();
$payload = json_encode('success');
$response->getBody()->write($payload);
return $response
->withHeader('Content-Type', 'application/json');
}
public function getResultDelete(Request $request, Response $response, array $args): Response {
$result = Result::where('id', $args['result_id'])->delete();
$payload = json_encode($result);
$referrer = $request->getHeaderLine('Referer');
if ($referrer) {
return $response
->withHeader('Location', $referrer)
->withStatus(302);
}
$response->getBody()->write($payload);
return $response
->withHeader('Content-Type', 'application/json');
}
public function getTestDetails(Request $request, Response $response, array $args): Response {
$urlParams = $request->getQueryParams();
$test = Test::where('id', $urlParams['test_id'])->first();
$payload = json_encode($test);
$response->getBody()->write($payload);
return $response
->withHeader('Content-Type', 'application/json');
}
}

View File

@@ -1,91 +0,0 @@
<?php
namespace BitGoblin\Colossus\Controllers;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Routing\RouteContext;
use Slim\Views\Twig;
use BitGoblin\Colossus\Models\Benchmark;
class BenchmarkController extends Controller {
public function getIndex(Request $request, Response $response): Response {
// redirect the user back to the home page
$routeContext = RouteContext::fromRequest($request);
$routeParser = $routeContext->getRouteParser();
return $response
->withHeader('Location', $routeParser->urlFor('benchmark.list'))
->withStatus(302);
}
public function getList(Request $request, Response $response): Response {
$benchmarks = Benchmark::orderByDesc('updated_at')->get();
$view = Twig::fromRequest($request);
return $view->render($response, 'benchmark/list.twig', [
'benchmarks' => $benchmarks,
]);
}
public function getView(Request $request, Response $response, array $args): Response {
$benchmark = Benchmark::where('id', $args['benchmark_id'])->first();
$view = Twig::fromRequest($request);
return $view->render($response, 'benchmark/view.twig', [
'benchmark' => $benchmark,
]);
}
public function getAdd(Request $request, Response $response): Response {
$view = Twig::fromRequest($request);
return $view->render($response, 'benchmark/add.twig');
}
public function postAdd(Request $request, Response $response): Response {
$params = (array)$request->getParsedBody();
$benchmark = new Benchmark;
$benchmark->name = $params['benchmark_name'];
$benchmark->description = $params['benchmark_description'];
$benchmark->scoring = $params['benchmark_scoring'];
$benchmark->save();
// redirect the user back to the home page
$routeContext = RouteContext::fromRequest($request);
$routeParser = $routeContext->getRouteParser();
return $response
->withHeader('Location', $routeParser->urlFor('benchmark.list'))
->withStatus(302);
}
public function getEdit(Request $request, Response $response, array $args): Response {
$benchmark = Benchmark::where('id', $args['benchmark_id'])->first();
$view = Twig::fromRequest($request);
return $view->render($response, 'benchmark/edit.twig', [
'benchmark' => $benchmark,
]);
}
public function postEdit(Request $request, Response $response, array $args): Response {
$benchmark = Benchmark::where('id', $args['benchmark_id'])->first();
$params = (array)$request->getParsedBody();
$benchmark->name = $params['benchmark_name'];
$benchmark->description = $params['benchmark_description'];
$benchmark->scoring = $params['benchmark_scoring'];
$benchmark->save();
// redirect the user back to the home page
$routeContext = RouteContext::fromRequest($request);
$routeParser = $routeContext->getRouteParser();
return $response
->withHeader('Location', $routeParser->urlFor('benchmark.view', ['benchmark_id' => $benchmark->id]))
->withStatus(302);
}
}

View File

@@ -1,89 +0,0 @@
<?php
namespace BitGoblin\Colossus\Controllers;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Routing\RouteContext;
use Slim\Views\Twig;
use BitGoblin\Colossus\Models\Component;
class ComponentController extends Controller {
public function getIndex(Request $request, Response $response): Response {
// redirect the user back to the home page
$routeContext = RouteContext::fromRequest($request);
$routeParser = $routeContext->getRouteParser();
return $response
->withHeader('Location', $routeParser->urlFor('component.list'))
->withStatus(302);
}
public function getList(Request $request, Response $response): Response {
$components = Component::orderByDesc('updated_at')->get();
$view = Twig::fromRequest($request);
return $view->render($response, 'component/list.twig', [
'components' => $components,
]);
}
public function getView(Request $request, Response $response, array $args): Response {
$component = Component::where('id', $args['component_id'])->first();
$view = Twig::fromRequest($request);
return $view->render($response, 'component/view.twig', [
'component' => $component,
]);
}
public function getAdd(Request $request, Response $response): Response {
$view = Twig::fromRequest($request);
return $view->render($response, 'component/add.twig');
}
public function postAdd(Request $request, Response $response): Response {
$params = (array)$request->getParsedBody();
$component = new Component;
$component->name = $params['component_name'];
$component->type = $params['component_type'];
$component->save();
// redirect the user back to the home page
$routeContext = RouteContext::fromRequest($request);
$routeParser = $routeContext->getRouteParser();
return $response
->withHeader('Location', $routeParser->urlFor('component.list'))
->withStatus(302);
}
public function getEdit(Request $request, Response $response, array $args): Response {
$component = Component::where('id', $args['component_id'])->first();
$view = Twig::fromRequest($request);
return $view->render($response, 'component/edit.twig', [
'component' => $component,
]);
}
public function postEdit(Request $request, Response $response, array $args): Response {
$component = Component::where('id', $args['component_id'])->first();
$params = (array)$request->getParsedBody();
$component->name = $params['component_name'];
$component->type = $params['component_type'];
$component->save();
// redirect the user back to the home page
$routeContext = RouteContext::fromRequest($request);
$routeParser = $routeContext->getRouteParser();
return $response
->withHeader('Location', $routeParser->urlFor('component.view', ['component_id' => $component->id]))
->withStatus(302);
}
}

View File

@@ -1,19 +0,0 @@
<?php
namespace BitGoblin\Colossus\Controllers;
use Psr\Container\ContainerInterface;
class Controller {
protected $container;
public function __construct(ContainerInterface $container) {
$this->container = $container;
}
public function get(string $name) {
return $this->container->get($name);
}
}

View File

@@ -1,16 +0,0 @@
<?php
namespace BitGoblin\Colossus\Controllers;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Views\Twig;
class HomeController extends Controller {
public function getIndex(Request $request, Response $response): Response {
$view = Twig::fromRequest($request);
return $view->render($response, 'index.twig');
}
}

View File

@@ -1,22 +0,0 @@
<?php
namespace BitGoblin\Colossus\Controllers;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Routing\RouteContext;
use Slim\Views\Twig;
use BitGoblin\Colossus\Models\Benchmark;
class ReportController extends Controller {
public function getGenerate(Request $request, Response $response): Response {
$benchmarks = Benchmark::get();
$view = Twig::fromRequest($request);
return $view->render($response, 'reports/generate.twig', [
'benchmarks' => $benchmarks,
]);
}
}

View File

@@ -1,121 +0,0 @@
<?php
namespace BitGoblin\Colossus\Controllers;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Routing\RouteContext;
use Slim\Views\Twig;
use BitGoblin\Colossus\Models\Benchmark;
use BitGoblin\Colossus\Models\Component;
use BitGoblin\Colossus\Models\Test;
class TestController extends Controller {
public function getList(Request $request, Response $response): Response {
$tests = Test::orderByDesc('updated_at')->get();
$view = Twig::fromRequest($request);
return $view->render($response, 'test/list.twig', [
'tests' => $tests,
]);
}
public function getView(Request $request, Response $response, array $args): Response {
$test = Test::where('id', $args['test_id'])->first();
$view = Twig::fromRequest($request);
return $view->render($response, 'test/view.twig', [
'test' => $test,
]);
}
public function getAdd(Request $request, Response $response): Response {
$benchmarks = Benchmark::all();
$components = Component::all();
$view = Twig::fromRequest($request);
return $view->render($response, 'test/add.twig', [
'benchmarks' => $benchmarks,
'components' => $components,
]);
}
public function postAdd(Request $request, Response $response): Response {
$params = (array)$request->getParsedBody();
$test = new Test;
$test->title = $params['test_title'];
$test->description = $params['test_description'];
$test->component_id = $params['test_component'];
$test->save();
// attach benchmarks to test
foreach ($params['test_benchmarks'] as $b) {
$test->benchmarks()->attach($b);
}
// redirect the user back to the home page
$routeContext = RouteContext::fromRequest($request);
$routeParser = $routeContext->getRouteParser();
return $response
->withHeader('Location', $routeParser->urlFor('test.list'))
->withStatus(302);
}
public function getEdit(Request $request, Response $response, array $args): Response {
$test = Test::where('id', $args['test_id'])->first();
$benchmarks = Benchmark::all();
$components = Component::all();
$view = Twig::fromRequest($request);
return $view->render($response, 'test/edit.twig', [
'test' => $test,
'benchmarks' => $benchmarks,
'components' => $components,
]);
}
public function postEdit(Request $request, Response $response, array $args): Response {
$params = (array)$request->getParsedBody();
$test = Test::where('id', $args['test_id'])->first();
$test->title = $params['test_title'];
$test->description = $params['test_description'];
$test->component_id = $params['test_component'];
$test->save();
// attach benchmarks to test that aren't already attached
foreach ($params['test_benchmarks'] as $b) {
if (!$test->isBenchmarkSelected($b)) {
$test->benchmarks()->attach($b);
}
}
// remove benchmarks are not in the list
foreach ($test->benchmarks as $b) {
if (!in_array($b->id, $params['test_benchmarks'])) {
$test->benchmarks()->detach($b);
}
}
// redirect the user back to the home page
$routeContext = RouteContext::fromRequest($request);
$routeParser = $routeContext->getRouteParser();
return $response
->withHeader('Location', $routeParser->urlFor('test.view', [ 'test_id' => $test->id ]))
->withStatus(302);
}
public function getResults(Request $request, Response $response, array $args): Response {
$test = Test::where('id', $args['test_id'])->first();
$view = Twig::fromRequest($request);
return $view->render($response, 'test/results.twig', [
'test' => $test,
]);
}
}

View File

@@ -1,26 +0,0 @@
<?php
namespace BitGoblin\Colossus\Middleware;
use Psr\Http\Message\ServerRequestInterface as Request;
class AppInfo {
protected $view;
public function __construct($view) {
$this->view = $view;
}
public function __invoke(Request $request, $handler) {
// add running app version
$composer = json_decode(file_get_contents(__DIR__ . '/../../composer.json'), true);
$this->view->getEnvironment()->addGlobal('APP_VERSION', $composer['version'] ?? 'unknown');
// add running PHP version
$this->view->getEnvironment()->addGlobal('PHP_VERSION', PHP_VERSION);
return $handler->handle($request);
}
}

View File

@@ -1,23 +0,0 @@
<?php
namespace BitGoblin\Colossus\Models;
use Illuminate\Database\Eloquent\Model;
class Benchmark extends Model {
protected $fillable = [
'name',
'description',
'scoring',
];
public function tests() {
return $this->belongsToMany(Test::class);
}
public function results() {
return $this->hasMany(Result::class);
}
}

View File

@@ -1,22 +0,0 @@
<?php
namespace BitGoblin\Colossus\Models;
use Illuminate\Database\Eloquent\Model;
class Component extends Model {
protected $fillable = [
'name',
'type',
];
public function tests() {
return $this->hasMany(Test::class);
}
public function results() {
return $this->hasMany(Result::class);
}
}

View File

@@ -1,25 +0,0 @@
<?php
namespace BitGoblin\Colossus\Models;
use Illuminate\Database\Eloquent\Model;
class Result extends Model {
protected $fillable = [
'test_id',
'benchmark_id',
'average',
'minimum',
'maximum',
];
public function test() {
return $this->belongsTo(Test::class);
}
public function benchmark() {
return $this->belongsTo(Benchmark::class);
}
}

View File

@@ -1,72 +0,0 @@
<?php
namespace BitGoblin\Colossus\Models;
use Illuminate\Database\Eloquent\Model;
class Test extends Model {
protected $fillable = [
'date_tag',
'benchmark_id',
'component_id',
];
public function results() {
return $this->hasMany(Result::class);
}
public function benchmarks() {
return $this->belongsToMany(Benchmark::class);
}
public function component() {
return $this->belongsTo(Component::class);
}
public function isBenchmarkSelected($benchmarkId) {
return $this->benchmarks()
->where('benchmarks.id', $benchmarkId)
->exists();
}
public function benchmarkResults() {
$data = [];
foreach ($this->benchmarks as $i => $b) {
$benchmarkResults = $this->results()->where('benchmark_id', $b->id)->get();
if (count($benchmarkResults) > 0) {
$averageResults = [];
$minimumResults = [];
$maximumResults = [];
foreach ($benchmarkResults as $r) {
array_push($averageResults, $r->average);
array_push($minimumResults, $r->minimum);
array_push($maximumResults, $r->maximum);
}
$data[$i] = [
'name' => $b->name,
'scoring' => $b->scoring,
'count' => count($benchmarkResults),
'average' => (array_sum($averageResults) / count($averageResults)),
'minimum' => (array_sum($minimumResults) / count($minimumResults)),
'maximum' => (array_sum($maximumResults) / count($maximumResults)),
];
} else {
$data[$i] = [
'name' => $b->name,
'scoring' => $b->scoring,
'count' => count($benchmarkResults),
'average' => 0,
'minimum' => 0,
'maximum' => 0,
];
}
}
return $data;
}
}

View File

@@ -1,47 +0,0 @@
<?php
use DI\Container;
use Noodlehaus\Config;
use Noodlehaus\Parser\Json;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;
use Slim\Views\Twig;
use Slim\Views\TwigMiddleware;
use BitGoblin\Colossus\Middleware\AppInfo;
require __DIR__ . '/../vendor/autoload.php';
// Load app configuration
$config = Config::load(__DIR__ . '/../conf/defaults.json');
// Create new container object and add our config object to it
$container = new Container();
$container->set('config', function () use ($config) {
return $config;
});
// Load database configuration
require_once __DIR__ . '/database.php';
// Set container to create App with on AppFactory
AppFactory::setContainer($container);
$app = AppFactory::create();
// Allow body parsing for POST parameters
$app->addBodyParsingMiddleware();
// Add Error Handling Middleware
$app->addErrorMiddleware(true, false, false);
// Create Twig
$twig = Twig::create(__DIR__ . '/../views', ['cache' => false]);
// Add Twig-View Middleware
$app->add(TwigMiddleware::create($app, $twig));
// Add middleware for injecting global vars for app's info
$app->add(new AppInfo($twig));
// Register routes
require_once __DIR__ . '/routes.php';

View File

@@ -1,10 +0,0 @@
<?php
$capsule = new \Illuminate\Database\Capsule\Manager;
$capsule->addConnection($config->get('database'));
$capsule->setAsGlobal();
$capsule->bootEloquent();
$container->set('db', function () use ($capsule) {
return $capsule;
});

View File

@@ -1,65 +0,0 @@
<?php
use Slim\Routing\RouteCollectorProxy;
$app->get('/', '\\BitGoblin\\Colossus\\Controllers\\HomeController:getIndex')->setName('dashboard');
$app->group('/benchmark', function(RouteCollectorProxy $group) {
$group->get('', '\\BitGoblin\\Colossus\\Controllers\\BenchmarkController:getIndex')->setName('benchmark.index');
$group->get('/list', '\\BitGoblin\\Colossus\\Controllers\\BenchmarkController:getList')->setName('benchmark.list');
$group->get('/add', '\\BitGoblin\\Colossus\\Controllers\\BenchmarkController:getAdd')->setName('benchmark.add');
$group->post('/add', '\\BitGoblin\\Colossus\\Controllers\\BenchmarkController:postAdd');
$group->group('/{benchmark_id}', function(RouteCollectorProxy $benchmark) {
$benchmark->get('', '\\BitGoblin\\Colossus\\Controllers\\BenchmarkController:getView')->setName('benchmark.view');
$benchmark->get('/edit', '\\BitGoblin\\Colossus\\Controllers\\BenchmarkController:getEdit')->setName('benchmark.edit');
$benchmark->post('/edit', '\\BitGoblin\\Colossus\\Controllers\\BenchmarkController:postEdit');
});
});
$app->group('/component', function(RouteCollectorProxy $group) {
$group->get('', '\\BitGoblin\\Colossus\\Controllers\\ComponentController:getIndex')->setName('component.index');
$group->get('/list', '\\BitGoblin\\Colossus\\Controllers\\ComponentController:getList')->setName('component.list');
$group->get('/add', '\\BitGoblin\\Colossus\\Controllers\\ComponentController:getAdd')->setName('component.add');
$group->post('/add', '\\BitGoblin\\Colossus\\Controllers\\ComponentController:postAdd');
$group->group('/{component_id}', function(RouteCollectorProxy $component) {
$component->get('', '\\BitGoblin\\Colossus\\Controllers\\ComponentController:getView')->setName('component.view');
$component->get('/edit', '\\BitGoblin\\Colossus\\Controllers\\ComponentController:getEdit')->setName('component.edit');
$component->post('/edit', '\\BitGoblin\\Colossus\\Controllers\\ComponentController:postEdit');
});
});
$app->group('/test', function(RouteCollectorProxy $group) {
$group->get('', '\\BitGoblin\\Colossus\\Controllers\\TestController:getList')->setName('test.list');
$group->get('/add', '\\BitGoblin\\Colossus\\Controllers\\TestController:getAdd')->setName('test.add');
$group->post('/add', '\\BitGoblin\\Colossus\\Controllers\\TestController:postAdd');
$group->group('/{test_id}', function(RouteCollectorProxy $test) {
$test->get('', '\\BitGoblin\\Colossus\\Controllers\\TestController:getView')->setName('test.view');
$test->get('/edit', '\\BitGoblin\\Colossus\\Controllers\\TestController:getEdit')->setName('test.edit');
$test->post('/edit', '\\BitGoblin\\Colossus\\Controllers\\TestController:postEdit');
$test->get('/results', '\\BitGoblin\\Colossus\\Controllers\\TestController:getResults')->setName('test.results');
});
});
$app->group('/reports', function(RouteCollectorProxy $group) {
$group->get('/generate', '\\BitGoblin\\Colossus\Controllers\ReportController:getGenerate')->setName('reports.generate');
});
$app->group('/api', function(RouteCollectorProxy $group) {
$group->group('/v1', function(RouteCollectorProxy $apiv1) {
$apiv1->get('/benchmark/details', '\\BitGoblin\\Colossus\\Controllers\\ApiController:getBenchmarkDetails')->setName('api.benchmarkDetails');
$apiv1->get('/benchmark/tests', '\\BitGoblin\\Colossus\\Controllers\\ApiController:getBenchmarkTests')->setName('api.benchmarkTests');
$apiv1->get('/result/list', '\\BitGoblin\\Colossus\\Controllers\\ApiController:getResultList')->setName('api.resultList');
$apiv1->post('/result/add', '\\BitGoblin\\Colossus\\Controllers\\ApiController:postResultAdd')->setName('api.resultAdd');
$apiv1->get('/result/{result_id}/delete', '\\BitGoblin\\Colossus\\Controllers\\ApiController:getResultDelete')->setName('api.resultDelete');
$apiv1->get('/test/details', '\\BitGoblin\\Colossus\\Controllers\\ApiController:getTestDetails')->setName('api.testDetails');
});
});

View File

@@ -1,42 +0,0 @@
{% extends 'layout.twig' %}
{% block title %}Add New Benchmark{% endblock %}
{% block content %}
<div class="row mb-4">
<div class="col-12">
<h1>Add new benchmark</h1>
</div>
</div>
<div class="row">
<form action="{{ url_for('benchmark.add') }}" method="POST">
<div class="row">
<div class="col-9 mb-3">
<label class="form-label" for="benchmark_name">Benchmark name:</label>
<input id="benchmark_name" class="form-control" type="text" name="benchmark_name">
</div>
<div class="col-3 mb-3">
<label class="form-label" for="benchmark_scoring">Scoring type:</label>
<select id="benchmark_scoring" class="form-select" name="benchmark_scoring">
<option value="fps">Frames per Second (fps)</option>
<option value="ms">Frame Time (ms)</option>
<option value="pts">Total Points</option>
</select>
</div>
</div>
<div class="row mb-3">
<div class="col-12">
<label for="benchmark_description">Description</label>
<textarea id="benchmark_description" class="form-control" name="benchmark_description" rows="5" placeholder="Describe this benchmark..."></textarea>
</div>
</div>
<input class="btn btn-primary" type="submit" value="Create Benchmark">
</form>
</div>
{% endblock %}

View File

@@ -1,42 +0,0 @@
{% extends 'layout.twig' %}
{% block title %}Editing Benchmark: {{ benchmark.name }}{% endblock %}
{% block content %}
<div class="row mb-4">
<div class="col-12">
<h1>Editing Benchmark: {{ benchmark.name }}</h1>
</div>
</div>
<div class="row">
<form action="{{ url_for('benchmark.edit', { benchmark_id: benchmark.id }) }}" method="POST">
<div class="row">
<div class="col-9 mb-3">
<label class="form-label" for="benchmark_name">Benchmark name:</label>
<input id="benchmark_name" class="form-control" type="text" name="benchmark_name" value="{{ benchmark.name }}">
</div>
<div class="col-3 mb-3">
<label class="form-label" for="benchmark_scoring">Scoring type:</label>
<select id="benchmark_scoring" class="form-select" name="benchmark_scoring">
<option value="fps" {% if benchmark.scoring == 'fps' %}selected{% endif %}>Frames per Second (fps)</option>
<option value="ms" {% if benchmark.scoring == 'ms' %}selected{% endif %}>Frame Time (ms)</option>
<option value="pts" {% if benchmark.scoring == 'pts' %}selected{% endif %}>Total Points</option>
</select>
</div>
</div>
<div class="row mb-3">
<div class="col-12">
<label for="benchmark_description">Description</label>
<textarea id="benchmark_description" class="form-control" name="benchmark_description" rows="5" placeholder="Describe this benchmark...">{{ benchmark.description }}</textarea>
</div>
</div>
<input class="btn btn-primary" type="submit" value="Submit Changes">
</form>
</div>
{% endblock %}

View File

@@ -1,34 +0,0 @@
{% extends 'layout.twig' %}
{% block title %}List of Benchmarks{% endblock %}
{% block content %}
<h1>List of Benchmarks</h1>
<p><a href="{{ url_for('benchmark.add') }}">Create new Benchmark</a></p>
{% if benchmarks | length > 0 %}
<table class="table table-hover table-responsive">
<thead class="table-light">
<tr>
<th>Benchmark name</th>
<th>Description</th>
<th>Scoring type</th>
<th>Last updated</th>
</tr>
</thead>
<tbody>
{% for b in benchmarks %}
<tr>
<td><a href="{{ url_for('benchmark.view', { benchmark_id: b.id }) }}">{{ b.name }}</a></td>
<td>{{ b.description | slice(0, 100) }}</td>
<td>{{ b.scoring }}</td>
<td>{{ b.updated_at | date("F jS \\a\\t g:ia") }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>There are no benchmarks in the database - perhaps you should <a href="{{ url_for('benchmark.add') }}">create one</a>?</p>
{% endif %}
{% endblock %}

View File

@@ -1,44 +0,0 @@
{% extends 'layout.twig' %}
{% block title %}Test: {{ test.name }}{% endblock %}
{% block content %}
<div class="row">
<div class="col-12">
<h1>{{ benchmark.name }}</h1>
<p><a href="{{ url_for('benchmark.edit', { benchmark_id: benchmark.id }) }}">Edit</a></p>
<p>{{ benchmark.description }}</p>
</div>
</div>
<hr>
<div class="row">
<div class="col-12">
<h3 class="mb-3">Tests using this benchmark:</h3>
{% if benchmark.tests | length > 0 %}
<table class="table table-hover table-responsive">
<thead class="table-light">
<tr>
<th>Test title</th>
<th>Benchmarks</th>
<th>Last updated</th>
</tr>
</thead>
<tbody>
{% for t in benchmark.tests %}
<tr>
<td><a href="{{ url_for('test.view', { test_id: t.id }) }}">{{ t.title }}</a></td>
<td>{{ t.benchmarks | length }}</td>
<td>{{ t.updated_at }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>There are no tests associated with this benchmark.</p>
{% endif %}
</div>
</div>
{% endblock %}

View File

@@ -1,36 +0,0 @@
{% extends 'layout.twig' %}
{% block title %}Add New Component{% endblock %}
{% block content %}
<div class="row mb-4">
<div class="col-12">
<h1>Add new component</h1>
</div>
</div>
<div class="row">
<div class="col-12">
<form action="{{ url_for('component.add') }}" method="POST">
<div class="row mb-3">
<div class="col-9">
<label class="form-label" for="component_name">Component name:</label>
<input id="component_name" class="form-control" type="text" name="component_name">
</div>
<div class="col-3">
<label class="form-label" for="component_type">Component type:</label>
<select id="component_type" class="form-select" name="component_type">
<option value="gpu">Graphics card</option>
<option value="cpu">Processor</option>
</select>
</div>
</div>
<input class="btn btn-primary" type="submit" value="Create Component">
</form>
</div>
</div>
{% endblock %}

View File

@@ -1,36 +0,0 @@
{% extends 'layout.twig' %}
{% block title %}Editing Component: {{ component.name }}{% endblock %}
{% block content %}
<div class="row mb-4">
<div class="col-12">
<h1>Editing Component: {{ component.name }}</h1>
</div>
</div>
<div class="row">
<div class="col-12">
<form action="{{ url_for('component.edit', { component_id: component.id }) }}" method="POST" class="u-full-width">
<div class="row mb-3">
<div class="col-9">
<label class="form-label" for="component_name">Component name:</label>
<input id="component_name" class="form-control" type="text" name="component_name" value="{{ component.name }}">
</div>
<div class="col-3">
<label class="form-label" for="component_type">Component type:</label>
<select id="component_type" class="form-select" name="component_type">
<option value="gpu" {% if component.type == 'gpu' %}selected{% endif %}>Graphics card</option>
<option value="cpu" {% if component.type == 'cpu' %}selected{% endif %}>Processor</option>
</select>
</div>
</div>
<input class="btn btn-primary" type="submit" value="Submit Changes">
</form>
</div>
</div>
{% endblock %}

View File

@@ -1,32 +0,0 @@
{% extends 'layout.twig' %}
{% block title %}List of Hardware Components{% endblock %}
{% block content %}
<h1>List of Hardware Components</h1>
<p><a href="{{ url_for('component.add') }}">Create new Hardware Component</a></p>
{% if components | length > 0 %}
<table class="table table-hover table-responsive">
<thead class="table-light">
<tr>
<th>Component name</th>
<th>Type</th>
<th>Last updated</th>
</tr>
</thead>
<tbody>
{% for c in components %}
<tr>
<td><a href="{{ url_for('component.view', { component_id: c.id }) }}">{{ c.name }}</a></td>
<td>{{ c.type }}</td>
<td>{{ c.updated_at | date("F jS \\a\\t g:ia") }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>There are no hardware components in the database - perhaps you should <a href="{{ url_for('component.add') }}">create one</a>?</p>
{% endif %}
{% endblock %}

View File

@@ -1,44 +0,0 @@
{% extends 'layout.twig' %}
{% block title %}Component: {{ component.name }}{% endblock %}
{% block content %}
<div class="row">
<div class="col-12">
<h1>{{ component.name }}</h1>
<p><a href="{{ url_for('component.edit', { component_id: component.id }) }}">Edit</a></p>
<p>{{ component.type }}</p>
</div>
</div>
<hr>
<div class="row">
<div class="col-12">
<h3>Tests using this component:</h3>
{% if component.tests | length > 0 %}
<table class="table table-hover table-responsive">
<thead class="table-light">
<tr>
<th>Test title</th>
<th>Benchmarks</th>
<th>Last updated</th>
</tr>
</thead>
<tbody>
{% for t in component.tests %}
<tr>
<td><a href="{{ url_for('test.view', { test_id: t.id }) }}">{{ t.title }}</a></td>
<td>{{ t.benchmarks | length }}</td>
<td>{{ t.updated_at }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>There are no tests associated with this component.</p>
{% endif %}
</div>
</div>
{% endblock %}

29
views/index.html Normal file
View File

@@ -0,0 +1,29 @@
{{ template "layout_header" . }}
<div id="main-wrapper" class="container">
<div class="row">
<div class="twelve columns">
<h1>Welcome to Colossus!</h1>
<p>Using Colossus you can easily keep track of your PC hardware benchmarking results and benchmark settings.</p>
</div>
</div>
<div class="row">
<div class="four columns">
<p><a href="/benchmark/add">Add benchmarking result</a></p>
</div>
<div class="four columns">
<p><a href="/hardware/add">Add new hardware</a></p>
<ul>
{{ range $i, $comp := .hardware }}
<li>{{ $comp.Name }}</li>
{{ end }}
</ul>
</div>
<div class="four columns">
<p><a href="/game/add">Add new game</a></p>
</div>
</div>
</div>
{{ template "layout_footer" . }}

View File

@@ -1,23 +0,0 @@
{% extends 'layout.twig' %}
{% block title %}Dashboard{% endblock %}
{% block content %}
<div class="row">
<div class="col-12">
<h1>Welcome to Colossus!</h1>
<p>Using Colossus, you can easily organize your hardware benchmark results.</p>
</div>
</div>
<hr>
<div class="row">
<div class="col-12">
<p><a href="{{ url_for('test.list') }}">View current tests</a></p>
<p><a href="{{ url_for('test.add') }}">Add a new test</a></p>
</div>
</div>
{% endblock %}

View File

@@ -1,23 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}{% endblock %} | Colossus</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/nardah.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.7/js/bootstrap.min.js"></script>
<script src="/js/bedabin.js"></script>
{% block scripts %}{% endblock %}
</head>
<body class="d-flex flex-column min-vh-100">
{% include 'partials/navbar.twig' %}
<div id="main-wrapper" class="container mb-5">
{% block content %}{% endblock %}
</div>
{% include 'partials/footer.twig' %}
</body>
</html>

4
views/layout/footer.html Normal file
View File

@@ -0,0 +1,4 @@
{{ define "layout_footer" }}
</body>
</html>
{{ end }}

16
views/layout/header.html Normal file
View File

@@ -0,0 +1,16 @@
{{ define "layout_header" }}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ .title }}</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css">
<link rel="stylesheet" href="/css/nardah.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
</head>
<body>
{{ template "navbar" . }}
{{ end }}

11
views/layout/navbar.html Normal file
View File

@@ -0,0 +1,11 @@
{{ define "navbar" }}
<nav id="main-nav">
<ul class="nav-left">
<li class="site-logo">Goliath</li>
<li class="nav-link"><a href="/">Dashboard</a></li>
<li class="nav-link"><a href="/benchmark">Benchmarks</a></li>
<li class="nav-link"><a href="/hardware">Hardware</a></li>
<li class="nav-link"><a href="/game">Games</a></li>
</ul>
</nav>
{{ end }}

View File

@@ -1,10 +0,0 @@
<footer id="main-footer" class="bg-light py-4 mt-auto">
<div class="container">
<div class="row">
<div class="col-12">
<p class="text-center mb-0">Colossus version {{ APP_VERSION }}</p>
<p class="text-center mb-0">Running PHP version {{ PHP_VERSION }}</p>
</div>
</div>
</div>
</footer>

View File

@@ -1,29 +0,0 @@
<nav id="main-nav" class="navbar navbar-expand-md navbar-dark bg-primary mb-3">
<div class="container-fluid">
<a class="navbar-brand mb-0 h1" href="#">Colossus</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-md-0">
<li class="nav-item">
<a class="nav-link" href="{{ url_for('dashboard') }}">Dashboard</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('benchmark.list') }}">Benchmarks</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('component.list') }}">Components</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('test.list') }}">Test</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('reports.generate') }}">Reports</a>
</li>
</ul>
</div>
</div>
</nav>

View File

@@ -1,53 +0,0 @@
{% extends 'layout.twig' %}
{% block title %}Dashboard{% endblock %}
{% block scripts %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.1/chart.umd.min.js" charset="utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chartjs-plugin-datalabels/2.2.0/chartjs-plugin-datalabels.min.js" charset="utf-8"></script>
<script src="/js/reports.js" charset="utf-8"></script>
{% endblock %}
{% block content %}
<div class="row">
<div class="twelve columns">
<h1>Generate a Report</h1>
</div>
</div>
<hr>
<div class="row">
<div class="col-5">
<select id="report-benchmarks" class="form-select">
{% for b in benchmarks %}
<option value="{{ b.id }}">{{ b.name }}</option>
{% endfor %}
</select>
</div>
<div class="col-7">
<select id="report-tests" class="form-select" multiple>
{% for t in benchmarks[0].tests %}
<option value="{{ t.id }}">{{ t.title }}</option>
{% endfor %}
</select>
</div>
</div>
<div class="row">
<div class="col-12">
<button id="reports-button" class="btn btn-primary" type="button" name="button">Generate Chart</button>
<button id="reports-download" class="btn btn-primary" type="button" name="button" disabled>Download Chart</button>
</div>
</div>
<div class="row">
<div class="col-12">
<canvas id="benchmark-chart" class="disabled" width="1200" height="720"></canvas>
</div>
</div>
{% endblock %}

View File

@@ -1,55 +0,0 @@
{% extends 'layout.twig' %}
{% block title %}Add New Test{% endblock %}
{% block content %}
<div class="row mb-4">
<div class="col-12">
<h1>Add new test</h1>
</div>
</div>
<div class="row">
<div class="col-12">
<form action="{{ url_for('test.add') }}" method="POST">
<div class="row mb-3">
<div class="col-6">
<label class="form-label" for="test_title">Test title:</label>
<input id="test_title" class="form-control" type="text" name="test_title" placeholder="My new test">
</div>
<div class="col-6">
<label class="form-label" for="test_component">Hardware component:</label>
<select id="test_component" class="form-select" name="test_component">
{% for c in components %}
<option value="{{ c.id }}">{{ c.name }}</option>
{% endfor %}
</select>
</div>
</div>
<div class="row">
<div class="col-12 mb-3">
<label class="form-label" for="test_benchmarks">Benchmarks:</label>
<select id="test_benchmarks" class="form-select" name="test_benchmarks[]" multiple>
{% for b in benchmarks %}
<option value="{{ b.id }}">{{ b.name }}</option>
{% endfor %}
</select>
</div>
</div>
<div class="row mb-3">
<div class="col-12">
<label class="form-label" for="test_description">Test description:</label>
<textarea id="test_description" class="form-control" name="test_description" rows="8"></textarea>
</div>
</div>
<input class="btn btn-primary" type="submit" value="Create Test">
</form>
</div>
</div>
{% endblock %}

View File

@@ -1,55 +0,0 @@
{% extends 'layout.twig' %}
{% block title %}Editing: {{ test.title }}{% endblock %}
{% block content %}
<div class="row mb-4">
<div class="col-12">
<h1>Editing: {{ test.title }}</h1>
</div>
</div>
<div class="row">
<div class="col-12">
<form action="{{ url_for('test.edit', { test_id: test.id }) }}" method="POST">
<div class="row mb-3">
<div class="col-6">
<label class="form-label" for="test_title">Test title:</label>
<input id="test_title" class="form-control" type="text" name="test_title" placeholder="My new test" value="{{ test.title }}">
</div>
<div class="col-6">
<label class="form-label" for="test_component">Hardware component:</label>
<select id="test_component" class="form-select" name="test_component">
{% for c in components %}
<option value="{{ c.id }}" {% if test.component.id == c.id %}selected{% endif %}>{{ c.name }}</option>
{% endfor %}
</select>
</div>
</div>
<div class="row">
<div class="col-12 mb-3">
<label class="form-label" for="test_benchmarks">Benchmarks:</label>
<select id="test_benchmarks" class="form-select" name="test_benchmarks[]" multiple>
{% for b in benchmarks %}
<option value="{{ b.id }}" {% if test.isBenchmarkSelected(b.id) %}selected{% endif %}>{{ b.name }}</option>
{% endfor %}
</select>
</div>
</div>
<div class="row mb-3">
<div class="col-12">
<label class="form-label" for="test_description">Test description:</label>
<textarea id="test_description" class="form-control" name="test_description" rows="8">{{ test.description }}</textarea>
</div>
</div>
<input class="btn btn-primary" type="submit" value="Submit Changes">
</form>
</div>
</div>
{% endblock %}

View File

@@ -1,34 +0,0 @@
{% extends 'layout.twig' %}
{% block title %}List of Tests{% endblock %}
{% block content %}
<h1>List of Hardware Tests</h1>
<p><a href="{{ url_for('test.add') }}">Create new test</a></p>
{% if tests | length > 0 %}
<table class="table table-hover table-responsive">
<thead class="table-light">
<tr>
<th>Test title</th>
<th>Hardware</th>
<th># of benchmarks</th>
<th>Last updated</th>
</tr>
</thead>
<tbody>
{% for t in tests %}
<tr>
<td><a href="{{ url_for('test.view', { test_id: t.id }) }}">{{ t.title }}</a></td>
<td>{{ t.component.name }}</td>
<td>{{ t.benchmarks().get() | length }}</td>
<td>{{ t.updated_at | date("F jS \\a\\t g:ia") }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>There are no tests in the database - perhaps you should <a href="{{ url_for('test.add') }}">create one</a>?</p>
{% endif %}
{% endblock %}

View File

@@ -1,44 +0,0 @@
{% extends 'layout.twig' %}
{% block title %}Result Details for {{ test.title }}{% endblock %}
{% block content %}
<div class="row mb-3">
<div class="col-12">
<h1>Result Details for {{ test.title }}</h1>
<p><a href="{{ url_for('test.view', { test_id: test.id }) }}">Back</a></p>
</div>
</div>
<hr class="mb-4">
<div class="row mb-4">
{% for b in test.benchmarks %}
<div class="col-12 mb-3">
<h2><a href="{{ url_for('benchmark.view', { benchmark_id: b.id }) }}">{{ b.name }}</a></h2>
<table class="table table-hover table-responsive">
<thead>
<tr>
<th>Average</th>
<th>Minimum</th>
<th>Maximum</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
{% for r in b.results().where('test_id', test.id).get() %}
<tr>
<td>{{ r.average }}</td>
<td>{{ r.minimum }}</td>
<td>{{ r.maximum }}</td>
<td><a href="#">Edit</a></td>
<td><a href="{{ url_for('api.resultDelete', { result_id: r.id }) }}">Delete</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endfor %}
</div>
{% endblock %}

View File

@@ -1,77 +0,0 @@
{% extends 'layout.twig' %}
{% block title %}Test: {{ test.title }}{% endblock %}
{% block content %}
<div class="row mb-3">
<div class="col-12">
<h1>{{ test.title }}</h1>
<p><a href="{{ url_for('test.edit', { test_id: test.id }) }}">Edit</a></p>
<p>{{ test.description }}</p>
</div>
</div>
<hr class="mb-4">
<div class="row mb-4">
<div class="col-12">
<form id="result-form" action="{{ url_for('api.resultAdd') }}" method="POST">
<div class="row">
<div class="col-4">
<select class="form-select" name="result_benchmark">
{% for b in test.benchmarks %}
<option value="{{ b.id }}">{{ b.name }}</option>
{% endfor %}
</select>
</div>
<div class="col-2">
<input class="form-control" type="number" step="0.01" name="result_avg" placeholder="0.0">
</div>
<div class="col-2">
<input class="form-control" type="number" step="0.01" name="result_min" placeholder="0.0">
</div>
<div class="col-2">
<input class="form-control" type="number" step="0.01" name="result_max" placeholder="0.0">
</div>
<div class="col-2">
<button class="btn btn-primary w-100" type="submit" name="button">Submit Result</button>
</div>
</div>
<input type="hidden" name="result_test" value="{{ test.id }}">
<input type="hidden" name="result_component" value="{{ test.component().id }}">
</form>
</div>
</div>
<hr class="mb-4">
<div class="row">
<div class="col-12">
<h3 class="mb-3">Benchmark results:</h3>
<table id="results-table" class="table table-hover table-responsive" data-test-id="{{ test.id }}">
<thead class="table-light">
<tr>
<th>Benchmark</th>
<th>Scoring</th>
<th># Results</th>
<th>Avg.</th>
<th>Min.</th>
<th>Max.</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for b in test.benchmarks %}
<tr data-benchmark-id="{{ b.id }}"></tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<script src="/js/test.js"></script>
{% endblock %}