@inherits ComponentBase

<TableContainer T="HostVolumeEntity"
                @ref="Container"
                @bind-Search="Search"
                Title="@Title"
                Breadcrumbs="@Breadcrumbs"
                Data="LoadDataAsync">
    <Header>
        <MudTh>
            <MudTableSortLabel SortLabel="Name" T="HostVolumeEntity">
                Name
            </MudTableSortLabel>
        </MudTh>
        @*<MudTh>
        <MudTableSortLabel SortLabel="Drive" T="HostVolumeEntity">
        Drive
        </MudTableSortLabel>
        </MudTh>*@
        <MudTh>
            <MudTableSortLabel SortLabel="Type" T="HostVolumeEntity">
                Type
            </MudTableSortLabel>
        </MudTh>
        <MudTh>
            <MudTableSortLabel SortLabel="FileSystem" T="HostVolumeEntity">
                File System
            </MudTableSortLabel>
        </MudTh>
        <MudTh>
            <MudTableSortLabel SortLabel="Size" T="HostVolumeEntity">
                Size
            </MudTableSortLabel>
        </MudTh>
        <MudTh>
            <MudTableSortLabel SortLabel="FreeSpace" T="HostVolumeEntity">
                Free
            </MudTableSortLabel>
        </MudTh>
    </Header>
    <RowTemplate>
        <MudTd DataLabel="Name">
            <MudLink Href="@Navigation.Management.Hosts.Systems.Volumes.DetailsHref(HostId, context?.Id.ToString())" Typo="Typo.inherit" Underline="Underline.None">
                @{
                    var name = context?.Name;

                    if (name is null)
                    {
                        name = "Unnamed";
                    }

                    if (context?.Label is not null)
                    {
                        name += $" ({@context?.Label})";
                    }

                    @name
                }
            </MudLink>
        </MudTd>
        @*<MudTd DataLabel="Drive">
        @context?.Name
        </MudTd>*@
        <MudTd DataLabel="Type">
            @context?.Type
        </MudTd>
        <MudTd DataLabel="FileSystem">
            @context?.FileSystem
        </MudTd>
        <MudTd DataLabel="Size">
            @{
                var capacity = "-";

                if (context?.Size is not null)
                {
                    capacity = $"{Math.Round((context.Size.Value / Math.Pow(1024, 3)), 2)} GB";
                }

                @capacity
            }
        </MudTd>
        <MudTd DataLabel="FreeSpace">
            @{
                double? size = null;
                double? free = null;
                var value = "-";

                if (context?.FreeSpace is not null)
                {
                    free = Math.Round((context.FreeSpace.Value / Math.Pow(1024, 3)), 2);
                    value = $"{free} GB";

                    if (context?.Size is not null && context?.Size is not null)
                    {
                        size = Math.Round((context.Size.Value / Math.Pow(1024, 3)), 2);
                        value += $" ({Math.Round(free.Value / size.Value * 100, 2)}%)";
                    }
                }

                @value
            }
        </MudTd>
    </RowTemplate>
</TableContainer>