{% extends "base.html" %}
{% block content %}
<p style="margin-bottom: 10px;"><img src="{{ STATIC_URL }}graphic/cuckoo.png" /></p>

<ul class="nav nav-tabs">
    <li class="active"><a href="#files" data-toggle="tab">Files</a></li>
    <li><a href="#urls" data-toggle="tab">URLs</a></li>
</ul>

<div class="tab-content">
    <div class="tab-pane fade in active" id="files">
        <div class="panel panel-primary">
            <div class="panel-heading">
                <h3 class="panel-title">Recent Files</h3>
            </div>
            {% if files %}
            <table class="table table-striped" style="table-layout: fixed;">
                <thead>
                <tr>
                    <th>Timestamp</th>
                    <th>MD5</th>
                    <th>Status</th>
                </tr>
                </thead>
                <tbody>
                {% for analysis in files %}
                    <tr>
                        <td>
                        {% if analysis.status == "reported" %}
                            {{analysis.completed_on}}
                        {% else %}
                            <span class="muted">{{analysis.added_on}} (added on)</span>
                        {% endif %}
                        </td>
                        <td style="word-wrap: break-word;">
                            {% if analysis.status == "reported" %}
                                <a href="{% url "analysis.views.report" analysis.id %}"><span class="mono">{{analysis.sample.md5}}</span></a>
                            {% else %}
                                <span class="mono">{{analysis.sample.md5}}</span>
                            {% endif %}
                        </td>
                        <td>
                            {% if analysis.status == "pending" %}
                                <span class="text-muted">pending</span>
                            {% elif analysis.status == "running" %}
                                <span class="text-warning">running</span>
                            {% elif analysis.status == "completed" %}
                                <span class="text-info">completed</span>
                            {% elif analysis.status == "reported" %}
                                {% if analysis.errors %}
                                    <span class="text-danger">
                                {% else %}
                                    <span class="text-success">
                                {% endif%}

                                reported</span>
                            {% else %}
                                <span class="text-danger">{{analysis.status}}</span>
                            {% endif %}
                        </td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
            {% else %}
            <div class="panel-body">No files analyzed yet.</div>
            {% endif %}
        </div>
    </div>

    <div class="tab-pane fade" id="urls">
        <div class="panel panel-primary">
            <div class="panel-heading">
                <h3 class="panel-title">Recent URLs</h3>
            </div>
            {% if urls %}
            <table class="table table-striped" style="table-layout: fixed;">
                <thead>
                <tr>
                    <th>Timestamp</th>
                    <th>URL</th>
                    <th>Status</th>
                </tr>
                </thead>
                <tbody>
                {% for analysis in urls %}
                    <tr>
                        <td>
                        {% if analysis.status == "reported" %}
                            {{analysis.completed_on}}
                        {% else %}
                            <span class="muted">{{analysis.added_on}} (added on)</span>
                        {% endif %}
                        </td>
                        <td style="word-wrap: break-word;">
                            {% if analysis.status == "reported" %}
                                <a href="{% url "analysis.views.report" analysis.id %}"><span class="mono">{{analysis.target}}</span></a></td>
                            {% else %}
                                <span class="mono">{{analysis.target}}</span>
                            {% endif %}
                        <td>
                            {% if analysis.status == "pending" %}
                                <span class="text-muted">pending</span>
                            {% elif analysis.status == "running" %}
                                <span class="text-warning">running</span>
                            {% elif analysis.status == "completed" %}
                                <span class="text-info">completed</span>
                            {% elif analysis.status == "reported" %}
                                <span class="text-success">reported</span>
                            {% else %}
                                <span class="text-danger">{{analysis.status}}</span>
                            {% endif %}
                        </td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
            {% else %}
            <div class="panel-body">No URLS analyzed yet.</div>
            {% endif %}
        </div>
    </div>
</div>
{% endblock %}
