{% extends "v3/base.html" %}
{% set alias = rgc.get_genome_alias(digest=genome) %}
{% block title %}{{ alias }}/{{ asset }}:{{ tag }}{% endblock %}
{% block head %}
    {{ super() }}
    <script>
        $(document).ready(function(){
          $('[data-toggle="tooltip"]').tooltip();
        });
    </script>
{% endblock %}
{% block content %}
{% set tag_data = rgc["genomes"][genome]["assets"][asset]["tags"][tag] %}
<div class="container">
    <div class="row align-items-center">
        <div class="col-12">
            <h2><a href="/v3/genomes/splash/{{ genome }}">{{ alias }}</a>/{{ asset }}:{{ tag }}</h2>
        </div>
    </div>
    <div class="row align-items-center">
        <div class="col-12">
            <p>Description: <i>{{ rgc["genomes"][genome]["assets"][asset]["asset_description"] }}</i></p>
        </div>
    </div>
    <div class="row">
        <div class="col-9">
            <h3>Attributes</h3>
            <ul>
            {% for attr_name, value in tag_data.items() %}
                {% if value is mapping %}
                    <li>{{ attr_name }}:</li>
                    <ul>
                    {% for seek_key, path  in value.items() %}
                        <li>
                            {% if is_data_remote %}
                                {% for remote_key, remote_dict in rgc["remotes"].items() %}
                                    <a href="/v3/assets/file_path/{{ genome }}/{{ asset }}/{{ seek_key }}?tag={{ tag }}&remoteClass={{ remote_key }}" data-toggle="tooltip" title="{{ remote_dict["description"] }}">{{ remote_key }}</a> {{ "|" if not loop.last }}
                                {% endfor %}
                            {% endif %}
                            {{ seek_key }}: <code>{{ path }}</code>
                        </li>
                    {% endfor %}
                    </ul>
                {% elif value is iterable and value is not string %}
                    <li>{{ attr_name }}:
                    {% if value|length == 0 %}
                        None</li>
                    {% else %}
                        <ul>
                        {% for asset_registry_path in value | sort %}
                            {% set parsed = prp(asset_registry_path) %}
                            {% if parsed["namespace"] is none %}
                            <!-- assign parent namespace to the same namespace the the asset of interest is in -->
                                {% set parent_genome = genome %}
                                {% set parent_alias = rgc.get_genome_alias(digest=parent_genome) %}
                            {% else %}
                            <!-- use the specified namespace -->
                                {% set parent_genome = parsed["namespace"] %}
                                {% set parent_alias = rgc.get_genome_alias(digest=parsed["namespace"]) %}
                            {% endif %}
                            <li><code><a href="/v3/assets/splash/{{ parent_genome }}/{{ parsed['item'] }}?tag={{ parsed['tag'] }}" data-toggle="tooltip" title="Asset splash page">{{ parent_alias }}/{{ parsed['item'] }}:{{ parsed['tag'] }}</a></code></li>
                        {% endfor %}
                        </ul>
                        </li>
                    {% endif %}
                {% else %}
                    <li>{{ attr_name }}: <code>{{ value }}</code></li>
                {% endif %}
            {% endfor %}
            </ul>
        </div>
        <div class="col-3">
            <h3>API endpoints</h3>
            <ul>
            {% for id, path in links_dict.items() %}
                <li><a href="{{ path }}?tag={{tag}}">{{ id }}</a></li>
            {% endfor %}
            </ul>
        </div>
    </div>
    {% if asset_dir_contents is not none %}
        <div class="row">
            <div class="col-12">
                <h3>Asset directory contents</h3>
                <ul>
                {% for file in asset_dir_contents|sort %}
                    <li>
                        {% if is_data_remote %}
                            {% for remote_key, asset_dir_path in asset_dir_paths.items() %}
                                <a href="{{ [asset_dir_path, file]|os_path_join }}">{{ remote_key }}</a>{{ ":" if loop.last else " |" }}
                            {% endfor %}
                            <code>{{ file }}</code>
                        {% else %}
                            <code>{{ file }}</code>
                        {% endif %}
                    </li>
                {% endfor %}
                </ul>
            </div>
        </div>
    {% endif %}
</div>
{% endblock %}
