update to show full gametype name on webfront

This commit is contained in:
RaidMax 2021-11-28 10:17:56 -06:00
parent 15cb114c15
commit 5d7ac7498f
5 changed files with 17 additions and 9 deletions

View File

@ -57,7 +57,7 @@ namespace IW4MAdmin
serverConfiguration, serverConfiguration,
serviceProvider.GetRequiredService<IManager>(), serviceProvider.GetRequiredService<IManager>(),
serviceProvider.GetRequiredService<IRConConnectionFactory>(), serviceProvider.GetRequiredService<IRConConnectionFactory>(),
serviceProvider.GetRequiredService<IGameLogReaderFactory>()) serviceProvider.GetRequiredService<IGameLogReaderFactory>(), serviceProvider)
{ {
_translationLookup = lookup; _translationLookup = lookup;
_metaService = metaService; _metaService = metaService;

View File

@ -13,11 +13,13 @@ using SharedLibraryCore.Interfaces;
using SharedLibraryCore.Database.Models; using SharedLibraryCore.Database.Models;
using ILogger = Microsoft.Extensions.Logging.ILogger; using ILogger = Microsoft.Extensions.Logging.ILogger;
using Data.Models; using Data.Models;
using Microsoft.Extensions.DependencyInjection;
namespace SharedLibraryCore namespace SharedLibraryCore
{ {
public abstract class Server : IGameServer public abstract class Server : IGameServer
{ {
protected readonly DefaultSettings DefaultSettings;
public enum Game public enum Game
{ {
COD = -1, COD = -1,
@ -36,7 +38,7 @@ namespace SharedLibraryCore
public Server(ILogger<Server> logger, SharedLibraryCore.Interfaces.ILogger deprecatedLogger, public Server(ILogger<Server> logger, SharedLibraryCore.Interfaces.ILogger deprecatedLogger,
ServerConfiguration config, IManager mgr, IRConConnectionFactory rconConnectionFactory, ServerConfiguration config, IManager mgr, IRConConnectionFactory rconConnectionFactory,
IGameLogReaderFactory gameLogReaderFactory) IGameLogReaderFactory gameLogReaderFactory, IServiceProvider serviceProvider)
{ {
Password = config.Password; Password = config.Password;
IP = config.IPAddress; IP = config.IPAddress;
@ -55,6 +57,7 @@ namespace SharedLibraryCore
this.gameLogReaderFactory = gameLogReaderFactory; this.gameLogReaderFactory = gameLogReaderFactory;
RConConnectionFactory = rconConnectionFactory; RConConnectionFactory = rconConnectionFactory;
ServerLogger = logger; ServerLogger = logger;
DefaultSettings = serviceProvider.GetRequiredService<DefaultSettings>();
InitializeTokens(); InitializeTokens();
InitializeAutoMessages(); InitializeAutoMessages();
} }
@ -307,6 +310,8 @@ namespace SharedLibraryCore
public string Hostname { get => ServerConfig.CustomHostname ?? hostname; protected set => hostname = value; } public string Hostname { get => ServerConfig.CustomHostname ?? hostname; protected set => hostname = value; }
public string Website { get; protected set; } public string Website { get; protected set; }
public string Gametype { get; set; } public string Gametype { get; set; }
public string GametypeName => DefaultSettings.Gametypes.FirstOrDefault(gt => gt.Game == GameName)?.Gametypes
?.FirstOrDefault(gt => gt.Name == Gametype)?.Alias ?? Gametype;
public string GamePassword { get; protected set; } public string GamePassword { get; protected set; }
public Map CurrentMap { get; set; } public Map CurrentMap { get; set; }
public int ClientNum public int ClientNum

View File

@ -4,14 +4,17 @@ using SharedLibraryCore.Dtos;
using SharedLibraryCore.Interfaces; using SharedLibraryCore.Interfaces;
using System.Linq; using System.Linq;
using Data.Models.Client.Stats; using Data.Models.Client.Stats;
using SharedLibraryCore.Configuration;
namespace WebfrontCore.Controllers namespace WebfrontCore.Controllers
{ {
public class ServerController : BaseController public class ServerController : BaseController
{ {
public ServerController(IManager manager) : base(manager) private readonly DefaultSettings _defaultSettings;
{
public ServerController(IManager manager, DefaultSettings defaultSettings) : base(manager)
{
_defaultSettings = defaultSettings;
} }
[HttpGet] [HttpGet]
@ -33,7 +36,7 @@ namespace WebfrontCore.Controllers
Map = s.CurrentMap.Alias, Map = s.CurrentMap.Alias,
ClientCount = s.Clients.Count(client => client != null), ClientCount = s.Clients.Count(client => client != null),
MaxClients = s.MaxClients, MaxClients = s.MaxClients,
GameType = s.Gametype, GameType = s.GametypeName,
Players = s.GetClientsAsList() Players = s.GetClientsAsList()
.Select(p => new PlayerInfo .Select(p => new PlayerInfo
{ {

View File

@ -62,7 +62,7 @@ namespace WebfrontCore.ViewComponents
Map = server.CurrentMap.Alias, Map = server.CurrentMap.Alias,
ClientCount = server.Clients.Count(client => client != null), ClientCount = server.Clients.Count(client => client != null),
MaxClients = server.MaxClients, MaxClients = server.MaxClients,
GameType = server.Gametype, GameType = server.GametypeName,
PlayerHistory = server.ClientHistory.ToArray(), PlayerHistory = server.ClientHistory.ToArray(),
Players = server.GetClientsAsList() Players = server.GetClientsAsList()
.Select(p => new PlayerInfo() .Select(p => new PlayerInfo()

View File

@ -21,7 +21,7 @@
@if (!string.IsNullOrEmpty(Model.GameType) && Model.GameType.Length > 1) @if (!string.IsNullOrEmpty(Model.GameType) && Model.GameType.Length > 1)
{ {
<span>&ndash;</span> <span>&ndash;</span>
<span>@Model.GameType.ToUpper()</span> <span>@Model.GameType</span>
} }
</div> </div>
<div class="text-center text-md-right col-md-4 d-flex align-self-center justify-content-center justify-content-md-end flex-column-reverse flex-sm-row"> <div class="text-center text-md-right col-md-4 d-flex align-self-center justify-content-center justify-content-md-end flex-column-reverse flex-sm-row">