mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +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;
|
||||
|
||||
use App\DataTables\LogDataTable;
|
||||
use App\Entity\Attachments\UserAttachment;
|
||||
use App\Entity\UserSystem\User;
|
||||
use App\Events\SecurityEvent;
|
||||
|
@ -53,6 +54,7 @@ use App\Services\EntityImporter;
|
|||
use App\Services\StructuralElementRecursionHelper;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use InvalidArgumentException;
|
||||
use Omines\DataTablesBundle\DataTableFactory;
|
||||
use Symfony\Component\Asset\Packages;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
@ -163,7 +165,7 @@ class UserController extends AdminPages\BaseAdminController
|
|||
*
|
||||
* @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 (null === $user) {
|
||||
|
@ -177,6 +179,21 @@ class UserController extends AdminPages\BaseAdminController
|
|||
$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')) {
|
||||
$avatar = $this->getGravatar($user->getEmail(), 200, 'identicon');
|
||||
} else {
|
||||
|
@ -195,6 +212,7 @@ class UserController extends AdminPages\BaseAdminController
|
|||
'user' => $user,
|
||||
'avatar' => $avatar,
|
||||
'form' => $builder->getForm()->createView(),
|
||||
'datatable' => $table,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ use Omines\DataTablesBundle\Column\TextColumn;
|
|||
use Omines\DataTablesBundle\DataTable;
|
||||
use Omines\DataTablesBundle\DataTableTypeInterface;
|
||||
use Psr\Log\LogLevel;
|
||||
use Symfony\Component\OptionsResolver\Options;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
@ -98,6 +99,16 @@ class LogDataTable implements DataTableTypeInterface
|
|||
'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']);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,14 +62,20 @@
|
|||
|
||||
{% block additional_content %}
|
||||
{% if is_granted('read', user) or is_granted('show_permissions', user) %}
|
||||
<div class="card mt-3">
|
||||
<div class="card-header"><i class="fas fa-gavel fa-fw"></i>
|
||||
{% trans %}user.permissions{% endtrans %}</div>
|
||||
<div class="card-body">
|
||||
{{ form_start(form) }}
|
||||
{{ form_row(form.permissions) }}
|
||||
{{ form_end(form) }}
|
||||
<div class="card mt-3">
|
||||
<div class="card-header"><i class="fas fa-gavel fa-fw"></i>
|
||||
{% trans %}user.permissions{% endtrans %}</div>
|
||||
<div class="card-body">
|
||||
{{ form_start(form) }}
|
||||
{{ form_row(form.permissions) }}
|
||||
{{ form_end(form) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="mt-2">
|
||||
{% if datatable is defined and datatable is not null %}
|
||||
{% include "LogSystem/_log_table.html.twig" %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
Loading…
Add table
Add a link
Reference in a new issue