{% extends "apps/base.html" %}
{% load filters_deploys %}
{% load staticfiles %}

{% block extra_css %}
{{ block.super }}
<link rel="stylesheet" href="{% static "css/deploys.css" %}" />
<link rel="stylesheet" href="{% static "css/dropzone.css" %}" />
{% endblock %}

{% block navbar %}
{% include "apps/navbar.html" with active="deploys" %}
{% endblock %}

{% block app-content %}
<div class="row">
  <div class="col-md-12" id="deploy-box">
  </div>
</div>
<div class="row">
  <div class="col-md-12">
    <table class="deploys table" id="list">
      {% for deploy in deploys %}
      <tr class="{% if deploy.Error %}bg-danger{% endif %}">
        <td>
          {{ deploy.Timestamp|string_to_date|date:" d-m-Y H:i:s " }}
          - deployed from: {{ deploy.Origin }}
          <br>
          duration: {{ deploy.Duration|time_to_string }} -
          <a href="{% url 'app-deploy' app.name deploy.ID  %}">view info</a>
          {% if deploy.CanRollback and forloop.counter0 %}
          -
          <a class="rollback" href="#rollback"
          data-toggle="modal" rollback-url="{% url 'app-rollback' app.name deploy.Image %}">roll back to here</a>
          {% endif %}
        </td>
      </tr>
      {% empty %}
      <div class="alert alert-info" role="alert">
        <span class="icon icon-info-sign"></span> Your app don't have any deploy.
      </div>
      {% endfor %}
    </table>
    {% include "deploys/paginator.html" %}
  </div>
</div>
</div>

<div id="deploy"
class="modal fade"
tabindex="-1"
role="dialog"
data-keyboard="false"
data-backdrop="static"
aria-labelledby="myModalLabel"
aria-hidden="true">
</div>

<div id="rollback"
class="modal fade"
tabindex="-1"
role="dialog"
data-keyboard="false"
data-backdrop="static"
aria-labelledby="myModalLabel"
aria-hidden="true">
</div>
{% endblock %}

{% block extra_js %}
<script src="{% static "js/lib/confirmation.js" %}"></script>
<script src="{% static "js/vendor/jszip.js" %}"></script>
<script src="{% static "js/pages/deploy.js" %}"></script>
{% endblock %}
