Skip to content

Commit

Permalink
2.20.28 Log Uploader parser gives warning reasons and 'Prepare Email'…
Browse files Browse the repository at this point in the history
… action
  • Loading branch information
classaxe committed Dec 4, 2020
1 parent 6ee13ac commit 6dee2c9
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 16 deletions.
4 changes: 2 additions & 2 deletions public/css/style.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Project: RXX - NDB Logging Database
* Homepage: https://rxx.classaxe.com
* Version: 2.20.26
* Date: 2020-12-02
* Version: 2.20.27
* Date: 2020-12-04
* Licence: LGPL
* Copyright: 2020 Martin Francis
*/
Expand Down
33 changes: 29 additions & 4 deletions public/js/functions.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Project: RXX - NDB Logging Database
* Homepage: https://rxx.classaxe.com
* Version: 2.20.26
* Date: 2020-12-02
* Version: 2.20.27
* Date: 2020-12-04
* Licence: LGPL
* Copyright: 2020 Martin Francis
*/
Expand Down Expand Up @@ -1413,13 +1413,38 @@ function initListenersLogUploadForm() {
$('#form_step').val(3);
});

$('#copyRemainder').on('click', function() {
var txt = $('#remainder_logs').val();
$('#copyDetails').on('click', function() {
var len = $('#remainder_format').val().length + 1;
var txt =
$('#logEmail').val() + '\n' +
"-".repeat(len) + '\n' +
$('#remainder_format').val() + '\n' +
"-".repeat(len) + '\n' +
$('#remainder_logs').val() + '\n\n';
copyToClipboard(txt);
alert(msg.log_upload.copy_remaining);
return false;
})

$('#copyEmail').on('click', function() {
var len = $('#remainder_format').val().length + 1;
var txt =
"To: " + $('#logEmail').val() + '\n' +
'Subject: Issues seen for log upload for ' + $('#logOwner').val() + '\n\n\n' +
"Dear Listener,\n" +
" Some potential issues were encountered when attempting to upload a submitted log.\n\n\n" +
"Would you please check the following log entries:\n\n" +
"-".repeat(len) + '\n' +
$('#remainder_format').val() + '\n' +
"-".repeat(len) + '\n' +
$('#remainder_logs').val() + '\n\n\n\n' +
"Sincerely,\n\n\n" +
$('#userName').val();
copyToClipboard(txt);
alert(msg.log_upload.prepare_email);
return false;
})

$('.jump .up').on('click', function() {
var id = parseInt($(this).parent().attr('id').split('_')[1]);
var row_id = $('#jump_' + (id - 1)).parent().attr('id').split('_')[1];
Expand Down
6 changes: 3 additions & 3 deletions public/js/functions.min.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/Controller/Web/Listeners/ListenerLogsUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function controller(
LogUploadForm $logUploadForm
) {
$isAdmin = $this->parameters['isAdmin'];
$userName = $this->parameters['user_name'];
$this->system = $system;
if (!$isAdmin || !$this->listener = $this->getValidListener($id)) {
return $this->redirectToRoute('listener', ['system' => $this->system, 'id' => $id]);
Expand Down Expand Up @@ -205,6 +206,8 @@ public function controller(
'heardIn' => $heardIn,
'logs' => $this->listener->getCountLogs(),
'logData' => $this->logs,
'logEmail' => $this->listener->getFormattedEmail(),
'logOwner' => $this->listener->getFormattedNameAndLocation(),
'region' => $region,
'selected' => $selected,
'signals' => $this->listener->getCountSignals(),
Expand All @@ -214,7 +217,8 @@ public function controller(
'tabs' => $this->listenerRepository->getTabs($this->listener, $isAdmin),
'tokens' => $this->tokens,
'tol_offsets' => 25,
'tol_secs' => 1
'tol_secs' => 1,
'userName' => $userName
];
$parameters = array_merge($parameters, $this->parameters);
return $this->render('listener/logs_upload/index.html.twig', $parameters);
Expand Down
8 changes: 8 additions & 0 deletions src/Entity/Listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,14 @@ public function getAddlog(): ?int

/* Custom getters for column display */

/**
* @return null|string
*/
public function getFormattedEmail(): ?string
{
return $this->name . ' <' . $this->email . '>';
}

/**
* @return null|string
*/
Expand Down
29 changes: 27 additions & 2 deletions src/js/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,38 @@ function initListenersLogUploadForm() {
$('#form_step').val(3);
});

$('#copyRemainder').on('click', function() {
var txt = $('#remainder_logs').val();
$('#copyDetails').on('click', function() {
var len = $('#remainder_format').val().length + 1;
var txt =
$('#logEmail').val() + '\n' +
"-".repeat(len) + '\n' +
$('#remainder_format').val() + '\n' +
"-".repeat(len) + '\n' +
$('#remainder_logs').val() + '\n\n';
copyToClipboard(txt);
alert(msg.log_upload.copy_remaining);
return false;
})

$('#copyEmail').on('click', function() {
var len = $('#remainder_format').val().length + 1;
var txt =
"To: " + $('#logEmail').val() + '\n' +
'Subject: Issues seen for log upload for ' + $('#logOwner').val() + '\n\n\n' +
"Dear Listener,\n" +
" Some potential issues were encountered when attempting to upload a submitted log.\n\n\n" +
"Would you please check the following log entries:\n\n" +
"-".repeat(len) + '\n' +
$('#remainder_format').val() + '\n' +
"-".repeat(len) + '\n' +
$('#remainder_logs').val() + '\n\n\n\n' +
"Sincerely,\n\n\n" +
$('#userName').val();
copyToClipboard(txt);
alert(msg.log_upload.prepare_email);
return false;
})

$('.jump .up').on('click', function() {
var id = parseInt($(this).parent().attr('id').split('_')[1]);
var row_id = $('#jump_' + (id - 1)).parent().attr('id').split('_')[1];
Expand Down
1 change: 1 addition & 0 deletions templates/i18n/i18n.js.twig
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ var msg = {
'3': "{% trans %}Please capture the remaining logs for later processing.{% endtrans %}"
},
'copy_remaining': "{% trans %}Copied remaining logs to clipboard.{% endtrans %}",
'prepare_email': "{% trans %}Copied Enquiry Email to clipboard.{% endtrans %}",
'last_item': "{% trans %}You are at the last item{% endtrans %}",
'prompt': {
'a': "{% trans %}Save this format for future logs by this listener?{% endtrans %}",
Expand Down
13 changes: 9 additions & 4 deletions templates/listener/logs_upload/parse.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@
<td>{{ o.dx_miles }}</td>
<td>{{ o.pwr ? o.pwr : '' }}</td>
<td>{{ hi|raw }}</td>
<td class="num"><i{% if lsb_check %} class="check"{% endif %}>{{ e.LSB_approx }}{{ e.LSB }}</i>{% if o.LSB_approx or o.LSB %}<br>{{ o.LSB_approx }}{{ o.LSB }}{% endif %}</td>
<td class="num"><i{% if usb_check %} class="check"{% endif %}>{{ e.USB_approx }}{{ e.USB }}</i>{% if o.USB_approx or o.USB %}<br>{{ o.USB_approx }}{{ o.USB }}{% endif %}</td>
<td class="num"><i{% if lsb_check %} class="check" title="Different by more than {{ tol_offsets }}Hz"{% endif %}>{{ e.LSB_approx }}{{ e.LSB }}</i>{% if o.LSB_approx or o.LSB %}<br>{{ o.LSB_approx }}{{ o.LSB }}{% endif %}</td>
<td class="num"><i{% if usb_check %} class="check" title="Different by more than {{ tol_offsets }}Hz"{% endif %}>{{ e.USB_approx }}{{ e.USB }}</i>{% if o.USB_approx or o.USB %}<br>{{ o.USB_approx }}{{ o.USB }}{% endif %}</td>
<td class="num"><i{%
if e.sec and o.sec and ((e.sec + tol_secs < o.sec) or (e.sec - tol_secs > o.sec)) %} class="check"{% endif
if e.sec and o.sec and ((e.sec + tol_secs < o.sec) or (e.sec - tol_secs > o.sec)) %} class="check" title="Different by more than {{ tol_secs }} Second"{% endif
%}>{{ e.sec }}</i>{% if o.sec %}<br>{{ o.sec }}{% endif %}</td>
<td class="text-nowrap"><i>{{ e.fmt }}</i>{% if o.format %}<br>{{ o.format }}{% endif %}</td>
</tr>
Expand Down Expand Up @@ -179,8 +179,13 @@
<div id="shim"></div>
</div>
</div>
<h2>{% trans %}Issues / Skipped logs{% endtrans %} (<span id="issueCount"></span>) <small>[ <a id="copyRemainder" href="#">Copy</a> ]</small></h2>
<small style="color:#444;float: right">Actions: [ <a id="copyDetails" href="#">Copy Details</a> | <a id="copyEmail" href="#">Prepare Email</a> ]</small>
<h2>{% trans %}Issues / Skipped logs{% endtrans %} (<span id="issueCount"></span>)</h2>
<label for="remainder_format" class="sr-only">{% trans %}Log Format{% endtrans %}</label>
<input type='hidden' id="logOwner" value="{{ logOwner }}" />
<input type='hidden' id="logOwner" value="{{ logOwner }}" />
<input type='hidden' id="logEmail" value="{{ logEmail }}" />
<input type='hidden' id="userName" value="{{ userName }}" />
<input type='text' style="width:100%;height:2em;padding: 0; margin-bottom: 0; font-family: 'Courier New bold', Courier, monospace; font-size:12px" id="remainder_format" />
<label for="remainder_logs" class="sr-only">{% trans %}Log Entries{% endtrans %}</label>
<textarea style="width:100%;height:10em;padding: 0; margin-top: 0; font-family: 'Courier New', Courier, monospace;font-size:12px" id="remainder_logs"></textarea>
Expand Down

0 comments on commit 6dee2c9

Please sign in to comment.