Skip to content

Commit

Permalink
improve emailDashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
azine committed Nov 28, 2017
1 parent 631ad40 commit ab2cfbc
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 6 deletions.
12 changes: 12 additions & 0 deletions Resources/translations/messages.de.xliff
Expand Up @@ -26,6 +26,10 @@
<source>email.dashboard.filter.button.label</source>
<target>Filtern</target>
</trans-unit>
<trans-unit id="5ba1d041f4fa38653872b3006ed590e4f2a66e82" resname="email.dashboard.form.clear.button.label">
<source>email.dashboard.form.clear.button.label</source>
<target>Filter leeren</target>
</trans-unit>
<trans-unit id="b9e935140c1e003e92226926606053159cb8d6f8" resname="email.dashboard.label">
<source>email.dashboard.label</source>
<target>E-Mail Dashboard</target>
Expand Down Expand Up @@ -54,6 +58,14 @@
<source>email.dashboard.token.label</source>
<target>Token</target>
</trans-unit>
<trans-unit id="c001a5f222392b068614726e5f24f50a5fd8dbcf" resname="email.dashboard.variables.click.to.close">
<source>email.dashboard.variables.click.to.close</source>
<target>Zum schliessen: hier klicken</target>
</trans-unit>
<trans-unit id="96bf95745d42eab6c7133267b794f9be5211b0f2" resname="email.dashboard.variables.click.to.show">
<source>email.dashboard.variables.click.to.show</source>
<target>Hier klicken um Details anzuzeigen.</target>
</trans-unit>
<trans-unit id="a7fd0798c64247348ae81ab22cd384e21ac182d0" resname="email.dashboard.variables.label">
<source>email.dashboard.variables.label</source>
<target>Variablen</target>
Expand Down
12 changes: 12 additions & 0 deletions Resources/translations/messages.en.xliff
Expand Up @@ -26,6 +26,10 @@
<source>email.dashboard.filter.button.label</source>
<target>Filter</target>
</trans-unit>
<trans-unit id="5ba1d041f4fa38653872b3006ed590e4f2a66e82" resname="email.dashboard.form.clear.button.label">
<source>email.dashboard.form.clear.button.label</source>
<target>Clear filters</target>
</trans-unit>
<trans-unit id="b9e935140c1e003e92226926606053159cb8d6f8" resname="email.dashboard.label">
<source>email.dashboard.label</source>
<target>Emails Dashboard</target>
Expand Down Expand Up @@ -54,6 +58,14 @@
<source>email.dashboard.token.label</source>
<target>Token</target>
</trans-unit>
<trans-unit id="c001a5f222392b068614726e5f24f50a5fd8dbcf" resname="email.dashboard.variables.click.to.close">
<source>email.dashboard.variables.click.to.close</source>
<target>Click here to close</target>
</trans-unit>
<trans-unit id="96bf95745d42eab6c7133267b794f9be5211b0f2" resname="email.dashboard.variables.click.to.show">
<source>email.dashboard.variables.click.to.show</source>
<target>Click here to show details.</target>
</trans-unit>
<trans-unit id="a7fd0798c64247348ae81ab22cd384e21ac182d0" resname="email.dashboard.variables.label">
<source>email.dashboard.variables.label</source>
<target>Variables</target>
Expand Down
16 changes: 16 additions & 0 deletions Resources/translations/messages.fr.xliff
Expand Up @@ -22,6 +22,14 @@
<source>email.dashboard.token.label</source>
<target>Détails</target>
</trans-unit>
<trans-unit id="09f43c8efdd487f74ae11228fe52e26ae4dbf0a7" resname="email.dashboard.filter.button.label">
<source>email.dashboard.filter.button.label</source>
<target>Filtre</target>
</trans-unit>
<trans-unit id="5ba1d041f4fa38653872b3006ed590e4f2a66e82" resname="email.dashboard.form.clear.button.label">
<source>email.dashboard.form.clear.button.label</source>
<target>Vide filtres</target>
</trans-unit>
<trans-unit id="b9e935140c1e003e92226926606053159cb8d6f8" resname="email.dashboard.label">
<source>email.dashboard.recipients.label</source>
<target>Tableau de bord d'e-mails</target>
Expand Down Expand Up @@ -50,6 +58,14 @@
<source>email.dashboard.token.label</source>
<target>Token</target>
</trans-unit>
<trans-unit id="c001a5f222392b068614726e5f24f50a5fd8dbcf" resname="email.dashboard.variables.click.to.close">
<source>email.dashboard.variables.click.to.close</source>
<target>Cliquez ici pour fermer</target>
</trans-unit>
<trans-unit id="96bf95745d42eab6c7133267b794f9be5211b0f2" resname="email.dashboard.variables.click.to.show">
<source>email.dashboard.variables.click.to.show</source>
<target>Cliquez ici pour afficher les détails.</target>
</trans-unit>
<trans-unit id="a7fd0798c64247348ae81ab22cd384e21ac182d0" resname="email.dashboard.variables.label">
<source>email.dashboard.variables.label</source>
<target>Variables</target>
Expand Down
60 changes: 54 additions & 6 deletions Resources/views/emailsDashboard.html.twig
Expand Up @@ -13,14 +13,43 @@
height: 50%;
overflow-y: scroll;
}
#reveal{
width: 80%;
height: 80%;
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 10000;
border: 1px solid black;
background-color: white;
display: none;
margin: auto;
}
.clickToClose{
height: 35px;
padding:5px;
vertical-align: middle;
border-bottom: 1px solid black;
background-color: lightgrey;
}
.clickToClose span{
float: right;
text-align: right;
}
.variables{
overflow-y: scroll;
height:100%;
}
</style>
{% endblock %}

