Add flag icon on client profile

This commit is contained in:
RaidMax 2019-08-04 17:06:07 -05:00
parent bb42861a92
commit 75378400e7
14 changed files with 143 additions and 30 deletions

View File

@ -8,7 +8,14 @@
<div class="bg-dark p-3 mb-2 border-bottom">
@foreach (var message in Model)
{
<span class="text-white">@message.Name</span><span> &mdash; <span class="@(message.IsQuickMessage ? "font-italic" : "")">@message.Message</span></span><br />
<span class="text-white">@message.Name</span>
<span>
&mdash;
<span class="@(message.IsQuickMessage ? "font-italic" : "")">
<color-code value="@message.Message" allow="ViewBag.EnableColorCodes"></color-code>
</span>
</span>
<br />
}
</div>
</div>

View File

@ -581,7 +581,7 @@ namespace SharedLibraryCore.Services
ClientId = _client.ClientId,
Name = _client.CurrentAlias.Name,
IPAddress = _client.CurrentAlias.IPAddress.ConvertIPtoString(),
LastConnection = _client.LastConnection
LastConnection = _client.FirstConnection
})
.OrderByDescending(_client => _client.ClientId)
.Take(10);

View File

@ -154,7 +154,7 @@ namespace SharedLibraryCore
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static string FixIW4ForwardSlash(this string str) => Regex.Match(str, @"(^\/+.*$)|(^.*\/+$)").Value.Replace("/", " /");
public static string FixIW4ForwardSlash(this string str) => str.Replace("/", " /");
/// <summary>
/// Get the IW Engine color code corresponding to an admin level

View File

@ -41,7 +41,8 @@ namespace WebfrontCore.Controllers
}
}
},
Action = "BanAsync"
Action = "BanAsync",
ShouldRefresh = true
};
return View("_ActionForm", info);
@ -99,7 +100,8 @@ namespace WebfrontCore.Controllers
Label = Localization["WEBFRONT_ACTION_LABEL_REASON"],
}
},
Action = "UnbanAsync"
Action = "UnbanAsync",
ShouldRefresh = true
};
return View("_ActionForm", info);
@ -167,7 +169,8 @@ namespace WebfrontCore.Controllers
.ToDictionary(p => p.ToString(), p=> p.ToLocalizedLevelName())
},
},
Action = "EditAsync"
Action = "EditAsync",
ShouldRefresh = true
};
return View("_ActionForm", info);
@ -247,5 +250,69 @@ namespace WebfrontCore.Controllers
var clients = await Manager.GetClientService().GetRecentClients();
return View("~/Views/Shared/Components/Client/_RecentClients.cshtml", clients);
}
public IActionResult FlagForm()
{
var info = new ActionInfo()
{
ActionButtonLabel = Localization["WEBFRONT_ACTION_FLAG_NAME"],
Name = "Flag",
Inputs = new List<InputInfo>()
{
new InputInfo()
{
Name = "reason",
Label = Localization["WEBFRONT_ACTION_LABEL_REASON"],
}
},
Action = "FlagAsync",
ShouldRefresh = true
};
return View("_ActionForm", info);
}
public async Task<IActionResult> FlagAsync(int targetId, string reason)
{
var server = Manager.GetServers().First();
return await Task.FromResult(RedirectToAction("ExecuteAsync", "Console", new
{
serverId = server.EndPoint,
command = $"!flag @{targetId} {reason}"
}));
}
public IActionResult UnflagForm()
{
var info = new ActionInfo()
{
ActionButtonLabel = Localization["WEBFRONT_ACTION_UNFLAG_NAME"],
Name = "Unflag",
Inputs = new List<InputInfo>()
{
new InputInfo()
{
Name = "reason",
Label = Localization["WEBFRONT_ACTION_LABEL_REASON"],
}
},
Action = "UnflagAsync",
ShouldRefresh = true
};
return View("_ActionForm", info);
}
public async Task<IActionResult> UnflagAsync(int targetId, string reason)
{
var server = Manager.GetServers().First();
return await Task.FromResult(RedirectToAction("ExecuteAsync", "Console", new
{
serverId = server.EndPoint,
command = $"!unflag @{targetId} {reason}"
}));
}
}
}

View File

@ -11,5 +11,6 @@ namespace WebfrontCore.ViewModels
public List<InputInfo> Inputs { get; set; }
public string ActionButtonLabel { get; set; }
public string Action { get; set; }
public bool ShouldRefresh { get; set; }
}
}

View File

@ -2,7 +2,7 @@
@{
Layout = null;
}
<form class="action-form" action="/Action/@Model.Action">
<form class="action-form @(Model.ShouldRefresh ? "refreshable" : "")" action="/Action/@Model.Action">
@foreach (var input in Model.Inputs)
{
string inputType = input.Type ?? "text";

View File

@ -5,6 +5,7 @@
var loc = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex;
string gravatarUrl = Model.Meta.FirstOrDefault(m => m.Key == "GravatarEmail")?.Value;
bool isTempBanned = Model.ActivePenaltyType == "TempBan";
bool isFlagged = Model.LevelInt == (int)SharedLibraryCore.Database.Models.EFClient.Permission.Flagged;
var informationMeta = Model.Meta
.Where(_meta => _meta.Type == SharedLibraryCore.Dtos.ProfileMeta.MetaType.Information)
.OrderBy(_meta => _meta.Order)
@ -56,6 +57,8 @@
@if (ViewBag.Authorized)
{
<div class="pr-lg-0 text-center text-lg-right">
<div class="profile-action oi oi-flag h3 ml-2 @(isFlagged ? "text-secondary" : "text-success")" data-action="@(isFlagged ? "unflag" : "flag")" aria-hidden="true"></div>
@if (Model.LevelInt < (int)ViewBag.User.Level && !Model.HasActivePenalty)
{
<div id="profile_action_ban_btn" class="profile-action oi oi-lock-unlocked text-success h3 ml-2" title="Ban Client" data-action="ban" aria-hidden="true"></div>
@ -74,6 +77,7 @@
}
}
@if (Model.LevelInt != -1)
{
<div id="profile_action_edit_btn" class="profile-action oi oi-cog text-muted h3 ml-2" title="Client Options" data-action="edit" aria-hidden="true"></div>

View File

@ -17,15 +17,27 @@
if (Model.ChatHistory[i].Message == "CONNECTED")
{
<span class="text-light"><span class="oi oi-account-login mr-2 text-success"> </span>@Model.ChatHistory[i].Name</span><br />
<span class="text-light">
<span class="oi oi-account-login mr-2 text-success"> </span>
<color-code value="@Model.ChatHistory[i].Name" allow="@ViewBag.EnableColorCodes"></color-code>
</span><br />
}
if (Model.ChatHistory[i].Message == "DISCONNECTED")
{
<span class="text-light"><span class="oi oi-account-logout mr-2 text-danger"> </span>@Model.ChatHistory[i].Name</span><br />
<span class="text-light">
<span class="oi oi-account-logout mr-2 text-danger"> </span>
<color-code value="@Model.ChatHistory[i].Name" allow="@ViewBag.EnableColorCodes"></color-code>
</span><br />
}
if (Model.ChatHistory[i].Message != "CONNECTED" && Model.ChatHistory[i].Message != "DISCONNECTED")
{
<span class="text-light">@Model.ChatHistory[i].Name</span><span> &mdash; @Model.ChatHistory[i].Message.Substring(0, Math.Min(65, Model.ChatHistory[i].Message.Length)) </span><br />
<span class="text-light">
<color-code value="@Model.ChatHistory[i].Name" allow="@ViewBag.EnableColorCodes"></color-code>
</span>
<span>
&mdash;
<color-code value="@Model.ChatHistory[i].Message.Substring(0, Math.Min(40, Model.ChatHistory[i].Message.Length))" allow="@ViewBag.EnableColorCodes"></color-code>
</span><br />
}
}
}
@ -83,12 +95,17 @@
if (Model.ChatHistory[i].Message == "CONNECTED")
{
<span class="text-light"><span class="oi oi-account-login mr-2 text-success"> </span>@Model.ChatHistory[i].Name</span><br />
<span class="text-light">
<span class="oi oi-account-login mr-2 text-success"> </span>
<color-code value="@Model.ChatHistory[i].Name" allow="@ViewBag.EnableColorCodes"></color-code>
</span><br />
}
if (Model.ChatHistory[i].Message == "DISCONNECTED")
{
<span class="text-light"><span class="oi oi-account-logout mr-2 text-danger"> </span>@Model.ChatHistory[i].Name</span><br />
<span class="text-light">
<span class="oi oi-account-logout mr-2 text-danger"> </span>
<color-code value="@Model.ChatHistory[i].Name" allow="@ViewBag.EnableColorCodes"></color-code>
</span><br />
}
if (Model.ChatHistory[i].Message != "CONNECTED" && Model.ChatHistory[i].Message != "DISCONNECTED")
{

View File

@ -302,7 +302,7 @@ form *, select {
}
.text-color-code-58 {
animation: color-change 60s infinite;
animation: color-change 54s infinite;
}
@keyframes color-change {

View File

@ -42,6 +42,7 @@ $(document).ready(function () {
$('#actionModal').trigger('action_form_received', actionType);
})
.fail(function (jqxhr, textStatus, error) {
$('#actionModal .modal-body-content').html('');
$('#actionModal .modal-message').text('Error — ' + error);
$('#actionModal').modal();
$('#actionModal .modal-message').fadeIn('fast');
@ -54,6 +55,7 @@ $(document).ready(function () {
$(document).on('submit', '.action-form', function (e) {
e.preventDefault();
$(this).append($('#target_id input'));
$('#actionModal').data('should-refresh', $('#actionModal').find('.refreshable').length !== 0);
const data = $(this).serialize();
showLoader();
$.get($(this).attr('action') + '/?' + data)
@ -102,4 +104,15 @@ $(document).ready(function () {
});
}
});
/*
* handle close event to refresh if need be
*/
$("#actionModal").on("hidden.bs.modal", function () {
let shouldRefresh = $(this).data('should-refresh');
if (shouldRefresh !== undefined && shouldRefresh) {
location.reload();
}
});
});

View File

@ -41,9 +41,19 @@ function loadMoreItems() {
loaderOffset += loadCount;
}
var hasScrollBar = false;
function _ScrollHandler(e) {
//throttle event:
/*
https://stackoverflow.com/questions/3898130/check-if-a-user-has-scrolled-to-the-bottom
*/
var $window = $(window);
var $document = $(document);
hasScrollBar = true;
let _throttleTimer = null;
let _throttleDelay = 100;
clearTimeout(_throttleTimer);
_throttleTimer = setTimeout(function () {
@ -69,18 +79,10 @@ function setupListeners() {
}
});
/*
https://stackoverflow.com/questions/3898130/check-if-a-user-has-scrolled-to-the-bottom
*/
var _throttleTimer = null;
var _throttleDelay = 100;
var $window = $(window);
var $document = $(document);
var hasScrollBar = false;
$document.ready(function () {
$window
$(document).ready(function () {
$(window)
.off('scroll', _ScrollHandler)
.on('scroll', _ScrollHandler);
$('.loader-load-more:not(.disabled)').click(function (e) {

View File

@ -80,7 +80,7 @@ function refreshClientActivity() {
cache: false
})
.done(function (response) {
const clientCount = $(response).find('.col-6 span').length;
const clientCount = $(response).find('a').length;
$('#server_header_' + serverId + ' .server-clientcount').text(clientCount);
$('#server_clientactivity_' + serverId).html(response);
})

View File

@ -20,7 +20,7 @@
if (interval < 1)
interval = 1;
let primaryColor = window.getComputedStyle(document.body).getPropertyValue('--primary').trim();
//let primaryColor = $('.nav-tabs .nav-link.active').first().css('background-color')
return new CanvasJS.Chart(id, {
backgroundColor: 'transparent',
@ -56,10 +56,11 @@
dockInsidePlotArea: true
},
data: [{
type: 'splineArea',
color: primaryColor.endsWith('80') ? primaryColor : primaryColor + '40',
markerSize: 3.5,
dataPoints: fixedData
type: 'spline',
color: '#c0c0c0',
markerSize: 0,
dataPoints: fixedData,
lineThickness: 2
}]
});
}

View File

@ -4,6 +4,7 @@ Version 2.4:
-added recently connected players dropdown option on webfront
-added "dashboard" to home view with quick stats
-added ability to customize accent color and branding on webfront
-added flag button to client profile
-hid flagged status of users on webfront unless logged in
Version 2.3: