@model Opserver.Views.PollInfoModel
@{
    var name = Model.Name;
    var node = Model.Node;
    var nodes = Model.Nodes;
    var cache = Model.Cache;
}
@if (node != null && (!node.HasPolled || node.LastFetch?.LastSuccess == null))
{
    <div class="row">
        <div class="col-md-6 col-md-offset-3 text-center" style="margin-top: 10px; margin-bottom: 10px;">
        @if (!node.HasPolled)
        {
            <h5><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> No data for @name yet</h5>
            <p class="text-muted small">First poll is underway - you'll see data appear in a few moments.</p>
            <div class="sk-wave"><div></div><div></div><div></div><div></div><div></div></div>
        }
        else if (node.LastFetch?.LastSuccess == null)
        {
            <h5><i class="fa fa-exclamation-triangle text-warning" aria-hidden="true"></i> Data unavailable for @name</h5>
            <p class="text-muted small">Last Attempt: @(node.LastPoll?.ToRelativeTimeSpan())</p>
            <div class="alert alert-warning">
                @if (node.LastFetch?.ErrorMessage.HasValue() ?? false)
                {
                    <p class="error-stack">@node.LastFetch.ErrorMessage</p>
                }
            </div>
        }
        </div>
    </div>
}
else if (nodes?.All(n => !n.HasPolled) == true)
{
    <div class="row">
        <div class="col-md-6 col-md-offset-3 text-center" style="margin-top: 10px; margin-bottom: 10px;">
            <h5><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> No data for @name yet</h5>
            <p class="text-muted small">First poll is underway - you'll see data appear in a few moments.</p>
            <div class="sk-wave"><div></div><div></div><div></div><div></div><div></div></div>
        </div>
    </div>
}
else if (cache != null && (!cache.LastPoll.HasValue || !cache.LastPollSuccessful))
{
    <div class="row">
        <div class="col-md-6 col-md-offset-3 text-center" style="margin-top: 10px; margin-bottom: 10px;">
            @if (!cache.LastPoll.HasValue)
            {
                <h5><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> No data for @name yet</h5>
                <p class="text-muted small">First poll is underway - you'll see data appear in a few moments.</p>
                <div class="sk-wave"><div></div><div></div><div></div><div></div><div></div></div>
            }
            else if (!cache.LastPollSuccessful)
            {
                <h5><i class="fa fa-exclamation-triangle text-warning" aria-hidden="true"></i> Data unavailable for @name</h5>
                <p class="text-muted small">Last Attempt: @(cache.LastPoll?.ToRelativeTimeSpan())</p>
                <div class="alert alert-warning">
                    @if (cache.ErrorMessage.HasValue())
                    {
                        <p class="error-stack">@cache.ErrorMessage</p>
                    }
                </div>
            }
        </div>
    </div>
}