{% extends "layouts/content_with_sidebar.html" %}


{% block extrahead %}
{{ block.super }}
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}lava-server/css/demo_table_jui.css"/>
<script type="text/javascript" src="{{ STATIC_URL }}lava-server/js/jquery.dataTables.min.js"></script> 
{% endblock %}


{% block sidebar %}
<h2>Broker configuration</h2>
<dl>
  <dt>BROKER_HOST</dt>
  <dd>{{ BROKER_HOST }}</dd>
  <dt>BROKER_PORT</dt>
  <dd>{{ BROKER_PORT }}</dd>
  <dt>BROKER_USER</dt>
  <dd>{{ BROKER_USER }}</dd>
  <dt>BROKER_PASSWORD</dt>
  <dd><em>Hidden</em></dd>
  <dt>BROKER_VHOST</dt>
  <dd>{{ BROKER_VHOST }}</dd>
  <dt>CELERYD_CONCURRENCY</dt>
  <dd>{{ CELERYD_CONCURRENCY|default_if_none:"Automatic" }}</dd>
  <dt>CELERYD_PREFETCH_MULTIPLIER</dt>
  <dd>{{ CELERYD_PREFETCH_MULTIPLIER }}</dd>
  <dt>CELERY_RESULT_BACKEND</dt>
  <dd>{{ CELERY_RESULT_BACKEND }}</dd>
  <dt>CELERY_RESULT_PERSISTENT</dt>
  <dd>{{ CELERY_RESULT_PERSISTENT|yesno }}</dd>
</dl>
{% endblock %}


{% block content %}
<h2>Workers</h2>
<table class="demo_jui display" id="celery_workers">
  <thead>
    <tr>
      <th>Hostname</th>
      <th>State</th>
    </tr>
  </thead>
  <tbody>
    {% for worker_state in worker_state_list %}
    <tr>
      <td>{{ worker_state.hostname }}</td>
      <td>
        {% if worker_state.is_alive %}
        <span style="color: green">Online</span>
        {% else %}
        <span style="color: red">Offline</span>
        {% endif %}
      </td>
    </tr>
    {% endfor %}
  </tbody>
</table>
<script type="text/javascript" charset="utf-8"> 
  $(document).ready(function() {
    oTable = $('#celery_workers').dataTable({
      bJQueryUI: true,
      sPaginationType: "full_numbers",
      aaSorting: [[1, "desc"]],
      iDisplayLength: 25,
      aLengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]],
    });
  });
</script>
<h2>Tasks</h2>
<table class="demo_jui display" id="celery_tasks">
  <thead>
    <tr>
      <th>State</th>
      <th>Task ID</th>
      <th>Name</th>
      <th>Timestamp</th>
      <th>Arguments</th>
      <th>Keyword arguments</th>
      <th>Retries</th>
      <th>Worker</th>
    </tr>
  </thead>
  <tbody>
    {% for task_state in task_state_list %}
    <tr>
      <td>{{ task_state.state }}</td>
      <td>{{ task_state.task_id }}</td>
      <td>{{ task_state.name }}</td>
      <td>{{ task_state.tstamp }}</td>
      <td>{{ task_state.args }}</td>
      <td>{{ task_state.kwargs  }}</td>
      <td>{{ task_state.retries }}</td>
      <td>{{ task_state.worker|default_if_none:"-"}}</td>
    </tr>
    {% endfor %}
  </tbody>
</table>
<script type="text/javascript" charset="utf-8"> 
  $(document).ready(function() {
    oTable = $('#celery_tasks').dataTable({
      bJQueryUI: true,
      sPaginationType: "full_numbers",
      aaSorting: [[1, "desc"]],
      iDisplayLength: 25,
      aLengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]],
    });
  });
</script>
{% endblock %}
