{% extends 'depcheck/layout.html' %}

{% set page_title = 'Dependency issues for ' + issue.package_name + ' ' + issue.package_version %}

{% block body_header %}
<h1 class="title">Issue details for {{'binary' if issue.package_type == PackageType.BINARY else 'source'}} {{issue.package_name}}/{{issue.package_version}}</h1>
<h2 class="subtitle is-4">in {{rss.repo.name}}/{{rss.suite.name}} <small><span class="text-secondary"><i class="fas fa-microchip"></i> {{issue.architectures|join(', ')}}</span></small></h2>
{% endblock %}

{% block body %}

<div class="columns is-mobile">
    <div class="column is-6">

        {% if missing %}
        <div class="card">
        <header class="card-header">
            <p class="card-header-title">
            Missing dependencies
            </p>
            <div class="card-header-icon">
            <span class="icon">
                <i class="fas fa-question" aria-hidden="true"></i>
            </span>
            </div>
        </header>
        <div class="card-content py-3">
            <div class="content">
                <ul>
                    {% for m in missing %}
                    <li>
                    <h5 class="subtitle mb-1">{{m.unsat_dependency}}</h5>
                    <p class="mb-1"><b>Required by:</b> {{m.package_name}}<br/>
                    {% if m.package_version %}<b>Version:</b> {{m.package_version}}<br/>{% endif %}

                    {% if m.package_type == PackageType.SOURCE %}
                    <b>Type:</b> <i class="fas fa-drafting-compass"></i> Source Package<br/>
                    {% elif m.package_type == PackageType.BINARY %}
                    <b>Type:</b> <i class="fas fa-cube"></i> Binary Package<br/>
                    {% endif %}
                    </li>
                    {% endfor %}
                </ul>
            </div>
        </div>
        </div>
        {% endif %}

        {% if conflicts %}
        <div class="card">
        <header class="card-header">
            <p class="card-header-title">
            Conflicts in the dependency chain
            </p>
            <div class="card-header-icon">
            <span class="icon">
                <i class="fas fa-bomb" aria-hidden="true"></i>
            </span>
            </div>
        </header>
        <div class="card-content py-3">
            <div class="content">
                {% for c in conflicts %}
                    <h4 class="subtitle mb-3">{{c.pkg1.package_name}} <span class="has-text-weight-light">vs.</span> {{c.pkg2.package_name}}</h4>
                    <div class="card has-background-white-ter">
                        <div class="card-content">

                        {% set pkg1_type_html = '' %}
                        {% if c.pkg1.package_type == PackageType.SOURCE %}
                        {% set pkg1_type_html = '<i class="fas fa-drafting-compass"></i>' %}
                        {% elif c.pkg1.package_type == PackageType.BINARY %}
                        {% set pkg1_type_html = '<i class="fas fa-cube"></i>' %}
                        {% endif %}

                        {% set pkg2_type_html = '' %}
                        {% if c.pkg2.package_type == PackageType.SOURCE %}
                        {% set pkg2_type_html = '<i class="fas fa-drafting-compass"></i>' %}
                        {% elif c.pkg2.package_type == PackageType.BINARY %}
                        {% set pkg2_type_html = '<i class="fas fa-cube"></i>' %}
                        {% endif %}

                        <!-- Package 1-->
                        <h5 class="subtitle mb-2">Package 1: {{c.pkg1.package_name}} {{c.pkg1.package_version}}&nbsp;&nbsp;{{ pkg1_type_html | safe }}</h5>
                        {% if c.pkg1.unsat_conflict %}
                        <span><b>Conflict:</b> {{c.pkg1.unsat_conflict}}</span>
                        {% endif %}

                        <ul class="mt-1">
                        {% for d in c.depchain1 %}
                            <li>
                                <b>{{d.package_name}} {{d.package_version}}</b> {% if d.package_type == PackageType.SOURCE %}<small><i class="fas fa-drafting-compass"></i></small>{% endif %}<br/>
                                <p class="mb-1 text-secondary"><b>Depends:</b> {{d.depends}}</p>
                            </li>
                        {% endfor %}
                        </ul>

                        <!-- Package 2-->
                        <h5 class="subtitle mb-2">Package 2: {{c.pkg2.package_name}} {{c.pkg2.package_version}}&nbsp;&nbsp;{{ pkg2_type_html | safe }}</h5>
                        {% if c.pkg2.unsat_conflict %}
                        <span><b>Conflict:</b> {{c.pkg2.unsat_conflict}}</span>
                        {% endif %}

                        <ul class="mt-1">
                        {% for d in c.depchain2 %}
                            <li>
                                <b>{{d.package_name}} {{d.package_version}}</b> {% if d.package_type == PackageType.SOURCE %}<small><i class="fas fa-drafting-compass"></i></small>{% endif %}<br/>
                                <p class="mb-1 text-secondary"><b>Depends:</b> {{d.depends}}</p>
                            </li>
                        {% endfor %}
                        </ul>
                    </div>
                    </div>
                {% endfor %}
            </div>
        </div>
        </div>
        {% endif %}

    </div>
</div>
{% endblock %}
