WIP: Implement admin dashboard

This commit is contained in:
Björn Fromme committed 2023-10-22 17:05:43 +02:00
1 parent 38d6fafcb2
commit 91f0f76ccc
15 files changed
+280 -4

No files matched your search

@@ -3,6 +3,7 @@
namespace App\Controller\Admin\Assignment;
use App\Entity\Assignment;
use App\Entity\User;
use App\Form\AssignmentType;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
@@ -24,7 +25,11 @@ class CreateController extends AbstractController
#[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(Request $request): Response
{
/** @var User $user */
$user = $this->getUser();
$assignment = new Assignment();
$assignment->setOwner($user);
$form = $this->createForm(AssignmentType::class, $assignment);
$form->handleRequest($request);
@@ -60,6 +60,16 @@ class CheckController extends AbstractController
case Upload::STATUS_REJECTED:
$this->rejectDocument($document, $formData->getComment());
$this->eventDispatcher->dispatch(new DocumentRejectedEvent($formData), DocumentRejectedEvent::NAME);
default:
$document->setStatus($formData->getStatus());
$this->entityManager->flush();
$this->addFlash('success', 'Der Status wurde aktualisiert');
$this->logger->info('Update document status', [
'document_id' => $document->getId(),
'document_filename' => $document->getOriginalFilename(),
'owner' => $document->getOwner()->getFullName(),
'status' => $formData->getStatus(),
]);
}
$returnUrl = $this->generateUrl('app_admin_document_index');
+36 -1
View File
@@ -2,6 +2,12 @@
namespace App\Controller\Admin;
use App\Entity\Application;
use App\Entity\Upload;
use App\Repository\ApplicationRepository;
use App\Repository\AssignmentRepository;
use App\Repository\AvailabilityRepository;
use App\Repository\UploadRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
@@ -9,10 +15,39 @@ use Symfony\Component\Security\Http\Attribute\IsGranted;
class IndexController extends AbstractController
{
public function __construct(
private readonly ApplicationRepository $applicationRepository,
private readonly AssignmentRepository $assignmentRepository,
private readonly AvailabilityRepository $availabilityRepository,
private readonly UploadRepository $uploadRepository
) {
}
#[Route('/admin', name: 'app_admin_index')]
#[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(): Response
{
return $this->render('admin/index.html.twig');
$applications = $this->applicationRepository->getNew();
$newApplicationsCount = $this->applicationRepository->getCountByStatus(Application::STATUS_NEW);
$pendingApplicationsCount = $this->applicationRepository->getCountByStatus(Application::STATUS_PENDING);
$assignments = $this->assignmentRepository->getNew();
$availabilities = $this->availabilityRepository->getNew();
$documents = $this->uploadRepository->getNew();
$newDocumentsCount = $this->uploadRepository->getCountByStatus(Upload::STATUS_NEW);
$pendingDocumentsCount = $this->uploadRepository->getCountByStatus(Upload::STATUS_PENDING);
return $this->render('admin/index.html.twig', [
'applications' => $applications,
'newApplicationsCount' => $newApplicationsCount,
'pendingApplicationsCount' => $pendingApplicationsCount,
'assignments' => $assignments,
'availabilities' => $availabilities,
'documents' => $documents,
'newDocumentsCount' => $newDocumentsCount,
'pendingDocumentsCount' => $pendingDocumentsCount,
]);
}
}