@using static Insight.Domain.Messages.Agent.VirtualDisk;
@inherits ComponentBase

<BaseContainer Title="@Title" Breadcrumbs="@Breadcrumbs" LoadData="LoadDataAsync">
    <Content>
        @if (HostVirtualDisk is not null)
        {
            <MudGrid>
                <MudItem xs="12" sm="6" md="6" lg="3">
                    <KeyValueCard T="string" Key="Name" Value="@HostVirtualDisk?.Name" />
                </MudItem>
                <MudItem xs="12" sm="6" md="6" lg="3">
                    @{
                        var color = Enum.Parse<HealthState>(HostVirtualDisk?.Health, true) switch
                        {
                            HealthState.Healthy => Color.Success,
                            HealthState.Warning => Color.Warning,
                            HealthState.Unhealthy => Color.Error,
                            HealthState.Unknown => Color.Inherit,
                            _ => Color.Error
                        };

                        <KeyValueCard T="string" Key="Health" Value="@HostVirtualDisk?.Health" ValueColor="color" />
                    }
                </MudItem>
                <MudItem xs="12" sm="6" md="6" lg="3">
                    <KeyValueCard T="string" Key="Access" Value="@HostVirtualDisk?.Access" />
                </MudItem>
                <MudItem xs="12" sm="6" md="6" lg="3">
                    <KeyValueCard T="string" Key="Provisioning" Value="@HostVirtualDisk?.Provisioning" />
                </MudItem>
                <MudItem xs="12" sm="6" md="6" lg="3">
                    <KeyValueCard T="string" Key="Resiliency" Value="@HostVirtualDisk?.Resiliency" />
                </MudItem>
                <MudItem xs="12" sm="6" md="6" lg="3">
                    <KeyValueCard T="ulong?" Key="Redundancy (Phyiscal)" Value="@HostVirtualDisk?.PhysicalRedundancy" />
                </MudItem>
                @if (HostVirtualDisk?.States != null)
                {
                    <MudItem xs="12" sm="6" md="6" lg="3">
                        <KeyValueCard T="string" Key="Status" Value="@string.Join(", ", HostVirtualDisk.States)" />
                    </MudItem>
                }
                <MudItem xs="12" sm="6" md="6" lg="3">
                    @{
                        var value = "-";

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

                        <KeyValueCard T="string" Key="Size" Value="@value" />
                    }
                </MudItem>
                <MudItem xs="12" sm="6" md="6" lg="3">
                    @{
                        var value = "-";

                        if (HostVirtualDisk?.AllocatedSize != null)
                        {
                            value = $"{Math.Round((HostVirtualDisk.AllocatedSize.Value / Math.Pow(1024, 3)), 2)} GB";
                        }

                        <KeyValueCard T="string" Key="Allocated" Value="@value" />
                    }
                </MudItem>
                <MudItem xs="12" sm="6" md="6" lg="3">
                    @{
                        var value = "-";

                        if (HostVirtualDisk?.Footprint != null)
                        {
                            value = $"{Math.Round((HostVirtualDisk.Footprint.Value / Math.Pow(1024, 3)), 2)} GB";
                        }

                        <KeyValueCard T="string" Key="Footprint" Value="@value" />
                    }
                </MudItem>
                <MudItem xs="12" sm="6" md="6" lg="3">
                    @{
                        var value = "-";

                        if (HostVirtualDisk?.ReadCacheSize != null)
                        {
                            value = $"{Math.Round((HostVirtualDisk.ReadCacheSize.Value / Math.Pow(1024, 3)), 2)} GB";
                        }

                        <KeyValueCard T="string" Key="Read Cache" Value="@value" />
                    }
                </MudItem>
                <MudItem xs="12" sm="6" md="6" lg="3">
                    @{
                        var value = "-";

                        if (HostVirtualDisk?.WriteCacheSize != null)
                        {
                            value = $"{Math.Round((HostVirtualDisk.WriteCacheSize.Value / Math.Pow(1024, 3)), 2)} GB";
                        }

                        <KeyValueCard T="string" Key="Write Cache" Value="@value" />
                    }
                </MudItem>
            </MudGrid>
        }
    </Content>
</BaseContainer>