@using Opserver.Data.Dashboard
@inject DashboardModule Dashboard
@model Node
@{
    var s = Model;
}
@functions
{
    public string GetItemClass(Node s)
    {
        var prefix = s.IsVM ? "virtual-machine " : "";
        return prefix + s.RowClass();
    }
    string Graph(Node s, string type)
    {
        if (!Dashboard.HasData)
        {
            <div class="text-muted">No Data Available</div>
        }
        else
        {
            <img class="js-dashboard-spark" src="@Url.Content("~/graph/")@type.ToLower()/spark?id=@s.Id" alt="" data-id="@s.Id" data-type="@type" data-node="@s.PrettyName" />
        }
        return null;
    }
}
<div class="item dashboard @s.TextClass() @GetItemClass(s)">
    <div class="server-name">
        @s.IconSpan()
        <a href="@Url.Action(nameof(DashboardController.Node), "Dashboard", new { node = s.PrettyName })">@s.PrettyName</a>
        @if (s.IsUnwatched)
        {
            <span class="unmanaged">(unmanaged)</span>
        }
        <span class="category">@s.Category.Name</span>
    </div>
    <div class="status-block cpu-status">
        <span class="label">CPU </span>@s.CPUStatusSpan() 
        <div class="status-graph">@Graph(s, "CPU")</div>
    </div>
    <div class="status-block mem-status">
        <span class="label">Mem </span>@s.MemoryPercentStatusSpan()
        <div class="status-graph">@s.MemoryStatusSpan()@if (s.HasValidMemoryReading) {
            <div class="space-used" style="width: 215px;"><div class="used @s.MemoryMonitorStatus().AsString(EnumFormat.Description)" style="width: @(s.PercentMemoryUsed?.ToString(CultureInfo.InvariantCulture))%"></div></div>
        }
        </div>
    </div>
    <div class="status-block net-status">
        <span class="label">Net </span>@s.PrettyTotalNetwork() 
        <div class="status-graph">@Graph(s, "Network")</div>
    </div>
</div>