{% extends "layout.html" %}
{% block title %}
    Active Installations For User
{% endblock %}

{% block body %}
{% if repos %}
<div class="container">
    <nav class="navbar navbar-expand-lg navbar-dark bg-light">
        <ul class="navbar-nav">
            <li>
                <h4>App Installations</h4>
            </li>
        </ul>
        <ul class="navbar-nav ml-auto">
        <li class="nav-item">
                <a class="nav-link" href="{{ url_for('show_users') }}" style="color:chocolate">
                    <i class="fas fa-arrow-alt-to-left"></i>
                    See all users
                </a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="{{ url_for('index') }}" style="color:blue">
                    <i class="fas fa-angle-double-left"></i>
                    Back To Main Page
                </a>
            </li>
        </ul>
        
        <ul class="navbar-nav ml-auto">
            <a class="nav-link" href="https://github.com/hamelsmu/MLapp/" style="color:grey">
                See App On 
                <i class="fab fa-github"></i>
            </a>
        </ul>
    </nav>
</div>
<br>
<p><span style="font-weight:bold">{{ username }}</span> has the app installed on {{ repos | length }} repo(s).</p>
<table class="table">
    <thead>
      <tr>
        <th scope="col">#</th>
        <th scope="col">Repo Name</th>
        <th scope="col">Stars</th>
        <th scope="col">Last Update At</th>
        <th scope="col">Link</th>
        <th scope="col">Predictions</th>
      </tr>
    </thead>
    <tbody>
    {% for repo in repos %}
    <tr>
        <th scope="row">{{ loop.index }}</th>
        {% if repo['name'] in repos_with_preds %}
            <td>{{ repo['full_name'] }}</td>
            {% else %}
            <td><span style="color:grey">{{ repo['full_name'] }}</span></td>
        {% endif %}
        <td>{{ repo['stargazers_count'] }}</td>
        <td>{{ repo['updated_at'] | truncate(13) }}</td>
        <td>
            <a class="nav-link" href="{{ repo['html_url'] }}" style="color:grey">
                <i class="fab fa-github"></i>
            </a>
        </td>
        <td>
            {% if repo['name'] in repos_with_preds %}
                <a class="nav-link" href="{{ url_for('data', owner=repo['owner']['login'], repo=repo['name']) }}" style="color:blue">
                {% else %}
                <a class="nav-link" style="color:lightgray">
            {% endif %}
                <i class="fas fa-arrow-from-left"></i></a>
        </td>
    </tr>
    {% endfor %}  
    </tbody>
</table>
{% endif %}
{% endblock %}