Skip to content

Commit

Permalink
Separate download dropdowns for each dataset.
Browse files Browse the repository at this point in the history
Clean up report list css.
  • Loading branch information
Jeremy Dorn committed Dec 15, 2014
1 parent 2ae970a commit e64741d
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 107 deletions.
5 changes: 3 additions & 2 deletions public/css/report_list.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#report_list a[name] {
padding-top: 10px;
margin-top: -30px;
padding: 0;
margin: 0;
height: 5px;
visibility: hidden;
}
#report_list h2.no_title {
Expand Down
209 changes: 106 additions & 103 deletions templates/default/html/report.twig
Original file line number Diff line number Diff line change
Expand Up @@ -67,117 +67,120 @@
{% endblock %}

{% block content %}
<div class='row export_links' style='margin: 10px 0;'>
{% block export_links %}
{% block download_link %}
{% if config.report_formats|length > 1 %}
<div class="btn-group">
<button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-toggle="dropdown">
<i class='icon-download'></i> Download/show as <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
{% for format in config.report_formats|keys %}
{% if config.report_formats[format] == 'divider' %}
<li class="divider"></li>
{% else %}
<li><a href='{{base}}/report/{{format}}/?{{report_querystring}}' class='report_link'>{{config.report_formats[format]}}</a></li>
{% endif %}
{% endfor %}
</ul>
</div>
{% else %}
<a href='{{base}}/report/{{config.report_formats|keys[0]}}/?{{report_querystring}}' class='report_link btn'>
<i class='icon-download'></i> Download {{config.report_formats[config.report_formats|keys[0]]}}
</a>
{% endif %}
{% endblock %}
{% if config.mail_settings.enabled %}
{% block email_report_button %}
<a data-toggle="modal" href="#email-modal" class="btn btn-primary btn-sm"><i class='icon-envelope'></i> Email Report</a>
<div class="modal fade" id="email-modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">Email Report</h4>
</div>
<div class="modal-body">
<div class="alert alert-danger" id="email-report-modal-alert" style="display: none;"></div>
<p>A CSV file will be attached and a link will be sent</p>
{% if is_ready %}
<div class='row export_links' style='margin: 10px 0;'>
{% block export_links %}
{% block download_link %}
{% if config.report_formats|length > 1 %}
{% if DataSets|length > 1 %}All Report Tables:{% endif %}
<div class="btn-group">
<button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-toggle="dropdown">
<i class='icon-download'></i> Download/show as <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
{% for format in config.report_formats|keys %}
{% if config.report_formats[format] == 'divider' %}
<li class="divider"></li>
{% elseif DataSets|length <= 1 or format != 'csv' %}
<li><a href='{{base}}/report/{{format}}/?{% if DataSets|length > 1 %}datasets=all&{% endif %}{{report_querystring}}' class='report_link'>{{config.report_formats[format]}}</a></li>
{% endif %}
{% endfor %}
</ul>
</div>
{% else %}
<a href='{{base}}/report/{{config.report_formats|keys[0]}}/?{{report_querystring}}' class='report_link btn'>
<i class='icon-download'></i> Download {{config.report_formats[config.report_formats|keys[0]]}}
</a>
{% endif %}
{% endblock %}
{% if config.mail_settings.enabled %}
{% block email_report_button %}
<a data-toggle="modal" href="#email-modal" class="btn btn-primary btn-sm"><i class='icon-envelope'></i> Email Report</a>
<div class="modal fade" id="email-modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">Email Report</h4>
</div>
<div class="modal-body">
<div class="alert alert-danger" id="email-report-modal-alert" style="display: none;"></div>
<p>A CSV file will be attached and a link will be sent</p>

