@using Moonlight.App.Models.Misc
@using System.Text
@using Moonlight.App.Helpers

@{
    string GetStatusColor(string s)
    {
        if (s == "Healthy")
            return "success";
        else if (s == "Unhealthy")
            return "danger";
        else
            return "warning";
    }
}

<div class="card">
    <div class="card-header">
        <div class="card-title">
            <TL>Moonlight health</TL>:
            <div class="ps-3 text-@(GetStatusColor(HealthCheck.Status))">
                <TL>@(HealthCheck.Status)</TL>
            </div>
        </div>
    </div>
    <div class="card-body">
        <div class="accordion" id="healthCheck">
            @foreach (var entry in HealthCheck.Entries)
            {
                <div class="accordion-item">
                    <h2 class="accordion-header" id="healthCheck_1_header_@(entry.Key.ToLower())">
                        <button class="accordion-button fs-4 fw-semibold text-@(GetStatusColor(entry.Value.Status))" type="button" data-bs-toggle="collapse" data-bs-target="#healthCheck_body_@(entry.Key.ToLower())">
                            @(entry.Key)
                        </button>
                    </h2>
                    <div id="healthCheck_body_@(entry.Key.ToLower())" class="accordion-collapse collapse" data-bs-parent="#healthCheck">
                        <div class="accordion-body">
                            <b><TL>Status</TL>:</b>&nbsp;<TL>@(entry.Value.Status)</TL><br/>
                            <b><TL>Description</TL>:</b>&nbsp;@(entry.Value.Description)<br/>
                            <br/>
                            @foreach (var x in entry.Value.Data)
                            {
                                <b>@(x.Key)</b>
                                <br/>
                                @(x.Value)<br/>
                            }
                        </div>
                    </div>
                </div>
            }
        </div>
    </div>
</div>

@code
{
    [Parameter]
    public HealthCheck HealthCheck { get; set; }
}