@model Node
@{
    var ifaces = Model.Interfaces;
}
<h4 class="modal-title">
    @Model.PrettyName Interfaces
</h4>
<div class="row small">
    <div class="col-md-12">
        @foreach (var i in ifaces.Where(i => !i.IsTeamMember)
                        .OrderBy(i => i.IsTeam ? 0 : 1)
                        .ThenByDescending(i => i.IPs?.Count ?? 0)
                        .ThenBy(i => i.Name))
        {
            <div class="panel panel-default">
                <div class="panel-heading">
                    @i.IconSpan()
                    @if (i.IsTeam)
                    {
                        <strong>Team</strong>
                    }
                    @i.PrettyName <span class="text-muted">(@i.Status.AsString(EnumFormat.Description))</span>
                </div>
                <div class="panel-body">
                    <div class="row">
                        @if (i.IsTeam)
                        {
                            <div class="col-sm-4">
                                @for (var j = 0; j < i.TeamMembers.Count; j++)
                                {
                                    var m = ifaces.FirstOrDefault(tm => tm.Id == i.TeamMembers[j]);
                                    if (m == null)
                                    {
                                        <div>Unknown: (@(i.TeamMembers[j]))</div>
                                    }
                                    <div class="panel panel-default">
                                        <div class="panel-heading">@m.IconSpan() @m.PrettyName <span class="text-muted">(@m.PrettySpeed.ColorCode())</span></div>
                                        <div class="panel-body">
                                            <ul class="ul-plain">
                                                <li><span class="text-muted">Current:</span> @Icon.Download @m.PrettyIn() @Icon.Upload @m.PrettyOut()</li>
                                                <li><span class="text-muted">MAC:</span> @m.PrettyMAC</li>
                                            </ul>
                                        </div>
                                    </div>
                                }
                            </div>
                        }
                        <div class="col-sm-4">
                            <div>Details</div>
                            <ul class="ul-tree">
                                <li><span class="text-muted">Link Speed:</span> @i.PrettySpeed.ColorCode()</li>
                                <li><span class="text-muted">Current:</span> @Icon.Download @i.PrettyIn() @Icon.Upload @i.PrettyOut()</li>
                                <li><span class="text-muted">MAC:</span> @i.PrettyMAC</li>
                                <li><span class="text-muted">MTU:</span> @((i.MTU?.ToString() ?? "Unknown").ColorCode())</li>
                            </ul>
                        </div>
                        <div class="col-sm-4">
                            <div>@i.IPs.Count.Pluralize("IP Address")</div>
                            <ul class="ul-tree">
                                @foreach (var ip in i.IPs)
                                {
                                    <li>
                                        <span class="text-muted">@ip.AddressFamilyDescription:</span>
                                        @ip.IPAddress<span class="text-muted">/@ip.CIDR.ToString()</span>
                                    </li>
                                }
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        }
    </div>
</div>