{% extends "layout.html" %}
{% block header %}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.8.1/bootstrap-table.css">
{% endblock %}
{% block body %}
<div class="discover">
    <h2>{{_('Tasks list')}}</h2>
    <table class="table table-no-bordered" id="table" data-url="{{'/ajax/emailstat'}}">
      <thead>
        <tr>
            {% if g.user.role_admin() %}
            <th data-field="user">{{_('User')}}</th>
            {% endif %}
            <th data-field="type">{{_('Task')}}</th>
            <th data-field="status">{{_('Status')}}</th>
            <th data-field="progress">{{_('Progress')}}</th>
            <th data-field="runtime">{{_('Runtime')}}</th>
            <th data-field="starttime">{{_('Starttime')}}</th>
        </tr>
      </thead>
    </table>
  <!--div class="btn btn-default" id="tasks_delete">{{_('Delete finished tasks')}}</div>
  <div class="btn btn-default" id="tasks_hide">{{_('Hide all tasks')}}</div-->
</div>
{% endblock %}
{% block js %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.8.1/bootstrap-table.js"></script>
        <script>
            $('#table').bootstrapTable({
               formatNoMatches: function () {
                return '';
                },
                striped: true
            });
            setInterval(function() {
                $.ajax({
                    method:"get",
                    url: "{{'/ajax/emailstat'}}",
                    async: true,
                    timeout: 900,
                    success:function(data){
                    $('#table').bootstrapTable("load", data);
                }
                });
            }, 1000);
        </script>

{% endblock %}
