37 lines
948 B
CoffeeScript
37 lines
948 B
CoffeeScript
$ ->
|
|
console.log('ready.')
|
|
|
|
$('#result-form').on('submit', addResult)
|
|
|
|
$('#report-benchmarks').on('change', ->
|
|
url = '/api/benchmark/' + $('#report-benchmarks').val() + '/tests'
|
|
$.get(url, (data) ->
|
|
# clear old contents from the selector
|
|
$('#report-tests').empty()
|
|
# add new elements to the selector
|
|
addOption(test) for test in data
|
|
)
|
|
)
|
|
|
|
addOption = (test) ->
|
|
$('#report-tests').append(
|
|
$('<option/>')
|
|
.attr('value', test.id)
|
|
.text(test.title)
|
|
)
|
|
|
|
addResult = (e) ->
|
|
e.preventDefault() # prevent browser from traveling to another page
|
|
|
|
$.post('/result/add', {
|
|
redirect: false
|
|
result_test: $('#result_test').val()
|
|
result_component: $('#result_component').val()
|
|
result_benchmark: $('#result_benchmark').val()
|
|
result_avg: $('#result_avg').val()
|
|
result_min: $('#result_min').val()
|
|
result_max: $('#result_max').val()
|
|
}, (data) ->
|
|
console.log(data)
|
|
)
|