{% extends "base.html" %}
{% set active_page = 'scheduler_list' %}
{% block custom_head %}
    <script type="text/javascript" src="/static/js/bootstrap-table.min.js"></script>
{% endblock %}
{% block page_nav %}
    <h2>Scheduler List</h2>
{% endblock %}
{% block body %}
    <div id="scheduler-list" class="row auto-refresh">
        <table data-classes="table" data-toggle="table">
            <thead>
            <tr>
                <th data-field="endpoint" data-sortable="true">Endpoint</th>
                <th data-field="cpu" data-sortable="true">CPU</th>
                <th data-field="mem" data-sortable="true">Mem</th>
                <th>Update Time</th>
            </tr>
            </thead>
            <tbody>
            {%- if scheduler_metrics %}
                {%- for endpoint in scheduler_metrics %}
                    {% set metrics = scheduler_metrics[endpoint] %}
                    <tr>
                        <td><a href="/scheduler/{{ endpoint }}">{{ endpoint }}</a></td>
                        <td>{{ '%0.2f' % metrics['cpu_used'] }} / {{ metrics['cpu_total'] }}</td>
                        <td>{{ metrics['memory_used'] | readable_size }} / {{ metrics['memory_total'] | readable_size }}</td>
                        <td>{{ scheduler_metrics[endpoint]['update_time'] | format_ts }}</td>
                    </tr>
                {% endfor -%}
            {% else %}
                <tr>
                    <td colspan="8" style="font-style: italic; text-align: center">No schedulers attached.</td>
                </tr>
            {% endif -%}
            </tbody>
        </table>
    </div>
{% endblock %}
