Compare commits

...

2 Commits

7 changed files with 147 additions and 5 deletions

View File

@ -27,4 +27,32 @@ class GameData < Sinatra::Base
redirect "/benchmark/#{benchmark.id}"
end
get '/benchmark/:benchmark_id' do
benchmark = Benchmark.where(id: params[:benchmark_id]).first()
erb :'benchmark/view', locals: {
title: benchmark.name,
benchmark: benchmark
}
end
get '/benchmark/:benchmark_id/edit' do
benchmark = Benchmark.where(id: params[:benchmark_id]).first()
erb :'benchmark/edit', locals: {
title: "Editing: #{benchmark.name}",
benchmark: benchmark
}
end
post '/benchmark/:benchmark_id/edit' do
benchmark = Benchmark.where(id: params[:benchmark_id]).first()
benchmark.update(
name: params[:benchmark_name],
scoring: params[:benchmark_scoring],
description: params[:benchmark_description]
)
redirect "/benchmark/#{benchmark.id}"
end
end

View File

@ -36,4 +36,23 @@ class GameData < Sinatra::Base
}
end
get '/hardware/:hardware_id/edit' do
hardware = Hardware.where(id: params[:hardware_id]).first()
erb :'hardware/edit', locals: {
title: "Editing: #{hardware.name}",
hardware: hardware
}
end
post '/hardware/:hardware_id/edit' do
hardware = Hardware.where(id: params[:hardware_id]).first()
hardware.update(
name: params[:hardware_name],
type: params[:hardware_type]
)
redirect "/hardware/#{hardware.id}"
end
end

43
views/benchmark/edit.erb Normal file
View File

@ -0,0 +1,43 @@
<div class="grid-x grid-margin-x">
<div class="cell small-12">
<h1>Editing: <%= benchmark.name %></h1>
</div>
</div>
<div class="grid-x grid-margin-x">
<form class="cell small-12" action="/benchmark/<%= benchmark.id %>/edit" 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" value="<%= benchmark.name %>">
</label>
</div>
<div class="cell medium-3">
<label>
Scoring type
<select name="benchmark_scoring">
<option value="fps" <% if benchmark.scoring == 'fps' %>selected<% end %>>Frames per Second (fps)</option>
<option value="ms" <% if benchmark.scoring == 'ms' %>selected<% end %>>Frame Time (ms)</option>
<option value="pts" <% if benchmark.scoring == 'pts' %>selected<% end %>>Total Points</option>
</select>
</label>
</div>
</div>
<div class="grid-x grid-padding-x">
<div class="cell small-12">
<textarea name="benchmark_description" class="cell small-12"><%= benchmark.description %></textarea>
</div>
</div>
<div class="grid-x grid-padding-x">
<div class="cell small-12">
<input type="submit" class="button" value="Submit">
</div>
</div>
</form>
</div>

View File

@ -18,17 +18,15 @@
<tr>
<th>Benchmark name</th>
<th>Scoring type</th>
<th>Date added</th>
<th>Date modified</th>
<th>Notes</th>
</tr>
</thead>
<tbody>
<% benchmarks.each do |b| %>
<tr>
<td><%= b.name %></td>
<td><a href="/benchmark/<%= b.id %>"><%= b.name %></a</td>
<td><%= b.scoring %></td>
<td><%= date_format(b.created_at) %></td>
<td><%= date_format(b.updated_at) %></td>
<td><%= b.description %></td>
</tr>
<% end %>
</tbody>

18
views/benchmark/view.erb Normal file
View File

@ -0,0 +1,18 @@
<div class="grid-x grid-margin-x">
<div class="cell small-12">
<h1><%= benchmark.name %></h1>
</div>
<div class="cell small-12">
<p><a href="/benchmark/<%= benchmark.id %>/edit">Edit</a></p>
</div>
<div class="cell small-12">
Benchmark scoring type: <%= benchmark.scoring %>
</div>
<div class="cell small-12">
Description:
<p><%= benchmark.description %></p>
</div>
</div>

32
views/hardware/edit.erb Normal file
View File

@ -0,0 +1,32 @@
<div class="grid-x grid-margin-x">
<div class="cell small-12">
<h1>Editing: <%= hardware.name %></h1>
</div>
</div>
<div class="grid-x grid-margin-x">
<form class="cell small-12" action="/hardware/<%= hardware.id %>/edit" 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" value="<%= hardware.name %>">
</label>
</div>
<div class="cell medium-3">
<label>
Type
<select name="hardware_type">
<option value="gpu" <% if hardware.type == 'gpu' %>selected<% end %>>Graphics card</option>
<option value="cpu" <% if hardware.type == 'cpu' %>selected<% end %>>Processor</option>
</select>
</label>
</div>
</div>
<input type="submit" class="button" value="Submit">
</form>
</div>

View File

@ -3,6 +3,10 @@
<h1><%= hardware.name %></h1>
</div>
<div class="cell small-12">
<p><a href="/hardware/<%= hardware.id %>/edit">Edit</a></p>
</div>
<div class="cell small-12">
Hardware type: <%= hardware.type %>
</div>