This commit is contained in:
afornerot 2024-11-22 08:47:33 +01:00
parent 1289b22a93
commit 0729b81d06
6 changed files with 151 additions and 55 deletions

View File

@ -3,6 +3,7 @@ import './bootstrap.js';
// jQuery // jQuery
import $ from 'jquery'; import $ from 'jquery';
window.$ = $; window.$ = $;
window.jQuery = $;
// Bootstrap // Bootstrap
import 'bootstrap' import 'bootstrap'

View File

@ -56,8 +56,9 @@ class InitCommand extends Command
$user->setUsername("admin"); $user->setUsername("admin");
$user->setPassword($hashedPassword); $user->setPassword($hashedPassword);
$this->em->persist($user); $this->em->persist($user);
$this->em->flush();
} }
$user->setRoles(["ROLE_ADMIN"]);
$this->em->flush();
// Création d'un company par defaut // Création d'un company par defaut
$io->text("> Création d'un company par defaut"); $io->text("> Création d'un company par defaut");

View File

@ -12,7 +12,8 @@ class HomeController extends AbstractController
public function index(): Response public function index(): Response
{ {
return $this->render('home/index.html.twig', [ return $this->render('home/index.html.twig', [
'controller_name' => 'HomeController', 'usemenu' => true,
]); 'usesidebar' => true,
]);
} }
} }

View File

@ -2,17 +2,87 @@
<html> <html>
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>{% block title %}Welcome!{% endblock %}</title> <title>{{appName}}{% block title %}{% endblock %}</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 128 128%22><text y=%221.2em%22 font-size=%2296%22>⚫️</text><text y=%221.3em%22 x=%220.2em%22 font-size=%2276%22 fill=%22%23fff%22>sf</text></svg>"> <link rel="icon" href="">
{% block stylesheets %}
{% endblock %}
{% block javascripts %} {% block javascripts %}
{% block importmap %}{{ importmap('app') }}{% endblock %} {% block importmap %}{{ importmap('app') }}{% endblock %}
{% endblock %} {% endblock %}
</head> </head>
<style>
html, body {
height:100%
}
body {
display:flex;
flex-direction: column;
align-items: stretch;
}
main {
display:flex;
flex-grow:1;
align-items: stretch;
}
sidebar {
width:300px;
padding:15px;
background-color:rgba(var(--bs-dark-rgb));
display: flex;
flex-direction:column;
}
sidebar div {
display: flex;
flex-direction:column;
border-bottom:1px solid var(--bs-body-color);
padding-bottom:10px;
}
sidebar a {
text-decoration: none;
color: var(--bs-body-color);;
opacity:0.6;
margin: 5px 0px;
}
sidebar a:hover {
text-decoration: none;
opacity:1;
}
content {
flex-grow:1;
align-items: stretch;
padding: 15px;
}
@media (max-width: 991px) {
sidebar {
width: 70px;
}
sidebar i {
font-size: 200%;
}
sidebar span {
display:none;
}
}
.form-group {
margin-bottom:5px;
}
</style>
<body> <body>
<nav class="navbar navbar-expand-lg bg-dark" data-bs-theme="dark"> {% if usemenu is defined and usemenu %}
<nav class="navbar navbar-expand-lg bg-dark" data-bs-theme="dark">
<div class="container-fluid"> <div class="container-fluid">
<a class="navbar-brand" href="#"><img src="{{asset("medias/logo/logo.png")}}"> {{appName}}</a> <a class="navbar-brand" href="#"><img src="{{asset("medias/logo/logo.png")}}"> {{appName}}</a>
@ -47,13 +117,44 @@
</div> </div>
<div class="navbar-nav ms-auto ps-3 d-flex flex-row position-absolute" style="right: 15px; top:15px"> <div class="navbar-nav ms-auto ps-3 d-flex flex-row position-absolute" style="right: 15px; top:15px">
<a class="nav-link px-2" href="#"><i class="fa-solid fa-user fa-2x"></i></a> {% if app.user %}
<a class="nav-link px-2" href="{{path('app_logout')}}"><i class="fa-solid fa-right-from-bracket fa-2x"></i></a>
{% else %}
<a class="nav-link px-2" href="{{path('app_login')}}"><i class="fa-solid fa-right-to-bracket fa-2x"></i></a>
{% endif %}
<a class="navbar-toggler nav-link px-2" href="#" data-bs-toggle="collapse" data-bs-target="#navbarColor02" aria-controls="navbarColor02" aria-expanded="false" aria-label="Toggle navigation"><i class="fa-solid fa-bars fa-2x"></i></a> <a class="navbar-toggler nav-link px-2" href="#" data-bs-toggle="collapse" data-bs-target="#navbarColor02" aria-controls="navbarColor02" aria-expanded="false" aria-label="Toggle navigation"><i class="fa-solid fa-bars fa-2x"></i></a>
</div> </div>
</div> </div>
</nav> </nav>
{% endif %}
{% block body %} <main>
{% endblock %} {% if usesidebar is defined and usesidebar %}
{% if is_granted('ROLE_ADMIN') %}
<sidebar>
<div>
<span>GENERALE</span>
<a href="" title="Configurations">
<i class="fas fa-cog fa-fw"></i>
<span>Configurations</span>
</a>
<a href="" title="Utilisateurs">
<i class="fas fa-user fa-fw"></i>
<span>Utilisateurs</span>
</a>
</div>
</sidebar>
{% endif %}
{% endif %}
<content>
{% block body %}
{% endblock %}
</content>
</main>
</body> </body>
{% block localscript %}
{% endblock %}
</html> </html>

