Skip to content

Commit

Permalink
0.7.1: Added login / logout concepts, admin-dependent menu items and …
Browse files Browse the repository at this point in the history
…columns
  • Loading branch information
classaxe committed Jun 26, 2018
1 parent b2dd237 commit 0de8925
Show file tree
Hide file tree
Showing 12 changed files with 592 additions and 60 deletions.
4 changes: 2 additions & 2 deletions public/css/style.css
Expand Up @@ -43,9 +43,9 @@ body.rww .footer { border-top: 3px solid #33a033;}
/* [ Menu ] */
body .menu-centered { width: 602px; margin: auto; }
body .menu-centered .header h2 { font-size: 130%; margin: 0.25em 0; }
body .menu-centered .system { background: #ffffff; border-top: none !important; border-bottom: none !important; }
body .menu-centered .system { background: #ffffff; border-top: none !important; }
body .menu-centered .system a { width: 200px; text-align: center; }
body .menu-centered .mode { background: #ffffff; }
body .menu-centered .mode { background: #ffffff; border-top: 0 !important; }
body .menu-centered .system a, body .menu-centered .mode a { padding: 0.25em 0.5em; font-size: 80%; }
body .menu-centered .system a:hover, body .menu-centered .mode a:hover { text-decoration: underline; }
body .menu-centered .system .is-active>a, body .menu-centered .mode .is-active>a { font-weight: bold; }
Expand Down
64 changes: 64 additions & 0 deletions src/Controller/BaseController.php
@@ -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(),
];
}
}
14 changes: 4 additions & 10 deletions src/Controller/ListenerList.php
Expand Up @@ -2,8 +2,6 @@
namespace App\Controller;

use App\Form\ListenerList as ListenerListForm;
use App\Repository\ModeRepository;
use App\Repository\SystemRepository;
use App\Repository\ListenerRepository;
use App\Utils\Rxx;
use Symfony\Component\Routing\Annotation\Route; // Required for annotations
Expand All @@ -14,7 +12,7 @@
* Class ListenerList
* @package App\Controller
*/
class ListenerList extends Controller {
class ListenerList extends BaseController {

/**
* @Route(
Expand All @@ -29,9 +27,7 @@ public function listenerListController(
$system,
Request $request,
ListenerListForm $form,
ListenerRepository $listenerRepository,
ModeRepository $modeRepository,
SystemRepository $systemRepository
ListenerRepository $listenerRepository
) {
$options = [
'system' => $system
Expand All @@ -48,7 +44,7 @@ public function listenerListController(
];
if ($form->isSubmitted() && $form->isValid()) {
$args = $form->getData();
// print Rxx::y($args);
// print $this->rxx::y($args);
}
$total = $listenerRepository->getTotalListeners($system);
$showingAll = (
Expand All @@ -73,9 +69,7 @@ public function listenerListController(
'listeners' => $filtered,
'matched' => $matched,
'mode' => 'Listeners List',
'modes' => $modeRepository->getAll(),
'system' => $system,
'systems' => $systemRepository->getAll(),
'text' =>
"<ul>\n"
." <li>Log and station counts are updated each time new log data is added - "
Expand All @@ -84,7 +78,7 @@ public function listenerListController(
." <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);
}

Expand Down
89 changes: 89 additions & 0 deletions src/Controller/Logoff.php
@@ -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);
}

}
90 changes: 90 additions & 0 deletions src/Controller/Logon.php
@@ -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);
}

}
13 changes: 3 additions & 10 deletions src/Controller/Maps.php
Expand Up @@ -2,9 +2,6 @@
namespace App\Controller;

use App\Repository\MapRepository;
use App\Repository\ModeRepository;
use App\Repository\SystemRepository;
use App\Utils\Rxx;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route; // Required for annotations

Expand All @@ -13,7 +10,7 @@
* Class CountryLocator
* @package App\Controller
*/
class Maps extends Controller {
class Maps extends BaseController {

/**
* @Route(
Expand Down Expand Up @@ -44,22 +41,18 @@ public function map($system, $area, MapRepository $mapRepository)
*/
public function mapsController(
$system,
MapRepository $mapRepository,
ModeRepository $modeRepository,
SystemRepository $systemRepository
MapRepository $mapRepository
) {
$systemMaps = $mapRepository->getAllForSystem($system);

$parameters = [
'mode' => 'Maps',
'modes' => $modeRepository->getAll(),
'system' => $system,
'systems' => $systemRepository->getAll(),
'title' => $systemMaps['title'],
'zones' => $systemMaps['maps'],
];

// return Rxx::debug($parameters);
$parameters = array_merge($parameters, $this->parameters);
return $this->render('maps/index.html.twig', $parameters);
}
}
12 changes: 4 additions & 8 deletions src/Controller/SignalList.php
Expand Up @@ -7,7 +7,7 @@
use Symfony\Component\Routing\Annotation\Route; // Required for annotations
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class SignalList extends Controller {
class SignalList extends BaseController {

/**
* @Route(
Expand All @@ -19,20 +19,16 @@ class SignalList extends Controller {
* )
*/
public function signalListController(
$system,
ModeRepository $modeRepository,
SystemRepository $systemRepository
$system
) {
$parameters = [
'mode' => 'Signals',
'modes' => $modeRepository->getAll(),
'signal' => $this->getDoctrine()
->getRepository(Signals::class)
->find(1),
'system' => $system,
'systems' => $systemRepository->getAll()
'system' => $system
];

$parameters = array_merge($parameters, $this->parameters);
return $this->render('signals/index.html.twig', $parameters);
}
}

0 comments on commit 0de8925

Please sign in to comment.