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

Added additional properties method to allow easier extension to client properties

updated VPN plugin to use WebClient
message is sent to client trying to execute commands before they are authenticated
fixed rare issue with ToAdmins failing
record bullet distance fraction for client kills (_customcallbacks)
change client level/permissions through webfront
ability to tempban through webfront
This commit is contained in:
RaidMax
2018-09-02 16:59:27 -05:00
parent 50b4426cab
commit bc0fe3daec
33 changed files with 1099 additions and 177 deletions

View File

@ -5,6 +5,7 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using SharedLibraryCore;
using WebfrontCore.ViewModels;
using static SharedLibraryCore.Objects.Player;
namespace WebfrontCore.Controllers
{
@ -22,6 +23,20 @@ namespace WebfrontCore.Controllers
{
Name = "Reason",
Label = Localization["WEBFRONT_ACTION_LABEL_REASON"],
},
new InputInfo()
{
Name ="Duration",
Label=Localization["WEBFRONT_ACTION_LABEL_DURATION"],
Type="select",
Values = new Dictionary<string, string>()
{
{"1", $"1 {Localization["GLOBAL_TIME_HOUR"]}" },
{"2", $"6 {Localization["GLOBAL_TIME_HOURS"]}" },
{"3", $"1 {Localization["GLOBAL_TIME_DAY"]}" },
{"4", $"1 {Localization["GLOBAL_TIME_WEEK"]}" },
{"5", $"{Localization["WEBFRONT_ACTION_SELECTION_PERMANENT"]}" },
}
}
},
Action = "BanAsync"
@ -30,14 +45,36 @@ namespace WebfrontCore.Controllers
return View("_ActionForm", info);
}
public async Task<IActionResult> BanAsync(int targetId, string Reason)
public async Task<IActionResult> BanAsync(int targetId, string Reason, int Duration)
{
string duration = string.Empty;
switch (Duration)
{
case 1:
duration = "1h";
break;
case 2:
duration = "6h";
break;
case 3:
duration = "1d";
break;
case 4:
duration = "1w";
break;
}
string command = Duration == 5 ?
$"!ban @{targetId} {Reason}" :
$"!tempban @{targetId} {duration} {Reason}";
var server = Manager.GetServers().First();
return await Task.FromResult(RedirectToAction("ExecuteAsync", "Console", new
{
serverId = server.GetHashCode(),
command = $"!ban @{targetId} {Reason}"
command
}));
}
@ -102,5 +139,42 @@ namespace WebfrontCore.Controllers
{
return await Task.FromResult(RedirectToAction("LoginAsync", "Account", new { clientId, password }));
}
public IActionResult EditForm()
{
var info = new ActionInfo()
{
ActionButtonLabel = Localization["WEBFRONT_ACTION_LABEL_EDIT"],
Name = "Edit",
Inputs = new List<InputInfo>()
{
new InputInfo()
{
Name ="level",
Label=Localization["WEBFRONT_PROFILE_LEVEL"],
Type="select",
Values = Enum.GetValues(typeof(Permission)).OfType<Permission>()
.Where(p => p <= Client.Level)
.Where(p => p != Permission.Banned)
.Where(p => p != Permission.Flagged)
.ToDictionary(p => p.ToString(), p=> p.ToLocalizedLevelName())
},
},
Action = "EditAsync"
};
return View("_ActionForm", info);
}
public async Task<IActionResult> EditAsync(int targetId, string level)
{
var server = Manager.GetServers().First();
return await Task.FromResult(RedirectToAction("ExecuteAsync", "Console", new
{
serverId = server.GetHashCode(),
command = $"!setlevel @{targetId} {level}"
}));
}
}
}

View File

@ -7,6 +7,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using static SharedLibraryCore.Objects.Penalty;
namespace WebfrontCore.Controllers
{
@ -20,6 +21,8 @@ namespace WebfrontCore.Controllers
return NotFound();
}
var activePenalties = await Manager.GetPenaltyService().GetActivePenaltiesAsync(client.AliasLinkId, client.IPAddress);
#if DEBUG
Authorized = true;
#endif
@ -48,6 +51,7 @@ namespace WebfrontCore.Controllers
.Distinct()
.OrderBy(i => i)
.ToList(),
HasActivePenalty = activePenalties.Count > 0,
Online = Manager.GetActiveClients().FirstOrDefault(c => c.ClientId == client.ClientId) != null,
TimeOnline = (DateTime.UtcNow - client.LastConnection).TimeSpanText(),
LinkedAccounts = client.LinkedAccounts

View File

@ -12,5 +12,7 @@ namespace WebfrontCore.ViewModels
public string Placeholder { get; set; }
public string Type { get; set; }
public string Value { get; set; }
public Dictionary<string, string> Values { get; set; }
public bool Checked { get; set; }
}
}

