{% extends "pyfarm/user_interface/layout.html" %}
{% block title %}Jobs{% endblock %}
{% block jobs_nb_class %}active{% endblock %}
{% block additional_styles %}
<link href="{{ url_for('static', filename='css/jobs.css') }}" rel="stylesheet">
{% endblock %}
{% block additional_scripts %}
<script src="{{ url_for('static', filename='js/jobs.js') }}" type="text/javascript"></script>
{% endblock %}
{% block content %}

<ul class="nav nav-tabs">
  <li role="presentation" class="active"><a href="#">Filters</a></li>
  <li role="presentation" class="dropdown">
    <a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-expanded="false">
      Selected Jobs <span class="caret"/>
    </a>
    <ul class="dropdown-menu" role="menu">
      <li role="presentation"><a href="#" id="selected-rerun">Rerun</a></li>
      <li role="presentation"><a href="#" id="selected-rerun-failed">Rerun Failed Tasks</a></li>
      <li role="presentation"><a href="#" id="selected-pause">Pause</a></li>
      <li role="presentation"><a href="#" id="selected-resume">Resume</a></li>
      <li role="presentation"><a href="#" id="selected-delete">Delete</a></li>
      <li role="presentation" class="divider"></li>
      <li role="presentation">
        <a href="#" id="selected-move">Move To Queue...</a>
      </li>
      <li role="presentation">
        <a href="#" id="selected-set-prio-weight">Set Priority and Weight...</a>
      </li>
    </ul>
  </li>
</ul>

