{% extends "layout.html" %}

{% block title %}
    Issue Label Predictions
{% endblock %}

{% block body %}
<div class="container"></div>
    <nav class="navbar navbar-expand-lg navbar-dark bg-light">
        <ul class="navbar-nav">
            <li>
                <h4>View Bot Predictions</h4>
            </li>
        </ul>
        <ul class="navbar-nav ml-auto">
            <li class="nav-item">
                <a class="nav-link" href="{{ url_for('get_repos', username=owner) }}" style="color:chocolate">
                    <i class="fas fa-arrow-alt-to-left"></i>
                    All Repos for <span style="font-weight:bold">{{ owner }}</span>
                    
                </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>
    <br>
    <form action="{{ url_for('data', owner=owner, repo=repo) }}" method="POST">
        <div class="text-center">
            {% if num_issues > 0  %}
            <h4 class="text-center">Data For {{ owner }}/{{ repo }} </h4>
                {% if results %}
                <p>Only showing last 50 predictions</p>
                    {% if installed %}
                    <button style="margin-top:10px; margin-bottom:10px; float:right" type="submit" class="btn btn-primary">Refresh ( <i class="fas fa-thumbs-up"></i>, <i class="fas fa-thumbs-down"></i>) </button>
                    {% endif %}
                {% endif %}
            {% endif %}
        </div>
    </form>
    {% if not results and is_public %}
    <p style="color:indianred">Issue Label Bot has not observed any issues for <span style="font-weight:bold">{{ owner }}/{{ repo }}</span> since the app was installed.</p>
    {% endif %} 
    {% if results %}
        <br>
        <table class="table">
            <thead>
              <tr>
                <th scope="col">#</th>
                <th scope="col">Title</th>
                <th scope="col">Body</th>
                <th scope="col">Link</th>
                <th scope="col">Prediction</th>
                <th scope="col">Confidence</th>
                <th scope="col">Labeled?</th>
                <th scope="col"><i class="fas fa-thumbs-up"></th>
                <th scope="col"><i class="fas fa-thumbs-down"></i></th>
              </tr>
            </thead>
            <tbody>
            {% for result in results %}
            <tr>
                <td>{{ result.issue.issue_num }}</td>
                <td>{{ result.issue.title }}</td>
                <td>{{ result.issue.body | truncate(100) }}</td>
                <td>
                    <a class="nav-link" href="https://github.com/{{ result.issue.username }}/{{ result.issue.repo }}/issues/{{ result.issue.issue_num }}" style="color:grey">
                        <i class="fab fa-github"></i>
                    </a>
                </td>
                <td>{{ result.prediction }}</td>
                <td>{{ result.probability|round(2, 'common') }}</td>
                <td>{{ result.labeled }}</td>
                <td>{{ result.likes }}</td>
                <td>{{ result.dislikes }}</td>
            </tr>
            {% endfor %}  
            </tbody>
        </table>
    {% endif %} 
</div>
{% endblock %}