1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-10 23:31:13 -05:00

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 21cda0123b
commit ba86810d4f
13 changed files with 126 additions and 24 deletions

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();