Compare commits
70 Commits
afd6ffc3f1
...
main
Author | SHA1 | Date | |
---|---|---|---|
a1fba9829c | |||
32632b2303 | |||
078edf5ab0 | |||
9dedba6364 | |||
bbe9c6575a | |||
295c7d1923 | |||
7a8b5a674c | |||
3f5f374a36 | |||
fec91b1c1c | |||
|
728c249c15 | ||
|
de9e082961 | ||
|
e59d606f8c | ||
|
4f0cb54190 | ||
|
23cfbc2efa | ||
|
e9e43187e4 | ||
|
1a7e41edb2 | ||
6e67d58a8b | |||
1b4fd8dec9 | |||
fad6899683 | |||
e42f453161 | |||
12b7743660 | |||
|
b4bd116367 | ||
|
cedad0e48d | ||
|
004a2ddef6 | ||
|
f473bdf9ab | ||
|
4a4f694831 | ||
|
10df46be3b | ||
|
b9b881ec0c | ||
|
94794f2ca1 | ||
|
b293254a41 | ||
|
a4aaae0cd4 | ||
|
27c9267261 | ||
|
de01e4b144 | ||
|
e0c6e3ef68 | ||
|
acbbbeb74f | ||
|
af9d788fe0 | ||
|
0510c80c34 | ||
|
0fde8c082e | ||
|
e3285bbaeb | ||
|
2f42f19c26 | ||
|
9aa0b57298 | ||
|
c81d6f0e32 | ||
|
4fab94b271 | ||
|
ca940932a7 | ||
|
9b575f8717 | ||
|
05b1374d1d | ||
|
de8e523c2c | ||
|
6079524c4e | ||
|
0844c8aead | ||
|
0b2c1b083c | ||
|
9e164485ed | ||
|
f27490e192 | ||
|
15377da52d | ||
|
6eaf7a0ba9 | ||
|
bd4c79a6fc | ||
33c9bf5cb5 | |||
0c1df2e7e6 | |||
96a69a94ba | |||
987ecde7c7 | |||
3349d42985 | |||
0dd7098681 | |||
e176398f41 | |||
|
408b3baf8f | ||
d6a72fcee3 | |||
950b12ee10 | |||
005b31dbd7 | |||
ca62be49b6 | |||
9a65b5f27a | |||
323152a8f5 | |||
ade48ccb2f |
21
.fresh.yaml
21
.fresh.yaml
@@ -1,21 +0,0 @@
|
||||
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
40
.gitignore
vendored
@@ -1,35 +1,13 @@
|
||||
# ---> Go
|
||||
# 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
|
||||
# Composer dependencies
|
||||
/vendor/
|
||||
|
||||
# Test binary, built with `go test -c`
|
||||
*.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/
|
||||
# Local data directory
|
||||
data/
|
||||
|
||||
# NPM dependencies for Grunt
|
||||
node_modules/
|
||||
|
||||
# Compiled CSS and JS
|
||||
public/css/
|
||||
public/js/
|
||||
|
||||
|
25
Dockerfile
Normal file
25
Dockerfile
Normal file
@@ -0,0 +1,25 @@
|
||||
# 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" ]
|
13
Dockerfile.grunt
Normal file
13
Dockerfile.grunt
Normal file
@@ -0,0 +1,13 @@
|
||||
# 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" ]
|
22
Gruntfile.js
22
Gruntfile.js
@@ -1,9 +1,9 @@
|
||||
module.exports = function(grunt) {
|
||||
|
||||
var pkg = grunt.file.readJSON('package.json')
|
||||
|
||||
// Project configuration.
|
||||
grunt.initConfig({
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
|
||||
sass: {
|
||||
dist: {
|
||||
options: {
|
||||
@@ -11,8 +11,8 @@ module.exports = function(grunt) {
|
||||
},
|
||||
files: [{
|
||||
expand: true,
|
||||
cwd: 'assets/sass',
|
||||
src: ['*.sass'],
|
||||
cwd: 'assets/styles',
|
||||
src: ['**/*.scss'],
|
||||
dest: 'public/css',
|
||||
ext: '.css'
|
||||
}]
|
||||
@@ -27,7 +27,7 @@ module.exports = function(grunt) {
|
||||
files: {
|
||||
expand: true,
|
||||
flatten: true,
|
||||
cwd: 'assets/coffee',
|
||||
cwd: 'assets/scripts',
|
||||
src: ['*.coffee'],
|
||||
dest: 'public/js',
|
||||
ext: '.js'
|
||||
@@ -36,15 +36,15 @@ module.exports = function(grunt) {
|
||||
|
||||
watch: {
|
||||
css: {
|
||||
files: ['assets/sass/*.sass'],
|
||||
files: ['assets/styles/**/*.scss'],
|
||||
tasks: ['sass'],
|
||||
options: {
|
||||
atBegin: true,
|
||||
spawn: false
|
||||
}
|
||||
},
|
||||
js: {
|
||||
files: ['assets/coffee/*.coffee'],
|
||||
coffee: {
|
||||
files: ['assets/scripts/**/*.coffee'],
|
||||
tasks: ['coffee'],
|
||||
options: {
|
||||
atBegin: true,
|
||||
@@ -54,12 +54,12 @@ module.exports = function(grunt) {
|
||||
}
|
||||
});
|
||||
|
||||
// Load task plugins
|
||||
// Load plugins.
|
||||
grunt.loadNpmTasks('grunt-contrib-watch');
|
||||
grunt.loadNpmTasks('grunt-contrib-sass');
|
||||
grunt.loadNpmTasks('grunt-contrib-coffee');
|
||||
grunt.loadNpmTasks('grunt-contrib-watch');
|
||||
|
||||
// Default task(s).
|
||||
// CLI tasks.
|
||||
grunt.registerTask('default', ['sass', 'coffee']);
|
||||
|
||||
};
|
||||
|
25
README.md
25
README.md
@@ -1,3 +1,26 @@
|
||||
# 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.
|
||||
|
@@ -1,8 +0,0 @@
|
||||
html,
|
||||
body
|
||||
margin: 0
|
||||
padding: 0
|
||||
background: lightgrey
|
||||
|
||||
#main-nav
|
||||
background: cornflowerblue
|
23
assets/scripts/bedabin.coffee
Normal file
23
assets/scripts/bedabin.coffee
Normal file
@@ -0,0 +1,23 @@
|
||||
$ ->
|
||||
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)
|
||||
)
|
110
assets/scripts/reports.coffee
Normal file
110
assets/scripts/reports.coffee
Normal file
@@ -0,0 +1,110 @@
|
||||
$ ->
|
||||
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')
|
64
assets/scripts/test.coffee
Normal file
64
assets/scripts/test.coffee
Normal file
@@ -0,0 +1,64 @@
|
||||
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)
|
34
assets/styles/nardah.scss
Normal file
34
assets/styles/nardah.scss
Normal file
@@ -0,0 +1,34 @@
|
||||
$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;
|
||||
}
|
4
bin/docker-build.bat
Normal file
4
bin/docker-build.bat
Normal file
@@ -0,0 +1,4 @@
|
||||
@ECHO OFF
|
||||
|
||||
docker build -t colossus-php .
|
||||
docker build -t colossus-grunt -f Dockerfile.grunt .
|
4
bin/docker-build.sh
Executable file
4
bin/docker-build.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
docker build -t colossus-php .
|
||||
docker build -t colossus-grunt -f Dockerfile.grunt .
|
3
bin/docker-composer.bat
Normal file
3
bin/docker-composer.bat
Normal file
@@ -0,0 +1,3 @@
|
||||
@ECHO OFF
|
||||
|
||||
docker run --rm -w "/usr/src/colossus" -v "%cd%:/usr/src/colossus" --name colossus_composer composer "%*"
|
3
bin/docker-phinx.sh
Executable file
3
bin/docker-phinx.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
docker exec colossus-php ./vendor/bin/phinx $@
|
4
bin/docker-run.bat
Normal file
4
bin/docker-run.bat
Normal file
@@ -0,0 +1,4 @@
|
||||
@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
|
4
bin/docker-run.sh
Executable file
4
bin/docker-run.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/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
|
4
bin/run-php.sh
Executable file
4
bin/run-php.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
# start a local instance of the app using PHP's built-in webserver
|
||||
php -S localhost:8080 -t public/ public/index.php
|
35
colossus.go
35
colossus.go
@@ -1,35 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/flamego/flamego"
|
||||
"github.com/flamego/template"
|
||||
)
|
||||
|
||||
func main() {
|
||||
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
|
||||
f.Get("/", func(t template.Template, data template.Data) {
|
||||
data["title"] = "Dashboard"
|
||||
t.HTML(http.StatusOK, "index")
|
||||
})
|
||||
|
||||
fmt.Println("test!!?")
|
||||
|
||||
f.Run()
|
||||
}
|
31
composer.json
Normal file
31
composer.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"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
Normal file
3743
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
6
conf/defaults.json
Normal file
6
conf/defaults.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"database": {
|
||||
"driver": "sqlite",
|
||||
"database": "./data/colossus.db"
|
||||
}
|
||||
}
|
0
data/.gitkeep
Normal file
0
data/.gitkeep
Normal file
27
db/migrations/20230921024609_add_initial_tables.php
Normal file
27
db/migrations/20230921024609_add_initial_tables.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?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();
|
||||
}
|
||||
|
||||
}
|
25
db/migrations/20230923020649_add_tests_table.php
Normal file
25
db/migrations/20230923020649_add_tests_table.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?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();
|
||||
}
|
||||
|
||||
}
|
22
db/migrations/20240603081359_add_results_table.php
Normal file
22
db/migrations/20240603081359_add_results_table.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?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();
|
||||
}
|
||||
|
||||
}
|
7
entrypoints/dev.sh
Normal file
7
entrypoints/dev.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/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
|
14
go.mod
14
go.mod
@@ -1,14 +0,0 @@
|
||||
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/mattn/go-colorable v0.1.9 // indirect
|
||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
|
||||
)
|
19
go.sum
19
go.sum
@@ -1,19 +0,0 @@
|
||||
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/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/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=
|
952
package-lock.json
generated
952
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "colossus",
|
||||
"version": "0.1.0",
|
||||
"version": "1.0.0",
|
||||
"description": "Self-hosted database for organizing PC hardware benchmarking results",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
@@ -9,17 +9,17 @@
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://git.metaunix.net/BitGoblin/colossus.git"
|
||||
"url": "https://git.metaunix.net/BitGoblin/colossus"
|
||||
},
|
||||
"keywords": [
|
||||
"benchmarking"
|
||||
"inventory"
|
||||
],
|
||||
"author": "Gregory Ballantine <gballantine@bitgoblin.tech>",
|
||||
"license": "BSD-2-Clause",
|
||||
"devDependencies": {
|
||||
"dependencies": {
|
||||
"grunt": "^1.5.3",
|
||||
"grunt-contrib-coffee": "^2.1.0",
|
||||
"grunt-contrib-sass": "^2.0.0",
|
||||
"grunt-contrib-coffee": "^2.1.0",
|
||||
"grunt-contrib-watch": "^1.1.0",
|
||||
"sass": "^1.56.1"
|
||||
}
|
||||
|
37
phinx.php
Normal file
37
phinx.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?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'
|
||||
];
|
5
public/.htaccess
Normal file
5
public/.htaccess
Normal file
@@ -0,0 +1,5 @@
|
||||
# rewrite rules
|
||||
RewriteEngine On
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule ^ index.php [QSA,L]
|
24
public/index.php
Normal file
24
public/index.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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();
|
||||
|
97
src/Controllers/ApiController.php
Normal file
97
src/Controllers/ApiController.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?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');
|
||||
}
|
||||
|
||||
}
|
91
src/Controllers/BenchmarkController.php
Normal file
91
src/Controllers/BenchmarkController.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?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);
|
||||
}
|
||||
|
||||
}
|
89
src/Controllers/ComponentController.php
Normal file
89
src/Controllers/ComponentController.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?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);
|
||||
}
|
||||
|
||||
}
|
19
src/Controllers/Controller.php
Normal file
19
src/Controllers/Controller.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?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);
|
||||
}
|
||||
|
||||
}
|
16
src/Controllers/HomeController.php
Normal file
16
src/Controllers/HomeController.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?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');
|
||||
}
|
||||
|
||||
}
|
22
src/Controllers/ReportController.php
Normal file
22
src/Controllers/ReportController.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?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,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
121
src/Controllers/TestController.php
Normal file
121
src/Controllers/TestController.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?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,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
26
src/Middleware/AppInfo.php
Normal file
26
src/Middleware/AppInfo.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?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);
|
||||
}
|
||||
|
||||
}
|
23
src/Models/Benchmark.php
Normal file
23
src/Models/Benchmark.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?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);
|
||||
}
|
||||
|
||||
}
|
22
src/Models/Component.php
Normal file
22
src/Models/Component.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?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);
|
||||
}
|
||||
|
||||
}
|
25
src/Models/Result.php
Normal file
25
src/Models/Result.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?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);
|
||||
}
|
||||
|
||||
}
|
72
src/Models/Test.php
Normal file
72
src/Models/Test.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
}
|
47
src/app.php
Normal file
47
src/app.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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';
|
10
src/database.php
Normal file
10
src/database.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
$capsule = new \Illuminate\Database\Capsule\Manager;
|
||||
$capsule->addConnection($config->get('database'));
|
||||
$capsule->setAsGlobal();
|
||||
$capsule->bootEloquent();
|
||||
|
||||
$container->set('db', function () use ($capsule) {
|
||||
return $capsule;
|
||||
});
|
65
src/routes.php
Normal file
65
src/routes.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?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');
|
||||
});
|
||||
});
|
42
views/benchmark/add.twig
Normal file
42
views/benchmark/add.twig
Normal file
@@ -0,0 +1,42 @@
|
||||
{% 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 %}
|
42
views/benchmark/edit.twig
Normal file
42
views/benchmark/edit.twig
Normal file
@@ -0,0 +1,42 @@
|
||||
{% 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 %}
|
34
views/benchmark/list.twig
Normal file
34
views/benchmark/list.twig
Normal file
@@ -0,0 +1,34 @@
|
||||
{% 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 %}
|
44
views/benchmark/view.twig
Normal file
44
views/benchmark/view.twig
Normal file
@@ -0,0 +1,44 @@
|
||||
{% 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 %}
|
36
views/component/add.twig
Normal file
36
views/component/add.twig
Normal file
@@ -0,0 +1,36 @@
|
||||
{% 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 %}
|
36
views/component/edit.twig
Normal file
36
views/component/edit.twig
Normal file
@@ -0,0 +1,36 @@
|
||||
{% 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 %}
|
32
views/component/list.twig
Normal file
32
views/component/list.twig
Normal file
@@ -0,0 +1,32 @@
|
||||
{% 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 %}
|
44
views/component/view.twig
Normal file
44
views/component/view.twig
Normal file
@@ -0,0 +1,44 @@
|
||||
{% 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 %}
|
@@ -1,5 +0,0 @@
|
||||
{{ template "layout_header" . }}
|
||||
|
||||
<p>This is a test.</p>
|
||||
|
||||
{{ template "layout_footer" . }}
|
23
views/index.twig
Normal file
23
views/index.twig
Normal file
@@ -0,0 +1,23 @@
|
||||
{% 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 %}
|
23
views/layout.twig
Normal file
23
views/layout.twig
Normal file
@@ -0,0 +1,23 @@
|
||||
<!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>
|
@@ -1,4 +0,0 @@
|
||||
{{ define "layout_footer" }}
|
||||
</body>
|
||||
</html>
|
||||
{{ end }}
|
@@ -1,16 +0,0 @@
|
||||
{{ 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 }}
|
@@ -1,11 +0,0 @@
|
||||
{{ define "navbar" }}
|
||||
<nav id="main-nav">
|
||||
<ul class="nav-left">
|
||||
<li>Goliath</li>
|
||||
<li><a href="/">Dashboard</a></li>
|
||||
<li><a href="/benchmark">Benchmarks</a></li>
|
||||
<li><a href="/hardware">Hardware</a></li>
|
||||
<li><a href="/game">Games</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
{{ end }}
|
10
views/partials/footer.twig
Normal file
10
views/partials/footer.twig
Normal file
@@ -0,0 +1,10 @@
|
||||
<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>
|
29
views/partials/navbar.twig
Normal file
29
views/partials/navbar.twig
Normal file
@@ -0,0 +1,29 @@
|
||||
<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>
|
53
views/reports/generate.twig
Normal file
53
views/reports/generate.twig
Normal file
@@ -0,0 +1,53 @@
|
||||
{% 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 %}
|
55
views/test/add.twig
Normal file
55
views/test/add.twig
Normal file
@@ -0,0 +1,55 @@
|
||||
{% 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 %}
|
55
views/test/edit.twig
Normal file
55
views/test/edit.twig
Normal file
@@ -0,0 +1,55 @@
|
||||
{% 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 %}
|
34
views/test/list.twig
Normal file
34
views/test/list.twig
Normal file
@@ -0,0 +1,34 @@
|
||||
{% 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 %}
|
44
views/test/results.twig
Normal file
44
views/test/results.twig
Normal file
@@ -0,0 +1,44 @@
|
||||
{% 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 %}
|
77
views/test/view.twig
Normal file
77
views/test/view.twig
Normal file
@@ -0,0 +1,77 @@
|
||||
{% 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 %}
|
Reference in New Issue
Block a user