<form class="form-horizontal" role="form">
<div class="form-group">
<label class="col-lg-5" for='email-report-modal-email'>Recipient Email Address</label>
<div class="col-lg-7">
<input type='email' id='email-report-modal-email' class='form-control' value='' />
<form class="form-horizontal" role="form">
<div class="form-group">
<label class="col-lg-5" for='email-report-modal-email'>Recipient Email Address</label>
<div class="col-lg-7">
<input type='email' id='email-report-modal-email' class='form-control' value='' />
</div>
</div>
</div>
<div class="form-group">
<label class="col-lg-5" for='email-report-modal-subject'>Subject</label>
<div class="col-lg-7">
<input type='text' id='email-report-modal-subject' class='form-control' value="Database Report - {{Name}}" />
<div class="form-group">
<label class="col-lg-5" for='email-report-modal-subject'>Subject</label>
<div class="col-lg-7">
<input type='text' id='email-report-modal-subject' class='form-control' value="Database Report - {{Name}}" />
</div>
</div>
</div>
<div class="form-group">
<label class="col-lg-5" for='email-report-modal-message'>Message (optional)</label>
<div class="col-lg-7">
<textarea rows='4' id='email-report-modal-message' class='form-control'></textarea>
<div class="form-group">
<label class="col-lg-5" for='email-report-modal-message'>Message (optional)</label>
<div class="col-lg-7">
<textarea rows='4' id='email-report-modal-message' class='form-control'></textarea>
</div>
</div>
</div>
</form>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn" data-dismiss="modal">Cancel</button>
<button type="submit" id="sendReport" class="btn btn-primary submit-button" data-loading-text="Sending">Send Email</button>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn" data-dismiss="modal">Cancel</button>
<button type="submit" id="sendReport" class="btn btn-primary submit-button" data-loading-text="Sending">Send Email</button>
</div>
</div>
</div>
</div>
</div>
<script>
$(function() {
$('#sendReport').on('click', function() {
var button = $(this);
button.button('loading');
var data = {
email: $('#email-report-modal-email').val(),
subject: $('#email-report-modal-subject').val(),
message: $('#email-report-modal-message').val(),
url: window.location.href
};
<script>
$(function() {
$('#sendReport').on('click', function() {
var button = $(this);
button.button('loading');
$.getJSON('{{base}}/email',data,function(response) {
if(response && response.success) {
$('#email-modal').modal('hide');
//show success message
$('#email-report-success-message').show(300).delay(5000).hide(300);
}
else {
var error = (response && response.error)? response.error : "There was a problem sending the email";
$('#email-report-modal-alert').text(error).show(300);
}
button.button('reset');
})
.error(function() {
$('#email-report-modal-alert').text("There was an error while sending the email").show(300);
});
return false;
});
});
</script>
{% endblock %}
{% endif %}
{% endblock %}
</div>
var data = {
email: $('#email-report-modal-email').val(),
subject: $('#email-report-modal-subject').val(),
message: $('#email-report-modal-message').val(),
url: window.location.href
};
$.getJSON('{{base}}/email',data,function(response) {
if(response && response.success) {
$('#email-modal').modal('hide');
//show success message
$('#email-report-success-message').show(300).delay(5000).hide(300);
}
else {
var error = (response && response.error)? response.error : "There was a problem sending the email";
$('#email-report-modal-alert').text(error).show(300);
}
button.button('reset');
})
.error(function() {
$('#email-report-modal-alert').text("There was an error while sending the email").show(300);
});
return false;
});
});
</script>
{% endblock %}
{% endif %}
{% endblock %}
</div>

{% if config.mail_settings.enabled %}
<div class='alert alert-success' style='display: none;' id='email-report-success-message'>
{% block email_report_success_message %}
Email Sent Successfully
{% endblock %}
</div>
{% if config.mail_settings.enabled %}
<div class='alert alert-success' style='display: none;' id='email-report-success-message'>
{% block email_report_success_message %}
Email Sent Successfully
{% endblock %}
</div>
{% endif %}
{% endif %}

<div id='report_content'>
Expand Down
28 changes: 26 additions & 2 deletions templates/default/html/table.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,31 @@
{% if not nodata %}
{% for dataset in DataSets %}
{% if dataset.title %}<h3>{{dataset.title}}</h3>
{% endif %}
{% if dataset.title %}<h3>{{dataset.title}}</h3>{% endif %}
{% if DataSets|length > 1 %}
{% block table_download_link %}
{% set dataset_id = loop.index - 1 %}
{% if config.report_formats|length > 1 %}
<div class="btn-group">
<button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-toggle="dropdown">
<i class='icon-download'></i> Download/show as <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
{% for format in config.report_formats|keys %}
{% if config.report_formats[format] == 'divider' %}
<li class="divider"></li>
{% else %}
<li><a href='{{base}}/report/{{format}}/?dataset={{ dataset_id }}&{{report_querystring}}' class='report_link'>{{config.report_formats[format]}}</a></li>
{% endif %}
{% endfor %}
</ul>
</div>
{% else %}
<a href='{{base}}/report/{{config.report_formats|keys[0]}}/?{{report_querystring}}' class='report_link btn'>
<i class='icon-download'></i> Download {{config.report_formats[config.report_formats|keys[0]]}}
</a>
{% endif %}
{% endblock %}
{% endif %}
<table{% if not inline_email %} id='result_table_{{loop.index}}' class='result_table table table-bordered table-striped'{% else %} border="1" cellspacing="0"{% endif %}>
{% if dataset.vertical %}
<thead>
Expand Down

0 comments on commit e64741d

Please sign in to comment.