Skip to content
Snippets Groups Projects
Commit 335a03c2 authored by Stauros Kroustouris's avatar Stauros Kroustouris
Browse files

prepare fod to accept graphs plugin

parent 8934a1b8
No related branches found
No related tags found
No related merge requests found
...@@ -25,5 +25,6 @@ def settings_vars(context): ...@@ -25,5 +25,6 @@ def settings_vars(context):
# you may add multiple values in there. # you may add multiple values in there.
return { return {
'VERSION': settings.SW_VERSION, 'VERSION': settings.SW_VERSION,
'BRANDING': settings.BRANDING 'BRANDING': settings.BRANDING,
'INSTALLED_APPS': settings.INSTALLED_APPS,
} }
...@@ -67,28 +67,84 @@ ...@@ -67,28 +67,84 @@
{% endif %} {% endif %}
</div> </div>
</div> </div>
</div> {% comment %}check if graphs plugin in installed apps{% endcomment %}
{% if 'graphs' in INSTALLED_APPS %}
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/bootstrap.daterangepicker/2/daterangepicker.css" />
<div class="col-md-12 graphs-wrapper" style="display: none">
<h3>{% trans 'Graphs' %}</h3>
<div class="col-md-3">
<div id="reportrange" style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc;">
<i class="glyphicon glyphicon-calendar fa fa-calendar"></i>&nbsp;
<span></span> <b class="caret"></b>
</div>
</div>
<div class="graphs col-md-12" data-url="{% url graphs route.name %}" >
loading...
</div>
</div>
{% endif %}
</div>
{% endblock %} {% endblock %}
{% block pagejsbottom %} {% block pagejsbottom %}
{% if 'graphs' in INSTALLED_APPS %}
<script src="https://cdn.jsdelivr.net/momentjs/2.9.0/moment.min.js"></script>
<script src="https://cdn.jsdelivr.net/bootstrap.daterangepicker/2/daterangepicker.js"></script>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function () {
var url = $('.graphs').data('url');
var start = moment().subtract(1, 'days').format('X')
var end = moment().format('X')
function cb(start, end) {
$('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
$('.graphs').load(url + '?start=' + start.format('X') + '&end=' + end.format('X'), function () {
$('.graphs-wrapper').show();
});
}
cb(moment().subtract(29, 'days'), moment());
$('body').on('click', ".del_button", function(){ $('#reportrange').daterangepicker({
last_element = false; ranges: {
var my = $(this); 'Today': [moment().subtract(1, 'days'), moment()],
my.html('Deactivating...') 'Yesterday': [moment().subtract(2, 'days'), moment().subtract(1, 'days')],
var routename = $(this).data("routename"); 'Last 7 Days': [moment().subtract(6, 'days'), moment()],
var delurl = "{% url delete-route 'route_placeholder'%}".replace('route_placeholder', routename.toString()); 'Last 30 Days': [moment().subtract(29, 'days'), moment()],
$.ajax({ 'This Month': [moment().startOf('month'), moment().endOf('month')],
type: 'POST', 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
url: delurl, }
cache: false, }, cb(moment().subtract(1, 'days'), moment()));
success: function(data) {
$('.del_button').addClass('disabled').text('Done'); $('body').on('apply.daterangepicker', '#reportrange', function(ev, picker) {
} cb(picker.startDate, picker.endDate);
});
});
</script>
{% endif %}
<script type="text/javascript">
$(document).ready(function () {
$('body').on('click', ".del_button", function(){
last_element = false;
var my = $(this);
my.html('Deactivating...')
var routename = $(this).data("routename");
var delurl = "{% url delete-route 'route_placeholder'%}".replace('route_placeholder', routename.toString());
$.ajax({
type: 'POST',
url: delurl,
cache: false,
success: function(data) {
$('.del_button').addClass('disabled').text('Done');
}
});
return false;
}); });
return false;
}); });
</script> </script>
{% endblock %} {% endblock %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment