fixed !setlevel

fixed previous alias displayed on welcome announcement
fixed duplicate events on profile page
tweaked display of non event meta on mobile
you can view other's stats from the webconsole
penalties show privileged client's level
don't have commands to chat history
This commit is contained in:
RaidMax 2018-02-23 23:56:03 -06:00
parent 9ee39b5260
commit 442569b339
15 changed files with 92 additions and 53 deletions

View File

@ -70,12 +70,16 @@ namespace IW4MAdmin
if (!aliasExists)
{
Logger.WriteDebug($"Client {polledPlayer} has connected previously under a different alias");
Logger.WriteDebug($"Client {polledPlayer} has connected previously under a different ip/name");
client.CurrentAlias = new SharedLibrary.Database.Models.EFAlias()
{
IPAddress = polledPlayer.IPAddress,
Name = polledPlayer.Name,
};
// we need to update their new ip and name to the virtual property
client.Name = polledPlayer.Name;
client.IPAddress = polledPlayer.IPAddress;
await Manager.GetClientService().Update(client);
}
player = client.AsPlayer();

View File

@ -24,8 +24,13 @@ namespace StatsPlugin.Commands
public override async Task ExecuteAsync(Event E)
{
if (E.Target?.ClientNumber < 0)
{
await E.Origin.Tell("The specified player must be ingame");
return;
}
if (E.Origin.ClientNumber < 0)
if (E.Origin.ClientNumber < 0 && E.Target == null)
{
await E.Origin.Tell("You must be ingame to view your stats");
return;
@ -45,7 +50,7 @@ namespace StatsPlugin.Commands
if (E.Target != null)
{
pStats = clientStats.Find(c => c.ServerId ==serverId && c.ClientId == E.Target.ClientId).First();
pStats = clientStats.Find(c => c.ServerId == serverId && c.ClientId == E.Target.ClientId).First();
statLine = String.Format("^5{0} ^7KILLS | ^5{1} ^7DEATHS | ^5{2} ^7KDR | ^5{3} ^7SKILL", pStats.Kills, pStats.Deaths, pStats.KDR, pStats.Skill);
}

View File

@ -41,7 +41,7 @@ namespace StatsPlugin
await Manager.RemovePlayer(E.Origin);
break;
case Event.GType.Say:
if (E.Data != string.Empty && E.Data.Trim().Length > 0)
if (E.Data != string.Empty && E.Data.Trim().Length > 0 && E.Data[0] != '!')
await Manager.AddMessageAsync(E.Origin.ClientId, E.Owner.GetHashCode(), E.Data);
break;
case Event.GType.MapChange:

View File

@ -429,15 +429,22 @@ namespace SharedLibrary.Commands
if (newPerm > Player.Permission.Banned)
{
var ActiveClient = E.Owner.Manager.GetActiveClients().FirstOrDefault(p => p.NetworkId == E.Target.NetworkId);
ActiveClient.Level = newPerm;
if (ActiveClient != null)
{
ActiveClient.Level = newPerm;
await ActiveClient.Tell("Congratulations! You have been promoted to ^3" + newPerm);
}
else
{
E.Target.Level = newPerm;
await E.Owner.Manager.GetClientService().Update(E.Target);
}
await E.Origin.Tell($"{E.Target.Name} was successfully promoted!");
E.Target.Level = newPerm;
await E.Owner.Manager.GetClientService().Update(E.Target);
}
else

View File

@ -12,6 +12,7 @@ namespace SharedLibrary.Dtos
public int OffenderId { get; set; }
public string PunisherName { get; set; }
public int PunisherId { get; set; }
public string PunisherLevel { get; set; }
public string Offense { get; set; }
public string Type { get; set; }
public string TimePunished { get; set; }

View File

@ -44,6 +44,8 @@ namespace WebfrontCore.Controllers
clientDto.Meta.AddRange(await IW4MAdmin.ApplicationManager.GetInstance().GetPenaltyService().ReadGetClientPenaltiesAsync(client.ClientId, false));
clientDto.Meta = clientDto.Meta.OrderByDescending(m => m.When).ToList();
ViewBag.Title = clientDto.Name;
return View("Profile/Index", clientDto);
}

View File

@ -28,6 +28,7 @@ namespace WebfrontCore.Controllers
var requestIPAddress = Request.HttpContext.Connection.RemoteIpAddress;
var intIP = requestIPAddress.ToString().ConvertToIP();
#if !DEBUG
var origin = (await IW4MAdmin.ApplicationManager.GetInstance().GetClientService().GetClientByIP(intIP))
.OrderByDescending(c => c.Level)
.FirstOrDefault()?.AsPlayer() ?? new Player()
@ -36,6 +37,9 @@ namespace WebfrontCore.Controllers
Level = Player.Permission.User,
IPAddress = intIP
};
#else
var origin = (await IW4MAdmin.ApplicationManager.GetInstance().GetClientService().GetUnique(0)).AsPlayer();
#endif
var server = IW4MAdmin.ApplicationManager.GetInstance().Servers.First(s => s.GetHashCode() == serverId);
origin.CurrentServer = server;

View File

@ -19,7 +19,7 @@ namespace WebfrontCore
#if !DEBUG
.UseUrls("http://server.nbsclan.org:8080")
#else
.UseUrls("http://192.168.88.254:5000")
.UseUrls("http://127.0.0.1:5000;http://192.168.88.254:5000")
#endif
.Build();

View File

