Skip to content

Commit

Permalink
0.12.0: Added listener stats, fixed signal type ordering, set listene…
Browse files Browse the repository at this point in the history
…r logs / signals default limit to 20 to fit window
  • Loading branch information
classaxe committed Oct 30, 2018
1 parent 8c6875d commit 1a9eff9
Show file tree
Hide file tree
Showing 12 changed files with 143 additions and 52 deletions.
19 changes: 17 additions & 2 deletions public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,21 @@ pre { border: 1px dashed #ccc; background: #eee; padding: 0.25em 1em !important;
.listener_edit #form textarea,
.listener_edit #form select { width: 75%; padding: 0.125em 0.25em; margin: 0 0 0.25em 0 }

/* [ Form listener_signals ] */
.listener_signals .results thead tr th {
height: 3em !important;
}

/* [ Form listener_logs ] */
.listener_logs .results thead tr th {
height: 3em !important;
}

/* [ Form listener_weather ] */
.listener_weather #form div { display: inline-block; }
.listener_weather #form_icao { width: 20em; font-size: 10pt; font-family: 'Courier New', monospace; font-weight: bold; }
.listener_weather #form_hours { width: 3.5em; text-align: right; }
.listener_weather #weather { height: 15em; font-size: 10pt; font-family: 'Courier New', monospace; }
.listener_weather #weather { height: 25em; font-size: 10pt; font-family: 'Courier New', monospace; }
.listener_weather #form div button { width: 8.5em; }

fieldset#group_weather_report_details div * {
Expand All @@ -179,6 +189,11 @@ fieldset#group_weather_report_details div * {
fieldset#group_weather_report_details div label {
width: auto; line-height: unset; margin: 0 0.5em;
}
/* [ Listener Stats ] */
.listener_stats div.stats { clear: both; border: 1px solid #ccc; background: #ffffff; padding: 0.25em 0.25em 0 0.25em; margin: 0.25em 0; width: 18em; }
.listener_stats div.signal_stat { margin: 0; padding: 0; display: inline-block; width: 20em; line-height: initial; }
.listener_stats div.signal_stat label { font-weight: bold; width: 15em; margin: 0; padding: 0.25em; border: 1px solid #ccc; float: left; line-height: initial; }
.listener_stats div.signal_stat div { display: inline-block; float: left; margin: 0 0.25em; padding: 0.25em; width: 4em; text-align: right; line-height: initial;}

/* [ Form logon ] */
.logon #form input[type='text'],
Expand Down Expand Up @@ -210,7 +225,7 @@ button.tiny { font-size: 0.4rem !important; line-height: 0.6em; }
.type_hambcn , tr.hambcn td { background-color: #b8ffc0 !important; }
.type_other , tr.other td { background-color: #b8f8ff !important; }

.type_all { background-color: #ff0000; }
.type_all { background-color: #ff0000; color: #ffffff; }
.type_all label { color: #fff; font-style:italic; font-weight: bold !important; }

/* [ Grid CSS } */
Expand Down
9 changes: 1 addition & 8 deletions src/Controller/Web/Listener/Export/Signalmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function signalmapController(
foreach ($listenerRepository->getSignalTypesForListener($id) as $type) {
$listenerSignalTypes[$type] = $typeRepository->getTypeForCode($type);
}
uasort($listenerSignalTypes, array('self', 'sortSignalTypesByLabel'));
uasort($listenerSignalTypes, array($typeRepository, 'sortByOrder'));
$parameters = [
'id' => $id,
'title' => strToUpper($system).' Signals received by '.$listener->getName(),
Expand All @@ -51,11 +51,4 @@ public function signalmapController(
$response = $this->render('listener/export/signalmap.html.twig', $parameters);
return $response;
}

public static function sortSignalTypesByLabel($a, $b) {
if ($a['label'] == $b['label']) {
return 0;
}
return ($a['label'] < $b['label']) ? -1 : 1;
}
}
4 changes: 2 additions & 2 deletions src/Controller/Web/Listener/Logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public function logsController(
ListenerRepository $listenerRepository,
TypeRepository $typeRepository
) {
$defaultlimit = 100;
$maxNoPaging = 100;
$defaultlimit = 20;
$maxNoPaging = 20;

if (!$listener = $this->getValidReportingListener($id, $listenerRepository)) {
return $this->redirectToRoute('listeners', ['system' => $system]);
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Web/Listener/Signals.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public function signalsController(
ListenerRepository $listenerRepository,
TypeRepository $typeRepository
) {
$defaultlimit = 100;
$maxNoPaging = 100;
$defaultlimit = 20;
$maxNoPaging = 20;

if ((int) $id) {
if (!$listener = $this->getValidReportingListener($id, $listenerRepository)) {
Expand Down
47 changes: 47 additions & 0 deletions src/Controller/Web/Listener/Stats.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
namespace App\Controller\Web\Listener;

use App\Controller\Web\Listener\Base;
use App\Repository\ListenerRepository;
use App\Repository\TypeRepository;

use App\Utils\Rxx;
use Symfony\Component\Routing\Annotation\Route; // Required for annotations

/**
* Class Listeners
* @package App\Controller\Web\Listener
*/
class Stats extends Base
{

/**
* @Route(
* "/{system}/listeners/{id}/stats",
* requirements={
* "system": "reu|rna|rww"
* },
* name="listener_stats"
* )
*/
public function statsController(
$system,
$id,
ListenerRepository $listenerRepository,
TypeRepository $typeRepository
) {
if (!$listener = $this->getValidListener($id, $listenerRepository)) {
return $this->redirectToRoute('listeners', ['system' => $system]);
}
$parameters = [
'id' => $id,
'mode' => $listener->getName().' &gt; Stats',
'listener' => $listener,
'system' => $system,
'tabs' => $listenerRepository->getTabs($listener),
'typeRepository' => $typeRepository
];
$parameters = array_merge($parameters, $this->parameters);
return $this->render('listener/stats.html.twig', $parameters);
}
}
2 changes: 1 addition & 1 deletion src/Controller/Web/Listener/Weather.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function weatherController(
"----------------------\n"
. "(Weather via ".strToUpper($system).")";
} else {
$weather[] = "(No data available from ".$form_data['icao']." for the last ".$form_data['hours']." hours)";
$weather[] = "(No data available from station ".$form_data['icao']." for the last ".$form_data['hours']." hours)";
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Form/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
class Base extends AbstractType
{
private $options;
private $limitOptions = [10, 25, 50, 100, 250, 500, 1000, 2500, 5000, 100000, 25000, 50000, 100000];
private $limitOptions = [10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 100000, 20000, 50000, 100000];

/**
* @param FormBuilderInterface $formBuilder
Expand Down
3 changes: 1 addition & 2 deletions src/Repository/ListenerRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ListenerRepository extends ServiceEntityRepository
['listener_logs', 'Logs (%%logs%%)'],
['listener_export', 'Export'],
['listener_weather', 'Weather'],
// ['listener_stats', 'stats']
['listener_stats', 'Stats']
];

private $listenersColumns;
Expand Down Expand Up @@ -393,5 +393,4 @@ public function getSignalTypesForListener($listenerID) {
}
return $out;
}

}
22 changes: 14 additions & 8 deletions src/Repository/TypeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
class TypeRepository
{
const types = [
0 => ['bbggrr' => 'ffffff', 'class' => 'NDB', 'color' => 'ffffff', 'label' => 'NDB', 'title' => 'NDB Beacon'],
1 => ['bbggrr' => 'ffd800', 'class' => 'DGPS', 'color' => '00d8ff', 'label' => 'DGPS', 'title' => 'DGPS Station'],
2 => ['bbggrr' => 'b0e0ff', 'class' => 'TIME', 'color' => 'ffe0b0', 'label' => 'Time', 'title' => 'Time Signal Station'],
3 => ['bbggrr' => 'd8b8ff', 'class' => 'NAVTEX', 'color' => 'ffb8d8', 'label' => 'Navtex', 'title' => 'NavTex Station'],
4 => ['bbggrr' => 'c0ffb8', 'class' => 'HAMBCN', 'color' => 'b8ffc0', 'label' => 'Ham', 'title' => 'Amateur Radio Beacon'],
5 => ['bbggrr' => 'fff8b8', 'class' => 'OTHER', 'color' => 'b8f8ff', 'label' => 'Other', 'title' => 'Other form of transmission'],
6 => ['bbggrr' => '00b0ff', 'class' => 'DSC', 'color' => 'ffb000', 'label' => 'DSC', 'title' => 'DSC Station']
1 => ['bbggrr' => 'ffd800', 'order' => 0, 'class' => 'DGPS', 'color' => '00d8ff', 'label' => 'DGPS', 'title' => 'DGPS Station'],
6 => ['bbggrr' => '00b0ff', 'order' => 1, 'class' => 'DSC', 'color' => 'ffb000', 'label' => 'DSC', 'title' => 'DSC Station'],
4 => ['bbggrr' => 'c0ffb8', 'order' => 2, 'class' => 'HAMBCN', 'color' => 'b8ffc0', 'label' => 'Ham', 'title' => 'Amateur Radio Beacon'],
3 => ['bbggrr' => 'd8b8ff', 'order' => 3, 'class' => 'NAVTEX', 'color' => 'ffb8d8', 'label' => 'Navtex', 'title' => 'NavTex Station'],
0 => ['bbggrr' => 'ffffff', 'order' => 4, 'class' => 'NDB', 'color' => 'ffffff', 'label' => 'NDB', 'title' => 'NDB Beacon'],
2 => ['bbggrr' => 'b0e0ff', 'order' => 5, 'class' => 'TIME', 'color' => 'ffe0b0', 'label' => 'Time', 'title' => 'Time Signal Station'],
5 => ['bbggrr' => 'fff8b8', 'order' => 6, 'class' => 'OTHER', 'color' => 'b8f8ff', 'label' => 'Other', 'title' => 'Other form of transmission'],
];

public function getAll()
Expand All @@ -25,7 +25,6 @@ public function getAllChoices()
foreach (static::types as $key => $type) {
$out[$type['label']] = 'type_'.$type['class'];
}
ksort($out);
$out['(All)'] = 'type_ALL';
return $out;
}
Expand All @@ -52,4 +51,11 @@ public function getTypeForCode($code)
{
return static::types[$code];
}

public function sortByOrder($a, $b) {
if ($a['order'] == $b['order']) {
return 0;
}
return ($a['order'] < $b['order']) ? -1 : 1;
}
}
33 changes: 33 additions & 0 deletions templates/listener/stats.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{% extends 'popup.html.twig' %}
{% block body %}
<div class="main fullwidth">
{% set form_class='listener_stats' %}
{% include 'listener/tabs.html.twig' %}
<div class="controlPanel {{ form_class }}">
<div class="header">{{ mode|raw }}</div>
<div class="content">
<h2>Signal Statistics</h2><br class="clear" />
<div class="stats clearfix">
{% for type,data in typeRepository.all %}
{% set idx = "count" ~ data.class|capitalize %}
<div class="signal_stat ">
<label class="type_{{ data.class|lower }}">{{ data.title }}{{ data.class != 'OTHER' ? 's' : '' }}:</label>
<div>{{ attribute(listener, idx)|number_format }}</div>
</div><br class="clear" />
{% endfor %}
<div class="signal_stat">
<label class="type_all">Total Signals:</label>
<div>{{ listener.countSignals|number_format }}</div>
</div><br class="clear" />
</div>
<h2>Log Statistics</h2><br class="clear" />
<div class="stats clearfix">
<div class="signal_stat">
<label class="type_all">Total Logs:</label>
<div>{{ listener.countLogs|number_format }}</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
25 changes: 0 additions & 25 deletions templates/listener/weather.form.html.twig

This file was deleted.

25 changes: 24 additions & 1 deletion templates/listener/weather.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,29 @@
<div class="main fullwidth">
{% set form_class='listener_weather' %}
{% include 'listener/tabs.html.twig' %}
{% include 'listener/weather.form.html.twig' %}
{% form_theme form 'forms/custom_form_div_layout.html.twig' %}
<div class="controlPanel {{ form_class }}">
<div class="header">{{ mode|raw }}</div>
<div class="content">
{{ form_start(form) }}
<div id="form">
{{ form_row(form.id) }}
{% for group, fields in fieldGroups %}
<fieldset id="group_{{ group|lower|replace({' ' : '_'}) }}">
<legend>{{ group }}</legend>
{% for field in fields %}
{% if field %}
{{ form_row(attribute(form, field)) }}
{% endif %}
{% endfor %}
<textarea id="weather">
{% if weather != false %}{{ weather|join("\n") }}{% else %}Press QNH to view recent barometric pressure readings.{% endif %}
</textarea>
</fieldset>
{% endfor %}
</div>
{{ form_end(form, {'render_rest': false}) }}
</div>
</div>
</div>
{% endblock %}

0 comments on commit 1a9eff9

Please sign in to comment.