{% extends 'generic/object.html' %}
{% load helpers %}
{% load plugins %}

{% block breadcrumbs %}
  <li class="breadcrumb-item"><a href="{% url 'extras:webhook_list' %}">Webhooks</a></li>
  <li class="breadcrumb-item">{{ object }}</li>
{% endblock %}

{% block content %}
<div class="row mb-3">
	<div class="col col-md-6">
    <div class="card">
      <h5 class="card-header">
        Webhook
      </h5>
      <div class="card-body">
        <table class="table table-hover attr-table">
          <tr>
            <th scope="row">Name</th>
            <td>{{ object.name }}</td>
          </tr>
          <tr>
            <th scope="row">Enabled</th>
            <td>
              {% if object.enabled %}
                <i class="mdi mdi-check-bold text-success" title="Yes"></i>
              {% else %}
                <i class="mdi mdi-close-thick text-danger" title="No"></i>
              {% endif %}
            </td>
          </tr>
        </table>
      </div>
    </div>
    <div class="card">
      <h5 class="card-header">
        Events
      </h5>
      <div class="card-body">
        <table class="table table-hover attr-table">
          <tr>
            <th scope="row">Create</th>
            <td>
              {% if object.type_create %}
                <i class="mdi mdi-check-bold text-success" title="Yes"></i>
              {% else %}
                <i class="mdi mdi-close-thick text-danger" title="No"></i>
              {% endif %}
            </td>
          </tr>
          <tr>
            <th scope="row">Update</th>
            <td>
              {% if object.type_create %}
                <i class="mdi mdi-check-bold text-success" title="Yes"></i>
              {% else %}
                <i class="mdi mdi-close-thick text-danger" title="No"></i>
              {% endif %}
            </td>
          </tr>
          <tr>
            <th scope="row">Delete</th>
            <td>
              {% if object.type_create %}
                <i class="mdi mdi-check-bold text-success" title="Yes"></i>
              {% else %}
                <i class="mdi mdi-close-thick text-danger" title="No"></i>
              {% endif %}
            </td>
          </tr>
        </table>
      </div>
    </div>
    <div class="card">
      <h5 class="card-header">
        HTTP Request
      </h5>
      <div class="card-body">
        <table class="table table-hover attr-table">
          <tr>
            <th scope="row">HTTP Method</th>
            <td>{{ object.get_http_method_display }}</td>
          </tr>
          <tr>
            <th scope="row">Payload URL</th>
            <td><code>{{ object.payload_url }}</code></td>
          </tr>
          <tr>
            <th scope="row">HTTP Content Type</th>
            <td>{{ object.http_content_type }}</td>
          </tr>
          <tr>
            <th scope="row">Secret</th>
            <td>{{ object.secret|placeholder }}</td>
          </tr>
        </table>
      </div>
    </div>
    <div class="card">
      <h5 class="card-header">
        SSL
      </h5>
      <div class="card-body">
        <table class="table table-hover attr-table">
          <tr>
            <th scope="row">SSL Verification</th>
            <td>
              {% if object.ssl_verification %}
                <i class="mdi mdi-check-bold text-success" title="Yes"></i>
              {% else %}
                <i class="mdi mdi-close-thick text-danger" title="No"></i>
              {% endif %}
            </td>
          </tr>
          <tr>
            <th scope="row">CA File Path</th>
            <td>
              {% if object.ca_file_path %}
                <code>{{ object.ca_file_path }}</code>
              {% else %}
                &mdash
              {% endif %}
            </td>
          </tr>
        </table>
      </div>
    </div>
    {% plugin_left_page object %}
	</div>
	<div class="col col-md-6">
    <div class="card">
      <h5 class="card-header">
        Assigned Models
      </h5>
      <div class="card-body">
        <table class="table table-hover attr-table">
          {% for ct in object.content_types.all %}
            <tr>
              <td>{{ ct }}</td>
            </tr>
          {% endfor %}
        </table>
      </div>
    </div>
    <div class="card">
      <h5 class="card-header">
        Additional Headers
      </h5>
      <div class="card-body">
        <pre>{{ object.additional_headers }}</pre>
      </div>
    </div>
    <div class="card">
      <h5 class="card-header">
        Body Template
      </h5>
      <div class="card-body">
        <pre>{{ object.body_template }}</pre>
      </div>
    </div>
    {% plugin_right_page object %}
  </div>
</div>
{% endblock %}