@ -19,6 +19,7 @@ namespace WebfrontCore.ViewComponents
OffenderName = p.Offender.Name,
PunisherId = p.PunisherId,
PunisherName = p.Punisher.Name,
PunisherLevel = p.Punisher.Level.ToString(),
Offense = p.Offense,
Type = p.Type.ToString(),
TimePunished = Utilities.GetTimePassed(p.When, false),

View File

@ -8,7 +8,7 @@
</div>
<div id="profile_info" class="text-center text-sm-left pr-3 pl-3">
<div id="profile_name">
<h1><span class="client-name">@Model.Name<span id="profile_aliases_btn" class="oi oi-caret-bottom pl-2"></span></span></h1>
<h1><span class="client-name mr-4">@Model.Name<span id="profile_aliases_btn" class="oi oi-caret-bottom pl-2"></span></span></h1>
<div id="profile_aliases" class="pr-0 pr-sm-4 pb-2 mb-2 text-muted">
@{
foreach (string alias in Model.Aliases)
@ -31,10 +31,11 @@
Last seen <span class="text-primary">@Model.LastSeen</span> ago
</div>
</div>
<div id="profile_meta" class="text-center text-sm-right pt-2 mt-md-4 pt-md-3">
<div id="profile_meta" class="text-center text-sm-right pt-2 mt-md-4 pt-md-3 mr-4 pr-4 mr-md-0 ml-4 pl-4 ml-md-0 pr-md-0 pl-md-0">
</div>
</div>
<div class="row d-md-flex pt-2">
<div id="profile_events" class="text-muted text-left ml-sm-0">
@{

View File

@ -28,7 +28,7 @@
<tr class="d-table-row d-md-none bg-dark">
<th scope="row" class="bg-primary">Admin</th>
<td>
@Html.ActionLink(Model.PunisherName, "ProfileAsync", "Client", new { id = Model.PunisherId }, new { @class = "link-inverse" })
@Html.ActionLink(Model.PunisherName, "ProfileAsync", "Client", new { id = Model.PunisherId }, new { @class = "level-color-" + Model.PunisherLevel.ToLower() })
</td>
</tr>
@ -60,7 +60,7 @@
@Model.Offense
</td>
<td>
@Html.ActionLink(Model.PunisherName, "ProfileAsync", "Client", new { id = Model.PunisherId }, new { @class = "link-inverse" })
@Html.ActionLink(Model.PunisherName, "ProfileAsync", "Client", new { id = Model.PunisherId }, new { @class = "level-color-" + Model.PunisherLevel.ToLower() })
</td>
<td class="text-right text-light">
@{

View File

@ -1,4 +1,7 @@

.level-bgcolor-console {
background-color: grey;
}
.level-color-user, .level-color-guest {
color: rgba(255, 255, 255, 0.85);
}
@ -23,7 +26,7 @@
background-color: rgba(253, 139, 22, 0.85);
}
.level-color-banned {
.level-color-banned, .level-color-console {
color: rgba(255, 69, 69, 0.85);
}

View File

@ -1,6 +1,16 @@
function executeCommand() {
const serverId = $('#console_server_select').val();
const command = $('#console_command_value').val();
if (command.length === 0) {
return false;
}
if (command[0] !== '!') {
$('#console_command_response').text('All commands must start with !').addClass('text-danger');
return false;
}
$.get('/Console/ExecuteAsync', { serverId: serverId, command: command })
.done(function (response) {
$('#console_command_response').html(response);

View File

@ -1,4 +1,7 @@
$(document).ready(function () {
// keeps track of how many events have been displayed
let count = 1;
$(document).ready(function () {
/*
Expand alias tab if they have any
*/
@ -9,14 +12,43 @@
}
});
/*
load the initial 40 events
*/
$.each(clientInfo.Meta, function (index, meta) {
loadMeta(meta);
if (count % 40 === 0) {
count++;
return false;
if (meta.key.includes("Event")) {
loadMeta(meta);
if (count % 40 === 0) {
count++;
return false;
}
count++
}
count++
});
/*
load additional events on scroll
*/
$(window).scroll(function () {
if ($(window).scrollTop() === $(document).height() - $(window).height() || $(document).height() === $(window).height()) {
while (count % 40 !== 0 && count < clientInfo.Meta.length) {
loadMeta(clientInfo.Meta[count - 1]);
count++;
}
count++;
}
});
/*
load meta thats not an event
*/
$.each(clientInfo.Meta, function (index, meta) {
if (!meta.key.includes("Event")) {
let metaString = `<div class="profile-meta-entry"><span class="profile-meta-value text-primary">${meta.value}</span><span class="profile-meta-title text-muted"> ${meta.key}</span></div>`;
$("#profile_meta").append(metaString);
}
});
});
function penaltyToName(penaltyName) {
@ -55,34 +87,3 @@ function loadMeta(meta) {
}
$('#profile_events').append(eventString);
}
let count = 1;
$(document).ready(function () {
$(window).scroll(function () {
if ($(window).scrollTop() === $(document).height() - $(window).height() || $(document).height() === $(window).height()) {
while (count % 40 !== 0 && count < clientInfo.Meta.length) {
loadMeta(clientInfo.Meta[count - 1]);
count++;
}
count++;
}
});
$.each(clientInfo.Meta, function (index, meta) {
if (!meta.key.includes("Event")) {
let metaString = `<div class="profile-meta-entry"><span class="profile-meta-value text-primary">${meta.value}</span><span class="profile-meta-title text-muted"> ${meta.key}</span></div>`;
$("#profile_meta").append(metaString);
}
});
$.each(clientInfo.Meta, function (index, meta) {
loadMeta(meta);
if (count % 40 === 0) {
count++;
return false;
}
count++;
});
});