fix issue with duplicate js function names for loader

hide flagged status of users on webfront unless logged in (will still show the level if they report someone because cba to update the view component w/out auth status)
add terminal to the radar maps
This commit is contained in:
RaidMax 2019-07-24 10:36:37 -05:00
parent d73d68d9f4
commit 9665d2d457
13 changed files with 126 additions and 24 deletions

View File

@ -23,6 +23,7 @@ namespace LiveRadar.Configuration
Bottom = 930, // yxmax
Top = 44 // pymin
},
new MapInfo()
{
Name = "mp_rust",
@ -36,17 +37,30 @@ namespace LiveRadar.Configuration
MaxBottom = -469
},
new MapInfo()
{
Name = "mp_terminal",
Top = 174,
Bottom = 846,
Left = 18,
Right = 14,
MaxTop = 2929,
MaxBottom = -513,
MaxLeft = 7520,
MaxRight = 2447
},
new MapInfo()
{
Name = "mp_subbase",
MaxLeft = 1841, // ymax
MaxRight = -3817, // ymin
MaxBottom = -1585, // xmin
MaxTop = 2593, // xmax
Left = 18, // pxmin
Right = 968, // pxmax
Bottom = 864, // pymax
Top = 160, // pymin
MaxLeft = 1841,
MaxRight = -3817,
MaxBottom = -1585,
MaxTop = 2593,
Left = 18,
Right = 968,
Bottom = 864,
Top = 160,
ViewPositionRotation = 180,
},

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace SharedLibraryCore.Dtos
{
public class IW4MAdminInfo
{
public int TotalClientCount { get; set; }
public int RecentClientCount { get; set; }
public int TotalOccupiedClientSlots { get; set; }
public int TotalAvailableClientSlots { get; set; }
}
}

View File

@ -532,6 +532,23 @@ namespace SharedLibraryCore.Services
}
}
/// <summary>
/// Returns the number of clients seen today
/// </summary>
/// <returns></returns>
public async Task<int> GetRecentClientCount()
{
using (var context = new DatabaseContext(true))
{
var startOfPeriod = DateTime.UtcNow.AddHours(-24);
var iqQuery = context.Clients.Where(_client => _client.LastConnection >= startOfPeriod);
#if DEBUG
string sql = iqQuery.ToSql();
#endif
return await iqQuery.CountAsync();
}
}
/// <summary>
/// gets the 10 most recently added clients to IW4MAdmin
/// </summary>

View File

@ -16,6 +16,7 @@ using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static SharedLibraryCore.Database.Models.EFClient;
using static SharedLibraryCore.Database.Models.EFPenalty;
using static SharedLibraryCore.Server;
@ -834,6 +835,8 @@ namespace SharedLibraryCore
return new[] { deltaX, deltaY };
}
public static bool ShouldHideLevel(this Permission perm) => perm == Permission.Flagged;
#if DEBUG == true
private static readonly TypeInfo QueryCompilerTypeInfo = typeof(QueryCompiler).GetTypeInfo();

View File

@ -7,6 +7,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using static SharedLibraryCore.Database.Models.EFClient;
using static SharedLibraryCore.Database.Models.EFPenalty;
namespace WebfrontCore.Controllers
@ -25,11 +26,20 @@ namespace WebfrontCore.Controllers
var activePenalties = (await Manager.GetPenaltyService().GetActivePenaltiesAsync(client.AliasLinkId, client.IPAddress))
.Where(_penalty => _penalty.Type != PenaltyType.Flag);
int displayLevelInt = (int)client.Level;
string displayLevel = client.Level.ToLocalizedLevelName();
if (!Authorized && client.Level.ShouldHideLevel())
{
displayLevelInt = (int)Permission.User;
displayLevel = Permission.User.ToLocalizedLevelName();
}
var clientDto = new PlayerInfo()
{
Name = client.Name,
Level = client.Level.ToLocalizedLevelName(),
LevelInt = (int)client.Level,
Level = displayLevel,
LevelInt = displayLevelInt,
ClientId = client.ClientId,
IPAddress = client.IPAddressString,
NetworkId = client.NetworkId,
@ -129,6 +139,15 @@ namespace WebfrontCore.Controllers
}
var clientsDto = await Manager.GetClientService().FindClientsByIdentifier(clientName);
foreach(var client in clientsDto)
{
if (!Authorized && ((Permission)Enum.Parse(typeof(Permission), client.Level)).ShouldHideLevel())
{
client.LevelInt = (int)Permission.User;
client.Level = Permission.User.ToLocalizedLevelName();
}
}
ViewBag.Title = $"{clientsDto.Count} {Localization["WEBFRONT_CLIENT_SEARCH_MATCHING"]} \"{clientName}\"";
return View("Find/Index", clientsDto);

View File

