{% if "Factory" in projects[0].name %}
{% set is_leap = False %}
{% else %}
{% set is_leap = True %}
{% endif%}
<!doctype html>
<html lang="en">

<head>
  <!-- Required meta tags -->
  <meta charset="utf-8">
  <meta http-equiv="refresh" content="60" />
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
  <style type="text/css">
    .openqapassed { color: #4a2; }
    .openqarunning { color: #59a; }
    .openqafailed { color: #a10; }
    .openqasoftfailed { color: #a60; }
  </style>
  <title>Dashboard for {{ projectname }}</title>
</head>

<body>
  <div class="container">
    <div class="row">
      <div class="h1 col text-left">Dashboard for {{ projectname }}</div>
      <div class="col-3 text-right">Last update: <time class="timeago" datetime="{{lastupdate}}">{{ lastupdate }}</time></div>
    </div>
    <table class="table">
      <thead>
        <tr>
          <th scope="col">Part</th>
          <th scope="col">standard</th>
          {% if is_leap %}
          <th scope="col">ports</th>
          <th scope="col">step</th>
          {% endif %}
          <th scope="col">images</th>
          {% if not is_leap %}
          <th scope="col">containerfile</th>
          {% endif %}
          <th scope="col">source</th>
          <th scope="col">testing</th>
          <th scope="col">published</th>
          <th scope="col">openQA</th>
        </tr>
      </thead>
      {% for project in projects %}
      <tr>
        <th scope="row"><a href="https://build.opensuse.org/project/show/{{ project.name }}">{{project.nick}}</a></th>
        <td>
          {% with repository = 'standard' %}
            {% include "repository.html" %}
          {% endwith %}
        </td>
        {% if is_leap %}
        <td>
          {% with repository = 'ports' %}
            {% include "repository.html" %}
          {% endwith %}
        </td>
        <td>
          {% with repository = 'step' %}
            {% include "repository.html" %}
          {% endwith %}
        </td>
        {% endif %}
        <td>
          {% with repository = 'images' %}
            {% include "repository.html" %}
          {% endwith %}
        </td>
        {% if not is_leap %}
        <td>
          {% with repository = 'containerfile' %}
            {% include "repository.html" %}
          {% endwith %}
        </td>
        {% endif %}
        <td>
        {% if project.ttm_version %}
          <a href="https://build.opensuse.org/package/show/{{ project.name }}/000product">{{ project.ttm_version }}</a>
        {% else %}
          n.a.
        {% endif %}
        </td>
        <td>
        {% set ttm_testing = project.ttm_status.get('testing') %}
        {% if ttm_testing %}
          {% if project.openqa_version %}
            <a href='https://openqa.opensuse.org/tests/overview?version={{ project.openqa_version }}&groupid={{ project.openqa_id }}'>{{ ttm_testing }}</a>
          {% else %}
            {{ ttm_testing }}
          {% endif %}
        {% else %}
          n.a.
        {% endif %}
        </td>
        <td>
        {% set ttm_published = project.ttm_status.get('published', None) %}
        {% if ttm_published %}
          <a href="{{ project.download_url }}">{{ ttm_published }}</a>
              {% else %}
            n.a.
        {% endif %}
        </td>
        <td>
        {% set openqa_summary = project.openqa_summary() %}
        {% for state in openqa_summary.keys() %}
          <span class="openqa{{ state }}">{{ state }}</span>: {{ openqa_summary[state]|length }}
        {% endfor %}
        </td>
      </tr>
      {% endfor %}
    </table>
  </div>
  <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-timeago/1.6.7/jquery.timeago.min.js" integrity="sha256-0+5OfvOxkLHqpLPPwy9pDjug8N3cwaqcmleaxnR5VS8=" crossorigin="anonymous"></script>
  <script>
    jQuery(document).ready(function() {
      jQuery("time.timeago").timeago();
    });
  </script>
</body>

</html>
