Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a596e76

Browse files
committed
Added some common page templates (login form, content page, blank page)
1 parent 700b674 commit a596e76

38 files changed

Lines changed: 608 additions & 6 deletions

assets/css/app.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@
3939
@import "./easyadmin-theme/switches.scss";
4040
@import "./easyadmin-theme/select2.scss";
4141
@import "./easyadmin-theme/errors.scss";
42+
@import "./easyadmin-theme/pages.scss";
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Page templates available or custom backends
2+
// ----------------------------------------------------------------------------
3+
4+
body.page-login {
5+
align-items: center;
6+
display: flex;
7+
height: 100vh;
8+
justify-content: center;
9+
overflow: hidden;
10+
position: absolute;
11+
width: 100vw;
12+
}
13+
14+
.login-wrapper {
15+
align-items: center;
16+
display: flex;
17+
flex-direction: column;
18+
text-align: center;
19+
width: 330px;
20+
}
21+
.login-wrapper .main-header {
22+
display: block;
23+
padding-right: 0;
24+
}
25+
.login-wrapper .main-header #header-logo {
26+
font-size: 24px;
27+
line-height: 1.2;
28+
}
29+
.login-wrapper .content {
30+
padding: 30px 20px;
31+
width: 100%;
32+
}
33+
.login-wrapper .form-widget {
34+
flex: 100%;
35+
padding-left: 0;
36+
}
37+
.login-wrapper .form-widget input {
38+
font-size: var(--font-size-lg);
39+
height: 38px;
40+
}
41+
42+
.page-blank .content-wrapper {
43+
display: block;
44+
}
45+
46+
.page-content-with-padding .content-body {
47+
padding: 18px 20px;
48+
}

doc/book/complex-dynamic-backends.rst

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,5 +548,84 @@ property of the ``BlogPost`` entity before persisting it:
548548
}
549549
}
550550
551+
Page Templates for Custom Backends
552+
----------------------------------
553+
554+
EasyAdmin provides several page templates which are useful when you are
555+
customizing your backends.
556+
557+
Login Form Template
558+
~~~~~~~~~~~~~~~~~~~
559+
560+
Twig Template Path: ``@EasyAdmin/page/login.html.twig``
561+
562+
It displays a simple username + password login form that matches the style of
563+
the rest of the backend. The template defines lots of config options, but most
564+
apps can rely on its default values:
565+
566+
.. code-block:: php
567+
568+
namespace App\Controller;
569+
570+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
571+
use Symfony\Component\HttpFoundation\Response;
572+
use Symfony\Component\Routing\Annotation\Route;
573+
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
574+
575+
class SecurityController extends AbstractController
576+
{
577+
/**
578+
* @Route("/login", name="login")
579+
*/
580+
public function login(AuthenticationUtils $authenticationUtils): Response
581+
{
582+
$error = $authenticationUtils->getLastAuthenticationError();
583+
$lastUsername = $authenticationUtils->getLastUsername();
584+
585+
return $this->render('@EasyAdmin/page/login.html.twig', [
586+
// parameters usually defined in Symfony login forms
587+
'error' => $error,
588+
'last_username' => $lastUsername,
589+
590+
// OPTIONAL parameters to customize the login form:
591+
592+
// the string used to generate the CSRF token. If you don't define
593+
// this parameter, the login form won't include a CSRF token
594+
'csrf_token_intention' => 'authenticate',
595+
// the URL users are redirected to after the login (default: path('easyadmin'))
596+
'target_path' => $this->generateUrl('admin_dashboard'),
597+
// the label displayed for the username form field (the |trans filter is applied to it)
598+
'username_label' => 'Your username',
599+
// the label displayed for the password form field (the |trans filter is applied to it)
600+
'password_label' => 'Your password',
601+
// the label displayed for the Sign In form button (the |trans filter is applied to it)
602+
'sign_in_label' => 'Log in',
603+
// the 'name' HTML attribute of the <input> used for the username field (default: '_username')
604+
'username_parameter' => 'my_custom_username_field',
605+
// the 'name' HTML attribute of the <input> used for the password field (default: '_password')
606+
'password_parameter' => 'my_custom_password_field',
607+
]);
608+
}
609+
}
610+
611+
Content Page Template
612+
~~~~~~~~~~~~~~~~~~~~~
613+
614+
Twig Template Path: ``@EasyAdmin/page/content.html.twig``
615+
616+
It displays a simple page similar to the list/show/edit/new pages, with the
617+
main header, the sidebar menu and the central content section. The only
618+
difference is that the content section is completely empty, so it's useful to
619+
display your own text contents, custom forms, etc.
620+
621+
Blank Page Template
622+
~~~~~~~~~~~~~~~~~~~
623+
624+
Twig Template Path: ``@EasyAdmin/page/blank.html.twig``
625+
626+
It displays a page with the same header and sidebar menu as the
627+
list/show/edit/new pages, but without the central content section. It's useful
628+
to define completely custom page, such as a complex dashboard.
629+
551630
.. _`the base Symfony controller`: https://symfony.com/doc/current/book/controller.html#the-base-controller-class
552631
.. _`GenericEvent class`: https://symfony.com/doc/current/components/event_dispatcher/generic_event.html