{% block javascripts -%}
{{ parent() }}
<script type="text/javascript">
$(".actionButton").click(function(e) {
$(".showDetailsButton, .showWebViewButton, .showWebViewLink").click(function(e) {
e.preventDefault();
var modal = $('#modal');
Expand All @@ -37,16 +66,32 @@
});
$( document ).ready(function() {
if($(".sentEmail").length == 1)
{
$( ".sentEmail .showWebViewButton" ).click();
}
$("td.variables").click(function(){
$("#reveal .variables").html($(this).attr('title'));
$("#reveal").css('display', "block");
});
$("#reveal .clickToClose").click(function(){
$("#reveal").hide();
});
$(".clearButton").click(function () {
$("input").val("");
});
});
</script>
{% endblock javascripts %}
{% block body %}
<div id="reveal">
<div class="clickToClose">{{ 'email.dashboard.variables.label'|trans }}
<span>{{ 'email.dashboard.variables.click.to.close' | trans }} x&nbsp;</span>
</div>
<div class="variables"></div>
</div>
<div class='overflowScrollY'>
<h1>{{'email.dashboard.label'|trans }}</h1>
<table class="table table-striped">
Expand All @@ -69,20 +114,23 @@
<td>{{ form_row(form.sent) }}</td>
<td>{{ form_row(form.variables) }}</td>
<td>{{ form_row(form.token) }}</td>
<td>{{ form_row(form.filter) }}</td>
<td>{{ form_row(form.filter) }} <a class="button clearButton">{{ 'email.dashboard.form.clear.button.label' | trans }}</a></td>
</tr>

{{ form_end(form) }}
</tbody>
{% for email in pagination %}
<tr class="sentEmail">
<td>{{ email.recipients | join(', ') }}</td>
<td>{{ email.template }}</td>
<td>{{ email.sent | date("j. F Y H:i") }}</td>
<td class="variables" title="{{ email.variables | printVars(true) }}">
{{ 'email.dashboard.variables.click.to.show' | trans }}
</td>
<td>
<pre>{{ email.variables | printVars }}</pre>
<a class="showWebViewLink" href="{{ path('azine_email_webview', {'token': email.token}) }}">
{{ email.token }}
</a>
</td>
<td>{{ email.token }}</td>
<td>
<a class = "actionButton button showWebViewButton" href="{{ path('azine_email_webview', {'token': email.token}) }}">{{ 'email.dashboard.show.button.label'|trans }}</a>
<a class = "actionButton button showDetailsButton" href="{{ path('azine_admin_email_details_by_token', {'token': email.token}) }}">{{ 'email.dashboard.details.button.label'|trans }}</a>
Expand Down
24 changes: 24 additions & 0 deletions Services/AzineEmailTwigExtension.php
Expand Up @@ -39,6 +39,7 @@ public function getFilters()
$filters[] = new \Twig_SimpleFilter('urlEncodeText', array($this, 'urlEncodeText'), array('is_safe' => array('html')));
$filters[] = new \Twig_SimpleFilter('addCampaignParamsForTemplate', array($this, 'addCampaignParamsForTemplate'), array('is_safe' => array('html')));
$filters[] = new \Twig_SimpleFilter('stripAndConvertTags', array($this, 'stripAndConvertTags'), array('is_safe' => array('html')));
$filters[] = new \Twig_SimpleFilter('printVars', array($this, 'printVars'));
return $filters;
}

Expand Down Expand Up @@ -171,4 +172,27 @@ public function stripAndConvertTags($html){
$txt = html_entity_decode($txt);
return $txt;
}

public function printVars(array $vars, $allDetails = false, $indent = ""){
$output = "";
$defaultIndent = " ";
ksort($vars);
foreach ($vars as $key => $value){
if (is_array($value)){
if($allDetails) {
$value = "\n" . $this->printVars($value, $allDetails, $indent.$defaultIndent);
} else {
$value = "array(".sizeof($value).")";
}
} else if (is_object($value)) {
if($allDetails) {
$value = "\n" . $this->printVars((array) $value, $allDetails, $indent.$defaultIndent);
} else {
$value = "object(".get_class($value).")";
}
}
$output .= "$indent $key: $value\n";
}
return $output;
}
}

0 comments on commit ab2cfbc

Please sign in to comment.