Compare commits

..

22 Commits
v0.1.0 ... main

Author SHA1 Message Date
771d26ec3b Improved some styles 2024-06-08 10:01:25 -04:00
da6397dd14 [Issue #8] - Licensing project under the BSD 2-Clause license (#10)
Adding license to project

Co-authored-by: Gregory Ballantine <gballantine@bitgoblin.tech>
Reviewed-on: #10
2024-05-31 09:28:23 -04:00
8e20e5e354 3-add-gruntjs (#9)
Adding Grunt.js to compile SASS and CoffeeScript assets

Co-authored-by: Gregory Ballantine <gregory.w.ballantine@nasa.gov>
Co-authored-by: Gregory Ballantine <gballantine555@gmail.com>
Reviewed-on: #9
2024-05-31 09:00:18 -04:00
Gregory Ballantine
533c407183 Updated some styles for tables and links 2024-05-29 15:07:54 -04:00
Gregory Ballantine
fb76f28643 Added tests to hardware page 2024-05-29 12:33:45 -04:00
Gregory Ballantine
06262431da Updated some styles 2024-05-29 12:10:27 -04:00
Gregory Ballantine
e734d4077d Updated some styles 2024-05-29 12:08:58 -04:00
Gregory Ballantine
9617f4280d Fixed results table in test view 2024-05-29 12:04:08 -04:00
Gregory Ballantine
3ec5605c53 Fixed results table in test view 2024-05-29 12:02:45 -04:00
Gregory Ballantine
ed5232371c Fixed results table in test view 2024-05-29 12:00:04 -04:00
Gregory Ballantine
29d9cbc59c Fixed results table in test view 2024-05-29 11:57:49 -04:00
Gregory Ballantine
3eca29c2db Added back reference associations for result; added table of results to test view 2024-05-29 11:52:01 -04:00
Gregory Ballantine
8df9b7684f added missing import 2024-05-29 11:43:42 -04:00
Gregory Ballantine
7282d0a4b6 Fixed result form stuff 2024-05-29 11:43:17 -04:00
Gregory Ballantine
0525838f4b Fixed float variable types 2024-05-29 11:41:53 -04:00
Gregory Ballantine
958c72ee63 Added result creation route 2024-05-29 11:40:42 -04:00
Gregory Ballantine
fa92321176 Added result model; added form to submit results 2024-05-29 11:26:42 -04:00
Gregory Ballantine
458646ee8e Added result model; added form to submit results 2024-05-29 11:26:17 -04:00
Gregory Ballantine
9df8f6c9e1 Added result model; added form to submit results 2024-05-29 11:25:45 -04:00
Gregory Ballantine
7e294c8f72 Cleaned up runtime version 2024-05-29 11:09:55 -04:00
Gregory Ballantine
cefa79a8b8 Added Go runtime version to the layout footer 2024-05-29 11:05:02 -04:00
Gregory Ballantine
1e87466ccb Added Go runtime version to the layout footer 2024-05-29 11:04:31 -04:00
29 changed files with 2313 additions and 106 deletions

7
.gitignore vendored
View File

@ -4,3 +4,10 @@ blt
# Local data files
data/
# Compiled assets
public/css/
public/js/
# Node modules
node_modules/

65
Gruntfile.js Normal file
View File

@ -0,0 +1,65 @@
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
dist: {
options: {
style: 'compressed'
},
files: [{
expand: true,
cwd: 'assets/styles',
src: ['**/*.sass'],
dest: 'public/css',
ext: '.css'
}]
}
},
coffee: {
options: {
sourceMap: true,
style: 'compressed'
},
files: {
expand: true,
flatten: true,
cwd: 'assets/scripts',
src: ['*.coffee'],
dest: 'public/js',
ext: '.js'
}
},
watch: {
css: {
files: ['assets/styles/**/*.sass'],
tasks: ['sass'],
options: {
atBegin: true,
spawn: false
}
},
js: {
files: ['assets/scripts/**/*.js'],
tasks: ['coffee'],
options: {
atBegin: true,
spawn: false
}
}
}
});
// Load plugins.
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-coffee');
// CLI tasks.
grunt.registerTask('default', ['sass', 'coffee']);
};

9
LICENSE Normal file
View File

@ -0,0 +1,9 @@
Copyright (c) 2023 Bit Goblin
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -4,7 +4,7 @@ VERSION=`git describe --tags`
.PHONY: build
## build: Compile the packages.
build:
@go build -o $(NAME) -ldflags "-X git.metaunix.net/bitgoblin/blt/app.Version=$(VERSION)"
@go build -o $(NAME) -ldflags "-X git.metaunix.net/bitgoblin/blt/app.AppVersion=$(VERSION)"
.PHONY: run
## run: Build and Run in development mode.