src/Resources/public/app.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Resources/public/app.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Resources/translations/EasyAdminBundle.ar.xlf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,20 @@
147147
<source>show.remaining_items</source>
148148
<target><![CDATA[{1} هناك عنصر آخر لم يتم عرضه في هذه القائمة|]1,Inf] عنصر آخر لم يتم عرضه في هذه القائمة %count% ]]></target>
149149
</trans-unit>
150+
151+
<!-- Login page -->
152+
<trans-unit id="login.username">
153+
<source>login.username</source>
154+
<target>Username</target>
155+
</trans-unit>
156+
<trans-unit id="login.password">
157+
<source>login.password</source>
158+
<target>Password</target>
159+
</trans-unit>
160+
<trans-unit id="login.sign_in">
161+
<source>login.sign_in</source>
162+
<target>Sign in</target>
163+
</trans-unit>
150164
</body>
151165
</file>
152166
</xliff>

src/Resources/translations/EasyAdminBundle.bg.xlf

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
<source>user.exit_impersonation</source>
118118
<target>Изход от представянето</target>
119119
</trans-unit>
120-
120+
121121
<!-- misc. elements -->
122122
<trans-unit id="delete_modal.title">
123123
<source>delete_modal.title</source>
@@ -185,6 +185,20 @@
185185
<source>exception.undefined_entity</source>
186186
<target>Приложението не е конфигурирано правилно за този вид елементи.</target>
187187
</trans-unit>
188+
189+
<!-- Login page -->
190+
<trans-unit id="login.username">
191+
<source>login.username</source>
192+
<target>Потребителско има</target>
193+
</trans-unit>
194+
<trans-unit id="login.password">
195+
<source>login.password</source>
196+
<target>Парола</target>
197+
</trans-unit>
198+
<trans-unit id="login.sign_in">
199+
<source>login.sign_in</source>
200+
<target>Вход</target>
201+
</trans-unit>
188202
</body>
189203
</file>
190204
</xliff>

src/Resources/translations/EasyAdminBundle.ca.xlf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,20 @@
135135
<source>errors</source>
136136
<target>Error|Errors</target>
137137
</trans-unit>
138+
139+
<!-- Login page -->
140+
<trans-unit id="login.username">
141+
<source>login.username</source>
142+
<target>Nom d'usuari</target>
143+
</trans-unit>
144+
<trans-unit id="login.password">
145+
<source>login.password</source>
146+
<target>Contrasenya</target>
147+
</trans-unit>
148+
<trans-unit id="login.sign_in">
149+
<source>login.sign_in</source>
150+
<target>Iniciar sessió</target>
151+
</trans-unit>
138152
</body>
139153
</file>
140154
</xliff>

src/Resources/translations/EasyAdminBundle.cs.xlf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,20 @@
147147
<source>errors</source>
148148
<target>Chyba|Chyby</target>
149149
</trans-unit>
150+
151+
<!-- Login page -->
152+
<trans-unit id="login.username">
153+
<source>login.username</source>
154+
<target>Login</target>
155+
</trans-unit>
156+
<trans-unit id="login.password">
157+
<source>login.password</source>
158+
<target>Heslo</target>
159+
</trans-unit>
160+
<trans-unit id="login.sign_in">
161+
<source>login.sign_in</source>
162+
<target>Přihlásit</target>
163+
</trans-unit>
150164
</body>
151165
</file>
152166
</xliff>

src/Resources/translations/EasyAdminBundle.da.xlf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,20 @@
177177
<source>exception.undefined_entity</source>
178178
<target>Applikationen er ikke korrekt konfigureret for denne type emner.</target>
179179
</trans-unit>
180+
181+
<!-- Login page -->
182+
<trans-unit id="login.username">
183+
<source>login.username</source>
184+
<target>Username</target>
185+
</trans-unit>
186+
<trans-unit id="login.password">
187+
<source>login.password</source>
188+
<target>Password</target>
189+
</trans-unit>
190+
<trans-unit id="login.sign_in">
191+
<source>login.sign_in</source>
192+
<target>Sign in</target>
193+
</trans-unit>
180194
</body>
181195
</file>
182196
</xliff>

0 commit comments

Comments
 (0)