{# The following variables are available to all scripts. #}
{% if overview or detailed %}
    {% set field_operation = "%s %s" %}
    {% set ns = namespace(field_parameters='', dash='') %}
{% endif %}
{% if detailed %}
    {% if parameters %}
        {% for para in parameters %}
            {% set ns.dash = ns.dash + '- | ' %}
            {% set ns.field_parameters = ns.field_parameters + '%s | ' %}
        {% endfor %}
        {% set para_head = ns.field_parameters | format(*parameters) %}
    {% endif %}
{% endif %}

{% block overview %}
    {% if overview %}
Overview: {{ total_num_jobs_or_aggregates }} jobs/aggregates, {{ total_num_eligible_jobs_or_aggregates }} jobs/aggregates with eligible operations.

        {% block progress %}
| label | ratio |
| ----- | ----- |
            {% for label in progress_sorted %}
| {{ label[0] }} | {{ label[1]|draw_progress_bar(total_num_job_labels, '\\') }} |
            {% endfor %}
        {% endblock progress %}

        {% block operation_summary %}
| operation/group | number of eligible jobs | submission status |
| --------------- | ----------------------- | ----------------- |
            {% for op, n_jobs, op_submission_status in op_counter %}
| {{ op }} | {{ n_jobs }} | {{ op_submission_status }} |
            {% endfor %}
        {% endblock operation_summary %}
    {% endif %}
{% endblock overview %}

{% block detailed %}
    {% if detailed %}
Detailed View:

| job id | operation/group | {{ para_head }}labels |
| ------ | --------- | {{ ns.dash }}-------- |
        {% for job in jobs %}
            {% if parameters %}
                {% set para_output = ns.field_parameters | format(*job['parameters'].values()) %}
            {% endif %}
            {% for key, value in job['groups'].items() if value | job_filter(scheduler_status_code, all_ops) %}
                {% if loop.first %}
| {{job['aggregate_id']}} | {{ field_operation | highlight(value['eligible'], pretty) | format(value['display_name'], '['+scheduler_status_code[value['scheduler_status']]+']') }} | {{ para_output }}{{ job['labels'] | join(', ') }} |
                {% else %}
|  | {{ field_operation | highlight(value['eligible'], pretty) | format(value['display_name'], '['+scheduler_status_code[value['scheduler_status']]+']') }} | {{ para_output }}{{ job['labels'] | join(', ') }} |
                {% endif %}
            {% endfor %}
        {% endfor %}
    {% endif %}
{% endblock detailed %}
{{ status_legend }}
