move all the deployment setup into 2.4 pr (#85)
* don't run build commands in release
* fix test file
* Set up CI with Azure Pipelines
[skip ci]
* Include fonts and fix automessage hidden command
* more project changes
* migration from bower to libman
* more lib man changes
* project update for sneaky commands
* add missing canvas.js dep
update projects not to have stupid extra dlls
include in previous
* update pipeline file
* update post publish script and pipeline definition
* fix broken yaml
* move encoding conversion to seperate script
* remove extra uneeded rank icons
remove garbage language files being created
remove frontend lib when done
* fix publish script path
* grab localizations through powershell
* fix broken batch 🤷
* actually fixed
* only include runtime compilation in debug mode for webfront
* don't deploy un minified css
use full jquery version
* add step to download the scss for open iconic
change the font path
* update mkdir for iconic path
* don't include old iconic css
* correct font path for real now
* copy script plugins
* lots of changes for deployment
* build the projects
* use projectdir instead of solution dir
* nerf script commands plugin
fix live radar left over command
* actually kill script command post build
* Update azure-pipelines.yml for Azure Pipelines
* Update azure-pipelines.yml for Azure Pipelines
* fix the font file copy (I think)
* maybe fix delete folder issue
* Update azure-pipelines.yml for Azure Pipelines
* Update azure-pipelines.yml for Azure Pipelines
* Update azure-pipelines.yml for Azure Pipelines
* Update azure-pipelines.yml for Azure Pipelines
* Update azure-pipelines.yml for Azure Pipelines
* Update azure-pipelines.yml for Azure Pipelines
152
Plugins/Web/StatsWeb/Controllers/StatsController.cs
Normal file
@ -0,0 +1,152 @@
|
||||
using IW4MAdmin.Plugins.Stats;
|
||||
using IW4MAdmin.Plugins.Stats.Helpers;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SharedLibraryCore;
|
||||
using SharedLibraryCore.Dtos;
|
||||
using SharedLibraryCore.Interfaces;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IW4MAdmin.Plugins.Web.StatsWeb.Controllers
|
||||
{
|
||||
public class StatsController : BaseController
|
||||
{
|
||||
private readonly IManager _manager;
|
||||
|
||||
public StatsController(IManager manager) : base(manager)
|
||||
{
|
||||
_manager = manager;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult TopPlayersAsync()
|
||||
{
|
||||
ViewBag.Title = Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_STATS_INDEX_TITLE"];
|
||||
ViewBag.Description = Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_STATS_INDEX_DESC"];
|
||||
ViewBag.Servers = _manager.GetServers().Select(_server => new ServerInfo() { Name = _server.Hostname, ID = _server.EndPoint });
|
||||
|
||||
return View("Index");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetTopPlayersAsync(int count, int offset, long? serverId = null)
|
||||
{
|
||||
// this prevents empty results when we really want aggregate
|
||||
if (serverId == 0)
|
||||
{
|
||||
serverId = null;
|
||||
}
|
||||
|
||||
var server = _manager.GetServers().FirstOrDefault(_server => _server.EndPoint == serverId);
|
||||
|
||||
if (server != null)
|
||||
{
|
||||
serverId = StatManager.GetIdForServer(server);
|
||||
}
|
||||
|
||||
var results = await Plugin.Manager.GetTopStats(offset, count, serverId);
|
||||
|
||||
// this returns an empty result so we know to stale the loader
|
||||
if (results.Count == 0 && offset > 0)
|
||||
{
|
||||
return Ok();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
return View("Components/TopPlayers/_List", results);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetMessageAsync(int serverId, long when)
|
||||
{
|
||||
var whenTime = DateTime.FromFileTimeUtc(when);
|
||||
var whenUpper = whenTime.AddMinutes(5);
|
||||
var whenLower = whenTime.AddMinutes(-5);
|
||||
|
||||
using (var ctx = new SharedLibraryCore.Database.DatabaseContext(true))
|
||||
{
|
||||
var iqMessages = from message in ctx.Set<Stats.Models.EFClientMessage>()
|
||||
where message.ServerId == serverId
|
||||
where message.TimeSent >= whenLower
|
||||
where message.TimeSent <= whenUpper
|
||||
select new ChatInfo()
|
||||
{
|
||||
ClientId = message.ClientId,
|
||||
Message = message.Message,
|
||||
Name = message.Client.CurrentAlias.Name,
|
||||
Time = message.TimeSent,
|
||||
ServerGame = message.Server.GameName ?? Server.Game.IW4
|
||||
};
|
||||
|
||||
var messages = await iqMessages.ToListAsync();
|
||||
|
||||
foreach (var message in messages)
|
||||
{
|
||||
if (message.Message.IsQuickMessage())
|
||||
{
|
||||
try
|
||||
{
|
||||
var quickMessages = _manager.GetApplicationSettings().Configuration()
|
||||
.QuickMessages
|
||||
.First(_qm => _qm.Game == message.ServerGame);
|
||||
message.Message = quickMessages.Messages[message.Message.Substring(1)];
|
||||
message.IsQuickMessage = true;
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
|
||||
return View("_MessageContext", messages);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Authorize]
|
||||
public async Task<IActionResult> GetAutomatedPenaltyInfoAsync(int penaltyId)
|
||||
{
|
||||
using (var ctx = new SharedLibraryCore.Database.DatabaseContext(true))
|
||||
{
|
||||
var penalty = await ctx.Penalties
|
||||
.Select(_penalty => new { _penalty.OffenderId, _penalty.PenaltyId, _penalty.When, _penalty.AutomatedOffense })
|
||||
.FirstOrDefaultAsync(_penalty => _penalty.PenaltyId == penaltyId);
|
||||
|
||||
var iqSnapshotInfo = ctx.Set<Stats.Models.EFACSnapshot>()
|
||||
.Where(s => s.ClientId == penalty.OffenderId)
|
||||
.Include(s => s.LastStrainAngle)
|
||||
.Include(s => s.HitOrigin)
|
||||
.Include(s => s.HitDestination)
|
||||
.Include(s => s.CurrentViewAngle)
|
||||
.Include(s => s.PredictedViewAngles)
|
||||
.ThenInclude(_angles => _angles.Vector)
|
||||
.OrderBy(s => s.When)
|
||||
.ThenBy(s => s.Hits);
|
||||
|
||||
var penaltyInfo = await iqSnapshotInfo.ToListAsync();
|
||||
|
||||
if (penaltyInfo.Count > 0)
|
||||
{
|
||||
return View("_PenaltyInfo", penaltyInfo);
|
||||
}
|
||||
|
||||
// we want to show anything related to the automated offense
|
||||
else
|
||||
{
|
||||
return View("_MessageContext", new[]
|
||||
{
|
||||
new ChatInfo()
|
||||
{
|
||||
ClientId = penalty.OffenderId,
|
||||
Message = penalty.AutomatedOffense,
|
||||
Time = penalty.When
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,12 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<RazorCompileOnBuild Condition="'$(CONFIG)'!='Debug'">true</RazorCompileOnBuild>
|
||||
<RazorCompiledOnPublish Condition="'$(CONFIG)'!='Debug'">true</RazorCompiledOnPublish>
|
||||
<PreserveCompilationContext Condition="'$(CONFIG)'!='Debug'">false</PreserveCompilationContext>
|
||||
<CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies>
|
||||
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
|
||||
<Configurations>Debug;Release;Prerelease</Configurations>
|
||||
<LangVersion>7.1</LangVersion>
|
||||
<ApplicationIcon />
|
||||
<OutputType>Library</OutputType>
|
||||
<StartupObject />
|
||||
<RunPostBuildEvent>Always</RunPostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="RaidMax.IW4MAdmin.SharedLibraryCore" Version="2.2.3" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Stats\Stats.csproj">
|
||||
@ -20,12 +29,7 @@
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
|
||||
<Exec Command="xcopy /E /K /Y /C /I "$(ProjectDir)wwwroot\images" "$(SolutionDir)WebfrontCore\wwwroot\images"" />
|
||||
</Target>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="copy "$(TargetPath)" "$(SolutionDir)BUILD\Plugins"" />
|
||||
<Exec Command="copy "$(TargetDir)$(ProjectName).Views$(TargetExt)" "$(SolutionDir)BUILD\Plugins"" />
|
||||
<Exec Command="dotnet publish $(ProjectPath) -c $(ConfigurationName) -o $(ProjectDir)..\..\..\BUILD\Plugins --no-build --no-restore --no-dependencies" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
@ -0,0 +1,28 @@
|
||||
using IW4MAdmin.Plugins.Stats;
|
||||
using IW4MAdmin.Plugins.Stats.Helpers;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IW4MAdmin.Plugins.Web.StatsWeb.Controllers
|
||||
{
|
||||
public class TopPlayersViewComponent : ViewComponent
|
||||
{
|
||||
public async Task<IViewComponentResult> InvokeAsync(int count, int offset, long? serverId = null)
|
||||
{
|
||||
if (serverId == 0)
|
||||
{
|
||||
serverId = null;
|
||||
}
|
||||
|
||||
var server = Plugin.ServerManager.GetServers().FirstOrDefault(_server => _server.EndPoint == serverId);
|
||||
|
||||
if (server != null)
|
||||
{
|
||||
serverId = StatManager.GetIdForServer(server);
|
||||
}
|
||||
|
||||
return View("_List", await Plugin.Manager.GetTopStats(offset, count, serverId));
|
||||
}
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 2.1 KiB |