Merge pull request #123 from RaidMax/feature/issue-77-allow-server-type-categorization
add server categorization feature (issue #77)
This commit is contained in:
commit
c376266090
@ -1036,7 +1036,7 @@ namespace IW4MAdmin
|
|||||||
baseGameDirectory.IndexOfAny(Utilities.DirectorySeparatorChars) != -1;
|
baseGameDirectory.IndexOfAny(Utilities.DirectorySeparatorChars) != -1;
|
||||||
|
|
||||||
bool baseGameIsRelative = baseGameDirectory.FixDirectoryCharacters()
|
bool baseGameIsRelative = baseGameDirectory.FixDirectoryCharacters()
|
||||||
.Equals(gameDirectory.FixDirectoryCharacters(), StringComparison.InvariantCultureIgnoreCase);
|
.Equals(gameDirectory?.FixDirectoryCharacters() ?? "", StringComparison.InvariantCultureIgnoreCase);
|
||||||
|
|
||||||
// we want to see if base game is provided and it 'looks' like a directory
|
// we want to see if base game is provided and it 'looks' like a directory
|
||||||
if (baseGameIsDirectory && !baseGameIsRelative)
|
if (baseGameIsDirectory && !baseGameIsRelative)
|
||||||
@ -1046,7 +1046,7 @@ namespace IW4MAdmin
|
|||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(modDirectory))
|
if (string.IsNullOrWhiteSpace(modDirectory))
|
||||||
{
|
{
|
||||||
logPath = Path.Combine(workingDirectory, gameDirectory, logFile);
|
logPath = Path.Combine(workingDirectory, gameDirectory ?? "", logFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -40,6 +40,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ScriptPlugins", "ScriptPlug
|
|||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
Plugins\ScriptPlugins\ParserCoD4x.js = Plugins\ScriptPlugins\ParserCoD4x.js
|
Plugins\ScriptPlugins\ParserCoD4x.js = Plugins\ScriptPlugins\ParserCoD4x.js
|
||||||
Plugins\ScriptPlugins\ParserIW4x.js = Plugins\ScriptPlugins\ParserIW4x.js
|
Plugins\ScriptPlugins\ParserIW4x.js = Plugins\ScriptPlugins\ParserIW4x.js
|
||||||
|
Plugins\ScriptPlugins\ParserPIW5.js = Plugins\ScriptPlugins\ParserPIW5.js
|
||||||
Plugins\ScriptPlugins\ParserPT6.js = Plugins\ScriptPlugins\ParserPT6.js
|
Plugins\ScriptPlugins\ParserPT6.js = Plugins\ScriptPlugins\ParserPT6.js
|
||||||
Plugins\ScriptPlugins\ParserRektT5M.js = Plugins\ScriptPlugins\ParserRektT5M.js
|
Plugins\ScriptPlugins\ParserRektT5M.js = Plugins\ScriptPlugins\ParserRektT5M.js
|
||||||
Plugins\ScriptPlugins\ParserTeknoMW3.js = Plugins\ScriptPlugins\ParserTeknoMW3.js
|
Plugins\ScriptPlugins\ParserTeknoMW3.js = Plugins\ScriptPlugins\ParserTeknoMW3.js
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using System;
|
using static SharedLibraryCore.Server;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace SharedLibraryCore.Dtos
|
namespace SharedLibraryCore.Dtos
|
||||||
{
|
{
|
||||||
@ -10,5 +8,15 @@ namespace SharedLibraryCore.Dtos
|
|||||||
public int RecentClientCount { get; set; }
|
public int RecentClientCount { get; set; }
|
||||||
public int TotalOccupiedClientSlots { get; set; }
|
public int TotalOccupiedClientSlots { get; set; }
|
||||||
public int TotalAvailableClientSlots { get; set; }
|
public int TotalAvailableClientSlots { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// specifies the game name filter
|
||||||
|
/// </summary>
|
||||||
|
public Game? Game { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// collection of unique game names being monitored
|
||||||
|
/// </summary>
|
||||||
|
public Game[] ActiveServerGames { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ using SharedLibraryCore.Interfaces;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using static SharedLibraryCore.Server;
|
||||||
|
|
||||||
namespace WebfrontCore.Controllers
|
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.Description = "IW4MAdmin is a complete server administration tool for IW4x.";
|
||||||
ViewBag.Title = Localization["WEBFRONT_HOME_TITLE"];
|
ViewBag.Title = Localization["WEBFRONT_HOME_TITLE"];
|
||||||
ViewBag.Keywords = "IW4MAdmin, server, administration, IW4x, MW2, Modern Warfare 2";
|
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()
|
var model = new IW4MAdminInfo()
|
||||||
{
|
{
|
||||||
TotalAvailableClientSlots = Manager.GetServers().Sum(_server => _server.MaxClients),
|
TotalAvailableClientSlots = servers.Sum(_server => _server.MaxClients),
|
||||||
TotalOccupiedClientSlots = Manager.GetActiveClients().Count,
|
TotalOccupiedClientSlots = servers.SelectMany(_server => _server.GetClientsAsList()).Count(),
|
||||||
TotalClientCount = await Manager.GetClientService().GetTotalClientsAsync(),
|
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);
|
return View(model);
|
||||||
|
@ -3,14 +3,15 @@ using SharedLibraryCore;
|
|||||||
using SharedLibraryCore.Dtos;
|
using SharedLibraryCore.Dtos;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using static SharedLibraryCore.Server;
|
||||||
|
|
||||||
namespace WebfrontCore.ViewComponents
|
namespace WebfrontCore.ViewComponents
|
||||||
{
|
{
|
||||||
public class ServerListViewComponent : ViewComponent
|
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()
|
var serverInfo = servers.Select(s => new ServerInfo()
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,23 @@
|
|||||||
</div>
|
</div>
|
||||||
</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 {
|
@section scripts {
|
||||||
<environment include="Development">
|
<environment include="Development">
|
||||||
|
Loading…
Reference in New Issue
Block a user