{% extends 'base/layout.html' %}
{% load render_table from django_tables2 %}
{% load helpers %}

{% block title %}{{ object.name }} - Z-Wave Network{% endblock %}

{% block content %}
  <div class="row">
    <div class="col col-md-12">
      <div class="card">
        <h5 class="card-header">
          <div class="row">
            <div class="col">
              {{ object.name }}
            </div>
            <div class="col col-md-auto text-end">
              <a href="{% url 'plugins:netbox_zwave:zwavenetwork_edit' pk=object.pk %}" class="btn btn-warning">
                <span class="mdi mdi-pencil" aria-hidden="true"></span> Edit
              </a>
              <a href="{% url 'plugins:netbox_zwave:zwavenetwork_delete' pk=object.pk %}" class="btn btn-danger">
                <span class="mdi mdi-trash-can-outline" aria-hidden="true"></span> Delete
              </a>
            </div>
          </div>
        </h5>
        <div class="card-body">
          <div class="row mb-3">
            <div class="col col-md-6">
              <table class="table table-hover attr-table">
                <tr>
                  <td>Network ID</td>
                  <td>{{ object.network_id }}</td>
                </tr>
                <tr>
                  <td>Home ID</td>
                  <td><code>{{ object.home_id }}</code></td>
                </tr>
                <tr>
                  <td>Status</td>
                  <td>{% badge object.get_status_display object.status %}</td>
                </tr>
                <tr>
                  <td>Controller Node ID</td>
                  <td>{{ object.controller_node_id|default:"—" }}</td>
                </tr>
              </table>
            </div>
            <div class="col col-md-6">
              <table class="table table-hover attr-table">
                <tr>
                  <td>Security Enabled</td>
                  <td>{% checkmark object.security_enabled %}</td>
                </tr>
                <tr>
                  <td>S2 Enabled</td>
                  <td>{% checkmark object.s2_enabled %}</td>
                </tr>
                <tr>
                  <td>Device Count</td>
                  <td>{{ object.devices.count }}</td>
                </tr>
                <tr>
                  <td>Created</td>
                  <td>{{ object.created|date:"M j, Y H:i" }}</td>
                </tr>
              </table>
            </div>
          </div>
          {% if object.description %}
            <div class="row mb-3">
              <div class="col col-md-12">
                <h6>Description</h6>
                <p>{{ object.description }}</p>
              </div>
            </div>
          {% endif %}
        </div>
      </div>
    </div>
  </div>
  
  <div class="row">
    <div class="col col-md-12">
      <div class="card">
        <h5 class="card-header">
          <div class="row">
            <div class="col">
              Devices
            </div>
            <div class="col col-md-auto text-end">
              <a href="{% url 'plugins:netbox_zwave:zwavedevice_add' %}?network={{ object.pk }}" class="btn btn-primary">
                <span class="mdi mdi-plus-thick" aria-hidden="true"></span> Add Device
              </a>
            </div>
          </div>
        </h5>
        <div class="card-body">
          {% render_table devices_table %}
        </div>
      </div>
    </div>
  </div>
{% endblock %}
