{% extends "spider_base/nouc_base.html" %}
{% load i18n static spider_rdf %}
{% block title %}{% url 'spider_base:ucomponent-listpublic' as listpublic %}{% if listpublic == request.path %}{% blocktrans trimmed %}
  Public Components
{% endblocktrans %}{% elif request.is_owner %}{% blocktrans trimmed %}
  Owned Components
{% endblocktrans %}{% else %}{% blocktrans trimmed with name=username %}
    Component List of {{name}}
  {% endblocktrans %}
{% endif %}{% endblock %}

{% block extrahead %}
{{block.super}}
<link rel="stylesheet" href="{% static 'admin/css/vendor/select2/select2.css' %}">
{% if DEBUG %}
  <script src="{% static 'admin/js/vendor/jquery/jquery.js' %}"></script>
  <script src="{% static 'admin/js/vendor/select2/select2.full.js' %}"></script>
{% else %}
  <script src="{% static 'admin/js/vendor/jquery/jquery.min.js' %}"></script>
  <script src="{% static 'admin/js/vendor/select2/select2.full.min.js' %}"></script>
{% endif %}
{% endblock %}

{% block content %}
  {% url 'spider_base:ucomponent-listpublic' as listpublic %}
  <div>
    {% if listpublic == request.path %}
    <span class="w3-left">
      <a class="w3-block" style="margin-bottom:10px" href="{% url 'home' %}?{{request.GET.urlencode}}">{% trans 'Home' %}</a>
    </span>
    <data hidden="hidden" property="spkc:strength" datatype="xsd:integer">0</data>
    {% else %}
    <span class="w3-left">
      <a class="" href="{% url 'spider_base:ucomponent-listpublic' %}?{{request.GET.urlencode}}">{% trans 'Up (Public)' %}</a>
    </span>
    <data hidden="hidden" property="spkc:strength" datatype="xsd:integer">10</data>
    {% endif %}
    {% if request.user.is_authenticated %}
      <span class="w3-right">
        <div style="margin-bottom:10px">
          <a href="{% url 'spider_base:ucomponent-create' %}">
            <i class="fa fa-plus" style="margin-right:10px" aria-hidden="true"></i>
            {% trans 'Add New Component' %}
          </a>
        </div>
        {% if listpublic == request.path %}
          <div style="text-align:right;">
            <a href="{% url 'spider_base:ucomponent-list' %}">{% trans 'Owned' %}</a>
          </div>
        {% else %}
          <div style="text-align:right;">
            <a href="{% url 'spider_base:ucomponent-export' user=request.user %}">
              {% trans 'Export' %}
            </a>
          </div>
        {% endif %}
      </span>
    {% endif %}
    <h1 class="w3-center">
      {% if listpublic == request.path %}{% blocktrans trimmed %}
        Public Components
      {% endblocktrans %}{% elif request.is_owner %}{% blocktrans trimmed %}
        Owned Components
      {% endblocktrans %}{% else %}{% blocktrans trimmed %}
          Component List of
        {% endblocktrans %} <b>{{username}}</b>
      {% endif %}
    </h1>
  </div>
  <div class="w3-margin">
    <table class="w3-table w3-bordered w3-hoverable" rel="spkc:components">
      {% for uc in object_list %}
        <tr class="color-front-{{uc.strength}}" title="{{uc.description|escape}}" resource="{% url 'spider_base:ucontent-list' id=uc.id nonce=uc.nonce %}" typeof="spkc:Component">
          <td class="{% if uc.is_index %}w3-large{% endif %}" style="width:40%; min-height:48px" >
            <data hidden="hidden" property="spkc:type">Component</data>
            <data hidden="hidden" property="spkc:strength" datatype="xsd:integer">{{uc.strength}}</data>
            <data rel="spkc:properties">
              <data typeof="spkc:Property">
                <data hidden="hidden" property="spkc:name">name</data>
                {% if uc.is_index %}
                  <span property="spkc:value">{% trans 'Private Component' %}</span>
                {% else %}
                  <span property="spkc:value">{{ uc.name }}</span>{% if not request.is_owner %} <em>({{uc.user}})</em>{% endif %}
                {% endif %}
              </data>
              <data hidden="hidden" typeof="spkc:Property">
                <data hidden="hidden" property="spkc:name">user</data>
                <data hidden="hidden" property="spkc:value">{{uc.username}}</data>
              </data>
              <data hidden="hidden" typeof="spkc:Property">
                <data hidden="hidden" property="spkc:name">description</data>
                <data hidden="hidden" property="spkc:value">{{uc.description|escape}}</data>
              </data>
            </data>
          </td>
          <td>
            {% blocktrans trimmed with time=uc.modified|timesince %}
            Modified: {{time}} ago
            {% endblocktrans %}
          </td>
          <td class="w3-show-inline-block">
            <div class="w3-bar w3-round-large w3-tiny w3-blue">
              <a class="w3-hover-black w3-button w3-bar-item w3-tooltip w3-mobile" href="{% url 'spider_base:ucontent-list' id=uc.id nonce=uc.nonce %}" property="spkc:action:view">
                <div class="spkc-entity-button"><i class="fa fa-list-ul" alt="{% trans 'List' %}" aria-label="{% trans 'List' %}"></i></div>
                <div aria-hidden="true" class="w3-text w3-black spkc-entity-button-text"><div class="w3-animate-opacity">{% trans "List" %}</div></div>
              </a>
              {% if uc.user == request.user %}
                <a class="w3-hover-black w3-button w3-bar-item w3-tooltip w3-mobile" href="{% url 'spider_base:ucomponent-update' name=uc.name nonce=uc.nonce %}" property="spkc:action:update">
                  <div class="spkc-entity-button"><i class="fa fa-edit" alt="{% trans 'Edit' %}" aria-label="{% trans 'Edit' %}"></i></div>
                  <div aria-hidden="true" class="w3-text w3-black spkc-entity-button-text"><div class="w3-animate-opacity">{% trans "Edit" %}</div></div>
                </a>
              {% endif %}
            </div>
          </td>
        </tr>
      {% empty %}
          <tr><td>{% trans 'No Components available.' %}</td></tr>
      {% endfor %}
    </table>
  </div>
  <div class="page-manipulation w3-padding" style="margin-top:40px">
    {% include 'spider_base/list_footer.html' %}
  </div>
{% endblock %}
