@inherits ComponentBase

<BaseContainer @ref="_container" Title="@_title" Breadcrumbs="@_breadcrumbs" LoadData="LoadDataAsync">
    <Content>
        <MudGrid>
            @if (_host is not null)
            {
                <MudItem xs="12" sm="6" md="6" lg="3">
                    <KeyValueCard T="string" Key="Name" Value="@_host.Name" Icon="@Icons.Material.Outlined.Devices" />
                </MudItem>
                <MudItem xs="12" sm="6" md="6" lg="3">
                    <KeyValueCard T="string" OnClick="()=>_customerDialog?.ToggleAsync(_host?.Id)" Key="Customer" Value="@(_host?.Customers?.FirstOrDefault()?.Name ?? "-")" Icon="@Icons.Material.Outlined.Business" IconColor="@Color.Primary" />
                </MudItem>
                <MudItem xs="12" sm="6" md="6" lg="3">
                    <KeyValueCard T="string" OnClick="()=>_agentDialog?.ToggleAsync(_host?.Id)" Key="Agent" Value="@(_host?.Agents?.FirstOrDefault()?.Hostname ?? "-")" Icon="@Icons.Material.Outlined.SignalCellularAlt" IconColor="@Color.Primary" />
                </MudItem>
                <MudItem xs="12" sm="6" md="6" lg="3">
                    <KeyValueCard T="long?" Href="@Navigation.Management.Hosts.LogsHref(HostId)" Key="Logs" Value="@(_logs ?? 0)" Icon="@Icons.Material.Outlined.Assignment" IconColor="@Color.Primary" />
                </MudItem>

                @if (string.IsNullOrWhiteSpace(_host?.Description) is false)
                {
                    <MudItem xs="12" sm="12" md="12" lg="12">
                        <InfoCard Key="Description" Lines="3" Text="@(_host.Description ?? "-")" />
                    </MudItem>
                }
            }
            @if (_os is not null)
            {
                <MudItem xs="12" sm="6" md="6" lg="3">
                    <KeyValueCard T="string" Key="Operation System" Value="@_os.Name" />
                </MudItem>

                @if (_system is not null)
                {
                    <MudItem xs="12" sm="6" md="6" lg="3">
                        <KeyValueCard T="string" Key="License" Value="@_system.License" />
                    </MudItem>
                }
            }
            @if (_system is not null)
            {
                    <MudItem xs="12" sm="6" md="6" lg="3">
                        <KeyValueCard T="string" Key="Boot Time" Value="@_system.BootUpTime?.ToLocalTime().ToString("dd.MM.yyyy HH:mm:ss")" />
                    </MudItem>
                    <MudItem xs="12" sm="6" md="6" lg="3">
                        <KeyValueCard T="string" Key="Local Time" Value="@_system.LocalTime?.ToLocalTime().ToString("dd.MM.yyyy HH:mm:ss")" />
                    </MudItem>
                    <MudItem xs="12" sm="6" md="6" lg="3">
                        <KeyValueCard T="string" Key="Processes" Value="@_system.Processes?.ToString()" />
                    </MudItem>
            }
        </MudGrid>
    </Content>
</BaseContainer>

<HostCustomerDialog @ref="_customerDialog" OnChanges="OnRefreshAsync" />
<HostAgentDialog @ref="_agentDialog" OnChanges="OnRefreshAsync" />

@code {
    private HostCustomerDialog? _customerDialog;
    private HostAgentDialog? _agentDialog;
}