small code cleanups
This commit is contained in:
parent
38f1169061
commit
50ba71c6fb
@ -27,7 +27,7 @@ namespace IW4MAdmin.Application
|
|||||||
{
|
{
|
||||||
public class ApplicationManager : IManager
|
public class ApplicationManager : IManager
|
||||||
{
|
{
|
||||||
private ConcurrentBag<Server> _servers;
|
private readonly ConcurrentBag<Server> _servers;
|
||||||
public List<Server> Servers => _servers.OrderByDescending(s => s.ClientNum).ToList();
|
public List<Server> Servers => _servers.OrderByDescending(s => s.ClientNum).ToList();
|
||||||
public ILogger Logger => GetLogger(0);
|
public ILogger Logger => GetLogger(0);
|
||||||
public bool Running { get; private set; }
|
public bool Running { get; private set; }
|
||||||
@ -46,15 +46,14 @@ namespace IW4MAdmin.Application
|
|||||||
public string ExternalIPAddress { get; private set; }
|
public string ExternalIPAddress { get; private set; }
|
||||||
public bool IsRestartRequested { get; private set; }
|
public bool IsRestartRequested { get; private set; }
|
||||||
static ApplicationManager Instance;
|
static ApplicationManager Instance;
|
||||||
List<Command> Commands;
|
private readonly List<Command> Commands;
|
||||||
readonly List<MessageToken> MessageTokens;
|
private readonly List<MessageToken> MessageTokens;
|
||||||
ClientService ClientSvc;
|
private readonly ClientService ClientSvc;
|
||||||
readonly AliasService AliasSvc;
|
readonly AliasService AliasSvc;
|
||||||
readonly PenaltyService PenaltySvc;
|
readonly PenaltyService PenaltySvc;
|
||||||
public BaseConfigurationHandler<ApplicationConfiguration> ConfigHandler;
|
public BaseConfigurationHandler<ApplicationConfiguration> ConfigHandler;
|
||||||
GameEventHandler Handler;
|
GameEventHandler Handler;
|
||||||
readonly IPageList PageList;
|
readonly IPageList PageList;
|
||||||
readonly SemaphoreSlim ProcessingEvent = new SemaphoreSlim(1, 1);
|
|
||||||
readonly Dictionary<long, ILogger> Loggers = new Dictionary<long, ILogger>();
|
readonly Dictionary<long, ILogger> Loggers = new Dictionary<long, ILogger>();
|
||||||
private readonly MetaService _metaService;
|
private readonly MetaService _metaService;
|
||||||
private readonly TimeSpan _throttleTimeout = new TimeSpan(0, 1, 0);
|
private readonly TimeSpan _throttleTimeout = new TimeSpan(0, 1, 0);
|
||||||
|
@ -61,8 +61,7 @@ namespace SharedLibraryCore.Commands
|
|||||||
|
|
||||||
if (Args[0][0] == '@') // user specifying target by database ID
|
if (Args[0][0] == '@') // user specifying target by database ID
|
||||||
{
|
{
|
||||||
int dbID = -1;
|
int.TryParse(Args[0].Substring(1, Args[0].Length - 1), out int dbID);
|
||||||
int.TryParse(Args[0].Substring(1, Args[0].Length - 1), out dbID);
|
|
||||||
|
|
||||||
var found = await Manager.GetClientService().Get(dbID);
|
var found = await Manager.GetClientService().Get(dbID);
|
||||||
if (found != null)
|
if (found != null)
|
||||||
|
@ -33,7 +33,7 @@ $(document).ready(function () {
|
|||||||
$('.profile-action').click(function (e) {
|
$('.profile-action').click(function (e) {
|
||||||
const actionType = $(this).data('action');
|
const actionType = $(this).data('action');
|
||||||
const actionId = $(this).data('action-id');
|
const actionId = $(this).data('action-id');
|
||||||
const actionIdKey = actionId == undefined ? '' : '?id=' + actionId;
|
const actionIdKey = actionId === undefined ? '' : '?id=' + actionId;
|
||||||
$.get('/Action/' + actionType + 'Form' + actionIdKey)
|
$.get('/Action/' + actionType + 'Form' + actionIdKey)
|
||||||
.done(function (response) {
|
.done(function (response) {
|
||||||
$('#actionModal .modal-message').fadeOut('fast');
|
$('#actionModal .modal-message').fadeOut('fast');
|
||||||
@ -90,12 +90,12 @@ $(document).ready(function () {
|
|||||||
*/
|
*/
|
||||||
$('#actionModal').off('action_form_received');
|
$('#actionModal').off('action_form_received');
|
||||||
$('#actionModal').on('action_form_received', function (e, actionType) {
|
$('#actionModal').on('action_form_received', function (e, actionType) {
|
||||||
if (actionType == 'RecentClients') {
|
if (actionType === 'RecentClients') {
|
||||||
const ipAddresses = $('.client-location-flag');
|
const ipAddresses = $('.client-location-flag');
|
||||||
$.each(ipAddresses, function (index, address) {
|
$.each(ipAddresses, function (index, address) {
|
||||||
$.get('https://ip2c.org/' + $(address).data('ip'), function (result) {
|
$.get('https://ip2c.org/' + $(address).data('ip'), function (result) {
|
||||||
const countryCode = result.split(';')[1].toLowerCase();
|
const countryCode = result.split(';')[1].toLowerCase();
|
||||||
if (countryCode != 'zz') {
|
if (countryCode !== 'zz') {
|
||||||
$(address).css('background-image', `url(https://www.countryflags.io/${countryCode}/flat/64.png)`);
|
$(address).css('background-image', `url(https://www.countryflags.io/${countryCode}/flat/64.png)`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -41,6 +41,20 @@ function loadMoreItems() {
|
|||||||
loaderOffset += loadCount;
|
loaderOffset += loadCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ScrollHandler(e) {
|
||||||
|
//throttle event:
|
||||||
|
hasScrollBar = true;
|
||||||
|
clearTimeout(_throttleTimer);
|
||||||
|
_throttleTimer = setTimeout(function () {
|
||||||
|
|
||||||
|
//do work
|
||||||
|
if ($window.scrollTop() + $window.height() > $document.height() - 100) {
|
||||||
|
loadMoreItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
}, _throttleDelay);
|
||||||
|
}
|
||||||
|
|
||||||
function setupListeners() {
|
function setupListeners() {
|
||||||
if ($(loaderResponseId).length === 1) {
|
if ($(loaderResponseId).length === 1) {
|
||||||
/*
|
/*
|
||||||
@ -73,21 +87,7 @@ function setupListeners() {
|
|||||||
if (!isLoaderLoading) {
|
if (!isLoaderLoading) {
|
||||||
loadMoreItems();
|
loadMoreItems();
|
||||||
}
|
}
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
function ScrollHandler(e) {
|
|
||||||
//throttle event:
|
|
||||||
hasScrollBar = true;
|
|
||||||
clearTimeout(_throttleTimer);
|
|
||||||
_throttleTimer = setTimeout(function () {
|
|
||||||
|
|
||||||
//do work
|
|
||||||
if ($window.scrollTop() + $window.height() > $document.height() - 100) {
|
|
||||||
loadMoreItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
}, _throttleDelay);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,21 @@
|
|||||||
let offset = 15;
|
let offset = 15;
|
||||||
let isLoading = false;
|
let isLoading = false;
|
||||||
|
|
||||||
|
|
||||||
|
function ScrollHandler(e) {
|
||||||
|
//throttle event:
|
||||||
|
hasScrollBar = true;
|
||||||
|
clearTimeout(_throttleTimer);
|
||||||
|
_throttleTimer = setTimeout(function () {
|
||||||
|
|
||||||
|
//do work
|
||||||
|
if ($window.scrollTop() + $window.height() > $document.height() - 100) {
|
||||||
|
loadMorePenalties();
|
||||||
|
}
|
||||||
|
|
||||||
|
}, _throttleDelay);
|
||||||
|
}
|
||||||
|
|
||||||
function loadMorePenalties() {
|
function loadMorePenalties() {
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return false;
|
return false;
|
||||||
@ -34,7 +49,7 @@ if ($('#penalty_table').length === 1) {
|
|||||||
https://stackoverflow.com/questions/19731730/jquery-js-detect-users-scroll-attempt-without-any-window-overflow-to-scroll
|
https://stackoverflow.com/questions/19731730/jquery-js-detect-users-scroll-attempt-without-any-window-overflow-to-scroll
|
||||||
*/
|
*/
|
||||||
$('html').bind('mousewheel DOMMouseScroll', function (e) {
|
$('html').bind('mousewheel DOMMouseScroll', function (e) {
|
||||||
var delta = (e.originalEvent.wheelDelta || -e.originalEvent.detail);
|
var delta = e.originalEvent.wheelDelta || -e.originalEvent.detail;
|
||||||
|
|
||||||
if (delta < 0 && !hasScrollBar) {
|
if (delta < 0 && !hasScrollBar) {
|
||||||
loadMorePenalties();
|
loadMorePenalties();
|
||||||
@ -59,18 +74,4 @@ if ($('#penalty_table').length === 1) {
|
|||||||
loadMorePenalties();
|
loadMorePenalties();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function ScrollHandler(e) {
|
|
||||||
//throttle event:
|
|
||||||
hasScrollBar = true;
|
|
||||||
clearTimeout(_throttleTimer);
|
|
||||||
_throttleTimer = setTimeout(function () {
|
|
||||||
|
|
||||||
//do work
|
|
||||||
if ($window.scrollTop() + $window.height() > $document.height() - 100) {
|
|
||||||
loadMorePenalties();
|
|
||||||
}
|
|
||||||
|
|
||||||
}, _throttleDelay);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -42,7 +42,7 @@
|
|||||||
showLoader();
|
showLoader();
|
||||||
const location = $(this).parent();
|
const location = $(this).parent();
|
||||||
$.get('/Stats/GetAutomatedPenaltyInfoAsync', {
|
$.get('/Stats/GetAutomatedPenaltyInfoAsync', {
|
||||||
'clientId': $(this).data('clientid'),
|
'clientId': $(this).data('clientid')
|
||||||
})
|
})
|
||||||
.done(function (response) {
|
.done(function (response) {
|
||||||
$('.penalty-info-context').remove();
|
$('.penalty-info-context').remove();
|
||||||
|
@ -55,7 +55,7 @@ $('.server-history-row').each(function (index, element) {
|
|||||||
let clientHistory = $(this).data('clienthistory');
|
let clientHistory = $(this).data('clienthistory');
|
||||||
let serverId = $(this).data('serverid');
|
let serverId = $(this).data('serverid');
|
||||||
let maxClients = parseInt($('#server_header_' + serverId + ' .server-maxclients').text());
|
let maxClients = parseInt($('#server_header_' + serverId + ' .server-maxclients').text());
|
||||||
let color = $(this).data('online') === 'True' ? 'rgba(0, 122, 204, 0.432)' : '#ff6060'
|
let color = $(this).data('online') === 'True' ? 'rgba(0, 122, 204, 0.432)' : '#ff6060';
|
||||||
let width = $('.server-header').first().width();
|
let width = $('.server-header').first().width();
|
||||||
let historyChart = getPlayerHistoryChart(clientHistory, serverId, width, color, maxClients);
|
let historyChart = getPlayerHistoryChart(clientHistory, serverId, width, color, maxClients);
|
||||||
historyChart.render();
|
historyChart.render();
|
||||||
@ -93,6 +93,6 @@ $(document).ready(function() {
|
|||||||
$('.server-join-button').click(function (e) {
|
$('.server-join-button').click(function (e) {
|
||||||
$(this).children('.server-header-ip-address').show();
|
$(this).children('.server-header-ip-address').show();
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
setInterval(refreshClientActivity, 2000);
|
setInterval(refreshClientActivity, 2000);
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
lineThickness: 0,
|
lineThickness: 0,
|
||||||
tickThickness: 0,
|
tickThickness: 0,
|
||||||
margin: 0,
|
margin: 0,
|
||||||
valueFormatString: ' ',
|
valueFormatString: ' '
|
||||||
},
|
},
|
||||||
axisY: {
|
axisY: {
|
||||||
labelFontSize: 12,
|
labelFontSize: 12,
|
||||||
|
Loading…
Reference in New Issue
Block a user