This commit is contained in:
@ -15,6 +15,7 @@ class GameData < Sinatra::Base
|
|||||||
get '/test/add' do
|
get '/test/add' do
|
||||||
hardware = Hardware.order(:name).all()
|
hardware = Hardware.order(:name).all()
|
||||||
benchmarks = Benchmark.order(:name).all()
|
benchmarks = Benchmark.order(:name).all()
|
||||||
|
|
||||||
erb :'test/add', locals: {
|
erb :'test/add', locals: {
|
||||||
title: 'Add Test',
|
title: 'Add Test',
|
||||||
hardware: hardware,
|
hardware: hardware,
|
||||||
@ -46,23 +47,28 @@ class GameData < Sinatra::Base
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/test/:hardware_id/edit' do
|
get '/test/:test_id/edit' do
|
||||||
hardware = Hardware.where(id: params[:hardware_id]).first()
|
tst = Test.where(id: params[:test_id]).first()
|
||||||
|
hardware = Hardware.order(:name).all()
|
||||||
|
benchmarks = Benchmark.order(:name).all()
|
||||||
|
|
||||||
erb :'test/edit', locals: {
|
erb :'test/edit', locals: {
|
||||||
title: "Editing: #{hardware.name}",
|
title: "Editing: #{tst.name}",
|
||||||
hardware: hardware
|
test: tst,
|
||||||
|
hardware: hardware,
|
||||||
|
benchmarks: benchmarks
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
post '/test/:hardware_id/edit' do
|
post '/test/:test_id/edit' do
|
||||||
hardware = Hardware.where(id: params[:hardware_id]).first()
|
tst = Test.where(id: params[:test_id]).first()
|
||||||
|
|
||||||
hardware.update(
|
tst.update(
|
||||||
name: params[:hardware_name],
|
name: params[:test_name],
|
||||||
type: params[:hardware_type]
|
type: params[:test_type]
|
||||||
)
|
)
|
||||||
|
|
||||||
redirect "/hardware/#{hardware.id}"
|
redirect "/test/#{tst.id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<% tests.each do |t| %>
|
<% tests.each do |t| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="/test/<%= t.id %>"><%= t.name %></a></td>
|
<td><a href="/test/<%= t.id %>"><%= t.name %></a></td>
|
||||||
<td><%= t.benchmark.length %></td>
|
<td><%= t.benchmarks.length %></td>
|
||||||
<td><%= t.updated_at %></td>
|
<td><%= t.updated_at %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -1,30 +1,47 @@
|
|||||||
<div class="row">
|
<div class="row mb-3">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<h1>Editing: <%= hardware.name %></h1>
|
<h1>Editing: <%= test.name %></h1>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
<form class="col-12" action="/hardware/<%= hardware.id %>/edit" method="post">
|
<form class="col-12" action="/test/<%= test.id %>/edit" method="post">
|
||||||
<div class="row mb-3">
|
<div class="row mb-0 mb-md-3">
|
||||||
<div class="col-12 col-md-9">
|
<div class="col-12 col-md-6 mb-3 mb-md-0">
|
||||||
<label for="hardware_name">Hardware name</label>
|
<label for="test_name">Test name</label>
|
||||||
<input id="hardware_name" class="form-control" type="text" name="hardware_name" placeholder="Example hardware" value="<%= hardware.name %>">
|
<input id="test_name" class="form-control" type="text" name="test_name" placeholder="My hardware test (01/99)" value="<%= test.name %>">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-12 col-md-3">
|
<div class="col-12 col-md-6 mb-3 mb-md-0">
|
||||||
<label for="hardware_type">Type</label>
|
<label for="test_hardware">Hardware to test</label>
|
||||||
<select id="hardware_type" class="form-control" name="hardware_type">
|
<select id="test_hardware" class="form-select" name="test_hardware">
|
||||||
<option value="gpu" <% if hardware.type == 'gpu' %>selected<% end %>>Graphics card</option>
|
<% for h in hardware %>
|
||||||
<option value="cpu" <% if hardware.type == 'cpu' %>selected<% end %>>Processor</option>
|
<option value="<%= h.id %>" <% if h.id == test.hardware.id %>selected<% end %>><%= h.name %></option>
|
||||||
|
<% end %>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="row mb-0 mb-md-3">
|
||||||
|
<div class="col-12 col-md-4 mb-3 mb-md-0">
|
||||||
|
<label for="test_benchmarks">Benchmarks</label>
|
||||||
|
<select id="test_benchmarks" class="form-select" name="test_benchmarks[]" multiple>
|
||||||
|
<% for b in benchmarks %>
|
||||||
|
<option value="<%= b.id %>"><%= b.name %></option>
|
||||||
|
<% end %>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-12 col-md-8 mb-3 mb-md-0">
|
||||||
|
<label for="test_description">Test description</label>
|
||||||
|
<textarea id="test_description" class="form-control" name="test_description" placeholder="This is my test for a hardware..."><%= test.description %></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<input class="btn btn-primary w-100" type="submit" value="Submit Changes">
|
<input class="btn btn-primary w-100" type="submit" value="Create Test">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
Reference in New Issue
Block a user