Commit c4487f61 authored by Baudouin Feildel's avatar Baudouin Feildel
Browse files

Add about page

parent d033f5de
Pipeline #646 passed with stage
in 1 minute and 29 seconds
......@@ -15,8 +15,11 @@ package:
APP_ENV: "prod"
script:
- echo "Packaged on " `date` > package.txt
- echo "{\"ddec-info\":\"$CI_COMMIT_TAG\",\"ddec-info-git-hash\":\"$CI_COMMIT_SHA\"}" > version.json
- rm -rf .env var .git .idea
artifacts:
name: "ddec-info-$CI_COMMIT_SHA"
name: "ddec-info-$CI_COMMIT_TAG-$CI_COMMIT_SHORT_SHA"
paths:
- .
only:
- tags
......@@ -2,8 +2,11 @@
namespace App\Controller;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DBALException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
......@@ -17,46 +20,86 @@ class AdminDefaultController extends AbstractController
return $this->render('admin/home.html.twig');
}
/**
* @Route("/admin/login", name="admin_login")
* @param AuthenticationUtils $authUtils The authentication utils
* @return Response
*/
/**
* @Route("/admin/login", name="admin_login")
* @param AuthenticationUtils $authUtils The authentication utils
* @return Response
*/
public function login(AuthenticationUtils $authUtils)
{
$error = $authUtils->getLastAuthenticationError();
$lastUsername = $authUtils->getLastUsername();
$error = $authUtils->getLastAuthenticationError();
$lastUsername = $authUtils->getLastUsername();
return $this->render('admin/login.html.twig', [
'last_username' => $lastUsername,
'error' => $error
]);
return $this->render('admin/login.html.twig', [
'last_username' => $lastUsername,
'error' => $error
]);
}
/**
* @Route("/admin/users", name="admin_users_and_groups")
* @return Response
*/
/**
* @Route("/admin/users", name="admin_users_and_groups")
* @return Response
*/
public function usersAndGroups()
{
return $this->render('admin/user_and_group.html.twig');
return $this->render('admin/user_and_group.html.twig');
}
/**
* @Route("/admin/pages", name="admin_pages")
* @return Response
*/
/**
* @Route("/admin/pages", name="admin_pages")
* @return Response
*/
public function pages()
{
return $this->render("admin/pages.html.twig");
return $this->render("admin/pages.html.twig");
}
/**
* @Route("/admin/settings", name="admin_settings")
* @return Response
*/
/**
* @Route("/admin/settings", name="admin_settings")
* @return Response
*/
public function settings()
{
return $this->render("admin/settings.html.twig");
return $this->render("admin/settings.html.twig");
}
private static function createVersionInfo(string $component, string $value): array
{
return [
'component' => $component,
'value' => $value,
];
}
private function getMySQLVersion(): string
{
/** @var Connection $conn */
$conn = $this->getDoctrine()->getConnection('ddec');
try {
return $conn->executeQuery('SELECT VERSION();')->fetchColumn();
} catch (DBALException $e) {
return "error";
}
}
/**
* @Route("/admin/about", name="admin_about")
* @return Response
*/
public function about()
{
$version_json = json_decode(file_get_contents(__DIR__ . '/../../version.json'), true);
$versions = [
self::createVersionInfo('DDEC-Info', $version_json['ddec-info']),
self::createVersionInfo('Framework Symfony', Kernel::VERSION),
self::createVersionInfo('PHP', PHP_VERSION),
self::createVersionInfo('MySQL', $this->getMySQLVersion()),
];
return $this->render('admin/about.html.twig', [
'versions' => $versions,
]);
}
}
{% extends 'admin/base.html.twig' %}
{% set page_title = "À propos" %}
{% block admin_menu %}
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Administration</h3>
</div>
</div>
{% endblock %}
{% block admin_content %}
<p>Informations de version:</p>
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Composant</th>
<th>Version</th>
</tr>
</thead>
<tbody>
{% for v in versions %}
<tr>
<td>{{ v.component }}</td>
<td>{{ v.value }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment