8 Commits

Author SHA1 Message Date
7c6977f4a6 Adding event: tag to the asset packaging step
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2025-07-14 13:53:50 -04:00
fcee38d33b Updating Grunt commands 2025-07-14 13:53:50 -04:00
0cc7113a8b Started working on test edit page; removed nodemon because it wasn't working 2025-07-14 13:53:50 -04:00
107a77d6f8 Added nodemon to dev dependencies to automatially reload the app on changes 2025-07-14 13:53:50 -04:00
1a3048b5f2 Fixed typo in Gruntfile; added Make tasks to compile frontend assets; Modernized the gathering of benchmark result data for the test view 2025-07-14 13:53:50 -04:00
4b9065ca4b Improved some styles 2025-07-14 13:53:50 -04:00
acdac071ed [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
2025-07-14 13:53:50 -04:00
90472e443c 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
2025-07-14 13:53:50 -04:00
5 changed files with 2 additions and 61 deletions

1
.gitignore vendored
View File

@ -3,7 +3,6 @@ blt
# Local data files
data/
tmp/
# Compiled assets
public/css/

View File

@ -1,8 +1,6 @@
package models
import (
"strconv"
"gorm.io/gorm"
)
@ -18,7 +16,3 @@ type Benchmark struct {
// has many results
Results []Result
}
func (b *Benchmark) StringID() string {
return strconv.Itoa(int(b.ID))
}

View File

@ -1,8 +1,6 @@
package models
import (
"strconv"
"gorm.io/gorm"
)
@ -21,12 +19,3 @@ type Test struct {
// has many results
Results []Result
}
func (t *Test) SelectedBenchmarks() []string {
benchmarks := t.Benchmarks
ids := make([]string, len(benchmarks))
for i, b := range benchmarks {
ids[i] = strconv.Itoa(int(b.ID))
}
return ids
}

View File

@ -30,9 +30,9 @@
<label for="test_benchmarks">
Benchmarks to Test:
<select id="test_benchmarks" class="u-full-width" name="test_benchmarks" multiple>
{{ $selectedBenchmarks := .selectedBenchmarks }}
{{ $testBenchmarks := .test.Benchmarks }}
{{ range $bm := .benchmarks }}
<option value="{{ $bm.ID }}" {{ if contains $selectedBenchmarks $bm.StringID }}selected{{ end }}>{{ $bm.Name }}</option>
<option value="{{ $bm.ID }}" {{ if contains $testBenchmarks $bm.ID }}selected{{ end }}>{{ $bm.Name }}</option>
{{ end }}
</select>
</label>

View File

@ -99,47 +99,6 @@ func TestGetEdit(c flamego.Context, t template.Template, data template.Data) {
models.DB.Find(&benchmarks)
data["benchmarks"] = benchmarks
// determine which benchmarks are selected in a test
selectedBenchmarks := test.SelectedBenchmarks()
data["selectedBenchmarks"] = selectedBenchmarks
data["title"] = fmt.Sprintf("Editing Test: %s", test.Name)
t.HTML(http.StatusOK, "test/edit")
}
func TestPostEdit(c flamego.Context, form forms.TestForm, errs binding.Errors) {
if len(errs) > 0 {
var err error
switch errs[0].Category {
case binding.ErrorCategoryValidation:
err = errs[0].Err.(validator.ValidationErrors)[0]
default:
err = errs[0].Err
}
log.Fatal(err)
}
// find test ID from request
testID := c.Param("test_id")
// find hardware from DB
var test models.Test
models.DB.Preload("Hardware").Preload("Benchmarks").First(&test, testID)
test := 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))
}