<form method="GET" action="{{ url_for('jobs_index_ui') }}" class="form-inline" role="form" style="margin-top: 15px;">
  <input type="hidden" name="order_by" value="{{ order_by }}"/>
  <input type="hidden" name="order_dir" value="{{ order_dir }}"/>
  <label for="tags">Tags</label>
  <input type="text" class="form-control" id="tags" name="tags" value="{{ filters.tags }}" placeholder="Tags separated by spaces"/>
  <label for="title">Title</label>
  <input type="text" class="form-control" id="title" name="title" value="{{ filters.title }}" placeholder="Part of job title"/>
  <div class="btn-group">
    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" id="state-dropdown-menu" aria-expanded="true">
      State <span class="caret"></span>
    </button>
    <ul class="dropdown-menu dropdown-menu-form" role="menu" aria-labelledby="state-dropdown-menu">
      <li>
        <label class="checkbox">
          {% if filters.state_paused or no_state_filters %}
          <input type="checkbox" name="state_paused" value="true" checked/>
          {% else %}
          <input type="checkbox" name="state_paused" value="true"/>
          {% endif %}
          Paused
        </label>
      </li>
      <li>
        <label class="checkbox">
          {% if filters.state_queued or no_state_filters %}
          <input type="checkbox" name="state_queued" value="true" checked/>
          {% else %}
          <input type="checkbox" name="state_queued" value="true"/>
          {% endif %}
          Queued
        </label>
      </li>
      <li>
        <label class="checkbox">
          {% if filters.state_running or no_state_filters %}
          <input type="checkbox" name="state_running" value="true" checked/>
          {% else %}
          <input type="checkbox" name="state_running" value="true"/>
          {% endif %}
          Running
        </label>
      </li>
      <li>
        <label class="checkbox">
          {% if filters.state_failed or no_state_filters %}
          <input type="checkbox" name="state_failed" value="true" checked/>
          {% else %}
          <input type="checkbox" name="state_failed" value="true"/>
          {% endif %}
          Failed
        </label>
      </li>
      <li>
        <label class="checkbox">
          {% if filters.state_done or no_state_filters %}
          <input type="checkbox" name="state_done" value="true" checked/>
          {% else %}
          <input type="checkbox" name="state_done" value="true"/>
          {% endif %}
          Done
        </label>
      </li>
    </ul>
  </div>
  <input type="hidden" name="hidden_filter" value="true">
  <div class="btn-group">
    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" id="hidden-dropdown-menu" aria-expanded="true">
      Hidden <span class="caret"></span>
    </button>
    <ul class="dropdown-menu dropdown-menu-form" role="menu" aria-labelledby="hidden-dropdown-menu">
      <li>
        <label class="checkbox">
          {% if filters.hidden %}
          <input type="checkbox" name="hidden" value="true" checked/>
          {% else %}
          <input type="checkbox" name="hidden" value="true"/>
          {% endif %}
          Show Hidden
        </label>
      </li>
      <li>
        <label class="checkbox">
          {% if filters.not_hidden %}
          <input type="checkbox" name="not_hidden" value="true" checked/>
          {% else %}
          <input type="checkbox" name="not_hidden" value="true"/>
          {% endif %}
          Show Not Hidden
        </label>
      </li>
    </ul>
  </div>
  <input type="hidden" name="blocked_filter" value="true">
  <div class="btn-group">
    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" id="blocked-dropdown-menu" aria-expanded="true">
      Blocked <span class="caret"></span>
    </button>
    <ul class="dropdown-menu dropdown-menu-form" role="menu" aria-labelledby="blocked-dropdown-menu">
      <li>
        <label class="checkbox">
          {% if filters.blocked %}
          <input type="checkbox" name="blocked" value="true" checked/>
          {% else %}
          <input type="checkbox" name="blocked" value="true"/>
          {% endif %}
          Show Blocked
        </label>
      </li>
      <li>
        <label class="checkbox">
          {% if filters.not_blocked %}
          <input type="checkbox" name="not_blocked" value="true" checked/>
          {% else %}
          <input type="checkbox" name="not_blocked" value="true"/>
          {% endif %}
          Show Not Blocked
        </label>
      </li>
    </ul>
  </div>
  <div class="btn-group">
    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" id="user-dropdown-menu" aria-expanded="true">
      User <span class="caret"></span>
    </button>
    <ul class="dropdown-menu dropdown-menu-form" role="menu" aria-labelledby="user-dropdown-menu">
      <li>
        <label class="checkbox">
          {% if filters.no_user %}
          <input type="checkbox" name="no_user" value="true" checked/>
          {% else %}
          <input type="checkbox" name="no_user" value="true"/>
          {% endif %}
        </label>
      </li>
      {% for user in users %}
      <li>
        <label class="checkbox">
          {% if user.id in filters.u %}
          <input type="checkbox" name="u" value="{{ user.id }}" checked/>
          {% else %}
          <input type="checkbox" name="u" value="{{ user.id }}"/>
          {% endif %}
          {{ user.username }}
        </label>
      </li>
      {% endfor %}
    </ul>
  </div>
  <div class="btn-group">
    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" id="jobqueue-dropdown-menu" aria-expanded="true">
      Queue <span class="caret"></span>
    </button>
    <ul class="dropdown-menu dropdown-menu-form" role="menu" aria-labelledby="jobqueue-dropdown-menu">
      <li>
        <label class="checkbox">
          {% if filters.no_queue %}
          <input type="checkbox" name="no_queue" value="true" checked/>
          {% else %}
          <input type="checkbox" name="no_queue" value="true"/>
          {% endif %}
        </label>
      </li>
      {% for jobqueue in jobqueues %}
      <li>
        <nobr>
          <label class="checkbox">
            {% if jobqueue.id in filters.q %}
            <input type="checkbox" name="q" value="{{ jobqueue.id }}" checked/>
            {% else %}
            <input type="checkbox" name="q" value="{{ jobqueue.id }}"/>
            {% endif %}
            {{ jobqueue.path() }}
          </label>
        </nobr>
      </li>
      {% endfor %}
    </ul>
  </div>
  <div class="btn-group">
    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" id="jobtype-dropdown-menu" aria-expanded="true">
      Jobtype <span class="caret"></span>
    </button>
    <ul class="dropdown-menu dropdown-menu-form" role="menu" aria-labelledby="jobtype-dropdown-menu">
      {% for jobtype in jobtypes %}
      <li>
        <nobr>
          <label class="checkbox">
            {% if jobtype.id in filters.jt %}
            <input type="checkbox" name="jt" value="{{ jobtype.id }}" checked/>
            {% else %}
            <input type="checkbox" name="jt" value="{{ jobtype.id }}"/>
            {% endif %}
            {{ jobtype.name }}
          </label>
        </nobr>
      </li>
      {% endfor %}
    </ul>
  </div>
  <div class="btn-group">
    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" id="priorities-dropdown-menu" aria-expanded="true">
      Prio <span class="caret"></span>
    </button>
    <ul class="dropdown-menu dropdown-menu-form" role="menu" aria-labelledby="priorities-dropdown-menu">
      {% for priority in priorities %}
      <li>
        <nobr>
          <label class="checkbox">
            {% if priority in filters.p %}
            <input type="checkbox" name="p" value="{{ priority }}" checked/>
            {% else %}
            <input type="checkbox" name="p" value="{{ priority }}"/>
            {% endif %}
            {{ priority }}
          </label>
        </nobr>
      </li>
      {% endfor %}
    </ul>
  </div>
  <label for="per_page" title="Zero or negative values for no pagination">Per page</label>
  <input type="text" class="form-control" id="per_page" name="per_page" value="{{ filters.per_page }}" placeholder="Number" size="4" style="width: 5em;"/>

  <input type="submit" class="btn" value="Filter">
</form>

<nav>
  <ul class="pagination">
    <li class="{{ 'disabled' if filters.page == 1 else '' }}">
      <a href="{{ url_for('jobs_index_ui', per_page=filters.per_page, page=filters.page - 1, **filters_and_order_wo_pagination) }}" aria-label="Previous">
        <span aria-hidden="true">&laquo;</span>
      </a>
    </li>
    {% for page in all_pages %}
    <li class="{{ 'active' if filters.page == page + 1 else '' }}">
      <a href="{{ url_for('jobs_index_ui', per_page=filters.per_page, page=page + 1, **filters_and_order_wo_pagination) }}">{{ page + 1}}</a>
    </li>
    {% endfor %}
    <li class="{{ 'disabled' if filters.page == num_pages else '' }}">
      <a href="{{ url_for('jobs_index_ui', per_page=filters.per_page, page=filters.page + 1, **filters_and_order_wo_pagination) }}" aria-label="Next">
        <span aria-hidden="true">&raquo;</span>
      </a>
    </li>
  </ul>
</nav>

<div>Jobs: {{ jobs_count }} (Queued: {{ queued_jobs_count }}, Running: {{ running_jobs_count}}, Failed: {{ failed_jobs_count }}, Done: {{ done_jobs_count }} )</div>

<table class="table table-striped table-bordered">
  <tr>
    <th><input type="checkbox" title="Select all rows" class="all-jobs-selector"/></th>
    <th></th>
    <th>
      <a href="{{ url_for('jobs_index_ui', order_by='state', order_dir='asc' if order_dir == 'desc' else 'desc', **filters) }}">
        State
        {% if order_by == 'state' and order_dir == 'desc' %}
        <span class="glyphicon glyphicon-chevron-down"></span>
        {% elif order_by == 'state' %}
        <span class="glyphicon glyphicon-chevron-up"></span>
        {% endif %}
     </a> /
     <a href="{{ url_for('jobs_index_ui', order_by='title', order_dir='asc' if order_dir == 'desc' else 'desc', **filters) }}">
        Title
        {% if order_by == 'title' and order_dir == 'desc' %}
        <span class="glyphicon glyphicon-chevron-down"></span>
        {% elif order_by == 'title' %}
        <span class="glyphicon glyphicon-chevron-up"></span>
        {% endif %}
      </a>
    </th>
    <th>
      <a href="{{ url_for('jobs_index_ui', order_by='jobtype_name', order_dir='asc' if order_dir == 'desc' else 'desc', **filters) }}">
        JobType
        {% if order_by == 'jobtype_name' and order_dir == 'desc' %}
        <span class="glyphicon glyphicon-chevron-down"></span>
        {% elif order_by == 'jobtype_name' %}
        <span class="glyphicon glyphicon-chevron-up"></span>
        {% endif %}
      </a>
    </th>
    <th>
      <a href="{{ url_for('jobs_index_ui', order_by='jobqueue_path', order_dir='asc' if order_dir == 'desc' else 'desc', **filters) }}">
        Queue
        {% if order_by == 'jobqueue_path' and order_dir == 'desc' %}
        <span class="glyphicon glyphicon-chevron-down"></span>
        {% elif order_by == 'jobqueue_path' %}
        <span class="glyphicon glyphicon-chevron-up"></span>
        {% endif %}
      </a>
    </th>
    <th>
      <a href="{{ url_for('jobs_index_ui', order_by='priority', order_dir='asc' if order_dir == 'desc' else 'desc', **filters) }}">
        Prio
        {% if order_by == 'priority' and order_dir == 'desc' %}
        <span class="glyphicon glyphicon-chevron-down"></span>
        {% elif order_by == 'priority' %}
        <span class="glyphicon glyphicon-chevron-up"></span>
        {% endif %}
      </a>
    </th>
    <th>
      <a href="{{ url_for('jobs_index_ui', order_by='username', order_dir='asc' if order_dir == 'desc' else 'desc', **filters) }}">
        User
        {% if order_by == 'username' and order_dir == 'desc' %}
        <span class="glyphicon glyphicon-chevron-down"></span>
        {% elif order_by == 'username' %}
        <span class="glyphicon glyphicon-chevron-up"></span>
        {% endif %}
      </a>
    </th>
    <th>
      Tasks (
      <a href="{{ url_for('jobs_index_ui', order_by='t_queued', order_dir='asc' if order_dir == 'desc' else 'desc', **filters) }}">
        queued
        {% if order_by == 't_queued' and order_dir == 'desc' %}
        <span class="glyphicon glyphicon-chevron-down"></span>
        {% elif order_by == 't_queued' %}
        <span class="glyphicon glyphicon-chevron-up"></span>
        {% endif %}
      </a>
      /
      <a href="{{ url_for('jobs_index_ui', order_by='t_running', order_dir='asc' if order_dir == 'desc' else 'desc', **filters) }}">
        running
        {% if order_by == 't_running' and order_dir == 'desc' %}
        <span class="glyphicon glyphicon-chevron-down"></span>
        {% elif order_by == 't_running' %}
        <span class="glyphicon glyphicon-chevron-up"></span>
        {% endif %}
      </a>
      /
      <a href="{{ url_for('jobs_index_ui', order_by='t_failed', order_dir='asc' if order_dir == 'desc' else 'desc', **filters) }}">
        failed
        {% if order_by == 't_failed' and order_dir == 'desc' %}
        <span class="glyphicon glyphicon-chevron-down"></span>
        {% elif order_by == 't_failed' %}
        <span class="glyphicon glyphicon-chevron-up"></span>
        {% endif %}
      </a>
      /
      <a href="{{ url_for('jobs_index_ui', order_by='t_done', order_dir='asc' if order_dir == 'desc' else 'desc', **filters) }}">
        done
        {% if order_by == 't_done' and order_dir == 'desc' %}
        <span class="glyphicon glyphicon-chevron-down"></span>
        {% elif order_by == 't_done' %}
        <span class="glyphicon glyphicon-chevron-up"></span>
        {% endif %}
      </a>)
    </th>
    <th>
      <a href="{{ url_for('jobs_index_ui', order_by='agent_count', order_dir='asc' if order_dir == 'desc' else 'desc', **filters) }}">
        Agents
        {% if order_by == 'agent_count' and order_dir == 'desc' %}
        <span class="glyphicon glyphicon-chevron-down"></span>
        {% elif order_by == 'agent_count' %}
        <span class="glyphicon glyphicon-chevron-up"></span>
        {% endif %}
      </a>
    </th>
    <th>
      <a href="{{ url_for('jobs_index_ui', order_by='time_submitted', order_dir='asc' if order_dir == 'desc' else 'desc', **filters) }}">
        Submitted
        {% if order_by == 'time_submitted' and order_dir == 'desc' %}
        <span class="glyphicon glyphicon-chevron-down"></span>
        {% elif order_by == 'time_submitted' %}
        <span class="glyphicon glyphicon-chevron-up"></span>
        {% endif %}
      </a>
    </th>
  </tr>
  {% for job in jobs %}
  <tr>
    <td><input type="checkbox" name="jobid" value="{{ job[0].id }}" title="Select job" class="job-selector"></td>
    <td>

      <form style="display: inline;" role="form" method="POST" action="{{ url_for('delete_single_job_ui', job_id=job[0].id, next=url_for('jobs_index_ui', **filters_and_order)) }}">
        <label for="delete-job-{{ job[0].id }}-submit" class="clickable-icon" title="Delete job"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></label>
        <input id="delete-job-{{ job[0].id }}-submit" type="submit" class="hidden" onclick="return confirm('Are you sure you want to delete this job?');"/>
      </form>

      <form style="display: inline;" role="form" method="POST" action="{{ url_for('rerun_single_job_ui', job_id=job[0].id, next=url_for('jobs_index_ui', **filters_and_order)) }}">
        <label for="rerun-job-{{ job[0].id }}-submit" class="clickable-icon" title="Rerun job"><span class="glyphicon glyphicon-repeat" aria-hidden="true"></span></label>
        <input id="rerun-job-{{ job[0].id }}-submit" type="submit" class="hidden" onclick="return confirm('Are you sure you want to rerun this job? This will include all tasks, even those already done.');"/>
      </form>

      {% if job[0].output_link %}
      <a href="{{ job[0].output_link }}">
        <span class="glyphicon glyphicon-folder-open"></span>
      </a>
      {% endif %}
    </td>
    <td>
      {% if job.blocker_count > 0 %}
      <span class="glyphicon glyphicon-ban-circle" title="blocked by {{ job.blocker_count }} parent {{ 'jobs' if job.blocker_count > 1 else 'job' }}"></span>
      {% endif %}
      {% if not job[0].state %}
      <span class="glyphicon glyphicon-time" title="queued"></span>
      {% endif %}
      {% if job[0].state == "running" %}
      <span style="color:#337AB7" class="glyphicon glyphicon-play" title="running"></span>
      {% endif %}
      {% if job[0].state == "done" %}
      <span style="color:#5CB85C" class="glyphicon glyphicon-ok" title="done"></span>
      {% endif %}
      {% if job[0].state == "failed" %}
      <span style="color:#D9534F" class="glyphicon glyphicon-remove" title="failed"></span>
      {% endif %}
      {% if job[0].state == "paused" %}
      <span class="glyphicon glyphicon-pause" title="paused"></span>
      {% endif %}
      {% if job[0].to_be_deleted %}
      <span class="glyphicon glyphicon-trash" title="deleting"></span>
      {% endif %}
      <a href="{{ url_for('single_job_ui', job_id=job[0].id) }}">
        {{ job[0].title }}
      </a>
      {% if job["child_count"] %}
      <span class="glyphicon glyphicon-circle-arrow-down clickable-icon subjob_toggle" data-jobid="{{ job[0].id }}" data-open=false></span>
      {%endif%}
      {% for tag in (tags_by_job_id[job[0].id] or []) %}
      {% if tag in filters.tags %}
      <span class="label label-default">
        {{ tag }}
      </span>
      {% else %}
      <a class="label label-info" style="margin:3px;" href="{{ url_for('jobs_index_ui', tags=(filters.tags or '') + ' ' + tag, title=filters.title, state=filters.state, **order) }}">
        {{ tag }}
      </a>
      {% endif %}
      {% endfor %}
    </td>
    <td><a href="{{ url_for('single_jobtype_ui', jobtype_id=job['jobtype_id']) }}">{{ job["jobtype_name"] }}</a></td>
    <td>
      {% if job[0].job_queue_id %}
      <a href="{{ url_for('single_jobqueue_ui', queue_id=job[0].job_queue_id) }}">
        {{ job['jobqueue_path'] }}
      </a>
      {% endif %}
    </td>
    <td>{{ job[0].priority }}</td>
    <td>{{ job.username or '' }}</td>
    <td>
      <div class="progress job_progress">
        <div class="progress-bar progress-bar-success" style="width:{{ (100 * job.t_done / (job.t_queued + job.t_running + job.t_failed + job.t_done)) if (job.t_queued + job.t_running + job.t_failed + job.t_done) > 0 else 0 }}%">
          <span class="sr-only">{{ (100 * job.t_done / (job.t_queued + job.t_running + job.t_failed + job.t_done))|round(1) if (job.t_queued + job.t_running + job.t_failed + job.t_done) > 0 else 0 }}%</span>
        </div>
        <div class="progress-bar progress-bar-striped" style="width:{{ (100 * job.t_running / (job.t_queued + job.t_running + job.t_failed + job.t_done)) if (job.t_queued + job.t_running + job.t_failed + job.t_done) > 0 else 0 }}%">
          <span class="sr-only">{{ (100 * job.t_running / (job.t_queued + job.t_running + job.t_failed + job.t_done))|round(1) if (job.t_queued + job.t_running + job.t_failed + job.t_done) > 0 else 0 }}%</span>
        </div>
        <div class="progress-bar progress-bar-danger" style="width:{{ (100 * job.t_failed / (job.t_queued + job.t_running + job.t_failed + job.t_done)) if (job.t_queued + job.t_running + job.t_failed + job.t_done) > 0 else 0 }}%">
          <span class="sr-only">{{ (100 * job.t_failed / (job.t_queued + job.t_running + job.t_failed + job.t_done))|round(1) if (job.t_queued + job.t_running + job.t_failed + job.t_done) > 0 else 0 }}%</span>
        </div>
      </div>
      {{ job.t_queued }}/{{ job.t_running }}/{{ job.t_failed }}/{{ job.t_done }}
    </td>
    <td>{{ job.agent_count }}</td>
    <td class="timestamp">{{ job[0].time_submitted.isoformat() }}</td>
  </tr>
  {% endfor %}
</table>

<nav>
  <ul class="pagination">
    <li class="{{ 'disabled' if filters.page == 1 else '' }}">
      <a href="{{ url_for('jobs_index_ui', per_page=filters.per_page, page=filters.page - 1, **filters_and_order_wo_pagination) }}" aria-label="Previous">
        <span aria-hidden="true">&laquo;</span>
      </a>
    </li>
    {% for page in all_pages %}
    <li class="{{ 'active' if filters.page == page + 1 else '' }}">
      <a href="{{ url_for('jobs_index_ui', per_page=filters.per_page, page=page + 1, **filters_and_order_wo_pagination) }}">{{ page + 1}}</a>
    </li>
    {% endfor %}
    <li class="{{ 'disabled' if filters.page == num_pages else '' }}">
      <a href="{{ url_for('jobs_index_ui', per_page=filters.per_page, page=filters.page + 1, **filters_and_order_wo_pagination) }}" aria-label="Next">
        <span aria-hidden="true">&raquo;</span>
      </a>
    </li>
  </ul>
</nav>

<form method="post" action="{{ url_for('rerun_multiple_jobs_ui', next=url_for('jobs_index_ui', **filters_and_order)) }}" id="rerun_multiple_form"></form>

<form method="post" action="{{ url_for('rerun_failed_multiple_jobs_ui', next=url_for('jobs_index_ui', **filters_and_order)) }}" id="rerun_failed_multiple_form"></form>

