{% load i18n sizeformat %}

<div class="detail">
  <dl class="dl-horizontal">
    <dt>{% trans "Name" %}</dt>
    <dd>{{ instance.name }}</dd>
    <dt>{% trans "ID" %}</dt>
    <dd>{{ instance.id }}</dd>
    <dt>{% trans "Datastore" %}</dt>
    <dd>{{ instance.datastore.type }}</dd>
    <dt>{% trans "Datastore Version" %}</dt>
    <dd>{{ instance.datastore.version }}</dd>
    <dt>{% trans "Status" %}</dt>
    <dd>{{ instance.status|title }}</dd>
    {% if instance.configuration %}
    <dt>{% trans "Configuration Group" %}</dt>
    <dd>
        <a href="{% url 'horizon:project:database_configurations:detail' instance.configuration.id %}">
            {{ instance.configuration.id }}
        </a>
    </dd>
    {% endif %}
    <dt>{% trans "Root Enabled" %}</dt>
    <dd>{{ root_enabled|capfirst }}</dd>
    {% if instance.locality %}
      <dt>{% trans "Locality" %}</dt>
      <dd>{{ instance.locality }}</dd>
    {% endif %}
  </dl>

  {% if instance.fault %}
    <h4>{% trans "Fault" %}</h4>
    <hr class="header_rule">
    <dl class="dl-horizontal">
      <dt>{% trans "Message" %}</dt>
      <dd>{{ instance.fault.message }}</dd>
      {% if instance.fault.details %}
        <dt>{% trans "Details" %}</dt>
        <dd>{{ instance.fault.details }}</dd>
      {% endif %}
      <dt>{% trans "Created" %}</dt>
      <dd>{{ instance.fault.created|parse_isotime }}</dd>
    </dl>
  {% endif %}

  <h4>{% trans "Specs" %}</h4>
  <hr class="header_rule">
  <dl class="dl-horizontal">
    <dt>{% trans "Flavor" %}</dt>
    <dd>{{ instance.full_flavor.name }}</dd>
    <dt>{% trans "RAM" %}</dt>
    <dd>{{ instance.full_flavor.ram|mb_float_format }}</dd>
    {% if instance.volume %}
      <dt>{% trans "Volume Size" %}</dt>
      <dd>{{ instance.volume.size|diskgbformat }}</dd>
    {% endif %}
    <dt>{% trans "Created" %}</dt>
    <dd>{{ instance.created|parse_isotime }}</dd>
    <dt>{% trans "Updated" %}</dt>
    <dd>{{ instance.updated|parse_isotime }}</dd>
  </dl>

{% block connection_info %}
{% endblock %}

{% if instance.replica_of or instance.replicas %}
  <h4>{% trans "Replication" %}</h4>
  <hr class="header_rule">
  <dl>
    {% if instance.replica_of %}
      <dt>{% trans "Is a Replica Of" %}</dt>
      <dd>
        {% url 'horizon:project:databases:detail' instance.replica_of.id as instance_url %}
        <a href="{{ instance_url }}">{{ instance.replica_of.id }}</a>
      </dd>
    {% endif %}

    {% if instance.replicas %}
      <dt>{% trans "Replicas" %}</dt>
      {% for replica in instance.replicas %}
        <dd>
          {% url 'horizon:project:databases:detail' replica.id as instance_url %}
          <a href="{{ instance_url }}">{{ replica.id }}</a>
        </dd>
      {% endfor %}
    {% endif %}
  </dl>
{% endif %}
</div>