View File

@ -3,18 +3,5 @@
{% block title %}Hello HomeController!{% endblock %} {% block title %}Hello HomeController!{% endblock %}
{% block body %} {% block body %}
<style> Pouet
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
</style>
<div class="example-wrapper">
<h1>Hello {{ controller_name }}! ✅</h1>
This friendly message is coming from:
<ul>
<li>Your controller at <code>/home/afornerot/cadoles/nine-project/ninecompta/src/Controller/HomeController.php</code></li>
<li>Your template at <code>/home/afornerot/cadoles/nine-project/ninecompta/templates/home/index.html.twig</code></li>
</ul>
</div>
{% endblock %} {% endblock %}

View File

@ -1,41 +1,46 @@
{% extends 'base.html.twig' %} {% extends 'base.html.twig' %}
{% block title %}Log in!{% endblock %}
{% block body %} {% block body %}
<form method="post"> <form method="post">
{% if error %} <img src="{{asset("/medias/logo/logo.png")}}" style="margin: 15px auto 15px auto; width:100px; display:block;">
<div class="alert alert-danger">{{ error.messageKey|trans(error.messageData, 'security') }}</div> <center style="font-size:200%;margin-bottom:30px;">{{appName}}</center>
{% endif %} <div class="card card-body m-auto" style="width:300px">
{% if error %}
<div class="alert alert-danger">{{ error.messageKey|trans(error.messageData, 'security') }}</div>
{% endif %}
{% if app.user %} {% if app.user %}
<div class="mb-3"> <div class="mb-3">
You are logged in as {{ app.user.userIdentifier }}, <a href="{{ path('app_logout') }}">Logout</a> Vous êtes déjà connecté avec le login {{ app.user.userIdentifier }} = <a href="{{ path('app_logout') }}">Logout</a>
</div>
{% endif %}
<div class="form-group">
<label for="username">Login</label>
<input class="form-control" type="text" value="{{ last_username }}" name="_username" id="username" class="form-control" autocomplete="username" required autofocus>
</div> </div>
{% endif %}
<h1 class="h3 mb-3 font-weight-normal">Please sign in</h1> <div class="form-group">
<label for="username">Username</label> <label for="password">Password</label>
<input type="text" value="{{ last_username }}" name="_username" id="username" class="form-control" autocomplete="username" required autofocus> <input class="form-control" type="password" name="_password" id="password" class="form-control" autocomplete="current-password" required>
<label for="password">Password</label>
<input type="password" name="_password" id="password" class="form-control" autocomplete="current-password" required>
<input type="hidden" name="_csrf_token"
value="{{ csrf_token('authenticate') }}"
>
{#
Uncomment this section and add a remember_me option below your firewall to activate remember me functionality.
See https://symfony.com/doc/current/security/remember_me.html
<div class="checkbox mb-3">
<input type="checkbox" name="_remember_me" id="_remember_me">
<label for="_remember_me">Remember me</label>
</div> </div>
#}
<button class="btn btn-lg btn-primary" type="submit"> <input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}">
Sign in
</button> <button class="btn btn-lg btn-primary" type="submit">
Valider
</button>
</div>
</form> </form>
{% endblock %} {% endblock %}
{% block localscript %}
<script>
$(document).ready(function () {
$("#password").focus();
console.log('DOM ready');
console.log($); // Vérifiez ici que $ est bien défini
});
</script>
{% endblock %}