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

{% block title %} Inventory {% endblock %}

{% block stylesheets %}
<style>
table a[href^="http"]::after,
table a[href^="https://"]::after
{
  content: "";
  width: 11px;
  height: 11px;
  margin-left: 4px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M8.636 3.5a.5.5 0 0 0-.5-.5H1.5A1.5 1.5 0 0 0 0 4.5v10A1.5 1.5 0 0 0 1.5 16h10a1.5 1.5 0 0 0 1.5-1.5V7.864a.5.5 0 0 0-1 0V14.5a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h6.636a.5.5 0 0 0 .5-.5z'/%3E%3Cpath fill-rule='evenodd' d='M16 .5a.5.5 0 0 0-.5-.5h-5a.5.5 0 0 0 0 1h3.793L6.146 9.146a.5.5 0 1 0 .708.708L15 1.707V5.5a.5.5 0 0 0 1 0v-5z'/%3E%3C/svg%3E");
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  display: inline-block;
}
</style>
{% endblock stylesheets %}

{% block content %}
  <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center py-4">
      <div class="d-block mb-4 mb-md-0">
          <nav aria-label="breadcrumb" class="d-none d-md-inline-block">
            <ol class="breadcrumb breadcrumb-dark breadcrumb-transparent">
              <li class="breadcrumb-item">
                <a href="/">
                  <svg class="icon icon-xxs" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"></path></svg>
                </a>
              </li>
              <li class="breadcrumb-item"><a href="{% url 'dashboard' %}">BRACE2</a></li>
              <li class="breadcrumb-item active" aria-current="page">Inventory</li>
            </ol>
          </nav>
          <h2 class="h4">All Assets</h2>
      </div>
      <div class="btn-toolbar mb-2 mb-md-0">
          <!-- <a href="#" class="btn btn-sm btn-gray-800 d-inline-flex align-items-center">
              <svg class="icon icon-xs me-2" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6"></path></svg>
              New Plan
          </a> -->

          <div class="btn-group ms-2 ms-lg-3">
            <!-- <button type="button" class="btn btn-sm btn-outline-gray-600">Share</button> -->
            <span class="d-inline-block" tabindex="0" data-bs-toggle="tooltip" data-bs-placement="left" title="Disabled">
              <button type="button" class="btn btn-sm btn-outline-gray-600 style="pointer-events: none;" disabled>Export</button>
            </span>
            <!-- <span class="d-inline-block" tabindex="0" data-bs-toggle="tooltip" title="Disabled tooltip">
                <button class="btn btn-primary" style="pointer-events: none;" type="button" disabled>Export</button>
            </span> -->
          </div>
      </div>
  </div>
          <div class="row">
            <div class="col-12 my-4">
              <div class="card bg-white-100 border-0 shadow">
                <!-- <div class="card-header d-sm-flex flex-row align-items-center flex-0">
                  <div class="d-block mb-3 mb-sm-0">
                      <div class="fs-5 fw-normal mb-2">Inventory Map</div>
                  </div>
                </div> -->
                <div class="card-body p-2">
                  {{ asset_map|safe }}
                </div>
              </div>
            </div>
          </div>
  
  <div class="table-settings mb-4">
      <div class="row align-items-center justify-content-between">
          <div class="col col-md-6 col-lg-3 col-xl-4">
            <span class="d-inline-block" tabindex="0" data-bs-toggle="tooltip" data-bs-placement="right" title="Disabled">
              <div class="input-group me-2 me-lg-3 fmxw-400">
                  <span class="input-group-text">
                      <svg class="icon icon-xs" x-description="Heroicon name: solid/search" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
                          <path fill-rule="evenodd" d="M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z" clip-rule="evenodd"></path>
                      </svg>
                  </span>
                  <input disabled type="text" class="form-control" placeholder="Search assets">
              </div>
            </span>
          </div>
          <!-- <div class="col-4 col-md-2 col-xl-1 ps-md-0 text-end">
              <div class="dropdown">
                  <button class="btn btn-link text-dark dropdown-toggle dropdown-toggle-split m-0 p-1" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                      <svg class="icon icon-sm" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M11.49 3.17c-.38-1.56-2.6-1.56-2.98 0a1.532 1.532 0 01-2.286.948c-1.372-.836-2.942.734-2.106 2.106.54.886.061 2.042-.947 2.287-1.561.379-1.561 2.6 0 2.978a1.532 1.532 0 01.947 2.287c-.836 1.372.734 2.942 2.106 2.106a1.532 1.532 0 012.287.947c.379 1.561 2.6 1.561 2.978 0a1.533 1.533 0 012.287-.947c1.372.836 2.942-.734 2.106-2.106a1.533 1.533 0 01.947-2.287c1.561-.379 1.561-2.6 0-2.978a1.532 1.532 0 01-.947-2.287c.836-1.372-.734-2.942-2.106-2.106a1.532 1.532 0 01-2.287-.947zM10 13a3 3 0 100-6 3 3 0 000 6z" clip-rule="evenodd"></path></svg>
                      <span class="visually-hidden">Toggle Dropdown</span>
                  </button>
                  <div class="dropdown-menu dropdown-menu-xs dropdown-menu-end pb-0">
                      <span class="small ps-3 fw-bold text-dark">Show</span>
                      <a class="dropdown-item d-flex align-items-center fw-bold" href="#">10 <svg class="icon icon-xxs ms-auto" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd"></path></svg></a>
                      <a class="dropdown-item fw-bold" href="#">20</a>
                      <a class="dropdown-item fw-bold rounded-bottom" href="#">30</a>
                  </div>
              </div> -->
          </div>
      </div>
  </div>
  
  <div class="card card-body border-0 shadow table-wrapper table-responsive">
<table class="table table-hover">
<thead>
  <tr>
    <th><span 
        title="Structure Number is an alphanumeric sequence assigned by each State to uniquely identify the structure within each State.">
        CALID
      </span></th>
    <th>CESMD</th>
    <th>Name</th>
      {% if false %}
    <th>Source code</th>
      {% endif %}
  </tr>
</thead>
<tbody>
  {% for v in bridges %}
    <tr>
      <td><code>{{ v.calid.split|first }}</code></td>

      <td><a target="_blank"
             href="https://www.strongmotioncenter.org/cgi-bin/CESMD/stationhtml.pl?stationID={{ v.cesmd }}&netword=CGS">
          <code>{{ v.cesmd }}</code></a></td>

      {% if v.name %}
      <td> <a href="{% url 'asset_profile' calid=v.calid %}" >{{ v.name }}</a></td>
      {% else %}
      <td> <a href="{% url 'asset_profile' calid=v.calid %}" >{{ v.calid }}</a></td>
      {% endif %}

      {% if False %}
      <td><code>{{ v.total_length.split|first }}</code></td>
      <td><code>{{ v.no_of_spans }}</code></td>
      {% endif %}

    </tr>
  {% endfor %}
</tbody>
</table>

<div class="card-footer px-3 border-0 d-flex flex-column flex-lg-row align-items-center justify-content-between">
  <nav aria-label="Page navigation example">
      <ul class="pagination mb-0">
        <li class="page-item {% if not bridges.has_previous %}disabled{% endif %}">
            {% if bridges.has_previous %}
              <a class="page-link" href="?page={{ bridges.previous_page_number }}/">Previous</a>
            {% else %}
              <a class="page-link disabled" href="#">Previous</a>
            {% endif %}
          </li>
          {% for page in bridges.paginator.page_range %}
          {% if page <= bridges.number|add:3 and page >= bridges.number|add:-3 %}
          <li class="page-item {% if page == bridges.number %}active{% endif %}">
              <a class="page-link" href="?page={{ page }}">{{ page }}</a>
          </li>
          {% endif %}
          {% endfor %}
          <li class="page-item {% if not bridges.has_next %}disabled{% endif %}">
            {% if bridges.has_next %}
                <a class="page-link" href="?page={{ bridges.next_page_number }}/">Next</a>
            {% else %}
              <a class="page-link disabled" href="#">Next</a>
            {% endif %}
          </li>
      </ul>
  </nav>
  <div class="fw-normal small mt-4 mt-lg-0">Showing <b>{{ bridges|length }}</b> out of <b>{{ bridges.paginator.count }}</b> entries</div>
</div>
{% comment %}
    <div class="card-footer px-3 border-0 d-flex flex-column flex-lg-row align-items-center justify-content-between">
      <nav aria-label="Page navigation example">
        <ul class="pagination mb-0">
          <li class="page-item disabled" >
              <a class="page-link" href="#">Previous</a>
          </li>
          <li class="page-item disabled">
              <a class="page-link" href="#">1</a>
          </li>
          <li class="page-item disabled" style="pointer-events: none;">
              <a class="page-link" href="#">Next</a>
          </li>
        </ul>
      </nav>
        <div class="fw-normal small mt-4 mt-lg-0">Showing <b>{{ bridges|length }}</b> out of <b>{{ bridges|length }}</b> entries</div>
    </div>
  </div>
{% endcomment %}
{% endblock content %}

{% block javascripts %}
<script>
    const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]')
    const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl))
</script>
{% endblock javascripts %}
