{% extends 'jobs/job_generic.html' %}

{% block job_details %}
{% if not spkg %}
<div class="notification is-danger">
  Unable to find a source package for this build job!
  It might have been removed entirely from the archive.
</div>
{% else %}

<h4 class="subtitle is-4" style="margin-bottom: 0.5rem;margin-top: 1.5rem;">Details</h4>
<p>
<b>Repository:</b> {{spkg.repo.name}}<br/>
<b>Suite:</b> {{suite_name}}<br/>
<b>Maintainer:</b> {{spkg.maintainer.replace('@', '[at]')}}<br/>
{% if spkg.uploaders %}<b>Uploaders:</b> {{'; '.join(spkg.uploaders).replace('@', '[at]')}}<br/>{% endif %}
<b>Version:</b> {{job.version}}<br/>
<b>Architecture:</b> {{job.architecture}}<br/>
</p>

{% if dep_issues %}
<h4 class="subtitle is-4 mt-4 mb-1">Dependency Issues</h4>
<div class="column is-6">

{% for issue in dep_issues %}
  {% if issue.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 issue.missing %}
                    <li>
                    <h5 class="subtitle mb-1">{{m.unsat_dependency}} <small><i class="fas fa-microchip"></i> {{m.architecture}}</small></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 %}
                    </li>
                    {% endfor %}
                </ul>
            </div>
        </div>
    </div>
  {% endif %}

  {% if issue.conflicts %}
    <div class="card">
        <header class="card-header">
            <p class="card-header-title">
            Conflicts in the dependency chain ({{issue.package_name}} {{issue.package_version}})
            </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 %}

{% endfor %}
</div>
{% endif %}

{% endif %}
{% endblock %}
