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 82 deletions

1
.gitignore vendored
View File

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

View File

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

View File

@ -1,9 +1,6 @@
package models package models
import ( import (
"fmt"
"strconv"
"gorm.io/gorm" "gorm.io/gorm"
) )
@ -22,29 +19,3 @@ type Test struct {
// has many results // has many results
Results []Result 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
}
func (t *Test) IsBenchmarkSelected(benchmarkID string) bool {
benchmarkConv, err := strconv.ParseUint(benchmarkID, 10, 0)
if err != nil {
fmt.Println("Error parsing Uint: ", err)
}
benchmarkUint := uint(benchmarkConv)
for _, b := range t.Benchmarks {
if b.ID == benchmarkUint {
return true
}
}
return false
}

View File

@ -30,9 +30,9 @@
<label for="test_benchmarks"> <label for="test_benchmarks">
Benchmarks to Test: Benchmarks to Test:
<select id="test_benchmarks" class="u-full-width" name="test_benchmarks" multiple> <select id="test_benchmarks" class="u-full-width" name="test_benchmarks" multiple>
{{ $selectedBenchmarks := .selectedBenchmarks }} {{ $testBenchmarks := .test.Benchmarks }}
{{ range $bm := .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 }} {{ end }}
</select> </select>
</label> </label>

View File

@ -99,50 +99,6 @@ func TestGetEdit(c flamego.Context, t template.Template, data template.Data) {
models.DB.Find(&benchmarks) models.DB.Find(&benchmarks)
data["benchmarks"] = 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) data["title"] = fmt.Sprintf("Editing Test: %s", test.Name)
t.HTML(http.StatusOK, "test/edit") 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.Name = form.Name
test.Description = form.Description
test.HardwareID = form.Hardware
// bind benchmarks to test that aren't already associated
for _, b := range form.Benchmarks {
if ! test.IsBenchmarkSelected(b) {
var benchmark models.Benchmark
models.DB.First(&benchmark, b) // find benchmark
models.DB.Model(&test).Association("Benchmarks").Append(&benchmark)
}
}
// removed associated benchmarks that weren't in the form
for _, b := range test.Benchmarks {
}
c.Redirect(fmt.Sprintf("/test/%d", test.ID))
}