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

{% block title %}About Products{% endblock %}
{% block head %}
    {{ super() }}
    <style type="text/css">

        a {
            font-weight: bold;
        }

        body {
            max-width: 100%;
        }
        .uri-path {
            margin-bottom: 10px;
        }

        li.lineage {
            line-height: 15px !important;
            list-style-type: none;
        }
    </style>
{% endblock %}
{% block panel %}

{% endblock %}
{% block content %}
    <div class="panel highlight">
        <h2 class="followed lonesome">Storage of {{ (product_summary_and_location | length) - (hidden_product_list | length) }} products</h2>
        <div class="header-follow">
            Open Data Cube {{ datacube_version }}
            {# TODO: Links to Website, CMI Metadata, DEA, ODC, help? #}
        </div>
        <div class="">
            Total indexed products: <span class="indexed-product-count">{{ product_summary_and_location | length}}</span>,
            hidden products: <span class="hidden-product-count">{{ hidden_product_list | length }}</span> <br/>
            Download csv for all products locations:
            <a href="{{ url_for('product.storage_csv') }}" class="badge header-badge">csv <i class="fa-solid fa-file-csv" aria-hidden="true"></i></a>
        </div>
    </div>
    <div class="panel overflowable">
        <table class="data-table">
            <thead>
                <tr>
                    <th>Name</th>
                    <th class="numeric">Count</th>
                    <th>Location</th>
                    <th class="numeric">License</th>
                    <th>Definition</th>
                    <th>Summary Age</th>
                    <th>Derived Products</th>
                    <th>Source Products</th>
                </tr>
            </thead>
            <tbody>
                {% for product, summary, locations in product_summary_and_location %}
                {% if product.name not in hidden_product_list %}
                <tr>
                    <td>{{ product.name | product_link }}</td>
                    <td class="numeric">{{ '{:,d}'.format(summary.dataset_count) }}</td>
                    <td>
                        {% if locations -%}
                            {%- for location in locations -%}
                                <div class="uri-path">{{- location.common_prefix -}}</div>
                            {%- endfor -%}
                        {% else -%}
                            -
                        {%- endif %}
                    </td>
                    <td class="numeric">{{ product | product_license_link }}</td>
                    <td><a href="{{url_for('product.raw_product_doc', name=product.name)}}" class="badge">doc</a></td>
                    <td>{{ summary.last_refresh_time | timesince }}</td>
                <td>
                    {% if summary.derived_products %}
                        {% for p in summary.derived_products %}
                            <li class="lineage">{{ p | product_link }}</li>
                        {% endfor%}
                    {% else %}
                        -
                    {% endif %}
                </td>
                <td>
                    {% if summary.source_products %}
                        {% for p in summary.source_products %}
                            <li class="lineage">{{ p | product_link}}</li>
                        {% endfor%}
                    {% else %}
                        -
                    {% endif %}
                </td>
                </tr>
                {% endif %}
              {% endfor %}
            </tbody>
        </table>


    </div>
{% endblock %}
