Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mathieu
potage
Commits
9691c361
Commit
9691c361
authored
Aug 23, 2018
by
Mat
Browse files
optimise les queries utilisateur, et ajoute le role au tableau des utilisateurs
parent
374bd10d
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/APIBundle/Controller/UtilisateurAPIController.php
View file @
9691c361
...
...
@@ -26,7 +26,7 @@ class UtilisateurAPIController extends MasterAPIController
$em
=
$this
->
getDoctrine
()
->
getManager
();
$em
->
persist
(
$utilisateur
);
$em
->
flush
();
return
$this
->
api
(
$utilisateur
);
return
$this
->
api
(
$utilisateur
,
200
,
array
(
'readUtilisateurs'
)
);
}
return
$this
->
api
(
$form
,
Response
::
HTTP_BAD_REQUEST
);
...
...
@@ -66,7 +66,7 @@ class UtilisateurAPIController extends MasterAPIController
if
(
$utilisateur
===
null
)
{
return
$this
->
api
(
'Not found'
,
Response
::
HTTP_NOT_FOUND
);
}
return
$this
->
api
(
$utilisateur
);
return
$this
->
api
(
$utilisateur
,
200
,
array
(
'readUtilisateurs'
)
);
}
...
...
@@ -92,7 +92,7 @@ class UtilisateurAPIController extends MasterAPIController
if
(
$form
->
isSubmitted
()
&&
$form
->
isValid
())
{
$em
->
flush
();
return
$this
->
api
(
$utilisateur
);
return
$this
->
api
(
$utilisateur
,
200
,
array
(
'readUtilisateurs'
)
);
}
return
$this
->
api
(
$form
,
Response
::
HTTP_BAD_REQUEST
);
}
...
...
src/PotageBundle/Entity/User.php
View file @
9691c361
...
...
@@ -30,6 +30,12 @@ class User extends BaseUser
*/
protected
$username
;
/**
* @var string
* @Serializer\Groups({"readUtilisateurs"})
*/
protected
$roles
;
/**
* @var
* @ORM\OneToOne(targetEntity="PotageBundle\Entity\Utilisateur", mappedBy="user")
...
...
src/PotageBundle/Entity/Utilisateur.php
View file @
9691c361
...
...
@@ -49,11 +49,11 @@ class Utilisateur
/**
* @var string
*
* @ORM\Column(name="email", type="string", length=1
0
0, unique=true)
* @ORM\Column(name="email", type="string", length=1
8
0, unique=true)
* @Assert\NotBlank()
* @Assert\Length(
* min = 3,
* max = 1
0
0,
* max = 1
8
0,
* minMessage = "Le champs doit contenir au minimum {{ limit }} caractères",
* maxMessage = "Le champs doit contenir au maximum {{ limit }} caractères"
* )
...
...
@@ -67,14 +67,14 @@ class Utilisateur
/**
* @var string
* @ORM\Column(name="nom", type="string", length=1
0
0)
* @ORM\Column(name="nom", type="string", length=1
8
0)
* @Serializer\Groups({"readUtilisateurs"})
*/
private
$nom
;
/**
* @var string
* @ORM\Column(name="prenom", type="string", length=1
0
0)
* @ORM\Column(name="prenom", type="string", length=1
8
0)
* @Serializer\Groups({"readUtilisateurs"})
*/
private
$prenom
;
...
...
src/PotageBundle/Resources/views/Utilisateur/ajaxDisplay.html.twig
View file @
9691c361
...
...
@@ -87,6 +87,10 @@
<a
href=
"javascript: void(0);"
id=
"email"
class=
"btn-sort"
>
Email
</a>
</th>
<th
scope=
"col"
>
<a
id=
"role"
>
Rôle
</a>
</th>
<th
scope=
"col"
>
<a
id=
"login"
>
Utilisateur associé
</a>
...
...
src/PotageBundle/Resources/views/Utilisateur/ajaxDisplay.js
View file @
9691c361
...
...
@@ -78,6 +78,15 @@ function buildRowUtilisateur(jsonRow)
td4
.
textContent
=
jsonRow
.
email
;
tr
.
appendChild
(
td4
);
let
td8
=
document
.
createElement
(
'
td
'
);
if
(
typeof
jsonRow
.
user
!==
'
undefined
'
)
{
for
(
let
i
=
0
;
i
<
jsonRow
.
user
.
roles
.
length
;
i
++
){
td8
.
textContent
+=
jsonRow
.
user
.
roles
[
i
];
}
td8
.
textContent
+=
jsonRow
.
user
.
roles
.
length
===
0
?
'
ROLE_USER
'
:
''
;
}
tr
.
appendChild
(
td8
);
let
td6
=
document
.
createElement
(
'
td
'
);
td6
.
textContent
=
jsonRow
.
user
?
jsonRow
.
user
.
username
:
''
;
tr
.
appendChild
(
td6
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment