61 lines
1.8 KiB
HTML
61 lines
1.8 KiB
HTML
{% load i18n %}
|
|
|
|
{% block cell-content %}
|
|
<h2>{{ cell.title }}</h2>
|
|
|
|
<div>
|
|
{% if form.fields %}
|
|
<form method='get' enctype='multipart/form-data' id='chart-filters'>
|
|
{{ form.as_p }}
|
|
<div class='buttons'>
|
|
<button class='submit-button'>{% trans 'Refresh' %}</button>
|
|
</div>
|
|
</form>
|
|
{% else %}
|
|
<p>
|
|
{% blocktrans trimmed %}
|
|
No filters are available. Note that only filters that are shared between all chart cells will appear. Furthermore, in case they have a value, it must be the same accross all cells.
|
|
{% endblocktrans %}
|
|
</p>
|
|
{% endif %}
|
|
</div>
|
|
|
|
|
|
<script>
|
|
$(function () {
|
|
if (!$('body').data('filters-cell-id')) {
|
|
$('body').data('filters-cell-id', Math.random().toString(36).slice(2, 7));
|
|
|
|
var loaded_cell_count = 0;
|
|
document.querySelectorAll('div.chartngcell embed').forEach(graph => {
|
|
graph.addEventListener('load', function() {
|
|
if (++loaded_cell_count == $('div.chartngcell embed').length) {
|
|
combo_load_cell($('.chart-filters-cell'));
|
|
loaded_cell_count = 0;
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
start_field = $('#id_time_range_start');
|
|
end_field = $('#id_time_range_end');
|
|
$('#id_time_range').change(function() {
|
|
if(this.value == 'range') {
|
|
start_field.parent().show();
|
|
end_field.parent().show();
|
|
} else {
|
|
start_field.parent().hide();
|
|
end_field.parent().hide();
|
|
}
|
|
}).change();
|
|
$('#chart-filters').submit(function(e) {
|
|
e.preventDefault();
|
|
$(window).trigger('combo:refresh-graphs');
|
|
chart_cell = $(this).parents('.cell');
|
|
new_url = chart_cell.data('ajax-cell-url') + '?filters_cell_id=' + $('body').data('filters-cell-id') + '&' + $(this).serialize();
|
|
chart_cell.data('ajax-cell-url', new_url);
|
|
});
|
|
});
|
|
</script>
|
|
{% endblock %}
|