{% extends 'base.html' %}
{% block content %}
<div class="toolbar">
  <div>
    <h1>{{ t('software.aggregated_list') }}</h1>
    <p class="muted">{{ t('software.aggregated_list_help') }}</p>
  </div>
  <a class="button button-secondary" href="/software">{{ t('common.back') }}</a>
</div>

<section class="panel">
  <div class="software-section-heading">
    <div>
      <h2>{{ t('software.summary_table') }}</h2>
      <p class="muted">{{ t('software.numeric_filter_help') }}</p>
    </div>
    <div class="software-summary-controls">
      <form method="get" action="/software/summary" class="inline-form software-grouping-form">
        <label for="software-summary-grouping">{{ t('software.grouping') }}</label>
        <select id="software-summary-grouping" name="grouping" title="{{ t('software.grouping.help')|e }}" onchange="this.form.submit()">
          <option value="name_platform" {% if grouping == 'name_platform' %}selected{% endif %}>{{ t('software.grouping.name_platform') }}</option>
          <option value="software" {% if grouping == 'software' %}selected{% endif %}>{{ t('software.grouping.software') }}</option>
          <option value="version" {% if grouping == 'version' %}selected{% endif %}>{{ t('software.grouping.version') }}</option>
        </select>
        <noscript><button type="submit" class="button button-secondary button-small">{{ t('common.apply') }}</button></noscript>
      </form>
      <span class="software-inventory-count">{{ software_summary|length }}</span>
    </div>
  </div>
  <div class="table-scroll management-table-scroll software-dedicated-table">
    <table class="data-table" id="software-aggregated" data-storage-key="software-aggregated">
      <thead><tr>
        <th>{{ t('common.name') }}</th>
        <th>{{ t('software.publisher') }}</th>
        <th>{{ t('software.platform') }}</th>
        <th>{{ t('software.versions') }}</th>
        <th data-numeric-filter="1" data-filter-placeholder="{{ t('software.numeric_filter_placeholder') }}">{{ t('software.version_count') }}</th>
        <th data-numeric-filter="1" data-filter-placeholder="{{ t('software.numeric_filter_placeholder') }}"><span title="{{ t('software.unique_asset_count_help')|e }}">{{ t('software.unique_asset_count') }} ⓘ</span></th>
        <th data-numeric-filter="1" data-filter-placeholder="{{ t('software.numeric_filter_placeholder') }}"><span title="{{ t('software.inventory_entry_count_help')|e }}">{{ t('software.inventory_entry_count') }} ⓘ</span></th>
        <th>{{ t('software.last_seen') }}</th>
      </tr></thead>
      <tbody>
      {% for row in software_summary %}
        <tr>
          <td>{{ row.name }}</td>
          <td>{{ row.publisher }}</td>
          <td>{{ t('software.platform.' ~ (row.platform or 'unknown'), row.platform or 'unknown') }}</td>
          <td>{{ row.versions }}</td>
          <td data-sort-value="{{ row.version_count }}">{{ row.version_count }}</td>
          <td data-sort-value="{{ row.asset_count }}">{{ row.asset_count }}</td>
          <td data-sort-value="{{ row.entries }}">{{ row.entries }}</td>
          <td data-sort-value="{{ row.last_seen_at.isoformat() if row.last_seen_at else '' }}">{% if row.last_seen_at %}<time class="local-time" datetime="{{ utc_iso(row.last_seen_at) }}" data-utc="{{ utc_iso(row.last_seen_at) }}">{{ row.last_seen_at }}</time>{% else %}{{ '' }}{% endif %}</td>
        </tr>
      {% else %}
        <tr><td colspan="8">{{ t('software.no_global_inventory') }}</td></tr>
      {% endfor %}
      </tbody>
    </table>
  </div>
</section>
{% endblock %}