View File

@ -1,5 +1,15 @@
package app
var (
Version string = "N/a"
import (
"runtime"
)
var (
AppVersion string = "N/a"
RuntimeVersion string = runtimeVersion()
)
func runtimeVersion() string {
raw_string := runtime.Version()
return raw_string[2:]
}

View File

@ -0,0 +1,2 @@
$ ->
console.log('DOM is ready.')

133
assets/styles/kourend.sass Normal file
View File

@ -0,0 +1,133 @@
html,
body
width: 100%
height: 100%
margin: 0
padding: 0
body
height: auto
min-height: 100%
box-sizing: border-box
padding-top: 80px
padding-bottom: 100px
background: #eee
a
color: teal
transition: color 180ms ease-in-out
&:hover
color: darkcyan
button.button-primary
background: teal
transition: background 180ms ease-in-out
&:hover
background: darkcyan
textarea
max-width: 100%
min-width: 100%
height: 100px
form select[multiple]
min-height: 100px
table
border: 1px solid #ddd
border-radius: 8px
border-spacing: 0
overflow: hidden
table th,
table td,
table th:first-child,
table td:first-child
border: none
padding: 7px 12px
table thead tr
border-radius: 8px 8px 0 0
&:last-child
border-radius: 0 0 8px 8px
table thead tr,
table tr:nth-child(even)
background: #eee
table tbody tr
transition: background 180ms ease-in-out
&:hover
background: lightgrey
/* Material card styles */
.card-1
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24)
transition: all 0.3s cubic-bezier(.25,.8,.25,1)
&:hover
box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22)
.card-2
box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23)
.card-3
box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23)
.card-4
box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22)
.card-5
box-shadow: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22)
.container
max-width: 1200px
#main-nav
position: fixed
top: 0
left: 0
width: 100%
height: 64px
background: teal
color: white
z-index: 20
ul
list-style: none
display: inline-block
li
display: inline-block
margin-left: 15px
h4
display: inline-block
margin-left: 25px
line-height: 64px
a
color: white
font-size: 2.25rem
line-height: 64px
transition: all 200ms ease-in-out
&:hover
color: #eee
font-size: 2.5rem
#main-content
padding: 15px 25px
background: white
border-radius: 8px
z-index: 10
#main-footer
position: fixed
bottom: 0
left: 0
width: 100%
height: 64px
p
margin-bottom: 5px
text-align: center

View File

@ -11,5 +11,8 @@ type Benchmark struct {
Description string
// many-to-many test
Tests[] Test `gorm:"many2many:tests_benchmarks;"`
Tests []Test `gorm:"many2many:tests_benchmarks;"`
// has many results
Results []Result
}

View File

@ -10,5 +10,8 @@ type Hardware struct {
Type string
// has many tests
Tests[] Test
Tests []Test
// has many results
Results []Result
}

View File

@ -21,6 +21,6 @@ func Open() {
}
// Migrate the schema
DB.AutoMigrate(&Test{}, &Hardware{}, &Benchmark{})
DB.AutoMigrate(&Test{}, &Hardware{}, &Benchmark{}, &Result{})
log.Println("Database migrations complete.")
}

24
models/result.go Normal file
View File

@ -0,0 +1,24 @@
package models
import (
"gorm.io/gorm"
)
type Result struct {
gorm.Model
AverageScore float32
MinimumScore float32
MaximumScore float32
// belongs to Hardware
HardwareID int
Hardware Hardware
// belongs to Benchmark
BenchmarkID int
Benchmark Benchmark
// belongs to Test
TestID int
Test Test
}

View File

@ -14,5 +14,8 @@ type Test struct {
Hardware Hardware
// many-to-many benchmarks
Benchmarks[] Benchmark `gorm:"many2many:tests_benchmarks;"`
Benchmarks []Benchmark `gorm:"many2many:tests_benchmarks;"`
// has many results
Results []Result
}

1853
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

35
package.json Normal file
View File

@ -0,0 +1,35 @@
{
"name": "blt",
"version": "0.1.0",
"description": "Self-hosted PC hardware benchmark logging tool",
"main": "index.js",
"scripts": {
"grunt": "grunt"
},
"repository": {
"type": "git",
"url": "gitea@git.metaunix.net:BitGoblin/blt.git"
},
"keywords": [
"hardware",
"benchmark",
"testing",
"PC"
],
"author": "Gregory Ballanine <gballantine@bitgoblin.tech>",
"uploaders": [
{
"name": "Gregory Ballantine",
"email": "gballantine@bitgoblin.tech"
}
],
"license": "BSD-2-Clause",
"devDependencies": {
"grunt": "^1.5.3",
"grunt-cli": "^1.4.3",
"grunt-contrib-sass": "^2.0.0",
"grunt-contrib-coffee": "^2.1.0",
"grunt-contrib-watch": "^1.1.0",
"sass": "^1.55.0"
}
}

View File

@ -1,87 +0,0 @@
html,
body{
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
body{
height: auto;
min-height: 100%;
box-sizing: border-box;
padding-top: 80px;
padding-bottom: 80px;
background: #eee;
}
textarea{
max-width: 100%;
min-width: 100%;
height: 100px;
}
form select[multiple]{
min-height: 100px;
}
.container{
max-width: 1024px;
}
#main-nav{
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 64px;
background: teal;
color: white;
z-index: 20;
}
#main-nav ul{
list-style: none;
display: inline-block;
}
#main-nav h4{
display: inline-block;
margin-left: 25px;
line-height: 64px;
}
#main-nav ul li{
display: inline-block;
margin-left: 15px;
}
#main-nav a{
color: white;
font-size: 2.25rem;
line-height: 64px;
transition: all 200ms ease-in-out;
}
#main-nav a:hover{
color: #eee;
font-size: 2.5rem;
}
#main-content{
padding: 14px 20px;
background: white;
border-radius: 8px;
z-index: 10;
}
#main-footer{
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height: 64px;
}
#main-footer p{
margin-bottom: 5px;
text-align: center;
}

View File

@ -4,7 +4,7 @@
<h2>Benchmark</h2>
<a href="/benchmark/create">Add new benchmark</a>
<table class="twelve columns">
<table class="twelve columns card-2">
<thead>
<tr>
<td>Name</td>

View File

@ -4,7 +4,7 @@
<h2>Hardware</h2>
<a href="/hardware/create">Add new hardware</a>
<table class="twelve columns">
<table class="twelve columns card-2">
<thead>
<tr>
<td>Name</td>

View File

@ -7,9 +7,30 @@
<hr>
<h4>Latest Benchmark Results:</h4>
<h4>Tests Using This Component:</h4>
<p>There are currently no benchmarks recorded using this hardware component.</p>
{{ $length := len .hardware.Tests }} {{ if eq $length 0 }}
<p>There are currently no tests using this hardware component.</p>
{{ else }}
<table class="u-full-width card-2">
<thead>
<tr>
<th>Test</th>
<th># of Benchmarks</th>
<th>Last Updated</th>
</tr>
</thead>
<tbody>
{{ range $test := .hardware.Tests }}
<tr>
<td><a href="/test/{{ $test.ID }}">{{ $test.Name }}</a></td>
<td>{{ len $test.Benchmarks }}</td>
<td>{{ $test.CreatedAt.Format "01/02/2006 15:04am" }}</td>
</tr>
{{ end }}
</tbody>
</table>
{{ end }}
<hr>

View File

@ -3,7 +3,7 @@
<!-- footer -->
<nav id="main-footer">
<p>BLT version {{ .app_version }}</p>
<p>BLT version {{ .app_version }} | Built with Go {{ .runtime_version }}</p>
</nav>
</body>

View File

@ -9,6 +9,7 @@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css">
<link rel="stylesheet" href="/css/kourend.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js" charset="utf-8"></script>
<script src="/js/kebos.js" charset="utf-8"></script>
</head>
<body>
@ -16,5 +17,5 @@
{{ template "navbar" . }}
<!-- main content -->
<div id="main-content" class="container">
<div id="main-content" class="container card-5">
{{ end }}

View File

@ -1,5 +1,5 @@
{{ define "navbar" }}
<nav id="main-nav">
<nav id="main-nav" class="card-2">
<div class="nav-left">
<h4>BLT</h4>
<ul>

View File

@ -4,7 +4,7 @@
<h2>Tests</h2>
<a href="/test/create">Create a new test</a>
<table class="twelve columns">
<table class="twelve columns card-2">
<thead>
<tr>
<td>Title</td>

View File

