{% extends "layout.html" %}
{% block body %}

<p><b>The following disk will be erased:</b></p>

{% for disk in blockdevs["blockdevices"] if disk["name"] == diskname %}
{% set disk_size = disk['size'] %}

<div style="padding-top: 20px;"> <!-- partition bars -->
<div style="background-color: gray; padding: 4px 6px 7px 6px; border-radius: 10px;">
<p> <span style="width: 100%; border-radius: 8px 8px 0 0;" class="tag is-black">
        <b>{{ disk['name'] }}: &nbsp; </b>  {{ disk['model'] }} - {{ disk['tran'] }} disk ({{(disk['size']/1024000000)|round(0)|int }} GB) - Serial: {{ disk['serial'] }} </p>
    <center style="padding: 5px; padding-bottom: 5px;">
    </center>

  {% if disk['maj:min'] == "252:0" %}
  <div class="column">
    <div class="box" style="width: 100%; border-radius: 0 0 0px 5px; height: 60px; padding-top: 5px; right: 0px;">
    <span class="tag is-link">swap</span>
    </p>
    </div>
    </div>
  {% endif %}

{% set colors = ['teal', '#E69F00', '#56B4E9', '#009E73', '#0072B2', '#D55E00', '#CC79A7'] %}

<div id="percentagebar" style="width: 100%; height: 50px; background-color: transparent; display: inline-block; margin: 5; padding: 5; overflow: hidden; display: flex;">
        {% for child in disk['children'] %}
        <a hx-get="/disks/partition/{{ child['name'] }}" hx-swap="outerHTML">
        <div style="min-width: 100px; width: {{ (((child['size'] / disk['size'])*100)|round(0)|int) }}%; height: 100%; background-color: {{ colors[loop.index0 % colors|length] }}; display: inline-block; margin: 1; padding: 1; border-radius: 8px;">
                &nbsp; <a hx-get="/disks/partition/{{ child['name'] }}" hx-swap="outerHTML"> <font color="white">{{ child['name'] }} </font>
        </div></a>
        {% endfor %}
</div>

<table width="100%">
        <th>Partition</th>
        <th>Type</th>
        <th>Mount Point</th>
        <th>Label</th>
        <th>Size</th>
{% for child in disk['children'] %}
<tr>
    <td><a hx-get="/disks/partition/{{ child['name'] }}" hx-swap="outerHTML"><span class="tag is-link">{{ child['name'] }}</span></a></td>
    <td>{{ child['fstype'] }}</td>
    <td>{{ child['mountpoint'] }}</td>
    <td>{{ child['label'] }} </td>
    <td>{{ (child['size']/1024000000)|round(2) }} GiB </td>
</tr>
{% endfor %}
</table>
</div>
</div>
{% endfor %}

<br>

<p><b>This layout will be created:</b></p>

{% for disk in blockdevs["blockdevices"] if disk["name"] == diskname %}
{% set disk_size = disk['size'] %}
<div style="padding-top: 20px;"> <!-- partition bars -->
<div style="background-color: gray; padding: 4px 6px 7px 6px; border-radius: 10px;">
<p> <span style="width: 100%; border-radius: 8px 8px 0 0;" class="tag is-black">
	<b>New GPT Partition Table on {{ disk['name'] }} </b> </p>
        <!-- TODO: Unhardcode that, it might be a BIOS or other type of partition -->
    <center style="padding: 5px; padding-bottom: 5px;">
    </center>

{% set colors = ['teal', '#E69F00', '#56B4E9', '#009E73', '#0072B2', '#D55E00', '#CC79A7'] %}

<div id="percentagebar" style="width: 100%; height: 50px; background-color: transparent; display: inline-block; margin: 5; padding: 5; overflow: hidden; display: flex;">
        {% for partition in partitions['command_set'] if partition['action-type'] == 'newpart' %}
        <a hx-get="/disks/partition/" hx-swap="outerHTML">
		<div style="min-width: 100px; width: {{ partition['size']}}; display: inline-block; margin: 1; padding: 1; border-radius: 8px; background-color: {{ colors[loop.index0 % colors|length] }}; display: inline-block; margin: 1; padding: 1; border-radius: 8px;">
		<!-- TODO: That is totally wrong, but works for POC -->
		&nbsp; <a hx-get="/disks/partition/" hx-swap="outerHTML"> <font color="white"> {{ partition['device'] }} </font>
        </div></a>
        {% endfor %}
</div>

<table width="100%">
        <th>Partition</th>
        <th>Type</th>
        <th>Mount Point</th>
        <th>Label</th>
        <th>Size</th>
{% for partition in partitions['command_set'] if partition['action-type'] == 'newpart' %}
<tr>
    <td><a hx-get="/disks/partition/{{ partition['device']}}" hx-swap="outerHTML"><span class="tag is-link">{{ partition['device'] }}</span></a></td>
    <td>{{ partition['fstype'] }}</td>
    <td>{{ partition['mountpoint'] }}</td>
    <td>{{ partition['label'] }}  </td>
    <td>{{ partition['size'] }} </td>
</tr>
{% endfor %}
</table>
</div>
</div>
{% endfor %}


<BR>

{% endblock %}
