{% extends "suite-base.html" %}
{% block title_name %}task jobs list{% endblock %}
{% block auto_refresh %}<meta http-equiv="refresh" content="120">{% endblock %}
{% block content %}
<div class="page-header">

<div class="panel-group" id="accordion-0">

<div class="panel panel-default">
  <div class="panel-heading">
    <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion-0"
    href="#filter">
      <i class="glyphicon glyphicon-wrench"></i>
      Display Options
    </a>
  </div>
  <div id="filter"
  class="panel-collapse collapse{% if not is_option_on %} in{% endif %}">
    <div class="panel-body">
      <form action="{{script}}/{{method}}">
        <input type="hidden" name="user" value="{{user}}" />
        <input type="hidden" name="suite" value="{{suite}}" />
        <input type="hidden" name="no_fuzzy_time" value="{{no_fuzzy_time}}" />
        <fieldset class="container-fluid">
          <div class="row">
{% for key, name, value in [
    ("cycles", "Cycles (before, after or patterns):" ~
     "&lt;CYCLE | &gt;CYCLE | GLOB ..." | safe , cycles),
    ("tasks", "Task Name Globs", tasks),
] -%}
            <div class="form-group col-sm-12 col-md-6">
              <label for="{{key}}">{{name}}</label>
              <input id="{{key}}" type="text" name="{{key}}" class="form-control"
              title="{{name}}" placeholder="{{name}}"
{% if value -%}
              value="{{value|escape}}"
{% endif -%}
              />
            </div>
{% endfor -%}
          </div>
          <div class="row">
            <div class="col-sm-12 col-md-12">
              <strong>Select by Task Statuses</strong>
              <br/>
              <button id="check_task_statuses" type="button"
              class="btn btn-default btn-xs">check all</button>
              <button id="uncheck_task_statuses" type="button"
              class="btn btn-default btn-xs">uncheck all</button>
            </div>
          </div>
          <div class="form-group row">
{% for key, value in task_statuses -%}
            <div class="col-sm-6 col-md-2">
              <label class="checkbox-inline" for="task_status_{{key}}">
                <input class="task_status" type="checkbox"
                name="task_status"
                value="{{key}}"
                title="Display jobs of {{key}} tasks"
{% if value == "1" -%}
                checked="checked"
{% endif -%}
                />
                {{key}}
              </label>
            </div>
{% endfor -%}
          </div>
          <div class="row">
            <div class="form-group col-sm-12 col-md-6">
              <label for="job_status">Select by Job Status</label>
              <select id="job_status" name="job_status"
              title="Select by Job Status" class="form-control">
{% for key in [
    "all",
    "submitted",
    "submitted,running",
    "submission-failed",
    "submission-failed,failed",
    "running",
    "running,succeeded,failed",
    "succeeded",
    "succeeded,failed",
    "failed",
]
 -%}
                <option
{% if job_status and key == job_status -%}
                selected="selected"
{% endif -%}
                value="{% if key != "all" -%}{{key}}{% endif -%}">{{key}}
                </option>
{% endfor -%}
              </select>
            </div>
            <div class="form-group col-sm-12 col-md-6">
              <label for="order">Sort Order</label>
              <select id="order" name="order" title="Sort Order"
              class="form-control">
{% for k, v in [
    ("time_desc", "new-&gt;old" | safe ),
    ("time_asc", "old-&gt;new" | safe ),
    ("cycle_desc_name_asc", "new-&gt;old cycle, a-z task name" | safe ),
    ("cycle_desc_name_desc", "new-&gt;old cycle, z-a task name" | safe ),
    ("cycle_asc_name_asc", "old-&gt;new cycle, a-z task name" | safe ),
    ("cycle_asc_name_desc", "old-&gt;new cycle, z-a task name" | safe ),
    ("name_asc_cycle_desc", "a-z task name, new-&gt;old cycle" | safe ),
    ("name_desc_cycle_desc", "z-a task name, new-&gt;old cycle" | safe ),
    ("name_asc_cycle_asc", "a-z task name, old-&gt;new cycle" | safe ),
    ("name_desc_cycle_asc", "z-a task name, old-&gt;new cycle" | safe ),
    ("time_submit_desc", "submit time, new-&gt;old" | safe ),
    ("time_submit_asc", "submit time, old-&gt;new" | safe ),
    ("time_run_desc", "run start time, new-&gt;old" | safe ),
    ("time_run_asc", "run start time, old-&gt;new" | safe ),
    ("time_run_exit_desc", "run exit time, new-&gt;old" | safe ),
    ("time_run_exit_asc", "run exit time, old-&gt;new" | safe ),
    ("duration_queue_desc", "queue duration, long-&gt;short" | safe ),
    ("duration_queue_asc", "queue duration, short-&gt;long" | safe ),
    ("duration_run_desc", "run duration, long-&gt;short" | safe ),
    ("duration_run_asc", "run duration, short-&gt;long" | safe ),
    ("duration_queue_run_desc", "queue+run duration, long-&gt;short" | safe ),
    ("duration_queue_run_asc", "queue+run duration, short-&gt;long" | safe ),
] -%}
                <option
{% if order and order == k -%}
                selected="selected"
{% endif -%}
                value="{{k}}">{{v}}
              </option>
{% endfor -%}
              </select>
            </div>
          </div>
          <div class="form-group row">
            <div class="col-sm-12 col-md-12">
              <label for="per_page">Entries/Page, max=300</label>
            </div>
            <div class="col-sm-6 col-md-2">
              <input id="per_page" type="text" name="per_page"
              class="form-control"
              title="Entries/Page, 0=unlimited" placeholder="Entries/Page"
{% if per_page_max <= per_page -%}
              disabled="disabled"
{% elif per_page is defined and per_page != per_page_default -%}
              value="{{per_page}}"
{% endif -%}
              />
            </div>
            <div class="col-sm-2 col-md-8">
              <label class="checkbox-inline" for="per_page_max">
                <input id="per_page_max" type="checkbox" name="per_page"
                value="{{per_page_max}}"
                title="Display maximum {{per_page_max}} number of entries"
{% if per_page_max <= per_page -%}
                checked="checked"
{% endif -%}
                />
                Max
              </label>
            </div>
            <div class="form-group col-sm-4 col-md-2 btn-toolbar">
              <div class="btn-group pull-right">
                <input type="button" class="btn btn-default" value="reset"
                title="Reset Display Options" id="reset_task_statuses"/>
                <input type="submit" class="btn btn-primary" value="update"
                title="Update Display Options"/>
              </div>
            </div>
          </div>
        </fieldset>
      </form>
    </div>
  </div>
</div>

</div>
</div>

{% include "pager.html" -%}

<div class="container-fluid">
  <div class="row">
    <div class="col-md-11">
      {% include "suite-state.html" -%}
    </div>
    <div class="col-md-1 text-right">
      <a id="toggle-fuzzy-time" data-no-fuzzy-time="{{no_fuzzy_time}}" href="#">
        <small>toggle &Delta;t</small>
      </a>
    </div>
  </div>
</div>

<!-- entries -->
<table summary="task job entries"
class="table table-bordered table-condensed table-striped">
  {% include "job-entry-head.html" %}
  <tbody>
{% for entry in entries -%}
  {% include "job-entry.html" %}
{% endfor -%}
  </tbody>
</table><!-- entries -->
{% endblock %}