@ -17,9 +17,79 @@
<hr>
<h4>Add new result:</h4>
<form class="u-full-width" action="/result/add" method="POST">
<div class="row">
<div class="columns four">
<label for="result_benchmark">
Benchmark:
<select id="result_benchmark" class="u-full-width" name="result_benchmark">
{{ range $bm := .test.Benchmarks }}
<option value="{{ $bm.ID }}">{{ $bm.Name }}</option>
{{ end }}
</select>
</label>
</div>
<div class="columns two">
<label for="result_avg">
Average score:
<input id="result_avg" class="u-full-width" type="number" name="result_avg" value="0">
</label>
</div>
<div class="columns two">
<label for="result_min">
Minimum score:
<input id="result_min" class="u-full-width" type="number" name="result_min" value="0">
</label>
</div>
<div class="columns two">
<label for="result_max">
Maximum score:
<input id="result_max" class="u-full-width" type="number" name="result_max" value="0">
</label>
</div>
<div class="columns two">
<button class="button-primary u-full-width" type="submit" name="button">Submit</button>
</div>
<input type="hidden" name="result_test" value="{{ .test.ID }}">
<input type="hidden" name="result_hardware" value="{{ .test.Hardware.ID }}">
</div>
</form>
<hr>
<h4>Latest Benchmark Results:</h4>
{{ $length := len .test.Results }} {{ if eq $length 0 }}
<p>There are currently no benchmarks recorded in this test.</p>
{{ else }}
<table class="u-full-width card-2">
<thead>
<tr>
<th>Benchmark</th>
<th>Average</th>
<th>Minimum</th>
<th>Maximum</th>
</tr>
</thead>
<tbody>
{{ range $res := .test.Results }}
<tr>
<td>{{ $res.Benchmark.Name }}</td>
<td>{{ $res.AverageScore }}</td>
<td>{{ if eq $res.MinimumScore 0.0 }}N/a{{ else }}{{ $res.MinimumScore }}{{ end }}</td>
<td>{{ if eq $res.MaximumScore 0.0 }}N/a{{ else }}{{ $res.MaximumScore }}{{ end }}</td>
</tr>
{{ end }}
</tbody>
</table>
{{ end }}
<hr>

10
web/forms/result.go Normal file
View File

@ -0,0 +1,10 @@
package forms
type ResultForm struct {
Test int `form:"result_test" validate:"required"`
Hardware int `form:"result_hardware" validate:"required"`
Benchmark int `form:"result_benchmark" validate:"required"`
AverageScore float32 `form:"result_avg" validate:"required"`
MinimumScore float32 `form:"result_min"`
MaximumScore float32 `form:"result_max"`
}

View File

@ -7,5 +7,6 @@ import (
)
func CustomVars(data template.Data) {
data["app_version"] = app.Version
data["app_version"] = app.AppVersion
data["runtime_version"] = app.RuntimeVersion
}

View File

@ -53,4 +53,9 @@ func RegisterRoutes(f *flamego.Flame) {
f.Get("/{test_id}", routes.TestGetView)
})
// result routes
f.Group("/result", func() {
f.Post("/add", binding.Form(forms.ResultForm{}), routes.ResultPostCreate)
})
}

View File

@ -30,7 +30,7 @@ func HardwareGetView(c flamego.Context, t template.Template, data template.Data)
// find hardware from DB
var hardware models.Hardware
models.DB.First(&hardware, hardwareID)
models.DB.Preload("Tests.Benchmarks").First(&hardware, hardwareID)
data["hardware"] = hardware
data["title"] = hardware.Name

39
web/routes/result.go Normal file
View File

@ -0,0 +1,39 @@
package routes
import (
"fmt"
"log"
"github.com/flamego/binding"
"github.com/flamego/flamego"
"github.com/flamego/validator"
"git.metaunix.net/bitgoblin/blt/models"
"git.metaunix.net/bitgoblin/blt/web/forms"
)
func ResultPostCreate(c flamego.Context, form forms.ResultForm, errs binding.Errors) {
if len(errs) > 0 {
var err error
switch errs[0].Category {
case binding.ErrorCategoryValidation:
err = errs[0].Err.(validator.ValidationErrors)[0]
default:
err = errs[0].Err
}
log.Fatal(err)
}
result := models.Result{
TestID: form.Test,
HardwareID: form.Hardware,
BenchmarkID: form.Benchmark,
AverageScore: form.AverageScore,
MinimumScore: form.MinimumScore,
MaximumScore: form.MaximumScore,
}
_ = models.DB.Create(&result)
c.Redirect(fmt.Sprintf("/test/%d", result.TestID))
}

View File

@ -30,7 +30,7 @@ func TestGetView(c flamego.Context, t template.Template, data template.Data) {
// find hardware from DB
var test models.Test
models.DB.Preload("Hardware").Preload("Benchmarks").First(&test, testID)
models.DB.Preload("Hardware").Preload("Benchmarks").Preload("Results.Benchmark").First(&test, testID)
data["test"] = test
data["title"] = test.Name