-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d7b3c2f
commit 0c7d3d8
Showing
4 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
namespace App\Controller; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
|
||
use Doctrine\ORM\EntityManagerInterface; | ||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | ||
use Symfony\Contracts\Translation\TranslatorInterface; | ||
|
||
use App\Entity\Domains; | ||
|
||
use App\Repository\DomainsRepository; | ||
|
||
class DomainsController extends AbstractController | ||
{ | ||
private $em; | ||
private $router; | ||
private $translator; | ||
|
||
public function __construct(EntityManagerInterface $em, UrlGeneratorInterface $router, TranslatorInterface $translator) | ||
{ | ||
$this->em = $em; | ||
$this->router = $router; | ||
$this->translator = $translator; | ||
} | ||
|
||
#[Route('/domains', name: 'app_domains')] | ||
public function index(): Response | ||
{ | ||
$this->denyAccessUnlessGranted('ROLE_ADMIN'); | ||
|
||
$pages=array("page"=>1,"next" => false,"prev" => false); | ||
|
||
if(isset($_GET["page"]) && $_GET["page"] > 0) | ||
{ | ||
$pages["page"] = intval($_GET["page"]); | ||
} else { | ||
$pages["page"] = 1; | ||
} | ||
|
||
if(isset($_GET["perpage"]) && $_GET["perpage"] > 0) | ||
{ | ||
$pages["perpage"] = intval($_GET["perpage"]); | ||
} else { | ||
$pages["perpage"] = 17; | ||
} | ||
|
||
$repository = $this->em->getRepository(Domains::class); | ||
$domains = $repository->findAll(array(),array('fqdn' => 'DESC'),$pages["perpage"], ($pages["page"]-1)*$pages["perpage"]); | ||
$totaldomains = $repository->getTotalRows(); | ||
|
||
if(count($domains) == 0 && $totaldomains != 0 ) { return $this->redirectToRoute('app_domains'); } | ||
|
||
if($totaldomains/$pages["perpage"] > $pages["page"]) { $pages["next"] = true; } | ||
if($pages["page"]-1 > 0) { $pages["prev"] = true; } | ||
|
||
return $this->render('domains/index.html.twig', [ | ||
'domains' => $domains, | ||
'pages' => $pages, | ||
'menuactive' => 'domains', | ||
'breadcrumbs' => array('0' => array('name' => $this->translator->trans("Domains"), 'url' => $this->router->generate('app_domains'))), | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{% extends 'base.html.twig' %} | ||
|
||
{% block title %}Domains{% endblock %} | ||
|
||
{% block body %} | ||
<div class="row"> | ||
<div class="col-12 col-xl-12 mb-4 mb-lg-0"> | ||
<div class="card"> | ||
<h5 class="card-header">Domains</h5> | ||
<div class="card-body"> | ||
<div class="table-responsive"> | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th scope="col">Id</th> | ||
<th scope="col">Domain FQDN</th> | ||
<th scope="col">Total reports</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for domain in domains %} | ||
<tr> | ||
<th scope="row">{{ domain.id }}</th> | ||
<td>{{ domain.fqdn }}</td> | ||
<td>{{ domain.reports|length }}</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
</div> | ||
<div class="clearfix"> | ||
<span class="float-start"> </span> | ||
<span class="float-end"> | ||
{% if pages.prev %} | ||
<a href="{{ path('app_logs', {page: pages.page - 1, perpage: pages.perpage }) }}" class="btn btn-sm btn-secondary"><</a> | ||
{% else %} | ||
<a href="#" class="btn btn-sm btn-light" disabled><</a> | ||
{% endif %} | ||
{% if pages.next %} | ||
<a href="{{ path('app_logs', {page: pages.page + 1, perpage: pages.perpage }) }}" class="btn btn-sm btn-secondary">></a> | ||
{% else %} | ||
<a href="#" class="btn btn-sm btn-light" disabled>></a> | ||
{% endif %} | ||
</span> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} |