Added functionality to add new hardware and benchmarks to tie to results (this may be moved to an admin panel later)
This commit is contained in:
parent
6c1c8bca0a
commit
291db231d5
25
src/routes/benchmark.rb
Normal file
25
src/routes/benchmark.rb
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
class GameData < Sinatra::Base
|
||||||
|
get '/benchmark' do
|
||||||
|
benchmarks = Benchmark.reverse(:updated_at).limit(10).all()
|
||||||
|
|
||||||
|
erb :'benchmark/index', locals: {
|
||||||
|
title: 'List of Benchmarks',
|
||||||
|
benchmarks: benchmarks
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
get '/benchmark/add' do
|
||||||
|
erb :'benchmark/add', locals: {
|
||||||
|
title: 'Add Benchmark'
|
||||||
|
}
|
||||||
|
end
|
||||||
|
post '/benchmark/add' do
|
||||||
|
benchmark = Benchmark.create(
|
||||||
|
name: params[:benchmark_name],
|
||||||
|
scoring: params[:benchmark_scoring],
|
||||||
|
description: params[:benchmark_description]
|
||||||
|
)
|
||||||
|
|
||||||
|
redirect "/benchmark"
|
||||||
|
end
|
||||||
|
end
|
24
src/routes/hardware.rb
Normal file
24
src/routes/hardware.rb
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
class GameData < Sinatra::Base
|
||||||
|
get '/hardware' do
|
||||||
|
hardware = Hardware.reverse(:updated_at).limit(10).all()
|
||||||
|
|
||||||
|
erb :'hardware/index', locals: {
|
||||||
|
title: 'List of Hardware',
|
||||||
|
hardware: hardware
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
get '/hardware/add' do
|
||||||
|
erb :'hardware/add', locals: {
|
||||||
|
title: 'Add Hardware'
|
||||||
|
}
|
||||||
|
end
|
||||||
|
post '/hardware/add' do
|
||||||
|
hardware = Hardware.create(
|
||||||
|
name: params[:hardware_name],
|
||||||
|
type: params[:hardware_type]
|
||||||
|
)
|
||||||
|
|
||||||
|
redirect "/hardware"
|
||||||
|
end
|
||||||
|
end
|
@ -1 +1,3 @@
|
|||||||
require_relative 'index'
|
require_relative 'index'
|
||||||
|
require_relative 'hardware'
|
||||||
|
require_relative 'benchmark'
|
||||||
|
37
views/benchmark/add.erb
Normal file
37
views/benchmark/add.erb
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<div class="grid-x grid-margin-x">
|
||||||
|
<div class="cell small-12">
|
||||||
|
<h1>Add new benchmark</h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid-x grid-margin-x">
|
||||||
|
|
||||||
|
<form class="cell small-12" action="/benchmark/add" method="post">
|
||||||
|
<div class="grid-x grid-padding-x">
|
||||||
|
<div class="cell medium-9">
|
||||||
|
<label>
|
||||||
|
Benchmark name
|
||||||
|
<input type="text" name="benchmark_name" placeholder="Example benchmark">
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="cell medium-3">
|
||||||
|
<label>
|
||||||
|
Scoring type
|
||||||
|
<select name="benchmark_scoring">
|
||||||
|
<option value="fps">Frames per Second (fps)</option>
|
||||||
|
<option value="ms">Frame Time (ms)</option>
|
||||||
|
<option value="pts">Total Points</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid-x grid-padding-x">
|
||||||
|
<textarea name="benchmark_description" class="cell small-12">Enter a description/notes here.</textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<input type="submit" class="button" value="Submit">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
42
views/benchmark/index.erb
Normal file
42
views/benchmark/index.erb
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<div class="grid-x grid-margin-x">
|
||||||
|
<div class="cell small-12">
|
||||||
|
<h1>List of benchmarks</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="cell small-12">
|
||||||
|
<p>
|
||||||
|
<a href="/benchmark/add">Add new benchmark</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid-x grid-margin-x">
|
||||||
|
<% if benchmarks.length > 0 %>
|
||||||
|
<div class="cell small-12">
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Benchmark name</th>
|
||||||
|
<th>Scoring type</th>
|
||||||
|
<th>Date added</th>
|
||||||
|
<th>Date modified</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% benchmarks.each do |b| %>
|
||||||
|
<tr>
|
||||||
|
<td><%= b.name %></td>
|
||||||
|
<td><%= b.scoring %></td>
|
||||||
|
<td><%= b.created_at %></td>
|
||||||
|
<td><%= b.updated_at %></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<% else %>
|
||||||
|
<div class="cell small-12">
|
||||||
|
<p>I'm sorry, there doesn't appear to be any benchmarks added yet. Check again later!</p>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
32
views/hardware/add.erb
Normal file
32
views/hardware/add.erb
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<div class="grid-x grid-margin-x">
|
||||||
|
<div class="cell small-12">
|
||||||
|
<h1>Add new hardware</h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid-x grid-margin-x">
|
||||||
|
|
||||||
|
<form class="cell small-12" action="/hardware/add" method="post">
|
||||||
|
<div class="grid-x grid-padding-x">
|
||||||
|
<div class="cell medium-9">
|
||||||
|
<label>
|
||||||
|
Hardware name
|
||||||
|
<input type="text" name="hardware_name" placeholder="Example hardware">
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="cell medium-3">
|
||||||
|
<label>
|
||||||
|
Type
|
||||||
|
<select name="hardware_type">
|
||||||
|
<option value="gpu">Graphics card</option>
|
||||||
|
<option value="cpu">Processor</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<input type="submit" class="button" value="Submit">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
42
views/hardware/index.erb
Normal file
42
views/hardware/index.erb
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<div class="grid-x grid-margin-x">
|
||||||
|
<div class="cell small-12">
|
||||||
|
<h1>List of hardware</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="cell small-12">
|
||||||
|
<p>
|
||||||
|
<a href="/hardware/add">Add new hardware</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid-x grid-margin-x">
|
||||||
|
<% if hardware.length > 0 %>
|
||||||
|
<div class="cell small-12">
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Hardware name</th>
|
||||||
|
<th>Type</th>
|
||||||
|
<th>Date added</th>
|
||||||
|
<th>Date modified</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% hardware.each do |h| %>
|
||||||
|
<tr>
|
||||||
|
<td><%= h.name %></td>
|
||||||
|
<td><%= h.type %></td>
|
||||||
|
<td><%= h.created_at %></td>
|
||||||
|
<td><%= h.updated_at %></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<% else %>
|
||||||
|
<div class="cell small-12">
|
||||||
|
<p>I'm sorry, there doesn't appear to be any hardware added yet. Check again later!</p>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
@ -3,9 +3,9 @@
|
|||||||
<ul class="menu">
|
<ul class="menu">
|
||||||
<li><a href="/">Dashboard</a></li>
|
<li><a href="/">Dashboard</a></li>
|
||||||
<li><a href="/hardware">Hardware</a></li>
|
<li><a href="/hardware">Hardware</a></li>
|
||||||
<li><a href="/benchmarks">Benchmarks</a></li>
|
<li><a href="/benchmark">Benchmarks</a></li>
|
||||||
<li><a href="/results">Results</a></li>
|
<li><a href="/result">Results</a></li>
|
||||||
<li><a href="/comparisons">Comparisons</a></li>
|
<li><a href="/comparison">Comparisons</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user