add admin dashboard

This commit is contained in:
Tykayn 2024-07-16 16:10:51 +02:00 committed by tykayn
parent a6c6a808f2
commit 2fa0183b42
11 changed files with 475 additions and 26 deletions

View File

@ -23,13 +23,13 @@
</component>
<component name="ChangeListManager">
<list default="true" id="7b6ae3ea-b7de-4daa-94af-b6fb4f3c8b8e" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.env.example" beforeDir="false" afterPath="$PROJECT_DIR$/.env.example" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/rector.php" beforeDir="false" afterPath="$PROJECT_DIR$/rector.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/composer.json" beforeDir="false" afterPath="$PROJECT_DIR$/composer.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/composer.lock" beforeDir="false" afterPath="$PROJECT_DIR$/composer.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/config/bundles.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/bundles.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/config/packages/security.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/config/packages/security.yaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/DataFixtures/AppFixtures.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/DataFixtures/AppFixtures.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/symfony.lock" beforeDir="false" afterPath="$PROJECT_DIR$/symfony.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/default/main-screen.html.twig" beforeDir="false" afterPath="$PROJECT_DIR$/templates/default/main-screen.html.twig" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/security/login.html.twig" beforeDir="false" afterPath="$PROJECT_DIR$/templates/security/login.html.twig" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -236,10 +236,10 @@
<path value="$PROJECT_DIR$/vendor/nelmio/cors-bundle" />
</include_path>
</component>
<component name="ProjectColorInfo"><![CDATA[{
"customColor": "",
"associatedIndex": 4
}]]></component>
<component name="ProjectColorInfo">{
&quot;customColor&quot;: &quot;&quot;,
&quot;associatedIndex&quot;: 4
}</component>
<component name="ProjectId" id="1RMlJsg2Tg46rvC91UMEe0aUs5g" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
<ConfirmationsSetting value="1" id="Add" />
@ -248,21 +248,22 @@
<option name="autoscrollFromSource" value="true" />
<option name="autoscrollToSource" value="true" />
<option name="hideEmptyMiddlePackages" value="true" />
<option name="openDirectoriesWithSingleClick" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"dart.analysis.tool.window.visible": "false",
"git-widget-placeholder": "master",
"last_opened_file_path": "/home/poule/encrypted/stockage-syncable/www/development/html/caisse",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "yarn",
"vue.rearranger.settings.migration": "true"
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;dart.analysis.tool.window.visible&quot;: &quot;false&quot;,
&quot;git-widget-placeholder&quot;: &quot;master&quot;,
&quot;last_opened_file_path&quot;: &quot;/home/poule/encrypted/stockage-syncable/www/development/html/caisse&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;yarn&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}
}]]></component>
}</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$" />
@ -311,7 +312,9 @@
<workItem from="1686851564377" duration="1602000" />
<workItem from="1687277447224" duration="3841000" />
<workItem from="1687943901322" duration="8313000" />
<workItem from="1721124162582" duration="3506000" />
<workItem from="1721124162582" duration="4590000" />
<workItem from="1721135270174" duration="484000" />
<workItem from="1721135995908" duration="3026000" />
</task>
<servers />
</component>

View File

@ -12,6 +12,7 @@
"doctrine/doctrine-bundle": "^2.12",
"doctrine/doctrine-migrations-bundle": "^3.3",
"doctrine/orm": "^3.1",
"easycorp/easyadmin-bundle": "^4.10",
"phpdocumentor/reflection-docblock": "^5.4",
"phpstan/phpdoc-parser": "^1.28",
"symfony/asset": "6.1.*",
@ -42,6 +43,7 @@
"symfony/web-link": "6.1.*",
"symfony/webpack-encore-bundle": "^1.17",
"symfony/yaml": "6.1.*",
"symfonycasts/reset-password-bundle": "^1.22",
"symfonycasts/verify-email-bundle": "^1.17",
"twig/extra-bundle": "^2.12|^3.0",
"twig/twig": "^2.12|^3.0"