View File

@ -5,19 +5,41 @@
<form class="action-form" action="/Action/@Model.Action">
@foreach (var input in Model.Inputs)
{
<div class="input-group mb-3">
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon-@input.Name">@input.Label</span>
</div>
@{
string inputType = input.Type ?? "text";
string value = input.Value ?? "";
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon-@input.Name">@input.Label</span>
</div>
@{
string inputType = input.Type ?? "text";
string value = input.Value ?? "";
<input type="@inputType" name="@input.Name" value="@value" class="form-control" placeholder="@input.Placeholder" aria-label="@input.Name" aria-describedby="basic-addon-@input.Name">
if (inputType == "select")
{
<select name="@input.Name" class="form-control" aria-label="@input.Name" aria-describedby="basic-addon-@input.Name">
@foreach (var item in input.Values)
{
<option value="@item.Key">@item.Value</option>
}
</select>
}
</div>
else if (inputType == "checkbox")
{
<div class="btn-group-toggle" data-toggle="buttons">
<label class="btn btn-primary active">
<input type="checkbox" name="@input.Name" @(input.Checked ? "checked" : "") autocomplete="off">@input.Label
</label>
</div>
}
else
{
<input type="@inputType" name="@input.Name" value="@value" class="form-control" placeholder="@input.Placeholder" aria-label="@input.Name" aria-describedby="basic-addon-@input.Name">
}
}
</div>
}
<button type="submit" class="btn btn-block btn-primary">@Model.ActionButtonLabel</button>
</form>

View File

@ -33,18 +33,20 @@
{
<div class="d-flex d-md-inline-flex justify-content-center order-1">
<div id="profile_aliases_btn" class="oi oi-caret-bottom h3 ml-0 ml-md-2"></div>
@if (Model.LevelInt < (int)ViewBag.User.Level &&
(SharedLibraryCore.Objects.Player.Permission)Model.LevelInt != SharedLibraryCore.Objects.Player.Permission.Banned)
@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>
}
@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>
}
@if (Model.LevelInt < (int)ViewBag.User.Level &&
(SharedLibraryCore.Objects.Player.Permission)Model.LevelInt == SharedLibraryCore.Objects.Player.Permission.Banned)
@if (Model.LevelInt < (int)ViewBag.User.Level && Model.HasActivePenalty)
{
<div id="profile_action_unban_btn" class="profile-action oi oi-lock-locked text-danger h3 ml-2" title="Unban Client" data-action="unban" aria-hidden="true"></div>
}
</div>
<div id="profile_aliases" class="pr-0 pr-sm-4 pb-2 mb-2 text-muted order-0">

View File

@ -6,6 +6,7 @@
@{
foreach (var response in Model)
{
<span class="text-success">@response.Response</span><br />
<span class="text-muted">@response.Response</span><br />
}
<hr />
}

View File

@ -6321,6 +6321,9 @@ a.link-inverse:hover {
#console_command_response {
min-height: 20rem; }
#console_command_response hr {
border-color: #6c757d; }
#console .form-control, #console button {
border-radius: 0;
border-color: #007ACC;
@ -6339,7 +6342,7 @@ a.link-inverse:hover {
form *, select {
border-radius: 0 !important; }
select {
#penalty_filter_selection {
border-left: none !important;
border-right: none !important;
border-bottom: none !important;

View File

@ -96,6 +96,10 @@ a.link-inverse:hover {
min-height: 20rem;
}
#console_command_response hr {
border-color: #6c757d;
}
#console .form-control, #console button {
border-radius: 0;
border-color: $primary;
@ -119,7 +123,7 @@ form *, select {
border-radius: 0 !important;
}
select {
#penalty_filter_selection {
border-left: none !important;
border-right: none !important;
border-bottom: none !important;
@ -205,4 +209,3 @@ select {
.client-message, .automated-penalty-info-detailed {
cursor: pointer;
}

View File

@ -24,7 +24,7 @@ $(document).ready(function () {
* hide loader when clicking
*/
$(document).click(function (e) {
hideLoader()
//hideLoader()
});
/*
@ -39,7 +39,7 @@ $(document).ready(function () {
$('#actionModal').modal();
})
.fail(function (jqxhr, textStatus, error) {
$('#actionModal .modal-message').text('Error &mdash ' + error);
$('#actionModal .modal-message').text('Error ' + error);
$('#actionModal').modal();
$('#actionModal .modal-message').fadeIn('fast');
});

View File

@ -14,7 +14,7 @@
$.get('/Console/ExecuteAsync', { serverId: serverId, command: command })
.done(function (response) {
hideLoader();
$('#console_command_response').html(response);
$('#console_command_response').append(response);
$('#console_command_value').val("");
})
.fail(function (jqxhr, textStatus, error) {