Dallinger/Dallinger

View on GitHub
dallinger/frontend/templates/dashboard_home.html

Summary

Maintainability
Test Coverage
{% extends "base/dashboard.html" %}

{% macro toggle_switch(var) %}
    <div class="custom-control custom-switch form-switch">

        <input type="checkbox" class="custom-control-input form-check-input" id="{{ var }}"
                {% if configuration_dictionary[var] %}
               checked
                {% endif %}
        >
    </div>
{% endmacro %}

{% block body %}
<h1>Experiment Configuration</h1>
<p>The active <a href="https://dallinger.readthedocs.io/en/latest/configuration.html">configuration</a>,
    assembled from your configuration files, Dallinger defaults, and any explicit overrides.
</p>

<table class="table table-sm table-striped">
    <thead class="thead-dark">
        <tr><th>Key</th><th>Active Value</th></tr>
    </thead>
    <tbody>
    {% for key, value in configuration %}
        <tr><th>{{ key }}</th><td>{{ value }} {% if key in changeable_params %} {{ toggle_switch(key) }} {% endif %}</td></tr>
    {% endfor %}
    </tbody>
</table>
{% endblock %}


{% block libs %}
    {{ super() }}
    <script>
        $('#panel-triggers input').on('change', function () {
            let id = this.id.replace("-trigger", "");
            $('#' + id).toggle();
        });

        $('#auto_recruit').on('change', function () {
            let auto_recruit = this.checked ? 1 : 0
            $.ajax({
                type: "POST",
                url: "/dashboard/auto_recruit/" + auto_recruit,
                success: function (){

                    location.reload()
                },
                error: function (e){
                    alert('Something went wrong' + e)
                }
            });
        });
    </script>
{% endblock %}