@using WebfrontCore.ViewModels
@model IEnumerable<WebfrontCore.ViewModels.ScoreboardInfo>
@{
    var selectedServer = Model?.FirstOrDefault(server => server.ServerId == ViewBag.SelectedServerId) ?? Model?.First();
}

<div class="content mt-20 row">
    <div class="col-12 col-lg-9">
        @if (Model is not null)
        {
            <div class="scoreboard-container" data-server-id="@ViewBag.SelectedServerId">
                <partial name="_Scoreboard" for="@selectedServer"/>
            </div>
        }
    </div>
    @{
        var menuItems = new SideContextMenuItems
        {
            MenuTitle = ViewBag.Localization["WEBFRONT_CONTEXT_MENU_GLOBAL_SERVER"], 
            Items = Model.Select(server => new SideContextMenuItem
            {
                IsLink = true,
                Reference = Url.Action("Scoreboard", "Server", new { serverId = server.ServerId }),
                Title = server.ServerName.StripColors(),
                IsActive = ViewBag.SelectedServerId == server.ServerId
            }).ToList()
        };
    }
    <partial name="_SideContextMenu" for="@menuItems"></partial>
</div>

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