{% extends 'commands.html' %}
{% import 'bootstrap/wtf.html' as wtf %}
{% import 'macros.html' as macros %}

{% set sidebar_state = 'disabled' %}
{% set btn_back = true %}

{% block nav_setup %} active{% endblock %}
{% block nav_setup_setup %} active{% endblock %}
{% block content %}

{% set ip_list = form.ips.data.split(' ') %}
{% set ip_count = ip_list | length %}
<h2 class="mx-5 subhead-heading">
  {{ _('Partitioning %(ip_count)d client(s)', ip_count=ip_count) }}
</h2>

{{ macros.cmd_selected_clients(selected_clients) }}

{% if common_disk_data|length > 0 %}

<div class="form-group mx-5">
  <label class="control-label">{{ _('Disk inventory') }}</label>
  <table class="table table-bordered">
      <thead class="thead-light">
          <tr>
              <th>{{ _('Disk') }}</th>
              <th>{{ _('Size (MiB)') }}</th>
              <th>{{ _('Clients') }}</th>
          </tr>
      </thead>
      <tbody>
          {% for disk, data in common_disk_data.items() %}
            {% for size, ips in data.inventory.items() %}
              <tr>
                {% if loop.first %}
                  <td rowspan="{{ data.inventory | length }}">{{ disk }}</td>
                {% endif %}
                <td>
                  {% if size == data.common_size %}
                      <strong>{{ size // 1024 }}</strong>
                  {% else %}
                      {{ size // 1024 }}
                  {% endif %}
                </td>
                <td>
                  {% for ip in ips %}<div class="card d-inline-block" style="padding: 5px; margin: 3px;">{{ ip }}</div>{% endfor %}
                </td>
              </tr>
            {% endfor %}

          {% endfor %}
      </tbody>
  </table>
  <p>{{ _('Note: the disk size in bold represents the selected common size for partitioning') }}</p>
</div>

{% endif %}

{{ wtf.quick_form(form,
                  action=url_for('action_setup_show'),
                  method='get',
                  button_map={'restore': 'primary'},
                  extra_classes='m-5') }}

{% endblock %}