@ -1,17 +1,28 @@
using Microsoft.AspNetCore.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using SharedLibraryCore.Dtos;
using System.Linq;
using System.Threading.Tasks;
namespace WebfrontCore.Controllers
{
public class HomeController : BaseController
{
public IActionResult Index()
public async Task<IActionResult> Index()
{
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";
return View();
var model = new IW4MAdminInfo()
{
TotalAvailableClientSlots = Manager.GetServers().Sum(_server => _server.MaxClients),
TotalOccupiedClientSlots = Manager.GetActiveClients().Count,
TotalClientCount = await Manager.GetClientService().GetTotalClientsAsync(),
RecentClientCount = await Manager.GetClientService().GetRecentClientCount()
};
return View(model);
}
public IActionResult Error()

View File

@ -45,7 +45,6 @@ namespace WebfrontCore.Controllers
using (var ctx = new DatabaseContext(disableTracking: true))
{
// todo: this seems like it's pulling unnecessary info from LINQ to entities.
var iqPenalties = ctx.Penalties
.AsNoTracking()
.Where(p => p.Type == PenaltyType.Ban && p.Active)

View File

@ -10,6 +10,8 @@
.OrderBy(_meta => _meta.Order)
.GroupBy(_meta => _meta.Column)
.OrderBy(_grouping => _grouping.Key);
}
<div id="profile_wrapper" class="pb-3 row d-flex flex-column flex-lg-row">

View File

@ -1,4 +1,25 @@
@await Component.InvokeAsync("ServerList")
@model SharedLibraryCore.Dtos.IW4MAdminInfo
@{
var loc = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex;
string formatTranslation(string translationKey, params object[] values)
{
var split = loc[translationKey].Split("::");
return $"<span class='font-weight-bold text-primary'>{SharedLibraryCore.Utilities.FormatExt(split[0], values)}</span><span>{split[1]}</span>";
}
}
<div class="row mb-4 border-bottom border-top pt-3 pb-3 bg-dark">
<div class="col-xl-4 col-12">
<div class="text-muted text-center text-xl-left">@Html.Raw(formatTranslation("WEBFRONT_HOME_CLIENTS_ONLINE", Model.TotalOccupiedClientSlots, Model.TotalAvailableClientSlots))</div>
</div>
<div class="col-xl-4 col-12">
<div class="text-muted text-center">@Html.Raw(formatTranslation("WEBFRONT_HOME_RECENT_CLIENTS", Model.RecentClientCount.ToString("#,##0")))</div>
</div>
<div class="col-xl-4 col-12">
<div class="text-muted text-center text-xl-right">@Html.Raw(formatTranslation("WEBFRONT_HOME_TOTAL_CLIENTS", Model.TotalClientCount.ToString("#,##0")))</div>
</div>
</div>
@await Component.InvokeAsync("ServerList")
@section scripts {
<environment include="Development">

View File

@ -3,11 +3,11 @@
Layout = null;
}
<div class="row server-header pt-1 pb-1 bg-primary " id="server_header_@Model.ID">
<div class="row server-header pt-1 pb-1 bg-primary " id="server_header_@Model.ID">
<div class="col-md-4 text-center text-md-left d-inline-flex justify-content-center justify-content-md-start">
<span>@Model.Name</span>
<a href="@Model.ConnectProtocolUrl" class="ml-2 mr-2 align-self-center d-none d-md-flex server-join-button" title="@SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_HOME_JOIN_DESC"]">
<span class="oi oi-play-circle mr-2 align-self-center"></span>
<span class="oi oi-play-circle mr-1 align-self-center"></span>
<span class="server-header-ip-address" style="display:none;">@Model.IPAddress</span>
</a>
@if (ViewBag.Authorized)
@ -21,8 +21,8 @@
@if (ViewBag.Authorized)
{
<div class="col-12 p-1">
<span class="oi oi-chat justify-content-center align-self-center profile-action d-flex d-md-none" data-action="chat" data-action-id="@Model.ID"></span>
<div class=" p-1 d-flex d-md-none justify-content-center col-12">
<span class="oi oi-chat align-self-center profile-action d-flex d-md-none" data-action="chat" data-action-id="@Model.ID"></span>
</div>
}
</div>

View File

@ -41,7 +41,7 @@ function loadMoreItems() {
loaderOffset += loadCount;
}
function ScrollHandler(e) {
function _ScrollHandler(e) {
//throttle event:
hasScrollBar = true;
clearTimeout(_throttleTimer);
@ -81,8 +81,8 @@ function setupListeners() {
$document.ready(function () {
$window
.off('scroll', ScrollHandler)
.on('scroll', ScrollHandler);
.off('scroll', _ScrollHandler)
.on('scroll', _ScrollHandler);
$('.loader-load-more:not(.disabled)').click(function (e) {
if (!isLoaderLoading) {
loadMoreItems();

View File

@ -2,7 +2,7 @@
let isLoading = false;
function ScrollHandler(e) {
function PenaltyScrollHandler(e) {
//throttle event:
hasScrollBar = true;
clearTimeout(_throttleTimer);
@ -67,8 +67,8 @@ if ($('#penalty_table').length === 1) {
$document.ready(function () {
$window
.off('scroll', ScrollHandler)
.on('scroll', ScrollHandler);
.off('scroll', PenaltyScrollHandle)
.on('scroll', PenaltyScrollHandle);
$('#load_penalties_button').click(function () {
loadMorePenalties();

View File

@ -2,6 +2,8 @@ Version 2.4:
-added "live radar" feature
-added chat message to server on server list view
-added recently connected players dropdown option on webfront
-added "dashboard" to home view with quick stats
-hid flagged status of users on webfront unless logged in
Version 2.3:
-added configuration option to ignore bots