Added form to hardware view page for adding test results
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
f7979cd005
commit
e6333b855f
@ -14,7 +14,7 @@ class GameData < Sinatra::Base
|
||||
|
||||
get '/hardware/add' do
|
||||
erb :'hardware/add', locals: {
|
||||
title: 'Add Hardware'
|
||||
title: 'Add Hardware',
|
||||
}
|
||||
end
|
||||
post '/hardware/add' do
|
||||
@ -27,10 +27,12 @@ class GameData < Sinatra::Base
|
||||
end
|
||||
|
||||
get '/hardware/:hardware_id' do
|
||||
benchmarks = Benchmark.order(:name).all()
|
||||
hardware = Hardware.where(id: params[:hardware_id]).first()
|
||||
erb :'hardware/view', locals: {
|
||||
title: hardware.name,
|
||||
hardware: hardware
|
||||
hardware: hardware,
|
||||
benchmarks: benchmarks
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -29,12 +29,20 @@ class GameData < Sinatra::Base
|
||||
Result.create(
|
||||
hardware_id: params[:result_hardware],
|
||||
benchmark_id: params[:result_benchmark],
|
||||
score: params[:result_average],
|
||||
minimum_score: result_minimum,
|
||||
maximum_score: result_maximum
|
||||
avg_score: params[:result_average],
|
||||
min_score: result_minimum,
|
||||
max_score: result_maximum
|
||||
)
|
||||
|
||||
if params.key?(:result_referrer)
|
||||
if params[:result_referrer] == 'hardware'
|
||||
redirect "/hardware/#{params[:result_hardware]}"
|
||||
elsif params[:result_referrer] == 'benchmark'
|
||||
redirect "/benchmark/#{params[:result_benchmark]}"
|
||||
end
|
||||
else
|
||||
redirect '/result'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -2,18 +2,66 @@
|
||||
<div class="cell small-12">
|
||||
<h1><%= hardware.name %></h1>
|
||||
</div>
|
||||
|
||||
<div class="cell small-12">
|
||||
Hardware type: <%= hardware.type %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="grix-x grix-margin-x">
|
||||
<div class="cell small-12">
|
||||
<%= hardware.type %>
|
||||
<form class="u-full-width" action="/result/add" method="post">
|
||||
<input type="hidden" name="result_hardware" value="<%= hardware.id %>">
|
||||
<input type="hidden" name="result_referrer" value="hardware">
|
||||
|
||||
<div class="grid-x grid-margin-x">
|
||||
<div class="cell medium-5">
|
||||
<label for="result_benchmark">
|
||||
Add benchmark result:
|
||||
<select class="u-full-width" id="result_benchmark" name="result_benchmark">
|
||||
<% benchmarks.each do |b| %>
|
||||
<option value="<%= b.id %>"><%= b.name %></option>
|
||||
<% end %>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="cell small-12">
|
||||
<div class="cell medium-2">
|
||||
<label for="result_average">
|
||||
Average score:
|
||||
<input type="text" id="result_average" name="result_average" value="">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="cell medium-2">
|
||||
<label for="result_minimum">
|
||||
Minimum score:
|
||||
<input type="text" id="result_minimum" name="result_minimum" value="">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="cell medium-2">
|
||||
<label for="result_maximum">
|
||||
Maximum score:
|
||||
<input type="text" id="result_maximum" name="result_maximum" value="">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="cell medium-1">
|
||||
<input type="submit" class="u-full-width button" value="Submit">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<hr>
|
||||
|
||||
<h4>Benchmark results involving this hardware:</h4>
|
||||
|
||||
<ul>
|
||||
<% hardware.results().each do |r| %>
|
||||
<li><% r.score %></li>
|
||||
<li><%= r.avg_score %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user