<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
        <title>minion CI</title>

        <!-- Bootstrap -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
        <link rel="stylesheet" href="//cdn.jsdelivr.net/font-hack/2.019/css/hack-extended.min.css">

        <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
          <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
          <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
        <![endif]-->
        <link rel=stylesheet type=text/css href="{{ url_for('static', filename='css/minion.css') }}">
    </head>
    <body>
        <div class="container">
            <img class="logo" src="{{ url_for('static', filename='images/minion.png') }}">
            <header>
                <h1>minion CI</h1>
            </header>
            <ul class="jobs">
                {% if jobs.items %}
                    {% for job in jobs.items %}
                        <li class="job">
                            <span class="time">{{ job.created_at }}</span>
                            <span class="repository_url">{{ job.repository_url }}</span>
                            <span class="revision">{{ job.commit_hash[:7] }}</span>
                            <div class="result_status">
                            {% if job.result.status == "succeded" %}
                            <span class="success">&#10003;&nbsp;SUCCESS</span>
                            {% elif job.result.status == "running" %}
                            <span class="running">&#8635;&nbsp;RUNNING</span>
                            {% else %}
                            <span class="failure">&#10008;&nbsp;FAILURE</span>
                            {% endif %}
                            </div>
                            <div class="result">
                                {% if job.result.status == "failure" %}
                                <strong class="failure_red">{{ job.result.error_msg }}:</strong> <br><br>
                                {% endif %}
                                {{ job.result.logs | nl2br }}
                            </div>
                        </li>
                    {% endfor %}
                {% else %}
                <li class="job">
                    There are no jobs in the database!
                </li>
                {% endif %}
            </ul>
            <footer>
                <nav class="my-pagination">
                    Page:
                    {%- for page in jobs.iter_pages() %}
                        {% if page %}
                            {% if page != jobs.page %}
                                <a href="{{ url_for('api.index', page=page) }}">{{ page }}</a>
                            {% else %}
                                <strong>{{ page }}</strong>
                            {% endif %}
                        {% else %}
                            <span class=ellipsis>…</span>
                        {% endif %}
                    {%- endfor %}
                </nav>
                <div class="copyright">
                    <strong>minion-ci</strong>, published under MIT. A <a href="https://github.com/timofurrer" target="_blank">Timo Furrer</a> Project.
                </div>
            </footer>
        </div>


        <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
        <!-- Include all compiled plugins (below), or include individual files as needed -->
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>

        <script>
            $(document).ready(function() {
                $(".job").click(function(event) {
                    $(this).find("div.result").toggle();
                });
            });
        </script>
    </body>
</html>
