Re-worked test views and routes for new DB schema
This commit is contained in:
parent
3349d42985
commit
987ecde7c7
@ -6,6 +6,8 @@ use Psr\Http\Message\ResponseInterface as Response;
|
|||||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||||
use Slim\Routing\RouteContext;
|
use Slim\Routing\RouteContext;
|
||||||
use Slim\Views\Twig;
|
use Slim\Views\Twig;
|
||||||
|
use BitGoblin\Colossus\Models\Benchmark;
|
||||||
|
use BitGoblin\Colossus\Models\Component;
|
||||||
use BitGoblin\Colossus\Models\Test;
|
use BitGoblin\Colossus\Models\Test;
|
||||||
|
|
||||||
class TestController extends Controller {
|
class TestController extends Controller {
|
||||||
@ -29,16 +31,23 @@ class TestController extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getAdd(Request $request, Response $response): Response {
|
public function getAdd(Request $request, Response $response): Response {
|
||||||
|
$benchmarks = Benchmark::all();
|
||||||
|
$components = Component::all();
|
||||||
|
|
||||||
$view = Twig::fromRequest($request);
|
$view = Twig::fromRequest($request);
|
||||||
return $view->render($response, 'test/add.twig');
|
return $view->render($response, 'test/add.twig', [
|
||||||
|
'benchmarks' => $benchmarks,
|
||||||
|
'components' => $components,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function postAdd(Request $request, Response $response): Response {
|
public function postAdd(Request $request, Response $response): Response {
|
||||||
$params = (array)$request->getParsedBody();
|
$params = (array)$request->getParsedBody();
|
||||||
|
|
||||||
$test = new Test;
|
$test = new Test;
|
||||||
$test->name = $params['test_name'];
|
$test->date_tag = $params['test_date_tag'];
|
||||||
$test->description = $params['test_description'];
|
$test->benchmark_id = $params['test_benchmark'];
|
||||||
|
$test->component_id = $params['test_component'];
|
||||||
|
|
||||||
$test->save();
|
$test->save();
|
||||||
|
|
||||||
|
@ -14,16 +14,33 @@
|
|||||||
<div class="twelve columns">
|
<div class="twelve columns">
|
||||||
<form action="{{ url_for('test.add') }}" method="POST" class="u-full-width">
|
<form action="{{ url_for('test.add') }}" method="POST" class="u-full-width">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="twelve columns">
|
<div class="two columns">
|
||||||
<label for="test_name">Test name:</label>
|
<label>
|
||||||
<input type="text" id="test_name" class="u-full-width" name="test_name">
|
Date Tag:
|
||||||
|
<input class="u-full-width" type="text" name="test_date_tag" placeholder="(XY/AB)">
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="five columns">
|
||||||
<div class="twelve columns">
|
<label>
|
||||||
<label for="test_description">Description</label>
|
Benchmark:
|
||||||
<textarea class="u-full-width" name="test_description" id="test_description" placeholder="Describe this test..."></textarea>
|
<select class="u-full-width" name="test_benchmark">
|
||||||
|
{% for b in benchmarks %}
|
||||||
|
<option value="{{ b.id }}">{{ b.name }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="five columns">
|
||||||
|
<label>
|
||||||
|
Hardware component:
|
||||||
|
<select class="u-full-width" name="test_component">
|
||||||
|
{% for c in components %}
|
||||||
|
<option value="{{ c.id }}">{{ c.name }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -9,16 +9,20 @@
|
|||||||
<table class="u-full-width">
|
<table class="u-full-width">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Test name</th>
|
<th>Test Date</th>
|
||||||
<th>Description</th>
|
<th>Benchmark</th>
|
||||||
|
<th>Hardware</th>
|
||||||
|
<th># of Results</th>
|
||||||
<th>Last updated</th>
|
<th>Last updated</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for t in tests %}
|
{% for t in tests %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="{{ url_for('test.view', { test_id: t.id }) }}">{{ t.name }}</a></td>
|
<td><a href="{{ url_for('test.view', { test_id: t.id }) }}">{{ t.date_tag }}</a></td>
|
||||||
<td>{{ t.description | slice(0, 100) }}</td>
|
<td>{{ t.benchmark.name }}</td>
|
||||||
|
<td>{{ t.component.name }}</td>
|
||||||
|
<td>{{ t.results | length }}</td>
|
||||||
<td>{{ t.updated_at | date("F jS \\a\\t g:ia") }}</td>
|
<td>{{ t.updated_at | date("F jS \\a\\t g:ia") }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
Loading…
Reference in New Issue
Block a user