{% extends "skins/base.html" %}
{% load i18n admin_urls admin_static %}

{% block content %}
<!-- using the version of jquery that Pailer was built against -->
<!-- other versions may work but have not been tested -->
<link href="{{STATIC_URL}}css/app_logs.css" rel="stylesheet">
<script src="{{STATIC_URL}}js/jquery-1.7.1.min.js"></script>
<script src="{{STATIC_URL}}js/jquery.pailer.js"></script>
<script>
$(document).ready(function() {

    {% for task_id in task_ids %}
    {% for path in paths %}
    $('#logs_{{path}}').pailer({
        'read': function(options) {
          var settings = $.extend({
            'offset': -1,
            'length': -1
          }, options);
          var url = '{% url "base:mesos_file_log_view" controller_pk=controller.pk task_id=task_id path=path %}'
            + '?offset=' + settings.offset
            + '&length=' + settings.length;
          return $.getJSON(url);
        },
        'indicator': $('#indicator_{{path}}')
      });
    {% endfor %}
    {% endfor %}

});
</script>
<div id="content-main" class="new-project">
    <div class="box-header with-border">
      <h3 class="box-title">Logs for <a href="{% url 'home' %}#{{controller.pk}}">{{controller.name|capfirst}}</a></h3>
    </div>
    {% for task_id in task_ids %}
    {% for path in paths %}
    <div class="box-header with-border">
        <h4 class="box-title">{{path}}</h4>
        <p>
            Download the <a href="{% url "base:mesos_file_log_view" controller_pk=controller.pk task_id=task_id path=path %}?download=true">full log file</a>.
        </p>
        <div id="indicator_{{path}}" class="indicator"></div>
        <div id="logs_{{path}}" class="logs"></div>
    </div>
    {% endfor %}
    {% endfor %}
</div>
{% endblock %}
