IW4M-Admin/WebfrontCore/Controllers/ServerController.cs
RaidMax 9db8ad80ef fixed bug with lifetime hit ratio causing erroneous ban
ip lookup on profile shows error if failed
truncate chat messages over 50 characters
removed html raw on client messages :c
show client rank colors on server overview if authorized
break long messages on profile page
prevent masked status showing up to non privileged users in webfront
2018-03-28 22:01:09 -05:00

43 lines
1.4 KiB
C#

using Microsoft.AspNetCore.Mvc;
using SharedLibrary.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace WebfrontCore.Controllers
{
public class ServerController : BaseController
{
[HttpGet]
[ResponseCache(NoStore = true, Duration = 0)]
public IActionResult ClientActivity(int id)
{
var s = Manager.GetServers().FirstOrDefault(s2 => s2.GetHashCode() == id);
if (s == null)
return View("Error", "Invalid server!");
var serverInfo = new ServerInfo()
{
Name = s.Hostname,
ID = s.GetHashCode(),
Port = s.GetPort(),
Map = s.CurrentMap.Alias,
ClientCount = s.ClientNum,
MaxClients = s.MaxClients,
GameType = s.Gametype,
Players = s.Players.Where(p => p != null).Select(p => new PlayerInfo
{
Name = p.Name,
ClientId = p.ClientId,
Level = p.Level.ToString()
}).ToList(),
ChatHistory = s.ChatHistory.OrderBy(c => c.Time).Take((int)Math.Ceiling(s.ClientNum / 2.0)).ToArray(),
PlayerHistory = s.PlayerHistory.ToArray()
};
return PartialView("_ClientActivity", serverInfo);
}
}
}