31 Commits

Author SHA1 Message Date
e3e4e24e56 Fixed associating benchmarks to test 2024-05-29 10:07:15 -04:00
2be6d216d1 Fixed creating new test 2024-05-29 09:52:41 -04:00
93170d0935 Fixed creating new test 2024-05-29 09:47:49 -04:00
2299ac0a93 Added more information to the test view page 2024-05-29 09:23:41 -04:00
3ec465872e Fixed typo in test view route 2024-05-29 09:19:53 -04:00
52e4d9c420 Fixed typos in benchmark list view 2024-05-29 09:17:07 -04:00
9ddf7fa928 Fixed typos in model searches 2024-05-29 09:16:32 -04:00
ab6b94cb5f Fixed typo in benchmark list view 2024-05-29 09:14:09 -04:00
39185f1144 Fixed benchmark form submission error 2024-05-29 09:13:10 -04:00
403ab7f166 Fixed mix up between benchmark and hardware routes files 2024-05-29 09:12:19 -04:00
ba06a2ea4c Added benchmarks routes and views 2024-05-29 09:11:13 -04:00
95fe5ab400 Slight tweak to create test view 2024-05-29 09:03:14 -04:00
9ddc3db48d Fixed form select field styling 2024-05-29 09:02:00 -04:00
8412163370 Fixed variable capitalization in create test view 2024-05-29 09:00:14 -04:00
86bf4d37f0 Added description field to Test model 2024-05-29 08:58:30 -04:00
6cb2ac0263 Passed hardware components and benchmarks to create test view 2024-05-29 08:57:52 -04:00
dea08d15dd Added route to view test 2024-05-29 08:45:53 -04:00
cf7623fbb9 Added route to view test 2024-05-29 08:43:57 -04:00
a51c8aa8a4 Added route to view test 2024-05-29 08:42:53 -04:00
9fd6ec6b0b Added route to view hardware component 2024-05-29 08:40:02 -04:00
5b14721b14 Added route to view hardware component 2024-05-29 08:39:27 -04:00
dcfc6e0115 Added route to view hardware component 2024-05-29 08:37:51 -04:00
4ad9a92306 Added hardware routes and views 2023-12-02 22:37:46 -05:00
c5df026d04 Lots of changes 2023-12-02 22:16:16 -05:00
16704aeeb1 Added ability to create projects 2023-11-28 16:36:11 -05:00
bae65994f8 Refactored models code to follow a better approach for opening and closing the database connection 2023-11-28 14:40:12 -05:00
19670e9abd Added models; started working on project routes 2023-11-27 23:41:48 -05:00
49925c6d8f Added Gorm to project 2023-11-27 22:36:58 -05:00
0ee3d06f89 Copied some styles from Leviathan 2023-11-27 22:26:36 -05:00
9dceaa8119 Started working on the layout of the app 2023-11-24 23:34:50 -05:00
cbc816ad70 Updated Makefile to auto-define version 2023-11-24 14:28:53 -05:00
31 changed files with 822 additions and 5 deletions

3
.gitignore vendored
View File

@ -1,3 +1,6 @@
# Compiled binary
blt
# Local data files
data/

View File

@ -1,5 +1,5 @@
NAME=blt
VERSION=0.0.1
VERSION=`git describe --tags`
.PHONY: build
## build: Compile the packages.

0
data/.gitkeep Normal file
View File

18
go.mod
View File

