mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 15:20:48 -05:00
add server categorization feature (issue #77)
This commit is contained in:
@ -6,6 +6,7 @@ using SharedLibraryCore.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using static SharedLibraryCore.Server;
|
||||
|
||||
namespace WebfrontCore.Controllers
|
||||
{
|
||||
@ -15,18 +16,22 @@ namespace WebfrontCore.Controllers
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Index()
|
||||
public async Task<IActionResult> Index(Game? game = null)
|
||||
{
|
||||
ViewBag.Description = "IW4MAdmin is a complete server administration tool for IW4x.";
|
||||
ViewBag.Title = Localization["WEBFRONT_HOME_TITLE"];
|
||||
ViewBag.Keywords = "IW4MAdmin, server, administration, IW4x, MW2, Modern Warfare 2";
|
||||
|
||||
var servers = Manager.GetServers().Where(_server => !game.HasValue ? true : _server.GameName == game);
|
||||
|
||||
var model = new IW4MAdminInfo()
|
||||
{
|
||||
TotalAvailableClientSlots = Manager.GetServers().Sum(_server => _server.MaxClients),
|
||||
TotalOccupiedClientSlots = Manager.GetActiveClients().Count,
|
||||
TotalAvailableClientSlots = servers.Sum(_server => _server.MaxClients),
|
||||
TotalOccupiedClientSlots = servers.SelectMany(_server => _server.GetClientsAsList()).Count(),
|
||||
TotalClientCount = await Manager.GetClientService().GetTotalClientsAsync(),
|
||||
RecentClientCount = await Manager.GetClientService().GetRecentClientCount()
|
||||
RecentClientCount = await Manager.GetClientService().GetRecentClientCount(),
|
||||
Game = game,
|
||||
ActiveServerGames = Manager.GetServers().Select(_server => _server.GameName).Distinct().ToArray()
|
||||
};
|
||||
|
||||
return View(model);
|
||||
|
@ -3,14 +3,15 @@ using SharedLibraryCore;
|
||||
using SharedLibraryCore.Dtos;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using static SharedLibraryCore.Server;
|
||||
|
||||
namespace WebfrontCore.ViewComponents
|
||||
{
|
||||
public class ServerListViewComponent : ViewComponent
|
||||
{
|
||||
public IViewComponentResult Invoke()
|
||||
public IViewComponentResult Invoke(Game? game)
|
||||
{
|
||||
var servers = Program.Manager.GetServers();
|
||||
var servers = Program.Manager.GetServers().Where(_server => !game.HasValue ? true : _server.GameName == game);
|
||||
|
||||
var serverInfo = servers.Select(s => new ServerInfo()
|
||||
{
|
||||
|
@ -19,7 +19,23 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@await Component.InvokeAsync("ServerList")
|
||||
@if (Model.ActiveServerGames.Length > 1)
|
||||
{
|
||||
<ul class="nav nav-tabs border-top border-bottom nav-fill row mb-4" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link @(Model.Game.HasValue ? "" : "active")" href="/" role="tab" aria-selected="true">@loc["GAME_ALL"]</a>
|
||||
</li>
|
||||
|
||||
@foreach (var gameName in Model.ActiveServerGames)
|
||||
{
|
||||
<li class="nav-item">
|
||||
<a asp-action="Index" asp-controller="Home" asp-route-game="@gameName" class="nav-link @(Model.Game == gameName ? "active" : "")" role="tab" aria-selected="false">@loc[$"GAME_{gameName}"]</a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
|
||||
@await Component.InvokeAsync("ServerList", Model.Game)
|
||||
|
||||
@section scripts {
|
||||
<environment include="Development">
|
||||
|
Reference in New Issue
Block a user