Refactor JSON to be in the html/head tag instead

of at the footer
This commit is contained in:
Mike Terzo
2017-01-26 17:30:58 -05:00
parent 8b883b32f8
commit 936814222d
4 changed files with 48 additions and 47 deletions

View File

@@ -4,6 +4,13 @@
{% if config.DAILY_REPORTS_CHART_ENABLED %}
<link href="{{ url_for('static', filename='css/c3.min.css') }}" rel="stylesheet">
{% endif %}
{% if config.DAILY_REPORTS_CHART_ENABLED %}
{% block script %}
<script src="{{url_for('static', filename='js/d3.min.js')}}"></script>
<script src="{{url_for('static', filename='js/c3.min.js')}}"></script>
<script src="{{url_for('static', filename='js/dailychart.js')}}"></script>
{% endblock script %}
{% endif %}
{% endblock head %}
{% block content %}
{% if config.REFRESH_RATE > 0 %}
@@ -124,10 +131,3 @@
</div>
</div>
{% endblock content %}
{% if config.DAILY_REPORTS_CHART_ENABLED %}
{% block script %}
<script src="{{url_for('static', filename='js/d3.min.js')}}"></script>
<script src="{{url_for('static', filename='js/c3.min.js')}}"></script>
<script src="{{url_for('static', filename='js/dailychart.js')}}"></script>
{% endblock script %}
{% endif %}

View File

@@ -19,6 +19,36 @@
{% endif %}
<link href="{{ url_for('static', filename='Semantic-UI-2.1.8/semantic.min.css') }}" rel="stylesheet" />
<link href="{{ url_for('static', filename='css/puppetboard.css') }}" rel="stylesheet" />
{% if config.OFFLINE_MODE %}
<script src="{{ url_for('static', filename='jquery-2.1.1/jquery.min.js') }}"></script>
<script src="{{ url_for('static', filename='jquery-datatables-1.10.13/jquery.dataTables.min.js') }}"></script>
<script src="{{ url_for('static', filename='jquery-datatables-1.10.13/dataTables.semanticui.min.js') }}"></script>
{% if config.LOCALISE_TIMESTAMP %}
<script src="{{ url_for('static', filename='moment.js-2.7.0/moment.min.js') }}"></script>
{% endif %}
{% else %}
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/datatables/1.10.13/js/jquery.dataTables.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/datatables/1.10.13/js/dataTables.semanticui.min.js"></script>
{% if config.LOCALISE_TIMESTAMP %}
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.7.0/moment.min.js"></script>
{% endif %}
{% endif %}
{% if config.LOCALISE_TIMESTAMP %}
<script src="{{ url_for('static', filename='js/timestamps.js')}}"></script>
{% endif %}
<script src="{{ url_for('static', filename='Semantic-UI-2.1.8/semantic.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/lists.js') }}"></script>
<script src="{{ url_for('static', filename='js/scroll.top.js') }}"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".ui.dropdown").dropdown();
{% block onload_script %} {% endblock onload_script %}
})
</script>
{% block script %} {% endblock script %}
{% block head %} {% endblock head %}
</head>
@@ -70,32 +100,5 @@
Copyright &copy; 2013-{{ now('%Y') }} <a href="https://github.com/voxpupuli" target="_blank">Puppet Community</a>. <span style="float:right">Live from PuppetDB.</span>
</div>
</footer>
{% if config.OFFLINE_MODE %}
<script src="{{ url_for('static', filename='jquery-2.1.1/jquery.min.js') }}"></script>
<script src="{{ url_for('static', filename='jquery-datatables-1.10.13/jquery.dataTables.min.js') }}"></script>
<script src="{{ url_for('static', filename='jquery-datatables-1.10.13/dataTables.semanticui.min.js') }}"></script>
{% if config.LOCALISE_TIMESTAMP %}
<script src="{{ url_for('static', filename='moment.js-2.7.0/moment.min.js') }}"></script>
{% endif %}
{% else %}
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/datatables/1.10.13/js/jquery.dataTables.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/datatables/1.10.13/js/dataTables.semanticui.min.js"></script>
{% if config.LOCALISE_TIMESTAMP %}
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.7.0/moment.min.js"></script>
{% endif %}
{% endif %}
{% if config.LOCALISE_TIMESTAMP %}
<script src="{{ url_for('static', filename='js/timestamps.js')}}"></script>
{% endif %}
<script src="{{ url_for('static', filename='Semantic-UI-2.1.8/semantic.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/lists.js') }}"></script>
<script src="{{ url_for('static', filename='js/scroll.top.js') }}"></script>
<script type="text/javascript">
$(".ui.dropdown").dropdown();
</script>
{% block script %} {% endblock script %}
</body>
</html>

View File

@@ -4,6 +4,15 @@
{% if config.DAILY_REPORTS_CHART_ENABLED %}
<link href="{{ url_for('static', filename='css/c3.min.css') }}" rel="stylesheet" />
{% endif %}
{% block script %}
<script type="text/javascript">
{{ macros.datatable_init(table_html_id="reports_table", ajax_url=url_for('reports_ajax', env=current_env, node_name=node.name), default_length=config.LITTLE_TABLE_COUNT, length_selector=config.TABLE_COUNT_SELECTOR, columns=columns) }}
</script>
{% if config.DAILY_REPORTS_CHART_ENABLED %}
<script src="{{url_for('static', filename='js/d3.min.js')}}"></script>
<script src="{{url_for('static', filename='js/c3.min.js')}}"></script>
<script src="{{url_for('static', filename='js/dailychart.js')}}"></script>
{% endif %}
{% endblock head %}
{% block content %}
<div class='ui two column grid'>
@@ -58,13 +67,4 @@
</div>
</div>
{% endblock content %}
{% block script %}
<script type="text/javascript">
{{ macros.datatable_init(table_html_id="reports_table", ajax_url=url_for('reports_ajax', env=current_env, node_name=node.name), default_length=config.LITTLE_TABLE_COUNT, length_selector=config.TABLE_COUNT_SELECTOR, columns=columns) }}
</script>
{% if config.DAILY_REPORTS_CHART_ENABLED %}
<script src="{{url_for('static', filename='js/d3.min.js')}}"></script>
<script src="{{url_for('static', filename='js/c3.min.js')}}"></script>
<script src="{{url_for('static', filename='js/dailychart.js')}}"></script>
{% endif %}
{% endblock script %}

View File

@@ -28,12 +28,11 @@
</tbody>
</table>
{% endblock content %}
{% block script %}
{% block onload_script %}
{% macro extra_options(caller) %}
// No initial loading
"deferLoading": true,
{% endmacro %}
<script type="text/javascript">
{{ macros.datatable_init(table_html_id="reports_table", ajax_url=url_for('reports_ajax', env=current_env, node_name=node_name), default_length=config.NORMAL_TABLE_COUNT, length_selector=config.TABLE_COUNT_SELECTOR, extra_options=extra_options, columns=columns) }}
// Event listener for status filters
@@ -56,5 +55,4 @@
$('#failed, #changed, #unchanged, #noop').change(status_filter_change);
// Call at init - fix page reload behavior
status_filter_change();
</script>
{% endblock script %}
{% endblock onload_script %}