@inherits ComponentBase

<TableContainer T="ViewModel"
                @ref="Container"
                @bind-Search="Search"
                Title="@Title"
                Breadcrumbs="@Breadcrumbs"
                Data="LoadDataAsync">
    <Header>
        <MudTh>
            <MudTableSortLabel SortLabel="Customer" T="ViewModel">
                Customer
            </MudTableSortLabel>
        </MudTh>
        <MudTh>
            <MudTableSortLabel SortLabel="Host" T="ViewModel">
                Host
            </MudTableSortLabel>
        </MudTh>
        <MudTh>
            <MudTableSortLabel SortLabel="Name" T="ViewModel">
                Name
            </MudTableSortLabel>
        </MudTh>
        <MudTh>
            <MudTableSortLabel SortLabel="Type" T="ViewModel">
                Type
            </MudTableSortLabel>
        </MudTh>
        <MudTh>
            <MudTableSortLabel SortLabel="Filesystem" T="ViewModel">
                Filesystem
            </MudTableSortLabel>
        </MudTh>
        <MudTh>
            <MudTableSortLabel SortLabel="Size" T="ViewModel">
                Size
            </MudTableSortLabel>
        </MudTh>
        <MudTh>
            <MudTableSortLabel SortLabel="Freespace" T="ViewModel">
                Freespace
            </MudTableSortLabel>
        </MudTh>
    </Header>
    <RowTemplate>
        <MudTd DataLabel="Customer">
            <MudLink Href="@Navigation.Management.Customers.DetailsHref(@context?.Customer?.Id)" Typo="Typo.inherit" Underline="Underline.None">
                @context?.Customer?.Name
            </MudLink>
        </MudTd>
        <MudTd DataLabel="Host">
            <MudLink Href="@Navigation.Management.Hosts.DetailsHref(@context?.Host?.Id)" Typo="Typo.inherit" Underline="Underline.None">
                @context?.Host?.Name
            </MudLink>
        </MudTd>
        <MudTd DataLabel="Name">
            <MudLink Href="@Navigation.Management.Hosts.Systems.Volumes.DetailsHref(@context?.Host?.Id, context?.Id?.ToString())" Typo="Typo.inherit" Underline="Underline.None">
                @{
                    var value = context?.Name;

                    if (string.IsNullOrWhiteSpace(value)) value = "N/A";

                    @value
                }
            </MudLink>
        </MudTd>
        <MudTd DataLabel="Type">
            @context?.Type
        </MudTd>
        <MudTd DataLabel="Filesystem">
            @context?.Filesystem
        </MudTd>
        <MudTd DataLabel="Size">
            @{
                double? size = null;
                var value = "-";

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

                @value
            }
        </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>