Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0.7.1: Added login / logout concepts, admin-dependent menu items and …
…columns
- Loading branch information
Showing
12 changed files
with
592 additions
and
60 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
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,64 @@ | ||
<?php | ||
namespace App\Controller; | ||
|
||
use App\Repository\ModeRepository; | ||
use App\Repository\SystemRepository; | ||
use App\Utils\Rxx; | ||
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
use Symfony\Component\HttpFoundation\Session\SessionInterface; | ||
|
||
/** | ||
* Class BaseController | ||
* @package App\Controller | ||
*/ | ||
class BaseController extends Controller { | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $parameters = []; | ||
|
||
/** | ||
* @var ModeRepository | ||
*/ | ||
protected $modeRepository; | ||
|
||
/** | ||
* @var Rxx | ||
*/ | ||
protected $rxx; | ||
|
||
/** | ||
* @var SessionInterface | ||
*/ | ||
protected $session; | ||
|
||
/** | ||
* @var SystemRepository | ||
*/ | ||
protected $systemRepository; | ||
|
||
/** | ||
* BaseController constructor. | ||
* @param ModeRepository $modeRepository | ||
* @param Rxx $rxx | ||
* @param SystemRepository $systemRepository | ||
* @param SessionInterface $session | ||
*/ | ||
public function __construct( | ||
ModeRepository $modeRepository, | ||
Rxx $rxx, | ||
SystemRepository $systemRepository, | ||
SessionInterface $session | ||
) { | ||
$this->modeRepository = $modeRepository; | ||
$this->rxx = $rxx; | ||
$this->systemRepository = $systemRepository; | ||
$this->session = $session; | ||
$this->parameters = [ | ||
'isAdmin' => $session->get('isAdmin', 0), | ||
'modes' => $modeRepository->getAll(), | ||
'systems' => $systemRepository->getAll(), | ||
]; | ||
} | ||
} |
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,89 @@ | ||
<?php | ||
namespace App\Controller; | ||
|
||
use App\Form\ListenerList as ListenerListForm; | ||
use App\Repository\ListenerRepository; | ||
use App\Utils\Rxx; | ||
use Symfony\Component\Routing\Annotation\Route; // Required for annotations | ||
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
/** | ||
* Class ListenerList | ||
* @package App\Controller | ||
*/ | ||
class Logoff extends BaseController { | ||
|
||
/** | ||
* @Route( | ||
* "/{system}/logoff", | ||
* requirements={ | ||
* "system": "reu|rna|rww" | ||
* }, | ||
* name="logoff" | ||
* ) | ||
*/ | ||
public function logoffController( | ||
$system, | ||
Request $request, | ||
ListenerListForm $form, | ||
ListenerRepository $listenerRepository | ||
) { | ||
if ($this->session->get('isAdmin', 0)) { | ||
$this->session->set('isAdmin', 0); | ||
return $this->redirectToRoute('logoff', ['system' => $system]); | ||
} | ||
$options = [ | ||
'system' => $system | ||
]; | ||
$form = $form->buildForm($this->createFormBuilder(), $options); | ||
$form->handleRequest($request); | ||
$args = [ | ||
'filter' => '', | ||
'types' => [], | ||
'country' => '', | ||
'region' => '', | ||
'sort' => 'name', | ||
'order' => 'a' | ||
]; | ||
if ($form->isSubmitted() && $form->isValid()) { | ||
$args = $form->getData(); | ||
// print $this->rxx::y($args); | ||
} | ||
$total = $listenerRepository->getTotalListeners($system); | ||
$showingAll = ( | ||
empty($args['filter']) && | ||
empty($args['country']) && | ||
empty($args['region']) | ||
); | ||
if (empty($args['types'])) { | ||
$args['types'][] = 'type_NDB'; | ||
} | ||
$filtered = $listenerRepository->getFilteredListeners($system, $args); | ||
$matched = | ||
($showingAll ? | ||
"(Showing all $total listeners)" | ||
: | ||
"(Showing ".count($filtered)." of $total listeners)" | ||
); | ||
$parameters = [ | ||
'args' => $args, | ||
'columns' => $listenerRepository->getColumns(), | ||
'form' => $form->createView(), | ||
'listeners' => $filtered, | ||
'matched' => $matched, | ||
'mode' => 'Listeners List', | ||
'system' => $system, | ||
'text' => | ||
"<ul>\n" | ||
." <li>Log and station counts are updated each time new log data is added - " | ||
."figures are for logs in the system at this time.</li>\n" | ||
." <li>To see stats for different types of signals, check the boxes shown for 'Types' below.</li>\n" | ||
." <li>This report prints best in Portrait.</li>\n" | ||
."</ul>\n", | ||
]; | ||
$parameters = array_merge($parameters, $this->parameters); | ||
return $this->render('listeners/index.html.twig', $parameters); | ||
} | ||
|
||
} |
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,90 @@ | ||
<?php | ||
namespace App\Controller; | ||
|
||
use App\Form\ListenerList as ListenerListForm; | ||
use App\Repository\ListenerRepository; | ||
use App\Utils\Rxx; | ||
use Symfony\Component\Routing\Annotation\Route; // Required for annotations | ||
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
/** | ||
* Class ListenerList | ||
* @package App\Controller | ||
*/ | ||
class Logon extends BaseController { | ||
|
||
/** | ||
* @Route( | ||
* "/{system}/logon", | ||
* requirements={ | ||
* "system": "reu|rna|rww" | ||
* }, | ||
* name="logon" | ||
* ) | ||
*/ | ||
public function logonController( | ||
$system, | ||
Request $request, | ||
ListenerListForm $form, | ||
ListenerRepository $listenerRepository | ||
) { | ||
if (!$this->session->get('isAdmin', 0)) { | ||
$this->session->set('isAdmin', 1); | ||
return $this->redirectToRoute('logon', ['system' => $system]); | ||
} | ||
$options = [ | ||
'system' => $system | ||
]; | ||
$form = $form->buildForm($this->createFormBuilder(), $options); | ||
$form->handleRequest($request); | ||
$args = [ | ||
'filter' => '', | ||
'types' => [], | ||
'country' => '', | ||
'region' => '', | ||
'sort' => 'name', | ||
'order' => 'a' | ||
]; | ||
if ($form->isSubmitted() && $form->isValid()) { | ||
$args = $form->getData(); | ||
// print $this->rxx::y($args); | ||
} | ||
$total = $listenerRepository->getTotalListeners($system); | ||
$showingAll = ( | ||
empty($args['filter']) && | ||
empty($args['country']) && | ||
empty($args['region']) | ||
); | ||
if (empty($args['types'])) { | ||
$args['types'][] = 'type_NDB'; | ||
} | ||
$filtered = $listenerRepository->getFilteredListeners($system, $args); | ||
$matched = | ||
($showingAll ? | ||
"(Showing all $total listeners)" | ||
: | ||
"(Showing ".count($filtered)." of $total listeners)" | ||
); | ||
$parameters = [ | ||
'args' => $args, | ||
'columns' => $listenerRepository->getColumns(), | ||
'form' => $form->createView(), | ||
'listeners' => $filtered, | ||
'matched' => $matched, | ||
'mode' => 'Listeners List', | ||
'system' => $system, | ||
'text' => | ||
"<ul>\n" | ||
." <li>Log and station counts are updated each time new log data is added - " | ||
."figures are for logs in the system at this time.</li>\n" | ||
." <li>To see stats for different types of signals, check the boxes shown for 'Types' below.</li>\n" | ||
." <li>This report prints best in Portrait.</li>\n" | ||
."</ul>\n", | ||
]; | ||
$parameters = array_merge($parameters, $this->parameters); | ||
// return $this->rxx::debug($this->parameters); | ||
return $this->render('listeners/index.html.twig', $parameters); | ||
} | ||
|
||
} |
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
Oops, something went wrong.