mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 17:39:06 +02:00
Show user history in user info page.
This commit is contained in:
parent
fe958781ea
commit
fca2ad9d99
3 changed files with 44 additions and 9 deletions
|
@ -42,6 +42,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\DataTables\LogDataTable;
|
||||||
use App\Entity\Attachments\UserAttachment;
|
use App\Entity\Attachments\UserAttachment;
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
use App\Events\SecurityEvent;
|
use App\Events\SecurityEvent;
|
||||||
|
@ -53,6 +54,7 @@ use App\Services\EntityImporter;
|
||||||
use App\Services\StructuralElementRecursionHelper;
|
use App\Services\StructuralElementRecursionHelper;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
|
use Omines\DataTablesBundle\DataTableFactory;
|
||||||
use Symfony\Component\Asset\Packages;
|
use Symfony\Component\Asset\Packages;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
@ -163,7 +165,7 @@ class UserController extends AdminPages\BaseAdminController
|
||||||
*
|
*
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function userInfo(?User $user, Packages $packages): Response
|
public function userInfo(?User $user, Packages $packages, Request $request, DataTableFactory $dataTableFactory): Response
|
||||||
{
|
{
|
||||||
//If no user id was passed, then we show info about the current user
|
//If no user id was passed, then we show info about the current user
|
||||||
if (null === $user) {
|
if (null === $user) {
|
||||||
|
@ -177,6 +179,21 @@ class UserController extends AdminPages\BaseAdminController
|
||||||
$this->denyAccessUnlessGranted('read', $user);
|
$this->denyAccessUnlessGranted('read', $user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$table = $this->dataTableFactory->createFromType(
|
||||||
|
LogDataTable::class,
|
||||||
|
[
|
||||||
|
'filter_elements' => $user,
|
||||||
|
'mode' => 'element_history',
|
||||||
|
],
|
||||||
|
['pageLength' => 10]
|
||||||
|
)
|
||||||
|
->handleRequest($request);
|
||||||
|
|
||||||
|
if ($table->isCallback()) {
|
||||||
|
return $table->getResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($this->getParameter('use_gravatar')) {
|
if ($this->getParameter('use_gravatar')) {
|
||||||
$avatar = $this->getGravatar($user->getEmail(), 200, 'identicon');
|
$avatar = $this->getGravatar($user->getEmail(), 200, 'identicon');
|
||||||
} else {
|
} else {
|
||||||
|
@ -195,6 +212,7 @@ class UserController extends AdminPages\BaseAdminController
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
'avatar' => $avatar,
|
'avatar' => $avatar,
|
||||||
'form' => $builder->getForm()->createView(),
|
'form' => $builder->getForm()->createView(),
|
||||||
|
'datatable' => $table,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,7 @@ use Omines\DataTablesBundle\Column\TextColumn;
|
||||||
use Omines\DataTablesBundle\DataTable;
|
use Omines\DataTablesBundle\DataTable;
|
||||||
use Omines\DataTablesBundle\DataTableTypeInterface;
|
use Omines\DataTablesBundle\DataTableTypeInterface;
|
||||||
use Psr\Log\LogLevel;
|
use Psr\Log\LogLevel;
|
||||||
|
use Symfony\Component\OptionsResolver\Options;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||||
use Symfony\Component\Security\Core\Security;
|
use Symfony\Component\Security\Core\Security;
|
||||||
|
@ -98,6 +99,16 @@ class LogDataTable implements DataTableTypeInterface
|
||||||
'filter_elements' => [],
|
'filter_elements' => [],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$optionsResolver->setAllowedTypes('filter_elements', ['array', 'object']);
|
||||||
|
$optionsResolver->setAllowedTypes('mode', 'string');
|
||||||
|
|
||||||
|
$optionsResolver->setNormalizer('filter_elements', function (Options $options, $value) {
|
||||||
|
if (!is_array($value)) {
|
||||||
|
return [$value];
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
});
|
||||||
|
|
||||||
$optionsResolver->setAllowedValues('mode', ['system_log', 'element_history', 'last_activity']);
|
$optionsResolver->setAllowedValues('mode', ['system_log', 'element_history', 'last_activity']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,14 +62,20 @@
|
||||||
|
|
||||||
{% block additional_content %}
|
{% block additional_content %}
|
||||||
{% if is_granted('read', user) or is_granted('show_permissions', user) %}
|
{% if is_granted('read', user) or is_granted('show_permissions', user) %}
|
||||||
<div class="card mt-3">
|
<div class="card mt-3">
|
||||||
<div class="card-header"><i class="fas fa-gavel fa-fw"></i>
|
<div class="card-header"><i class="fas fa-gavel fa-fw"></i>
|
||||||
{% trans %}user.permissions{% endtrans %}</div>
|
{% trans %}user.permissions{% endtrans %}</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
{{ form_start(form) }}
|
{{ form_start(form) }}
|
||||||
{{ form_row(form.permissions) }}
|
{{ form_row(form.permissions) }}
|
||||||
{{ form_end(form) }}
|
{{ form_end(form) }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
<div class="mt-2">
|
||||||
|
{% if datatable is defined and datatable is not null %}
|
||||||
|
{% include "LogSystem/_log_table.html.twig" %}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
Loading…
Add table
Add a link
Reference in a new issue