<form method="post" action="{{ url_for('pause_multiple_jobs_ui', next=url_for('jobs_index_ui', **filters_and_order)) }}" id="pause_multiple_form"></form>

<form method="post" action="{{ url_for('unpause_multiple_jobs_ui', next=url_for('jobs_index_ui', **filters_and_order)) }}" id="resume_multiple_form"></form>

<form method="post" action="{{ url_for('delete_multiple_jobs_ui', next=url_for('jobs_index_ui', **filters_and_order)) }}" id="delete_multiple_form"></form>

<div class="modal" id="selected-move-modal" role="dialog" aria-labelledby="selected-move-label" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="selected-move-label">Move Selected Jobs</h4>
      </div>
      <div class="modal-body">
        <form method="post" id="move-multiple-form" action="{{ url_for('move_multiple_jobs_ui', next=url_for('jobs_index_ui', **filters_and_order)) }}">
          <div class="form-group">
            <label for="selected-move-target">Jobqueue</label>
            <select class="form-control" id="selected-move-target" name="queue">
              {% for jobqueue in jobqueues %}
              <option value="{{jobqueue.id}}">{{jobqueue.path()}}</option>
              {% endfor%}
            </select>
          </div>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary" id="move-multiple-submit">Move Jobs</button>
      </div>
    </div>
  </div>
</div>

<div class="modal" id="selected-set-prio-weight-modal" role="dialog" aria-labelledby="selected-set-prio-weight-label" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="selected-set-prio-weight-label">Set Priority And Weight On Selected Jobs</h4>
      </div>
      <div class="modal-body">
        <form method="post" id="set-prio-weight-multiple-form" action="{{ url_for('set_prio_weight_on_jobs', next=url_for('jobs_index_ui', **filters_and_order)) }}">
          <div class="form-group">
            <label for="selected-prio">Priority</label>
            <input type="text" class="form-control" id="selected-prio" name="prio" value="0"/>
          </div>
          <div class="form-group">
            <label for="selected-weight">Weight</label>
            <input type="text" class="form-control" id="selected-weight" name="weight" value="10"/>
          </div>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary" id="set-prio-weight-submit">Set Priority And Weight</button>
      </div>
    </div>
  </div>
</div>

{% endblock %}