297
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "f9827a90d38bc8fd6f97e651d6298db0",
"content-hash": "fbec70f426422bb2239be4fa6216fb5a",
"packages": [
{
"name": "amphp/amp",
@ -2203,6 +2203,101 @@
},
"time": "2023-08-16T21:49:04+00:00"
},
{
"name": "easycorp/easyadmin-bundle",
"version": "v4.10.4",
"source": {
"type": "git",
"url": "https://github.com/EasyCorp/EasyAdminBundle.git",
"reference": "8c697782e59dfbd76e6a8cae69d8d3b96dcdbfa1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/EasyCorp/EasyAdminBundle/zipball/8c697782e59dfbd76e6a8cae69d8d3b96dcdbfa1",
"reference": "8c697782e59dfbd76e6a8cae69d8d3b96dcdbfa1",
"shasum": ""
},
"require": {
"doctrine/doctrine-bundle": "^2.5",
"doctrine/orm": "^2.10|^3.0",
"ext-json": "*",
"php": ">=8.0.2",
"symfony/asset": "^5.4|^6.0|^7.0",
"symfony/cache": "^5.4|^6.0|^7.0",
"symfony/config": "^5.4|^6.0|^7.0",
"symfony/dependency-injection": "^5.4|^6.0|^7.0",
"symfony/deprecation-contracts": "^3.0",
"symfony/doctrine-bridge": "^5.4|^6.0|^7.0",
"symfony/event-dispatcher": "^5.4|^6.0|^7.0",
"symfony/filesystem": "^5.4|^6.0|^7.0",
"symfony/form": "^5.4|^6.0|^7.0",
"symfony/framework-bundle": "^5.4|^6.0|^7.0",
"symfony/http-foundation": "^5.4|^6.0|^7.0",
"symfony/http-kernel": "^5.4|^6.0|^7.0",
"symfony/intl": "^5.4|^6.0|^7.0",
"symfony/property-access": "^5.4|^6.0|^7.0",
"symfony/security-bundle": "^5.4|^6.0|^7.0",
"symfony/string": "^5.4|^6.0|^7.0",
"symfony/translation": "^5.4|^6.0|^7.0",
"symfony/twig-bundle": "^5.4|^6.0|^7.0",
"symfony/uid": "^5.4|^6.0|^7.0",
"symfony/validator": "^5.4|^6.0|^7.0"
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.4|3.5.x-dev",
"phpstan/extension-installer": "^1.2",
"phpstan/phpstan": "^1.9",
"phpstan/phpstan-phpunit": "^1.2",
"phpstan/phpstan-strict-rules": "^1.4",
"phpstan/phpstan-symfony": "^1.2",
"psr/log": "^1.0",
"symfony/browser-kit": "^5.4|^6.0|^7.0",
"symfony/css-selector": "^5.4|^6.0|^7.0",
"symfony/debug-bundle": "^5.4|^6.0|^7.0",
"symfony/dom-crawler": "^5.4|^6.0|^7.0",
"symfony/expression-language": "^5.4|^6.0|^7.0",
"symfony/phpunit-bridge": "^5.4|^6.0|^7.0"
},
"type": "symfony-bundle",
"extra": {
"branch-alias": {
"dev-master": "4.0.x-dev"
}
},
"autoload": {
"psr-4": {
"EasyCorp\\Bundle\\EasyAdminBundle\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Project Contributors",
"homepage": "https://github.com/EasyCorp/EasyAdminBundle/graphs/contributors"
}
],
"description": "Admin generator for Symfony applications",
"homepage": "https://github.com/EasyCorp/EasyAdminBundle",
"keywords": [
"admin",
"backend",
"generator"
],
"support": {
"issues": "https://github.com/EasyCorp/EasyAdminBundle/issues",
"source": "https://github.com/EasyCorp/EasyAdminBundle/tree/v4.10.4"
},
"funding": [
{
"url": "https://github.com/javiereguiluz",
"type": "github"
}
],
"time": "2024-07-12T18:15:07+00:00"
},
{
"name": "egulias/email-validator",
"version": "4.0.2",
@ -6361,6 +6456,85 @@
],
"time": "2024-01-29T20:11:03+00:00"
},
{
"name": "symfony/polyfill-uuid",
"version": "v1.30.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-uuid.git",
"reference": "2ba1f33797470debcda07fe9dce20a0003df18e9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-uuid/zipball/2ba1f33797470debcda07fe9dce20a0003df18e9",
"reference": "2ba1f33797470debcda07fe9dce20a0003df18e9",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"provide": {
"ext-uuid": "*"
},
"suggest": {
"ext-uuid": "For best performance"
},
"type": "library",
"extra": {
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Uuid\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Grégoire Pineau",
"email": "lyrixx@lyrixx.info"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for uuid functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"polyfill",
"portable",
"uuid"
],
"support": {
"source": "https://github.com/symfony/polyfill-uuid/tree/v1.30.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-05-31T15:07:36+00:00"
},
{
"name": "symfony/process",
"version": "v6.1.11",
@ -7881,6 +8055,80 @@
],
"time": "2023-01-01T08:36:55+00:00"
},
{
"name": "symfony/uid",
"version": "v6.1.11",
"source": {
"type": "git",
"url": "https://github.com/symfony/uid.git",
"reference": "7c53913df24517eb5e0fab4caf294e84fcecc277"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/uid/zipball/7c53913df24517eb5e0fab4caf294e84fcecc277",
"reference": "7c53913df24517eb5e0fab4caf294e84fcecc277",
"shasum": ""
},
"require": {
"php": ">=8.1",
"symfony/polyfill-uuid": "^1.15"
},
"require-dev": {
"symfony/console": "^5.4|^6.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\Uid\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Grégoire Pineau",
"email": "lyrixx@lyrixx.info"
},
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Provides an object-oriented API to generate and represent UIDs",
"homepage": "https://symfony.com",
"keywords": [
"UID",
"ulid",
"uuid"
],
"support": {
"source": "https://github.com/symfony/uid/tree/v6.1.11"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2023-01-01T08:36:55+00:00"
},
{
"name": "symfony/validator",
"version": "v6.1.11",
@ -8387,6 +8635,53 @@
],
"time": "2023-01-10T18:53:01+00:00"
},
{
"name": "symfonycasts/reset-password-bundle",
"version": "v1.22.0",
"source": {
"type": "git",
"url": "https://github.com/SymfonyCasts/reset-password-bundle.git",
"reference": "d9cf4395c0a19a3093bc51b10f508b38f98117f5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/SymfonyCasts/reset-password-bundle/zipball/d9cf4395c0a19a3093bc51b10f508b38f98117f5",
"reference": "d9cf4395c0a19a3093bc51b10f508b38f98117f5",
"shasum": ""
},
"require": {
"ext-json": "*",
"php": ">=8.1.10",
"symfony/config": "^5.4 | ^6.0 | ^7.0",
"symfony/dependency-injection": "^5.4 | ^6.0 | ^7.0",
"symfony/deprecation-contracts": "^2.2 | ^3.0",
"symfony/http-kernel": "^5.4 | ^6.0 | ^7.0"
},
"require-dev": {
"doctrine/annotations": "^1.0",
"doctrine/doctrine-bundle": "^2.8",
"doctrine/orm": "^2.13",
"phpstan/phpstan": "^1.11.x-dev",
"symfony/framework-bundle": "^5.4 | ^6.0 | ^7.0",
"symfony/phpunit-bridge": "^5.4 | ^6.0 | ^7.0"
},
"type": "symfony-bundle",
"autoload": {
"psr-4": {
"SymfonyCasts\\Bundle\\ResetPassword\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Symfony bundle that adds password reset functionality.",
"support": {
"issues": "https://github.com/SymfonyCasts/reset-password-bundle/issues",
"source": "https://github.com/SymfonyCasts/reset-password-bundle/tree/v1.22.0"
},
"time": "2024-06-06T11:59:57+00:00"
},
{
"name": "symfonycasts/verify-email-bundle",
"version": "v1.17.0",

View File

@ -14,4 +14,6 @@ return [
SymfonyCasts\Bundle\VerifyEmail\SymfonyCastsVerifyEmailBundle::class => ['all' => true],
Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle::class => ['all' => true],
SymfonyCasts\Bundle\ResetPassword\SymfonyCastsResetPasswordBundle::class => ['all' => true],
];

View File

@ -0,0 +1,5 @@
symfonycasts_reset_password:
# Replace symfonycasts.reset_password.fake_request_repository with the full
# namespace of the password reset request repository after it has been created.
# i.e. App\Repository\ResetPasswordRequestRepository
request_password_repository: symfonycasts.reset_password.fake_request_repository

View File

@ -52,7 +52,7 @@ security:
# Easy way to control access for large sections of your site
# Note: Only the *first* access control that matches will be used
access_control:
- { path: ^/admin, roles: ROLE_ADMIN }
# - { path: ^/admin, roles: ROLE_ADMIN }
- { path: ^/profile, roles: ROLE_USER }
- { path: ^/account, roles: ROLE_USER }

View File

@ -0,0 +1,56 @@
<?php
namespace App\Controller\Admin;
use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use UserCrudController;
use App\Entity\User;
class DashboardController extends AbstractDashboardController
{
#[Route('/admin', name: 'admin')]
public function index(): Response
{
// return parent::index();
// Option 1. You can make your dashboard redirect to some common page of your backend
//
// $adminUrlGenerator = $this->container->get(AdminUrlGenerator::class);
// Option 1. Make your dashboard redirect to the same page for all users
// return $this->redirect($adminUrlGenerator->setController(UserCrudController::class)->generateUrl());
// Option 2. You can make your dashboard redirect to different pages depending on the user
//
// if ('jane' === $this->getUser()->getUsername()) {
// return $this->redirect('...');
// }
// Option 3. You can render some custom template to display a proper dashboard with widgets, etc.
// (tip: it's easier if your template extends from @EasyAdmin/page/content.html.twig)
//
return $this->render('admin/dashboard.html.twig');
}
public function configureDashboard(): Dashboard
{
return Dashboard::new()
->setTitle('Caisse');
}
public function configureMenuItems(): iterable
{
return [
MenuItem::linkToDashboard('Dashboard', 'fa fa-home'),
MenuItem::section('Users'),
MenuItem::linkToCrud('Users', 'fa fa-user', User::class),
];
}
}

View File

@ -0,0 +1,49 @@
<?php
namespace App\Controller\Admin;
use App\Entity\User;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
class UserCrudController extends AbstractCrudController
{
public static function getEntityFqcn(): string
{
return User::class;
}
public function configureCrud(Crud $crud): Crud
{
return $crud
// set this option if you prefer the page content to span the entire
// browser width, instead of the default design which sets a max width
->renderContentMaximized()
// set this option if you prefer the sidebar (which contains the main menu)
// to be displayed as a narrow column instead of the default expanded design
// ->renderSidebarMinimized()
;
}
public function configureMenuItems(): iterable
{
return[
MenuItem::linkToCrud('Categories', 'fa fa-tags', Category::class),
MenuItem::section('Users'),
];
}
public function configureFields(string $pageName): iterable
{
return [
IdField::new('id'),
TextField::new('email'),
TextEditorField::new('description'),
TextEditorField::new('last_login'),
];
}
}

View File

@ -9,8 +9,17 @@ class AppFixtures extends Fixture
{
public function load(ObjectManager $manager): void
{
// $product = new Product();
// $manager->persist($product);
$product = new Product();
$product->setName('Un Livre d\'exemple');
$demo_user = new User();
$demo_user->setEmail('contact+admin@cipherbliss.com')->setRoles('ROLE_ADMIN')->addProduct($product);
$manager->persist($product);
$manager->persist($demo_user);
$manager->flush();
}

View File

@ -38,6 +38,15 @@
"migrations/.gitignore"
]
},
"easycorp/easyadmin-bundle": {
"version": "4.10",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "3.0",
"ref": "b131e6cbfe1b898a508987851963fff485986285"
}
},
"phpstan/phpstan": {
"version": "1.11",
"recipe": {
@ -298,6 +307,18 @@
"webpack.config.js"
]
},
"symfonycasts/reset-password-bundle": {
"version": "1.22",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "1.0",
"ref": "97c1627c0384534997ae1047b93be517ca16de43"
},
"files": [
"config/packages/reset_password.yaml"
]
},
"symfonycasts/verify-email-bundle": {
"version": "v1.17.0"
},

View File

@ -0,0 +1,7 @@
{% extends '@EasyAdmin/layout.html.twig' %}
{% block main %}
<h1>Coucou le dashboard</h1>
{% endblock main %}