@ -2,20 +2,34 @@ module git.metaunix.net/bitgoblin/blt
go 1.18
require (
github.com/flamego/flamego v1.9.4
github.com/flamego/template v1.2.2
gorm.io/driver/sqlite v1.5.4
gorm.io/gorm v1.25.5
)
require (
github.com/alecthomas/participle/v2 v2.0.0 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/lipgloss v0.7.1 // indirect
github.com/charmbracelet/log v0.2.3 // indirect
github.com/flamego/flamego v1.9.4 // indirect
github.com/flamego/template v1.2.2 // indirect
github.com/flamego/binding v1.3.0 // indirect
github.com/flamego/validator v1.0.0 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/mattn/go-sqlite3 v1.14.18 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/termenv v0.15.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
golang.org/x/crypto v0.0.0-20210920023735-84f357641f63 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

59
go.sum
View File

@ -1,33 +1,92 @@
github.com/alecthomas/assert/v2 v2.2.2/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ=
github.com/alecthomas/participle/v2 v2.0.0 h1:Fgrq+MbuSsJwIkw3fEj9h75vDP0Er5JzepJ0/HNHv0g=
github.com/alecthomas/participle/v2 v2.0.0/go.mod h1:rAKZdJldHu8084ojcWevWAL8KmEU+AT+Olodb+WoN2Y=
github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
github.com/charmbracelet/lipgloss v0.7.1 h1:17WMwi7N1b1rVWOjMT+rCh7sQkvDU75B2hbZpc5Kc1E=
github.com/charmbracelet/lipgloss v0.7.1/go.mod h1:yG0k3giv8Qj8edTCbbg6AlQ5e8KNWpFujkNawKNhE2c=
github.com/charmbracelet/log v0.2.1/go.mod h1:GwFfjewhcVDWLrpAbY5A0Hin9YOlEn40eWT4PNaxFT4=
github.com/charmbracelet/log v0.2.2/go.mod h1:Zs11hKpb8l+UyX4y1srwZIGW+MPCXJHIty3MB9l/sno=
github.com/charmbracelet/log v0.2.3 h1:YVmBhJtpGL7nW/nlf5u+SEloU8XYljxozGzZpgwIvhs=
github.com/charmbracelet/log v0.2.3/go.mod h1:ZApwwzDbbETVTIRTk7724yQRJAXIktt98yGVMMaa3y8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/flamego/binding v1.3.0 h1:CPbnSuP0SxT50JR7lK2khTjcQi1oOECqRK7kbOYw91U=
github.com/flamego/binding v1.3.0/go.mod h1:xgm6FEpEKKkF8CQilK2X3MJ5kTjOTnYdz/ooFctDTdc=
github.com/flamego/flamego v1.9.1/go.mod h1:WjaZO8GM/EGvIIGXlOiwp3oPuyy1fAdjWqEgEJWovJo=
github.com/flamego/flamego v1.9.4 h1:SNsooIfNa6ljQM1rBmfg4cFcXPIhQdG/uvNHqXxPvD8=
github.com/flamego/flamego v1.9.4/go.mod h1:2tAVbugA3fgX8xOBoqR2jmJSSvZDLBFGXTFCR5h5eAU=
github.com/flamego/template v1.2.2 h1:aMpt8RzXBb2ZGuABf9p/q8oBBpXrurUV8rgBbz7mj2o=
github.com/flamego/template v1.2.2/go.mod h1:xTAmwCCPaOuxN5t4CpzOP7WZN5WkLRiJfJCpsiB0aUg=
github.com/flamego/validator v1.0.0 h1:ixuWHVgiVGp4pVGtUn/0d6HBjZJbbXfJHDNkxW+rZoY=
github.com/flamego/validator v1.0.0/go.mod h1:POYn0/5iW4sdamdPAYPrzqN6DFC4YaczY0gYY+Pyx5E=
github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4=
github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98=
github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU=
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-sqlite3 v1.14.17/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/mattn/go-sqlite3 v1.14.18 h1:JL0eqdCOq6DJVNPSvArO/bIV9/P7fbGrV00LZHc+5aI=
github.com/mattn/go-sqlite3 v1.14.18/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
github.com/muesli/termenv v0.15.1/go.mod h1:HeAQPTzpfs016yGtA4g00CsdYnVLJvxsS4ANqrZs2sQ=
github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo=
github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210920023735-84f357641f63 h1:kETrAMYZq6WVGPa8IIixL0CaEcIUNi+1WX7grUoi3y8=
golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/driver/sqlite v1.5.4 h1:IqXwXi8M/ZlPzH/947tn5uik3aYQslP9BVveoax0nV0=
gorm.io/driver/sqlite v1.5.4/go.mod h1:qxAuCol+2r6PannQDpOP1FP6ag3mKi4esLnB/jHed+4=
gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
gorm.io/gorm v1.25.5 h1:zR9lOiiYf09VNh5Q1gphfyia1JpiClIWG9hQaxB/mls=
gorm.io/gorm v1.25.5/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=

View File

@ -7,6 +7,7 @@ import (
"github.com/flamego/flamego"
"github.com/flamego/template"
"git.metaunix.net/bitgoblin/blt/models"
"git.metaunix.net/bitgoblin/blt/web"
"git.metaunix.net/bitgoblin/blt/web/middleware"
)
@ -17,6 +18,9 @@ func main() {
// initial Flamego server object
f := flamego.Classic()
// initialize database
models.Open()
// initialize templating engine
f.Use(template.Templater())

15
models/benchmark.go Normal file
View File

@ -0,0 +1,15 @@
package models
import (
"gorm.io/gorm"
)
type Benchmark struct {
gorm.Model
Name string
ScoringType string
Description string
// many-to-many test
Tests[] Test `gorm:"many2many:tests_benchmarks;"`
}

14
models/hardware.go Normal file
View File

@ -0,0 +1,14 @@
package models
import (
"gorm.io/gorm"
)
type Hardware struct {
gorm.Model
Name string
Type string
// has many tests
Tests[] Test
}

26
models/init.go Normal file
View File

@ -0,0 +1,26 @@
package models
import (
"log"
"gorm.io/gorm"
"gorm.io/driver/sqlite"
)
var (
DB *gorm.DB
)
// Initializes the Gorm database object
func Open() {
// Initialize database object
var err error
DB, err = gorm.Open(sqlite.Open("data/blt.db"), &gorm.Config{})
if err != nil {
panic("Failed to connect database")
}
// Migrate the schema
DB.AutoMigrate(&Test{}, &Hardware{}, &Benchmark{})
log.Println("Database migrations complete.")
}

18
models/test.go Normal file
View File

@ -0,0 +1,18 @@
package models
import (
"gorm.io/gorm"
)
type Test struct {
gorm.Model
Name string
Description string
// belongs to hardware
HardwareID int
Hardware Hardware
// many-to-many benchmarks
Benchmarks[] Benchmark `gorm:"many2many:tests_benchmarks;"`
}

87
public/css/kourend.css Normal file
View File

@ -0,0 +1,87 @@
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

@ -0,0 +1,38 @@
{{ template "header" . }}
<div class="row">
<h2>Add new benchmark</h2>
<form class="twelve columns" action="/benchmark/create" method="POST">
<div class="row">
<div class="nine columns">
<label for="benchmark_name">
Benchmark name:
<input id="benchmark_name" class="u-full-width" type="text" name="benchmark_name" placeholder="Unigine Heaven">
</label>
</div>
<div class="three columns">
<label for="benchmark_scoring">
Benchmark type:
<select id="benchmark_scoring" class="u-full-width" name="benchmark_scoring">
<option value="fps">Frames per second</option>
<option value="ms">Frame time</option>
<option value="pts">Total points</option>
</select>
</label>
</div>
</div>
<div class="row">
<label for="benchmark_description">
Benchmark description:
<textarea id="benchmark_description" class="twelve columns" cols="30" rows="10" name="benchmark_description"></textarea>
</label>
</div>
<input class="button-primary u-full-width" type="submit" value="Submit">
</form>
</div>
{{ template "footer" . }}

View File

@ -0,0 +1,27 @@
{{ template "header" . }}
<div class="row">
<h2>Benchmark</h2>
<a href="/benchmark/create">Add new benchmark</a>
<table class="twelve columns">
<thead>
<tr>
<td>Name</td>
<td>Created at</td>
<td>Last updated</td>
</tr>
</thead>
<tbody>
{{ range $b := .benchmarks }}
<tr>
<td><a href="/benchmark/{{ $b.ID }}">{{ $b.Name }}</a></td>
<td>{{ $b.CreatedAt.Format "01/02/2006 15:04am" }}</td>
<td>{{ $b.UpdatedAt.Format "01/02/2006 15:04am" }}</td>
</tr>
{{ end }}
</tbody>
</table>
</div>
{{ template "footer" . }}

View File

@ -0,0 +1,19 @@
{{ template "header" . }}
<div class="row">
<h2>{{ .benchmark.Name }}</h2>
<p>{{ .benchmark.ScoringType }}</p>
<hr>
<h4>Latest Benchmark Results:</h4>
<p>There are currently no results recorded using this benchmark.</p>
<hr>
<p><a href="/benchmark">Back</a></p>
</div>
{{ template "footer" . }}

View File

@ -0,0 +1,34 @@
{{ template "header" . }}
<div class="row">
<h2>Add new hardware</h2>
<form class="twelve columns" action="/hardware/create" method="POST">
<div class="row">
<div class="nine columns">
<label for="hardware_name">
Hardware name:
<input id="hardware_name" class="u-full-width" type="text" name="hardware_name" placeholder="EVGA RTX 3080 Ti">
</label>
</div>
<div class="three columns">
<label for="hardware_type">
Hardware type:
<select id="hardware_type" class="u-full-width" name="hardware_type">
<option value="cpu">Processor</option>
<option value="mem">Memory</option>
<option value="gpu">Graphics Card</option>
<option value="ssd">Solid State Drive</option>
<option value="hdd">Hard Drive</option>
<option value="nic">Network Card</option>
</select>
</label>
</div>
</div>
<input class="button-primary u-full-width" type="submit" value="Submit">
</form>
</div>
{{ template "footer" . }}

View File

@ -0,0 +1,27 @@
{{ template "header" . }}
<div class="row">
<h2>Hardware</h2>
<a href="/hardware/create">Add new hardware</a>
<table class="twelve columns">
<thead>
<tr>
<td>Name</td>
<td>Created at</td>
<td>Last updated</td>
</tr>
</thead>
<tbody>
{{ range $h := .hardware }}
<tr>
<td><a href="/hardware/{{ $h.ID }}">{{ $h.Name }}</a></td>
<td>{{ $h.CreatedAt.Format "01/02/2006 15:04am" }}</td>
<td>{{ $h.UpdatedAt.Format "01/02/2006 15:04am" }}</td>
</tr>
{{ end }}
</tbody>
</table>
</div>
{{ template "footer" . }}

View File

@ -0,0 +1,19 @@
{{ template "header" . }}
<div class="row">
<h2>{{ .hardware.Name }}</h2>
<p>{{ .hardware.Type }}</p>
<hr>
<h4>Latest Benchmark Results:</h4>
<p>There are currently no benchmarks recorded using this hardware component.</p>
<hr>
<p><a href="/hardware">Back</a></p>
</div>
{{ template "footer" . }}

View File

@ -2,6 +2,4 @@
<p>This is the BLT dashboard.</p>
<p>BLT version {{ .app_version }}</p>
{{ template "footer" . }}

View File

@ -1,4 +1,11 @@
{{ define "footer" }}
</div>
<!-- footer -->
<nav id="main-footer">
<p>BLT version {{ .app_version }}</p>
</nav>
</body>
</html>
{{ end }}

View File

@ -6,6 +6,15 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>{{ .title }} | BLT</title>
<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>
</head>
<body>
<!-- navbar -->
{{ template "navbar" . }}
<!-- main content -->
<div id="main-content" class="container">
{{ end }}

View File

@ -0,0 +1,13 @@
{{ define "navbar" }}
<nav id="main-nav">
<div class="nav-left">
<h4>BLT</h4>
<ul>
<li><a href="/">Dashboard</a></li>
<li><a href="/test">Tests</a></li>
<li><a href="/hardware">Hardware</a></li>
<li><a href="/benchmark">Benchmarks</a></li>
</ul>
</div>
</nav>
{{ end }}

View File

@ -0,0 +1,51 @@
{{ template "header" . }}
<div class="row">
<h2>Create a test</h2>
<form class="twelve columns" action="/test/create" method="POST">
<div class="row">
<div class="columns four">
<label for="test_hardware">
Hardware Component:
<select id="test_hardware" class="u-full-width" name="test_hardware">
{{ range $hw := .hardware }}
<option value="{{ $hw.ID }}">{{ $hw.Name }}</option>
{{ end }}
</select>
</label>
</div>
<div class="columns eight">
<label for="test_name">
Test name:
<input id="test_name" class="u-full-width" type="text" name="test_name" placeholder="My hardware benchmarking test">
</label>
</div>
</div>
<div class="row">
<div class="columns twelve">
<label for="test_benchmarks">
Benchmarks to Test:
<select id="test_benchmarks" class="u-full-width" name="test_benchmarks" multiple>
{{ range $bm := .benchmarks }}
<option value="{{ $bm.ID }}">{{ $bm.Name }}</option>
{{ end }}
</select>
</label>
</div>
</div>
<div class="row">
<label for="test_description">
Test description:
<textarea id="test_description" class="twelve columns" cols="30" rows="10" name="test_description"></textarea>
</label>
</div>
<input class="button-primary u-full-width" type="submit" value="Submit">
</form>
</div>
{{ template "footer" . }}

27
templates/test/list.tmpl Normal file
View File

@ -0,0 +1,27 @@
{{ template "header" . }}
<div class="row">
<h2>Tests</h2>
<a href="/test/create">Create a new test</a>
<table class="twelve columns">
<thead>
<tr>
<td>Title</td>
<td>Created at</td>
<td>Last updated</td>
</tr>
</thead>
<tbody>
{{ range $p := .tests }}
<tr>
<td><a href="/test/{{ $p.ID }}">{{ $p.Name }}</a></td>
<td>{{ $p.CreatedAt.Format "01/02/2006 15:04am" }}</td>
<td>{{ $p.UpdatedAt.Format "01/02/2006 15:04am" }}</td>
</tr>
{{ end }}
</tbody>
</table>
</div>
{{ template "footer" . }}

29
templates/test/view.tmpl Normal file
View File

@ -0,0 +1,29 @@
{{ template "header" . }}
<div class="row">
<h2>{{ .test.Name }}</h2>
<p><a href="/hardware/{{ .test.Hardware.ID }}">link to hardware tested.</a></p>
<p>{{ .test.Description }}</p>
<h4>Benchmarks used:</h4>
<ul>
{{ range $bm := .test.Benchmarks }}
<li><a href="/benchmark/{{ $bm.ID }}">{{ $bm.Name }}</a></li>
{{ end }}
</ul>
<hr>
<h4>Latest Benchmark Results:</h4>
<p>There are currently no benchmarks recorded in this test.</p>
<hr>
<p><a href="/test">Back</a></p>
</div>
{{ template "footer" . }}

7
web/forms/benchmark.go Normal file
View File

@ -0,0 +1,7 @@
package forms
type BenchmarkForm struct {
Name string `form:"benchmark_name" validate:"required"`
ScoringType string `form:"benchmark_scoring" validate:"required"`
Description string `form:"benchmark_description"`
}

6
web/forms/hardware.go Normal file
View File

@ -0,0 +1,6 @@
package forms
type HardwareForm struct {
Name string `form:"hardware_name" validate:"required"`
Type string `form:"hardware_type" validate:"required"`
}

8
web/forms/test.go Normal file
View File

@ -0,0 +1,8 @@
package forms
type TestForm struct {
Name string `form:"test_name" validate:"required"`
Description string `form:"test_description"`
Hardware int `form:"test_hardware" validate:"required"`
Benchmarks []string `form:"test_benchmarks" validate:"required"`
}

View File

@ -1,12 +1,56 @@
package web
import (
"github.com/flamego/binding"
"github.com/flamego/flamego"
"git.metaunix.net/bitgoblin/blt/web/forms"
"git.metaunix.net/bitgoblin/blt/web/routes"
)
func RegisterRoutes(f *flamego.Flame) {
// index routes
f.Get("/", routes.GetDashboard)
// hardware routes
f.Group("/hardware", func() {
f.Get("", func(c flamego.Context) {
c.Redirect("/hardware/list")
})
f.Get("/list", routes.HardwareGetList)
f.Get("/create", routes.HardwareGetCreate)
f.Post("/create", binding.Form(forms.HardwareForm{}), routes.HardwarePostCreate)
f.Get("/{hardware_id}", routes.HardwareGetView)
})
// benchmark routes
f.Group("/benchmark", func() {
f.Get("", func(c flamego.Context) {
c.Redirect("/benchmark/list")
})
f.Get("/list", routes.BenchmarkGetList)
f.Get("/create", routes.BenchmarkGetCreate)
f.Post("/create", binding.Form(forms.BenchmarkForm{}), routes.BenchmarkPostCreate)
f.Get("/{benchmark_id}", routes.BenchmarkGetView)
})
// test routes
f.Group("/test", func() {
f.Get("", func(c flamego.Context) {
c.Redirect("/test/list")
})
f.Get("/list", routes.TestGetList)
f.Get("/create", routes.TestGetCreate)
f.Post("/create", binding.Form(forms.TestForm{}), routes.TestPostCreate)
f.Get("/{test_id}", routes.TestGetView)
})
}

66
web/routes/benchmark.go Normal file
View File

@ -0,0 +1,66 @@
package routes
import (
"fmt"
"log"
"net/http"
"github.com/flamego/binding"
"github.com/flamego/flamego"
"github.com/flamego/template"
"github.com/flamego/validator"
"git.metaunix.net/bitgoblin/blt/models"
"git.metaunix.net/bitgoblin/blt/web/forms"
)
func BenchmarkGetList(t template.Template, data template.Data) {
// add benchmarks to template
var benchmarks []models.Benchmark
models.DB.Find(&benchmarks)
data["benchmarks"] = benchmarks
data["title"] = "List of Benchmarks"
t.HTML(http.StatusOK, "benchmark/list")
}
func BenchmarkGetView(c flamego.Context, t template.Template, data template.Data) {
// find benchmark ID from request
benchmarkID := c.Param("benchmark_id")
// find benchmark from DB
var benchmark models.Benchmark
models.DB.First(&benchmark, benchmarkID)
data["benchmark"] = benchmark
data["title"] = benchmark.Name
t.HTML(http.StatusOK, "benchmark/view")
}
func BenchmarkGetCreate(t template.Template, data template.Data) {
data["title"] = "Add New Benchmark"
t.HTML(http.StatusOK, "benchmark/create")
}
func BenchmarkPostCreate(c flamego.Context, form forms.BenchmarkForm, errs binding.Errors) {
if len(errs) > 0 {
var err error
switch errs[0].Category {
case binding.ErrorCategoryValidation:
err = errs[0].Err.(validator.ValidationErrors)[0]
default:
err = errs[0].Err
}
log.Fatal(err)
}
benchmark := models.Benchmark{
Name: form.Name,
ScoringType: form.ScoringType,
Description: form.Description,
}
_ = models.DB.Create(&benchmark)
c.Redirect(fmt.Sprintf("/benchmark/%d", benchmark.ID))
}

65
web/routes/hardware.go Normal file
View File

@ -0,0 +1,65 @@
package routes
import (
"fmt"
"log"
"net/http"
"github.com/flamego/binding"
"github.com/flamego/flamego"
"github.com/flamego/template"
"github.com/flamego/validator"
"git.metaunix.net/bitgoblin/blt/models"
"git.metaunix.net/bitgoblin/blt/web/forms"
)
func HardwareGetList(t template.Template, data template.Data) {
// add hardwares to template
var hardware []models.Hardware
models.DB.Find(&hardware)
data["hardware"] = hardware
data["title"] = "List of Hardware"
t.HTML(http.StatusOK, "hardware/list")
}
func HardwareGetView(c flamego.Context, t template.Template, data template.Data) {
// find hardware ID from request
hardwareID := c.Param("hardware_id")
// find hardware from DB
var hardware models.Hardware
models.DB.First(&hardware, hardwareID)
data["hardware"] = hardware
data["title"] = hardware.Name
t.HTML(http.StatusOK, "hardware/view")
}
func HardwareGetCreate(t template.Template, data template.Data) {
data["title"] = "Add New Hardware"
t.HTML(http.StatusOK, "hardware/create")
}
func HardwarePostCreate(c flamego.Context, form forms.HardwareForm, errs binding.Errors) {
if len(errs) > 0 {
var err error
switch errs[0].Category {
case binding.ErrorCategoryValidation:
err = errs[0].Err.(validator.ValidationErrors)[0]
default:
err = errs[0].Err
}
log.Fatal(err)
}
hardware := models.Hardware{
Name: form.Name,
Type: form.Type,
}
_ = models.DB.Create(&hardware)
c.Redirect(fmt.Sprintf("/hardware/%d", hardware.ID))
}

83
web/routes/test.go Normal file
View File

@ -0,0 +1,83 @@
package routes
import (
"fmt"
"log"
"net/http"
"github.com/flamego/binding"
"github.com/flamego/flamego"
"github.com/flamego/template"
"github.com/flamego/validator"
"git.metaunix.net/bitgoblin/blt/models"
"git.metaunix.net/bitgoblin/blt/web/forms"
)
func TestGetList(t template.Template, data template.Data) {
// add tests to template
var tests []models.Test
models.DB.Find(&tests)
data["tests"] = tests
data["title"] = "List of Tests"
t.HTML(http.StatusOK, "test/list")
}
func TestGetView(c flamego.Context, t template.Template, data template.Data) {
// find test ID from request
testID := c.Param("test_id")
// find hardware from DB
var test models.Test
models.DB.Preload("Hardware").Preload("Benchmarks").First(&test, testID)
data["test"] = test
data["title"] = test.Name
t.HTML(http.StatusOK, "test/view")
}
func TestGetCreate(t template.Template, data template.Data) {
// add hardware components to template
var hardware []models.Hardware
models.DB.Find(&hardware)
data["hardware"] = hardware
// add benchmarks to template
var benchmarks []models.Benchmark
models.DB.Find(&benchmarks)
data["benchmarks"] = benchmarks
data["title"] = "Create a Test"
t.HTML(http.StatusOK, "test/create")
}
func TestPostCreate(c flamego.Context, form forms.TestForm, errs binding.Errors) {
if len(errs) > 0 {
var err error
switch errs[0].Category {
case binding.ErrorCategoryValidation:
err = errs[0].Err.(validator.ValidationErrors)[0]
default:
err = errs[0].Err
}
log.Fatal(err)
}
test := models.Test{
Name: form.Name,
Description: form.Description,
HardwareID: form.Hardware,
}
_ = models.DB.Create(&test)
// bind benchmarks to test
for _, v := range form.Benchmarks {
var benchmark models.Benchmark
models.DB.First(&benchmark, v) // find benchmark
models.DB.Model(&test).Association("Benchmarks").Append(&benchmark)
}
c.Redirect(fmt.Sprintf("/test/%d", test.ID))
}