Added functionality to add a benchmark result

This commit is contained in:
2023-07-05 23:39:08 -04:00
parent 691e2e9b1e
commit 7655b75410
6 changed files with 142 additions and 2 deletions

60
views/result/add.erb Normal file
View File

@ -0,0 +1,60 @@
<div class="grid-x grid-margin-x">
<div class="cell small-12">
<h1>Add new result</h1>
</div>
</div>
<div class="grid-x grid-margin-x">
<form class="cell small-12" action="/result/add" method="post">
<div class="grid-x grid-padding-x">
<div class="cell medium-6">
<label>
Hardware:
<select name="result_hardware">
<% hardware.each do |h| %>
<option value="<%= h.id %>"><%= h.name %></option>
<% end %>
</select>
</label>
</div>
<div class="cell medium-6">
<label>
Benchmark:
<select name="result_benchmark">
<% benchmarks.each do |b| %>
<option value="<%= b.id %>"><%= b.name %></option>
<% end %>
</select>
</label>
</div>
</div>
<div class="grid-x grid-padding-x">
<div class="cell medium-4">
<label>
Average score:
<input type="number" name="result_average" value="0.0" step="0.01">
</label>
</div>
<div class="cell medium-4">
<label>
Minimum score:
<input type="number" name="result_minimum" value="0.0" step="0.01">
</label>
</div>
<div class="cell medium-4">
<label>
Maximum score:
<input type="number" name="result_maximum" value="0.0" step="0.01">
</label>
</div>
</div>
<input type="submit" class="button" value="Submit">
</form>
</div>

44
views/result/index.erb Normal file
View File

@ -0,0 +1,44 @@
<div class="grid-x grid-margin-x">
<div class="cell small-12">
<h1>List of results</h1>
</div>
<div class="cell small-12">
<p>
<a href="/result/add">Add new result</a>
</p>
</div>
</div>
<div class="grid-x grid-margin-x">
<% if results.length > 0 %>
<div class="cell small-12">
<table>
<thead>
<tr>
<th>Hardware</th>
<th>Benchmark</th>
<th>Score (type)</th>
<th>Date added</th>
<th>Date modified</th>
</tr>
</thead>
<tbody>
<% results.each do |r| %>
<tr>
<td><%= r.hardware.name %></td>
<td><%= r.benchmark.name %></td>
<td><%= r.score %> (<%= r.benchmark.scoring %>)</td>
<td><%= date_format(r.created_at) %></td>
<td><%= date_format(r.updated_at) %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% else %>
<div class="cell small-12">
<p>I'm sorry, there don't appear to be any results added yet. Check again later!</p>
</div>
<% end %>
</div>