{% extends "vac-templater/vcl/layout.html" %}
{% load i18n %}
{% load humanize %}

{% block title %}{% trans 'VCL' %} > {% trans 'Deployment' %}{% endblock %}

{% block sidebar_section %}deployment{% endblock %}

{% block sidebar_content %}
  <div class="page-header">
    <h1>
      {% trans 'Deployment' %}
      <small>{% trans 'Detailed view for an specific deployment' %}</small>
    </h1>
  </div>

  <div id="breadcrumb">
    <i class="glyphicon glyphicon-home"></i>
    <span class="item">{% trans 'VCL' %}</span>
    <a href="{% url 'vcl:deployment' deployment_id=deployment.id %}" class="current">{% trans 'Deployment' %}</a>
  </div>

  <form class="form-horizontal">
    <div class="well">
      <div class="form-group">
        <label class="col-sm-2 control-label">{% trans 'Deployment id' %}</label>
        <div class="col-sm-10">
          <p class="form-control-static">{{ deployment.id }}</p>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-2 control-label">{% trans 'Cache group' %}</label>
        <div class="col-sm-10">
          <p class="form-control-static">{{ deployment.group_name }} ({{ deployment.group_oid }})</p>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-2 control-label">{% trans 'VCL branch' %}</label>
        <div class="col-sm-10">
          <p class="form-control-static">{{ deployment.branch_name }} ({{ deployment.branch_oid }})</p>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-2 control-label">{% trans 'VCL commits' %}</label>
        <div class="col-sm-10">
          <p class="form-control-static">{{ deployment.old_head_oid }} → {{ deployment.new_head_oid }}</p>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-2 control-label">{% trans 'Deployed' %}</label>
        <div class="col-sm-10">
          <p class="form-control-static"><span data-toggle="tooltip" title="{{ deployment.created_at|date:"DATETIME_FORMAT" }}">{{ deployment.created_at|naturaltime }}</span></p>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-2 control-label">{% trans 'User' %}</label>
        <div class="col-sm-10">
          <p class="form-control-static">{{ deployment.user }}</p>
        </div>
      </div>
    </div>

    <pre class="bg-success">{{ deployment.message }}</pre>

    <table class="changes table table-striped table-bordered">
      <tr>
        <th>{% trans 'Setting' %}</th>
        <th>{% trans 'Old value' %}</th>
        <th>{% trans 'New value' %}</th>
      </tr>
      {% if deployment.changes %}
        {% for setting, from, to in deployment.changes %}
          <tr>
            <td>{{ setting }}</td>
            <td class="value">{% if from != None %}{{ from }}{% endif %}</td>
            <td class="value">{% if to != None %}{{ to }}{% endif %}</td>
          </tr>
        {% endfor %}
      {% else %}
        <tr>
          <td colspan="3">{% trans 'No changes have been done in this commit.' %}</td>
        </tr>
      {% endif %}
    </table>

    <pre>{{ deployment.vcl }}</pre>
  </form>
{% endblock %}
