Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2.59.3 Added Channels mode for CLE admins
- Loading branch information
Showing
4 changed files
with
147 additions
and
2 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,82 @@ | ||
<?php | ||
namespace App\Controller\Web\Channels; | ||
|
||
use App\Controller\Web\Base; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Routing\Annotation\Route; // Required for annotations | ||
|
||
/** | ||
* Class Logs | ||
* @package App\Controller\Web | ||
*/ | ||
class Channels extends Base | ||
{ | ||
/** | ||
* @Route( | ||
* "/{_locale}/{system}/channels", | ||
* requirements={ | ||
* "system": "reu|rna|rww" | ||
* }, | ||
* name="channels" | ||
* ) | ||
* @param $_locale | ||
* @param $system | ||
* | ||
* @return Response | ||
*/ | ||
public function channels( | ||
$_locale, | ||
$system | ||
) { | ||
$i18n = $this->translator; | ||
$minDate = '2023-01-01'; | ||
$minTimes = 5; | ||
$regions = $this->regionRepository->getAllOptions(false, false); | ||
$regionCodes = array_values($regions); | ||
$groupedSlots = []; | ||
foreach ($regionCodes as $r) { | ||
$groupedSlots[$r] = 0; | ||
} | ||
$data = $this->statsRepository->getChannels($minDate, $minTimes); | ||
$grouped = []; | ||
foreach ($data as $row) { | ||
if (!isset($grouped[$row['khz']])) { | ||
$grouped[$row['khz']] = $groupedSlots; | ||
} | ||
$grouped[$row['khz']][$row['region']] = $row['stations']; | ||
} | ||
$table = " | ||
<table border='1' class='channels' style='border-collapse: collapse'> | ||
<thead> | ||
<tr> | ||
<th>KHz</th>"; | ||
foreach ($regions as $label => $value) { | ||
$table .= "<th>" . $label . "</th>"; | ||
} | ||
$table .= " | ||
</tr> | ||
</thead> | ||
<tbody>"; | ||
foreach ($grouped as $khz => $stations) { | ||
$table .= "<tr>\n <th>" . (0 + $khz) . "</th>"; | ||
foreach ($regionCodes as $regionCode) { | ||
$table .= "<td>" . ($stations[$regionCode] ? $stations[$regionCode] : "") . "</td>"; | ||
} | ||
$table .= "</tr>"; | ||
} | ||
$table .= "</tbody>\n</table>"; | ||
|
||
$parameters = [ | ||
'_locale' => $_locale, | ||
'mode' => $i18n->trans('Channels'), | ||
'system' => $system, | ||
'minTimes' => $minTimes, | ||
'minDate' => $minDate, | ||
'table' => $table | ||
]; | ||
$parameters = array_merge($parameters, $this->parameters); | ||
return $this->render('channels/channels.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
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,26 @@ | ||
{% extends 'main.html.twig' %} | ||
{% block body %} | ||
<style> | ||
table.channels { | ||
font-size: 80%; | ||
width: auto; | ||
} | ||
table.channels thead th { | ||
background: #ccc; | ||
width: 5em; | ||
padding: 0.25em; | ||
} | ||
table.channels tbody th, | ||
table.channels tbody td { | ||
text-align: right; | ||
padding: 0.25em; | ||
} | ||
</style> | ||
<div class="main"> | ||
<h1>Channels</h1> | ||
<p>Showing NDB channel usage by region for signals received at least {{ minTimes }} time(s) | ||
since {{ minDate }}</p> | ||
|
||
{{ table | raw }} | ||
</div> | ||
{% endblock %} |