{% extends "fmd_base.html" %}
{% set title="Testmonitor" %}
{% block content %}
    <div class="card mb-3">
        <div class="card-header"><h4>Testmonitor Overview</h4></div>
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0"
                       data-page-length="10">
                    <thead>
                    <tr>
                        <th colspan="2"></th>
                        <th colspan="2" style="text-align: center; font-size: large;">Number of times tested</th>
                        <th colspan="2" style="text-align: center; font-size: large;">Median request duration</th>
                        <th></th>
                    </tr>
                    <tr>
                        <th></th>
                        <th>Endpoint</th>
                        <th>Latest version</th>
                        <th>Overall</th>
                        <th>Latest version</th>
                        <th>Overall</th>
                        <th>Last tested</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for record in result %}
                        <tr style="cursor: pointer"
                            onclick="window.location='{{ url_for('dashboard.endpoint_test_details', end=record.name) }}';">
                            <td style="background-color: {{ record.color }}"></td>
                            <td style="max-width: 200px;">{{ record.name }}</td>
                            <td style="text-align: right;">{{ "{:,d}".format(record['tests-latest-version']) }}</td>
                            <td style="text-align: right;">{{ "{:,d}".format(record['tests-overall']) }}</td>
                            <td style="text-align: right;"><time>{{ record['median-latest-version'] }}</time></td>
                            <td style="text-align: right;"><time>{{ record['median-overall'] }}</time></td>
                            <td style="text-align: center;">{{ "{:%Y-%m-%d %H:%M:%S }".format(record['last-tested']) }}</td>
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
{% endblock %}

{% block script %}
    <script type="text/javascript">
        $('#dataTable').DataTable().order([[4, "desc"]]).draw();
    </script>
{% endblock %}