@using WebfrontCore.ViewModels
@using Humanizer
@model SharedLibraryCore.Dtos.IW4MAdminInfo
@{
    var loc = Utilities.CurrentLocalization.LocalizationIndex;

    string FormatTranslation(string translationKey, params object[] values)
    {
        var split = loc[translationKey].Split("::");
        return split.Length == 2 ? $"<span class='font-weight-bold text-primary'>{split[0].FormatExt(values)}</span><span>{split[1]}</span>" : translationKey;
    }
}
<div class="content mt-20 row">
    <div class="col-12 col-lg-9">
        <h2 class="content-title mb-0">@ViewBag.Localization["WEBFRONT_SERVERS_TITLE"]</h2>
        @if (Model.Game.HasValue)
        {
            <span class="text-muted">@loc[$"GAME_{Model.Game.Value}"]</span>
        }
        else
        {
            <span class="text-muted">@ViewBag.Localization["WEBFRONT_STATS_INDEX_ALL_SERVERS"]</span>
        }
        <div class="card p-0 m-0">
            <div class="d-flex flex-column flex-md-row justify-content-md-between bg-dark-dm bg-light-lm p-10 mt-15 mb-15 rounded">
                <div class="align-self-center align-content-md-start">@Html.Raw(FormatTranslation("WEBFRONT_HOME_CLIENTS_ONLINE", Model.TotalOccupiedClientSlots, Model.TotalAvailableClientSlots))</div>
                <div class="align-self-center align-content-md-start" data-toggle="tooltip" data-title="@Model.MaxConcurrentClientsTime.HumanizeForCurrentCulture().Titleize()">@Html.Raw(FormatTranslation("WEBFRONT_HOME_MAX_CONCURRENT_CLIENTS", Model.MaxConcurrentClients.ToString("#,##0")))</div>
                <div class="align-self-center align-content-md-start">@Html.Raw(FormatTranslation("WEBFRONT_HOME_RECENT_CLIENTS", Model.RecentClientCount.ToString("#,##0")))</div>
                <div class="align-self-center align-content-md-start">@Html.Raw(FormatTranslation("WEBFRONT_HOME_TOTAL_CLIENTS", Model.TotalClientCount.ToString("#,##0")))</div>
            </div>
        </div>
        @await Component.InvokeAsync("ServerList", Model.Game)
    </div>

    @{
        var menuItems = new SideContextMenuItems
        {
            MenuTitle = ViewBag.Localization["WEBFRONT_CONTEXT_MENU_GLOBAL_GAME"],
            Items = Model.ActiveServerGames.Select(game => new SideContextMenuItem
            {
                IsLink = true,
                Reference = Url.Action("Index", "Home", new { game }),
                Title = loc[$"GAME_{game}"],
                IsActive = game == Model.Game
            }).Prepend(new SideContextMenuItem
            {
                IsLink = true,
                Reference = Url.Action("Index", "Home"),
                Title = loc["GAME_ALL"],
                IsActive = !Model.Game.HasValue
            }).ToList()
        };
    }
    <partial name="_SideContextMenu" for="@menuItems"></partial>
</div>

@section scripts {
    <environment include="Development">
        <script type="text/javascript" src="~/js/server.js" defer="defer"></script>
    </environment>
}
