Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
2.43.4 Added csv and txt export for Remote Logs and included Operator…
… in logs export for Listener if Multi-Operator facility
- Loading branch information
Showing
11 changed files
with
224 additions
and
31 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,114 @@ | ||
<?php | ||
namespace App\Controller\Web\Listeners\Export; | ||
|
||
use App\Controller\Web\Listeners\Base; | ||
|
||
use Symfony\Component\HttpFoundation\RedirectResponse; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Routing\Annotation\Route; // Required for annotations | ||
|
||
/** | ||
* Class Listeners | ||
* @package App\Controller\Web\Listener\Export | ||
*/ | ||
class RemoteLogs extends Base | ||
{ | ||
/** | ||
* @Route( | ||
* "/{_locale}/{system}/listeners/{id}/remotelogs/export/csv", | ||
* requirements={ | ||
* "_locale": "de|en|es|fr", | ||
* "system": "reu|rna|rww" | ||
* }, | ||
* defaults={"id"=""}, | ||
* name="listener_remotelogs_export_csv" | ||
* ) | ||
* @param $_locale | ||
* @param $system | ||
* @param $id | ||
* @return RedirectResponse|Response | ||
*/ | ||
public function csv( | ||
$_locale, | ||
$system, | ||
$id | ||
) { | ||
return $this->export($_locale, $system, $id, 'csv'); | ||
} | ||
|
||
/** | ||
* @Route( | ||
* "/{_locale}/{system}/listeners/{id}/remotelogs/export/txt", | ||
* requirements={ | ||
* "_locale": "de|en|es|fr", | ||
* "system": "reu|rna|rww" | ||
* }, | ||
* defaults={"id"=""}, | ||
* name="listener_remotelogs_export_txt" | ||
* ) | ||
* @param $_locale | ||
* @param $system | ||
* @param $id | ||
* @return RedirectResponse|Response | ||
*/ | ||
public function txt( | ||
$_locale, | ||
$system, | ||
$id | ||
) { | ||
return $this->export($_locale, $system, $id, 'txt'); | ||
} | ||
|
||
/** | ||
* @param $_locale | ||
* @param $system | ||
* @param $id | ||
* @param $mode | ||
* @return RedirectResponse|Response | ||
*/ | ||
private function export( | ||
$_locale, | ||
$system, | ||
$id, | ||
$mode | ||
) { | ||
if (!$listener = $this->getValidReportingListener($id)) { | ||
return $this->redirectToRoute( | ||
'listeners', | ||
['system' => $system] | ||
); | ||
} | ||
|
||
$sortableColumns = $this->listenerRepository->getColumns('logs'); | ||
$args = [ | ||
'operatorId' => $id, | ||
'sort' => 'logDate', | ||
'order' => 'a', | ||
]; | ||
$logs = $this->logRepository->getLogs($args, $sortableColumns); | ||
|
||
$parameters = [ | ||
'_locale' => $_locale, | ||
'title' => strToUpper($system) . ' remote logs for '.$listener->getName() . " on " . date('Y-m-d'), | ||
'subtitle' => '(' . count($logs) . ' records sorted by Date and Time)', | ||
'system' => $system, | ||
'listener' => $listener, | ||
'logs' => $logs, | ||
'typeRepository' => $this->typeRepository | ||
]; | ||
$parameters = array_merge($parameters, $this->parameters); | ||
switch ($mode) { | ||
case 'csv': | ||
$response = $this->render("listener/export/remotelogs.csv.twig", $parameters); | ||
break; | ||
case 'txt': | ||
$response = $this->render("listener/export/remotelogs.txt.twig", $parameters); | ||
break; | ||
default: | ||
die("Invalid mode"); | ||
} | ||
$response->headers->set('Content-Type', 'text/plain'); | ||
$response->headers->set('Content-Disposition',"attachment;filename=listener_{$id}_remotelogs.{$mode}"); | ||
return $response; | ||
} | ||
} |
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
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
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,45 @@ | ||
"{% trans %}Remote Receiver{% endtrans %}","{% | ||
trans %}YYYY-MM-DD{% endtrans %}","{% | ||
trans %}hh:mm{% endtrans %}","{% | ||
trans %}KHZ{% endtrans %}","{% | ||
trans %}ID{% endtrans %}","{% | ||
trans %}Type{% endtrans %}","{% | ||
trans %}Active{% endtrans %}","{% | ||
trans %}'Name' and Location{% endtrans %}","{% | ||
trans %}S/P{% endtrans %}","{% | ||
trans %}ITU{% endtrans %}","{% | ||
trans %}Region{% endtrans %}","{% | ||
trans %}GSQ{% endtrans %}","{% | ||
trans %}Lat{% endtrans %}","{% | ||
trans %}Lon{% endtrans %}","{% | ||
trans %}LSB{% endtrans %}","{% | ||
trans %}USB{% endtrans %}","{% | ||
trans %}Sec{% endtrans %}","{% | ||
trans %}Fmt.{% endtrans %}","{% | ||
trans %}PWR{% endtrans %}","{% | ||
trans %}KM{% endtrans %}","{% | ||
trans %}Miles{% endtrans %}","{% | ||
trans %}Daytime{% endtrans%}" | ||
{% for l in logs %}"{{ l.receiver }}","{{ | ||
l.logDate }}","{{ | ||
l.logTime|slice(0,2) }}:{{ l.logTime|slice(2,2) }}","{{ | ||
l.khz }}","{{ | ||
l.call }}","{{ | ||
typeRepository.typeForCode(l.type)['label']|trans }}","{{ | ||
l.active ? 'Y' : 'N' }}","{{ | ||
l.qth|raw }}","{{ | ||
l.sp }}","{{ | ||
l.itu }}","{{ | ||
l.region }}","{{ | ||
l.gsq }}","{{ | ||
l.lat }}","{{ | ||
l.lon }}","{{ | ||
l.lsb }}","{{ | ||
l.usb }}","{{ | ||
l.sec }}","{{ | ||
l.format }}","{{ | ||
l.pwr ? l.pwr : '' }}","{{ | ||
l.dxKm }}","{{ | ||
l.dxMiles }}","{{ | ||
(l.daytime ? 'Y' : 'N') }}" | ||
{% endfor %} |
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,33 @@ | ||
{{ title }} | ||
{{ subtitle }} | ||
A - {% trans %}Active{% endtrans %} | ||
|
||
D - {% trans %}Logged between 10am and 2pm local time{% endtrans %} | ||
|
||
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
Remote Receiver YYYY-MM-DD hh:mm KHZ ID Type A LSB USB sec fmt PWR KM Miles GSQ Lat Lon D SP ITU QTH | ||
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
{% for l in logs %} | ||
{{ l.receiver|length > 40 ? l.receiver|slice(0, 37) ~ '...' : "% -40s" | format(l.receiver ? l.receiver : '') }} {{ | ||
l.logDate | date('Y-m-d') }} {{ l.logTime|slice(0,2) }}:{{ l.logTime|slice(2,2) }} {{ | ||
"% -8s" | format(l.khz) }} {{ | ||
"% -10s" | format(l.call) }} {{ | ||
"% -6s" | format( typeRepository.typeForCode(l.type)['label']|trans) }} {{ | ||
"% -1s" | format(l.active ? 'Y' : 'N') }} {{ | ||
"% 5s" | format(l.lsb ? l.lsb : '') }} {{ | ||
"% 5s" | format(l.usb ? l.usb : '') }} {{ | ||
"% 6s" | format(l.sec ? l.sec : '') }} {{ | ||
"% 10s" | format(l.format ? l.format : '') }} {{ | ||
"% 4s" | format(l.pwr ? l.pwr : '') }} {{ | ||
"% 6s" | format(l.dxKm) }} {{ | ||
"% 6s" | format(l.dxMiles) }} {{ | ||
"% 6s" | format(l.gsq) }} {{ | ||
"% 8s" | format(l.lat) }} {{ | ||
"% 8s" | format(l.lon) }} {{ | ||
"% 1s" | format(l.daytime ? 'Y' : 'N') }} {{ | ||
"% 2s" | format(l.sp) }} {{ | ||
"% 3s" | format(l.itu) }} {{ | ||
l.qth|raw|replace({' ': ' '}) | ||
}} | ||
{% endfor %} | ||
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
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