{% extends 'generic/object_detail.html' %}
{% load buttons %}
{% load custom_links %}
{% load helpers %}
{% load perms %}
{% load plugins %}

{% block buttons %}
    {% plugin_buttons object %}
    {% if user|can_delete:object %}
        {% delete_button object %}
    {% endif %}
{% endblock buttons %}

{% block content %}
{% if not job_class_found %}
<div class="alert alert-danger">
    <i class="mdi mdi-alert"></i>
    This job source for this scheduled job is no longer installed.
    This scheduled job will fail to run unless reinstalled at the original location.
</div>
{% endif %}
{{ block.super }}
{% endblock content %}

{% block content_left_page %}
      <div class="panel panel-default">
          <div class="panel-heading">
              <strong>Scheduled Job</strong>
          </div>
          <table class="table table-hover panel-body attr-table">
              <tr>
                  <td>Name</td>
                  <td>
                      {{ object.name }}
                  </td>
              </tr>
              <tr>
                  <td>Description</td>
                  <td>
                      {{ object.description }}
                  </td>
              </tr>
              <tr>
                  <td>Task</td>
                  <td>
                      <code>{{ object.task }}</code>
                  </td>
              </tr>
              <tr>
                  <td>Requester</td>
                  <td>
                      {{ object.user }}
                  </td>
              </tr>
              <tr>
                  <td>Approver</td>
                  <td>
                      {{ object.approved_by_user | placeholder }}
                  </td>
              </tr>
              <tr>
                  <td>Approval Required?</td>
                  <td>{{ object.approval_required | render_boolean }}</td>
              </tr>
              <tr>
                  <td>Approved At</td>
                  <td>
                      {{ object.approved_at | placeholder }}
                  </td>
              </tr>
          </table>
      </div>
      <div class="panel panel-default">
          <div class="panel-heading">
              <strong>Scheduling</strong>
          </div>
          <table class="table table-hover panel-body attr-table">
              <tr>
                  <td>Enabled?</td>
                  <td>{{ object.enabled | render_boolean }}</td>
              </tr>
              <tr>
                  <td>Interval</td>
                  <td>
                      {{ object.interval }}
                      {% if object.interval == "custom" %}({{ object.crontab }}){% endif %}
                  </td>
              </tr>
              <tr>
                  <td>One Off?</td>
                  <td>{{ object.one_off | render_boolean }}</td>
              </tr>
              <tr>
                  <td>Start Time</td>
                  <td>
                      {{ object.start_time }}
                  </td>
              </tr>
              <tr>
                  <td>Last Run At</td>
                  <td>
                      {{ object.last_run_at|placeholder }}
                  </td>
              </tr>
              <tr>
                  <td>Total Run Count</td>
                  <td>
                      {{ object.total_run_count }}
                  </td>
              </tr>
          </table>
      </div>
{% endblock %}
{% block content_right_page %}
    {% if job_class_found %}
      <div class="panel panel-default">
          <div class="panel-heading">
              <strong>User Inputs</strong>
          </div>
          <table class="table table-hover panel-body attr-table">
              {% for key, value in object.kwargs.items %}
              <tr>
                <td>{{ labels|get_item:key }}</td>
                <td>{% if value is None %}–{% else %}<code>{{ value }}</code>{% endif %}</td>
              </tr>
              {% empty %}
                <tr><td>—</td></tr>
              {% endfor %}
          </table>
      </div>
    {% endif %}
{% endblock %}
