{% extends 'generic/object.html' %}
{% load helpers %}
{% load plugins %}
{% load render_table from django_tables2 %}
{% load i18n %}

{% block breadcrumbs %}
  {{ block.super }}
  <li class="breadcrumb-item"><a href="{% url 'dcim:powerpanel_list' %}?site_id={{ object.site.pk }}">{{ object.site }}</a></li>
  {% if object.location %}
    <li class="breadcrumb-item">{{ object.location|linkify }}</li>
  {% endif %}
{% endblock %}

{% block content %}
<div class="row">
	<div class="col col-12 col-md-6">
    <div class="card">
      <h2 class="card-header">{% trans "Power Panel" %}</h2>
      <table class="table table-hover attr-table">
        <tr>
          <th scope="row">{% trans "Site" %}</th>
          <td>{{ object.site|linkify }}</td>
        </tr>
        <tr>
          <th scope="row">{% trans "Location" %}</th>
          <td>{{ object.location|linkify|placeholder }}</td>
        </tr>
        <tr>
          <th scope="row">{% trans "Description" %}</th>
          <td>{{ object.description|placeholder }}</td>
        </tr>
      </table>
    </div>
    {% include 'inc/panels/tags.html' %}
    {% include 'inc/panels/comments.html' %}
    {% plugin_left_page object %}
  </div>
	<div class="col col-12 col-md-6">
    {% include 'inc/panels/related_objects.html' %}
    {% include 'inc/panels/custom_fields.html' %}
    {% include 'inc/panels/image_attachments.html' %}
    {% plugin_right_page object %}
  </div>
</div>
<div class="row my-3">
  <div class="col col-md-12">
    <form method="post">
      {% csrf_token %}
      <div class="card">
        <h2 class="card-header">{% trans "Power Feeds" %}</h2>
        {% htmx_table 'dcim:powerfeed_list' power_panel_id=object.pk %}
        <div class="card-footer d-print-none">
          {% if perms.dcim.change_powerfeed %}
            <button type="submit" name="_edit" {% formaction %}="{% url 'dcim:powerfeed_bulk_edit' %}?return_url={% url 'dcim:powerpanel' pk=object.pk %}" class="btn btn-warning">
              <span class="mdi mdi-pencil" aria-hidden="true"></span> {% trans "Edit" %}
            </button>
          {% endif %}
          {% if perms.dcim.delete_cable %}
            <button type="submit" name="_disconnect" {% formaction %}="{% url 'dcim:powerfeed_bulk_disconnect' %}?return_url={% url 'dcim:powerpanel' pk=object.pk %}" class="btn btn-outline-danger">
              <span class="mdi mdi-ethernet-cable-off" aria-hidden="true"></span> {% trans "Disconnect" %}
            </button>
          {% endif %}
          {% if perms.dcim.delete_powerfeed %}
            <button type="submit" name="_delete" {% formaction %}="{% url 'dcim:powerfeed_bulk_delete' %}?return_url={% url 'dcim:powerpanel' pk=object.pk %}" class="btn btn-danger">
              <span class="mdi mdi-trash-can-outline" aria-hidden="true"></span> {% trans "Delete" %}
            </button>
          {% endif %}
          {% if perms.dcim.add_powerfeed %}
            <div class="float-end">
              <a href="{% url 'dcim:powerfeed_add' %}?power_panel={{ object.pk }}&return_url={% url 'dcim:powerpanel' pk=object.pk %}" class="btn btn-primary">
                <span class="mdi mdi-plus-thick" aria-hidden="true"></span> {% trans "Add Power Feeds" %}
              </a>
            </div>
          {% endif %}
        </div>
      </div>
    </form>
    {% plugin_full_width_page object %}
  </div>
</div>
{% endblock %}
