{# 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 }} jobs, {{ total_num_eligible_jobs }} jobs 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%}

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

{% block detailed %}
{% if detailed %}
{{ 'Detailed View: \n' }}
| job id | operation | {{ 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(key, '['+scheduler_status_code[value['scheduler_status']]+']') }} | {{ para_output }}{{ job['labels'] | join(', ') }} |
{% else %}
|  | {{ field_operation | highlight(value['eligible'], pretty) | format(key, '['+scheduler_status_code[value['scheduler_status']]+']') }} | {{ para_output }}{{ job['labels'] | join(', ') }} |
{% endif %}
{% endfor %}
{% endfor %}
{% endif %}
{% endblock %}
{{ status_legend }}
