{% extends "base.html" %}
{% block content %}
    <div class="results">
        <div class="page-header">
            <h3>Results</h3>
        </div>
        <div class="overview">
        <table class="table table-striped table-bordered">
            <thead>
                <tr>
                    <th>Filename</th>
                    <th>File Size</th>
                    <th>MD5</th>
                    <th>Processing Start</th>
                    <th>Duration</th>
                    <th>Status</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                	<td>{{filename}}</td>
                	<td>{{filesize|filesizeformat}}</td>
                	<td>{{md5}}</td>
                	<td>{{start}}</td>
                	<td>{{duration}}</td>
                	<td>{{status}}</td>
                </tr>
			</tbody>
		</table>        	
        </div>
		{% for error in errors %}
		<div class="alert alert-danger">{{error}}</div>
		{% endfor %}
		<ul class="nav nav-tabs">
			{% for analysis in analyses %}
		    <li {% if loop.first %}class="active"{% endif %}><a href="#{{ analysis.name }}" data-toggle="tab">{{ analysis.name }} ({{ analysis.alerts|count }})</a></li>
		    {% endfor %}
		</ul>
		<div class="tab-content">
		{% for analysis in analyses %}
			<div class="tab-pane fade in {% if loop.first %}active{% endif %}" id="{{ analysis.name }}">
			<div class="panel panel-primary analysis">
	        <table class="table table-striped table-bordered">
	            <thead>
	                <tr>
	                    <th>IDS</th>
	                    <th>Version</th>
	                    <th>Ruleset</th>
	                    <th>Duration</th>
	                </tr>
	            </thead>
	            <tbody>
	                <tr>
	                    <td>{{analysis.module}}</td>
	                    <td>{{analysis.version}}</td>
	                    <td>{{analysis.ruleset}}</td>
	                    <td>{{analysis.duration}}</td>
	                </tr>
	            </tbody>
	        </table>
	        <div class="alerts">
	        <table class="table table-striped table-bordered">
	            <thead>
	                <tr>
	                    <th>Timestamp</th>
	                    <th>SID</th>
	                    <th>Class Type</th>
	                    <th style="width: 40%;">Message</th>
	                    <th>Source</th>
	                    <th>Destination</th>
	                    <th>Protocol</th>
	                </tr>
	            </thead>
	            <tbody>
	            {% for row in analysis.alerts | sort(attribute='timestamp')%}
	                <tr>
	                    <td>{{row.timestamp}}</td>
	                    <td>{{row.sid}}</td>
	                    <td>{{row.classtype}}</td>
	                    <td>{{row.message}}</td>
	                    <td>{{row.source}}</td>
	                    <td>{{row.destination}}</td>
	                    <td>{{row.protocol}}</td>
	                </tr>
	            {% else %}
	            <tr><td colspan="7">No Alerts Generated</td></tr>
	            {% endfor %}
	            </tbody>
	        </table>
	        </div>
	        </div>
	    </div>
        {% else %}
        No analysis of PCAP performed
        {% endfor %}
    </div>
{% endblock %}