Added a details page for test results; added an API route for removing test results
This commit is contained in:
@ -53,6 +53,8 @@ fetchTestBenchmarkResults = (testId, benchmarkId) ->
|
||||
else
|
||||
tableRow.append('<td>N/a</td>')
|
||||
tableRow.append('<td>N/a</td>')
|
||||
|
||||
tableRow.append('<td><a href="/test/' + testId + '/results">Details</a></td>')
|
||||
catch error
|
||||
console.error 'An error occurred while fetching benchmark results.', error
|
||||
|
||||
|
@ -22,6 +22,10 @@ table{
|
||||
border: 1px solid #eee;
|
||||
}
|
||||
|
||||
a{
|
||||
transition: color 210ms ease-in-out;
|
||||
}
|
||||
|
||||
#main-wrapper{
|
||||
padding: 1.5rem 2rem;
|
||||
background: white;
|
||||
|
@ -66,6 +66,23 @@ class ApiController extends Controller {
|
||||
->withHeader('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
public function getResultDelete(Request $request, Response $response, array $args): Response {
|
||||
$result = Result::where('id', $args['result_id'])->delete();
|
||||
|
||||
$payload = json_encode($result);
|
||||
|
||||
$referrer = $request->getHeaderLine('Referer');
|
||||
if ($referrer) {
|
||||
return $response
|
||||
->withHeader('Location', $referrer)
|
||||
->withStatus(302);
|
||||
}
|
||||
|
||||
$response->getBody()->write($payload);
|
||||
return $response
|
||||
->withHeader('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
public function getTestDetails(Request $request, Response $response, array $args): Response {
|
||||
$urlParams = $request->getQueryParams();
|
||||
$test = Test::where('id', $urlParams['test_id'])->first();
|
||||
|
@ -109,4 +109,13 @@ class TestController extends Controller {
|
||||
->withStatus(302);
|
||||
}
|
||||
|
||||
public function getResults(Request $request, Response $response, array $args): Response {
|
||||
$test = Test::where('id', $args['test_id'])->first();
|
||||
|
||||
$view = Twig::fromRequest($request);
|
||||
return $view->render($response, 'test/results.twig', [
|
||||
'test' => $test,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -42,6 +42,8 @@ $app->group('/test', function(RouteCollectorProxy $group) {
|
||||
|
||||
$test->get('/edit', '\\BitGoblin\\Colossus\\Controllers\\TestController:getEdit')->setName('test.edit');
|
||||
$test->post('/edit', '\\BitGoblin\\Colossus\\Controllers\\TestController:postEdit');
|
||||
|
||||
$test->get('/results', '\\BitGoblin\\Colossus\\Controllers\\TestController:getResults')->setName('test.results');
|
||||
});
|
||||
});
|
||||
|
||||
@ -56,6 +58,7 @@ $app->group('/api', function(RouteCollectorProxy $group) {
|
||||
|
||||
$apiv1->get('/result/list', '\\BitGoblin\\Colossus\\Controllers\\ApiController:getResultList')->setName('api.resultList');
|
||||
$apiv1->post('/result/add', '\\BitGoblin\\Colossus\\Controllers\\ApiController:postResultAdd')->setName('api.resultAdd');
|
||||
$apiv1->get('/result/{result_id}/delete', '\\BitGoblin\\Colossus\\Controllers\\ApiController:getResultDelete')->setName('api.resultDelete');
|
||||
|
||||
$apiv1->get('/test/details', '\\BitGoblin\\Colossus\\Controllers\\ApiController:getTestDetails')->setName('api.testDetails');
|
||||
});
|
||||
|
44
views/test/results.twig
Normal file
44
views/test/results.twig
Normal file
@ -0,0 +1,44 @@
|
||||
{% extends 'layout.twig' %}
|
||||
|
||||
{% block title %}Result Details for {{ test.title }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row mb-3">
|
||||
<div class="col-12">
|
||||
<h1>Result Details for {{ test.title }}</h1>
|
||||
<p><a href="{{ url_for('test.view', { test_id: test.id }) }}">Back</a></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr class="mb-4">
|
||||
|
||||
<div class="row mb-4">
|
||||
{% for b in test.benchmarks %}
|
||||
<div class="col-12 mb-3">
|
||||
<h2><a href="{{ url_for('benchmark.view', { benchmark_id: b.id }) }}">{{ b.name }}</a></h2>
|
||||
<table class="table table-hover table-responsive">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Average</th>
|
||||
<th>Minimum</th>
|
||||
<th>Maximum</th>
|
||||
<th>Edit</th>
|
||||
<th>Delete</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for r in b.results().where('test_id', test.id).get() %}
|
||||
<tr>
|
||||
<td>{{ r.average }}</td>
|
||||
<td>{{ r.minimum }}</td>
|
||||
<td>{{ r.maximum }}</td>
|
||||
<td><a href="#">Edit</a></td>
|
||||
<td><a href="{{ url_for('api.resultDelete', { result_id: r.id }) }}">Delete</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endblock %}
|
@ -61,6 +61,7 @@
|
||||
<th>Avg.</th>
|
||||
<th>Min.</th>
|
||||
<th>Max.</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
Reference in New Issue
Block a user