Added routes and views for adding and listing benchmarks and components
This commit is contained in:
parent
0dd7098681
commit
3349d42985
@ -10,6 +10,15 @@ use BitGoblin\Colossus\Models\Benchmark;
|
|||||||
|
|
||||||
class BenchmarkController extends Controller {
|
class BenchmarkController extends Controller {
|
||||||
|
|
||||||
|
public function getIndex(Request $request, Response $response): Response {
|
||||||
|
// redirect the user back to the home page
|
||||||
|
$routeContext = RouteContext::fromRequest($request);
|
||||||
|
$routeParser = $routeContext->getRouteParser();
|
||||||
|
return $response
|
||||||
|
->withHeader('Location', $routeParser->urlFor('benchmark.list'))
|
||||||
|
->withStatus(302);
|
||||||
|
}
|
||||||
|
|
||||||
public function getList(Request $request, Response $response): Response {
|
public function getList(Request $request, Response $response): Response {
|
||||||
$benchmarks = Benchmark::orderByDesc('updated_at')->get();
|
$benchmarks = Benchmark::orderByDesc('updated_at')->get();
|
||||||
|
|
||||||
|
@ -10,6 +10,15 @@ use BitGoblin\Colossus\Models\Component;
|
|||||||
|
|
||||||
class ComponentController extends Controller {
|
class ComponentController extends Controller {
|
||||||
|
|
||||||
|
public function getIndex(Request $request, Response $response): Response {
|
||||||
|
// redirect the user back to the home page
|
||||||
|
$routeContext = RouteContext::fromRequest($request);
|
||||||
|
$routeParser = $routeContext->getRouteParser();
|
||||||
|
return $response
|
||||||
|
->withHeader('Location', $routeParser->urlFor('component.list'))
|
||||||
|
->withStatus(302);
|
||||||
|
}
|
||||||
|
|
||||||
public function getList(Request $request, Response $response): Response {
|
public function getList(Request $request, Response $response): Response {
|
||||||
$components = Component::orderByDesc('updated_at')->get();
|
$components = Component::orderByDesc('updated_at')->get();
|
||||||
|
|
||||||
@ -38,7 +47,7 @@ class ComponentController extends Controller {
|
|||||||
|
|
||||||
$component = new Component;
|
$component = new Component;
|
||||||
$component->name = $params['component_name'];
|
$component->name = $params['component_name'];
|
||||||
$component->type = $params['component_description'];
|
$component->type = $params['component_type'];
|
||||||
|
|
||||||
$component->save();
|
$component->save();
|
||||||
|
|
||||||
|
@ -5,17 +5,19 @@ use Slim\Routing\RouteCollectorProxy;
|
|||||||
$app->get('/', '\\BitGoblin\\Colossus\\Controllers\\HomeController:getIndex')->setName('dashboard');
|
$app->get('/', '\\BitGoblin\\Colossus\\Controllers\\HomeController:getIndex')->setName('dashboard');
|
||||||
|
|
||||||
$app->group('/benchmark', function(RouteCollectorProxy $group) {
|
$app->group('/benchmark', function(RouteCollectorProxy $group) {
|
||||||
$group->get('', '\\BitGoblin\\Colossus\\Controllers\\BenchmarkController:getList')->setName('benchmark.list');
|
$group->get('', '\\BitGoblin\\Colossus\\Controllers\\BenchmarkController:getIndex')->setName('benchmark.index');
|
||||||
|
$group->get('/list', '\\BitGoblin\\Colossus\\Controllers\\BenchmarkController:getList')->setName('benchmark.list');
|
||||||
$group->get('/add', '\\BitGoblin\\Colossus\\Controllers\\BenchmarkController:getAdd')->setName('benchmark.add');
|
$group->get('/add', '\\BitGoblin\\Colossus\\Controllers\\BenchmarkController:getAdd')->setName('benchmark.add');
|
||||||
$group->post('/add', '\\BitGoblin\\Colossus\\Controllers\\BenchmarkController:postAdd');
|
$group->post('/add', '\\BitGoblin\\Colossus\\Controllers\\BenchmarkController:postAdd');
|
||||||
$group->get('/{test_id}', '\\BitGoblin\\Colossus\\Controllers\\BenchmarkController:getView')->setName('benchmark.view');
|
$group->get('/{benchmark_id}', '\\BitGoblin\\Colossus\\Controllers\\BenchmarkController:getView')->setName('benchmark.view');
|
||||||
});
|
});
|
||||||
|
|
||||||
$app->group('/component', function(RouteCollectorProxy $group) {
|
$app->group('/component', function(RouteCollectorProxy $group) {
|
||||||
$group->get('', '\\BitGoblin\\Colossus\\Controllers\\ComponentController:getList')->setName('component.list');
|
$group->get('', '\\BitGoblin\\Colossus\\Controllers\\ComponentController:getIndex')->setName('component.index');
|
||||||
|
$group->get('/list', '\\BitGoblin\\Colossus\\Controllers\\ComponentController:getList')->setName('component.list');
|
||||||
$group->get('/add', '\\BitGoblin\\Colossus\\Controllers\\ComponentController:getAdd')->setName('component.add');
|
$group->get('/add', '\\BitGoblin\\Colossus\\Controllers\\ComponentController:getAdd')->setName('component.add');
|
||||||
$group->post('/add', '\\BitGoblin\\Colossus\\Controllers\\ComponentController:postAdd');
|
$group->post('/add', '\\BitGoblin\\Colossus\\Controllers\\ComponentController:postAdd');
|
||||||
$group->get('/{test_id}', '\\BitGoblin\\Colossus\\Controllers\\ComponentController:getView')->setName('component.view');
|
$group->get('/{component_id}', '\\BitGoblin\\Colossus\\Controllers\\ComponentController:getView')->setName('component.view');
|
||||||
});
|
});
|
||||||
|
|
||||||
$app->group('/test', function(RouteCollectorProxy $group) {
|
$app->group('/test', function(RouteCollectorProxy $group) {
|
||||||
|
46
views/benchmark/add.twig
Normal file
46
views/benchmark/add.twig
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
{% extends 'layout.twig' %}
|
||||||
|
|
||||||
|
{% block title %}Add New Benchmark{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="twelve columns">
|
||||||
|
<h1>Add new benchmark</h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="twelve columns">
|
||||||
|
<form action="{{ url_for('benchmark.add') }}" method="POST" class="u-full-width">
|
||||||
|
<div class="row">
|
||||||
|
<div class="nine columns">
|
||||||
|
<label for="benchmark_name">Benchmark name:</label>
|
||||||
|
<input type="text" id="benchmark_name" class="u-full-width" name="benchmark_name">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="three columns">
|
||||||
|
<label>
|
||||||
|
Scoring type
|
||||||
|
<select class="u-full-width" 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="row">
|
||||||
|
<div class="twelve columns">
|
||||||
|
<label for="benchmark_description">Description</label>
|
||||||
|
<textarea class="u-full-width" name="benchmark_description" id="benchmark_description" rows="5" placeholder="Describe this benchmark..."></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<input class="button button-primary u-full-width" type="submit" value="Submit">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
38
views/component/add.twig
Normal file
38
views/component/add.twig
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{% extends 'layout.twig' %}
|
||||||
|
|
||||||
|
{% block title %}Add New Component{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="twelve columns">
|
||||||
|
<h1>Add new component</h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="twelve columns">
|
||||||
|
<form action="{{ url_for('component.add') }}" method="POST" class="u-full-width">
|
||||||
|
<div class="row">
|
||||||
|
<div class="nine columns">
|
||||||
|
<label for="component_name">Component name:</label>
|
||||||
|
<input type="text" id="component_name" class="u-full-width" name="component_name">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="three columns">
|
||||||
|
<label>
|
||||||
|
Component type:
|
||||||
|
<select class="u-full-width" name="component_type">
|
||||||
|
<option value="gpu">Graphics card</option>
|
||||||
|
<option value="cpu">Processor</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<input class="button button-primary u-full-width" type="submit" value="Submit">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
@ -0,0 +1,50 @@
|
|||||||
|
{% extends 'layout.twig' %}
|
||||||
|
|
||||||
|
{% block title %}Component: {{ component.name }}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="twelve columns">
|
||||||
|
<h1>{{ component.name }}</h1>
|
||||||
|
<p>{{ component.type }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="twelve columns">
|
||||||
|
<h3>Test results:</h3>
|
||||||
|
<p><a href="{{ url_for('result.add') }}">Add new result</a></p>
|
||||||
|
|
||||||
|
{% if test.results | length > 0 %}
|
||||||
|
<table class="u-full-width">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Component</th>
|
||||||
|
<th>Benchmark</th>
|
||||||
|
<th>Scoring</th>
|
||||||
|
<th>Avg.</th>
|
||||||
|
<th>Min.</th>
|
||||||
|
<th>Max.</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for r in test.results %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ r.component }}</td>
|
||||||
|
<td>{{ r.benchmark }}</td>
|
||||||
|
<td>{{ r.type | capitalize }}</td>
|
||||||
|
<td>{{ r.average }}</td>
|
||||||
|
<td>{{ r.minimum ? r.minimum : 'N/a' }}</td>
|
||||||
|
<td>{{ r.maximum ? r.maximum : 'N/a' }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% else %}
|
||||||
|
<p>There are no results associated with this.</p>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user