@inherits ComponentBase
@using Insight.Web.Pages.Management.Hosts.Systems.VirtualMaschines.Snapshots
@using Microsoft.AspNetCore.Components.Rendering

<BaseContainer Title="@Title" Breadcrumbs="@Breadcrumbs" LoadData="LoadDataAsync">
    <Content>
        <MudGrid>
            <MudItem xs="12" sm="6" md="6" lg="3">
                <KeyValueCard T="string" Key="UID" Value="@Snapshot?.UniqueId" />
            </MudItem>

            <MudItem xs="12" sm="6" md="6" lg="3">
                <KeyValueCard T="string" Key="Name" Value="@(_active ? "-" : Snapshot?.Name)" />
            </MudItem>

            @{
                <MudItem xs="12" sm="6" md="6" lg="3">
                    <KeyValueCard T="string" Key="State" Value="@(_active ? "Active" : "Not Active")" ValueColor="@(_active ? Color.Success : Color.Error)" />
                </MudItem>
            }

            @if (ParentSnapshot?.Id is not null)
            {
                <MudItem xs="12" sm="6" md="6" lg="3">
                    <KeyValueCard T="string" OnClick="OnParent" Key="Parent" Value="@ParentSnapshot?.Name" />
                </MudItem>
            }

            @if (Snapshot?.CreationTime is not null)
            {
                <MudItem xs="12" sm="6" md="6" lg="3">
                    <KeyValueCard T="DateTime?" Key="Created" Value="@Snapshot?.CreationTime?.ToLocalTime()" />
                </MudItem>
            }

            <MudItem xs="12" sm="6" md="6" lg="3">
                <KeyValueCard T="string" Key="Generation" Value="@Snapshot?.Generation" />
            </MudItem>

            <MudItem xs="12" sm="6" md="6" lg="3">
                <KeyValueCard T="bool?" Key="Secure Boot" Value="@Snapshot?.SecureBootEnabled" />
            </MudItem>

            <MudItem xs="12" sm="6" md="6" lg="3">
                <KeyValueCard T="bool?" Key="Automatic Snapshot" Value="@Snapshot?.IsAutomaticSnapshot" />
            </MudItem>

            <MudItem xs="12" sm="6" md="6" lg="3">
                <KeyValueCard T="bool?" Key="Automatic Snapshot (Enabled)" Value="@Snapshot?.AutomaticSnapshotsEnabled" />
            </MudItem>
           
        </MudGrid>

        @if (string.IsNullOrWhiteSpace(Snapshot?.Notes) is false)
        {
            <div class="mt-7 mb-7">
                <MudItem xs="12" sm="12" md="12" lg="12">
                    <KeyValueCard T="string" Key="Notes" Value="@Snapshot?.Notes" />
                </MudItem>
            </div>
        }

        <div class="mt-7 mb-7">
            <MudItem xs="12" sm="12" md="12" lg="12">
                <KeyValueCard T="string" Key="Config (Root)" Value="@Snapshot?.ConfigurationDataRoot" />
            </MudItem>
        </div>

        <div class="mt-7 mb-7">
            <MudItem xs="12" sm="12" md="12" lg="12">
                <KeyValueCard T="string" Key="State (File)" Value="@Snapshot?.GuestStateFile" />
            </MudItem>
        </div>

        <div class="mt-7 mb-7">
            <MudItem xs="12" sm="12" md="12" lg="12">
                <KeyValueCard T="string" Key="Snapshot (File)" Value="@Snapshot?.ConfigurationFile" />
            </MudItem>
        </div>

    </Content>
</BaseContainer>

@code{
    private bool _active => Snapshot?.UniqueId == VirtualMaschine?.UniqueId;

    private void OnParent()
    {
        NavigationManager.NavigateTo(Navigation.Management.Hosts.Systems.VirtualMaschines.Snapshots.DetailsHref(HostId, VirtualMaschineId, ParentSnapshot?.Id), true);
    }
}