diff --git a/Application/Application.csproj b/Application/Application.csproj index d51fa7f89..681fdcb5e 100644 --- a/Application/Application.csproj +++ b/Application/Application.csproj @@ -48,4 +48,8 @@ + + + + diff --git a/Application/BuildScripts/PostBuild.bat b/Application/BuildScripts/PostBuild.bat index 88a048f9c..ca9ed7616 100644 --- a/Application/BuildScripts/PostBuild.bat +++ b/Application/BuildScripts/PostBuild.bat @@ -15,4 +15,4 @@ if not exist "%TargetDir%Plugins" ( xcopy /y "%SolutionDir%Build\Plugins" "%TargetDir%Plugins\" echo Copying plugins for publish -xcopy /Y "%SolutionDir%BUILD\Plugins" "%SolutionDir%Publish\Windows\Plugins\" +xcopy /Y "%SolutionDir%BUILD\Plugins" "%SolutionDir%Publish\Windows\Plugins\" \ No newline at end of file diff --git a/Application/BuildScripts/PostPublish.bat b/Application/BuildScripts/PostPublish.bat index 93db844e1..8b8f091fc 100644 --- a/Application/BuildScripts/PostPublish.bat +++ b/Application/BuildScripts/PostPublish.bat @@ -1 +1,29 @@ set SolutionDir=%1 +set ProjectDir=%2 +set TargetDir=%3 + +echo Deleting extra language files +if exist "%SolutionDir%Publish\Windows\de\" powershell Remove-Item -Force -Recurse '%SolutionDir%Publish\Windows\de' +if exist "%SolutionDir%Publish\Windows\es\" powershell Remove-Item -Force -Recurse '%SolutionDir%Publish\Windows\es' +if exist "%SolutionDir%Publish\Windows\fr\" powershell Remove-Item -Force -Recurse '%SolutionDir%Publish\Windows\fr' +if exist "%SolutionDir%Publish\Windows\it\" powershell Remove-Item -Force -Recurse '%SolutionDir%Publish\Windows\it' +if exist "%SolutionDir%Publish\Windows\ja\" powershell Remove-Item -Force -Recurse '%SolutionDir%Publish\Windows\ja' +if exist "%SolutionDir%Publish\Windows\ko\" powershell Remove-Item -Force -Recurse '%SolutionDir%Publish\Windows\ko' +if exist "%SolutionDir%Publish\Windows\ru\" powershell Remove-Item -Force -Recurse '%SolutionDir%Publish\Windows\ru' +if exist "%SolutionDir%Publish\Windows\zh-Hans\" powershell Remove-Item -Force -Recurse '%SolutionDir%Publish\Windows\zh-Hans' +if exist "%SolutionDir%Publish\Windows\zh-Hant\" powershell Remove-Item -Force -Recurse '%SolutionDir%Publish\Windows\zh-Hant' + +echo Deleting extra runtime files +if exist "%SolutionDir%Publish\Windows\runtimes\linux-arm" powershell Remove-Item -Force -Recurse '%SolutionDir%Publish\Windows\runtimes\linux-arm' +if exist "%SolutionDir%Publish\Windows\runtimes\linux-arm64" powershell Remove-Item -Force -Recurse '%SolutionDir%Publish\Windows\runtimes\linux-arm64' +if exist "%SolutionDir%Publish\Windows\runtimes\linux-armel" powershell Remove-Item -Force -Recurse '%SolutionDir%Publish\Windows\runtimes\linux-armel' + +if exist "%SolutionDir%Publish\Windows\runtimes\osx" powershell Remove-Item -Force -Recurse '%SolutionDir%Publish\Windows\runtimes\osx' +if exist "%SolutionDir%Publish\Windows\runtimes\osx-x64" powershell Remove-Item -Force -Recurse '%SolutionDir%Publish\Windows\runtimes\osx-x64' + +if exist "%SolutionDir%Publish\Windows\runtimes\win-arm" powershell Remove-Item -Force -Recurse '%SolutionDir%Publish\Windows\runtimes\win-arm' +if exist "%SolutionDir%Publish\Windows\runtimes\win-arm64" powershell Remove-Item -Force -Recurse '%SolutionDir%Publish\Windows\runtimes\win-arm64' + +echo Deleting misc files +if exist "%SolutionDir%Publish\Windows\web.config" del "%SolutionDir%Publish\Windows\web.config" +del "%SolutionDir%Publish\Windows\*pdb" diff --git a/Application/EventParsers/IW4EventParser.cs b/Application/EventParsers/IW4EventParser.cs index f5dfafd8b..e6f3c424e 100644 --- a/Application/EventParsers/IW4EventParser.cs +++ b/Application/EventParsers/IW4EventParser.cs @@ -1,6 +1,5 @@ using System; using System.Linq; -using System.Text; using System.Text.RegularExpressions; using SharedLibraryCore; using SharedLibraryCore.Interfaces; diff --git a/Application/IW4MAdminSettings.json b/Application/IW4MAdminSettings.json index fb3c78fea..eb6056e3d 100644 --- a/Application/IW4MAdminSettings.json +++ b/Application/IW4MAdminSettings.json @@ -234,6 +234,135 @@ "Name": "mp_bloc_sh" } ] + }, + { + "Game": "T6M", + "Maps": [ + { + "Alias": "Aftermath", + "Name": "mp_la" + }, + { + "Alias": "Cargo", + "Name": "mp_dockside" + }, + { + "Alias": "Carrier", + "Name": "mp_carrier" + }, + { + "Alias": "Drone", + "Name": "mp_drone" + }, + { + "Alias": "Express", + "Name": "mp_express" + }, + { + "Alias": "Hijacked", + "Name": "mp_hijacked" + }, + { + "Alias": "Meltdown", + "Name": "mp_meltdown" + }, + { + "Alias": "Overflow", + "Name": "mp_overflow" + }, + { + "Alias": "Plaza", + "Name": "mp_nightclub" + }, + { + "Alias": "Raid", + "Name": "mp_raid" + }, + { + "Alias": "Slums", + "Name": "mp_slums" + }, + { + "Alias": "Standoff", + "Name": "mp_village" + }, + { + "Alias": "Turbine", + "Name": "mp_turbine" + }, + { + "Alias": "Yemen", + "Name": "mp_socotra" + }, + { + "Alias": "Nuketown 2025", + "Name": "mp_nuketown_2020" + }, + { + "Alias": "Downhill", + "Name": "mp_downhill" + }, + { + "Alias": "Mirage", + "Name": "mp_mirage" + }, + { + "Alias": "Hydro", + "Name": "mp_hydro" + }, + { + "Alias": "Grind", + "Name": "mp_skate" + }, + { + "Alias": "Encore", + "Name": "mp_concert" + }, + { + "Alias": "Magma", + "Name": "mp_magma" + }, + { + "Alias": "Vertigo", + "Name": "mp_vertigo" + }, + { + "Alias": "Studio", + "Name": "mp_studio" + }, + { + "Alias": "Uplink", + "Name": "mp_uplink" + }, + { + "Alias": "Detour", + "Name": "mp_bridge" + }, + { + "Alias": "Cove", + "Name": "mp_castaway" + }, + { + "Alias": "Rush", + "Name": "mp_paintball" + }, + { + "Alias": "Dig", + "Name": "mp_dig" + }, + { + "Alias": "Frost", + "Name": "mp_frostbite" + }, + { + "Alias": "Pod", + "Name": "mp_pod" + }, + { + "Alias": "Takeoff", + "Name": "mp_takeoff" + } + ] } ] -} \ No newline at end of file +} diff --git a/Application/Main.cs b/Application/Main.cs index f80826d40..0d83c2569 100644 --- a/Application/Main.cs +++ b/Application/Main.cs @@ -38,7 +38,7 @@ namespace IW4MAdmin.Application ServerManager = ApplicationManager.GetInstance(); ServerManager.Init().Wait(); - Task.Run((Action)(() => + Task.Run(() => { String userInput; Player Origin = ServerManager.GetClientService().Get(1).Result.AsPlayer(); @@ -59,9 +59,12 @@ namespace IW4MAdmin.Application Console.Write('>'); } while (ServerManager.Running); - })); + }); - Task.Run(() => WebfrontCore.Program.Init(ServerManager)); + if (ServerManager.GetApplicationSettings().Configuration().EnableWebFront) + { + Task.Run(() => WebfrontCore.Program.Init(ServerManager)); + } ServerManager.Start(); ServerManager.Logger.WriteVerbose("Shutdown complete"); diff --git a/Application/Manager.cs b/Application/Manager.cs index d6dad8917..8a7f2a62a 100644 --- a/Application/Manager.cs +++ b/Application/Manager.cs @@ -136,7 +136,7 @@ namespace IW4MAdmin.Application else if (config.Servers.Count == 0) throw new ServerException("A server configuration in IW4MAdminSettings.json is invalid"); - + #endregion #region PLUGINS SharedLibraryCore.Plugins.PluginImporter.Load(this); @@ -156,46 +156,6 @@ namespace IW4MAdmin.Application } #endregion - foreach (var Conf in config.Servers) - { - try - { - var ServerInstance = new IW4MServer(this, Conf); - await ServerInstance.Initialize(); - - lock (_servers) - { - _servers.Add(ServerInstance); - } - - Logger.WriteVerbose($"Now monitoring {ServerInstance.Hostname}"); - - // this way we can keep track of execution time and see if problems arise. - var Status = new AsyncStatus(ServerInstance, UPDATE_FREQUENCY); - lock (TaskStatuses) - { - TaskStatuses.Add(Status); - } - } - - catch (ServerException e) - { - Logger.WriteError($"Not monitoring server {Conf.IPAddress}:{Conf.Port} due to uncorrectable errors"); - if (e.GetType() == typeof(DvarException)) - Logger.WriteDebug($"Could not get the dvar value for {(e as DvarException).Data["dvar_name"]} (ensure the server has a map loaded)"); - else if (e.GetType() == typeof(NetworkException)) - { - Logger.WriteDebug(e.Message); - //Logger.WriteDebug($"Internal Exception: {e.Data["internal_exception"]}"); - } - - // throw the exception to the main method to stop before instantly exiting - throw e; - } - - } - #endregion - #region COMMANDS if (ClientSvc.GetOwners().Result.Count == 0) Commands.Add(new COwner()); @@ -239,6 +199,48 @@ namespace IW4MAdmin.Application Commands.Add(C); #endregion + #region INIT + async Task Init(ServerConfiguration Conf) + { + try + { + var ServerInstance = new IW4MServer(this, Conf); + await ServerInstance.Initialize(); + + lock (_servers) + { + _servers.Add(ServerInstance); + } + + Logger.WriteVerbose($"Now monitoring {ServerInstance.Hostname}"); + + // this way we can keep track of execution time and see if problems arise. + var Status = new AsyncStatus(ServerInstance, UPDATE_FREQUENCY); + lock (TaskStatuses) + { + TaskStatuses.Add(Status); + } + } + + catch (ServerException e) + { + Logger.WriteError($"Not monitoring server {Conf.IPAddress}:{Conf.Port} due to uncorrectable errors"); + if (e.GetType() == typeof(DvarException)) + Logger.WriteDebug($"Could not get the dvar value for {(e as DvarException).Data["dvar_name"]} (ensure the server has a map loaded)"); + else if (e.GetType() == typeof(NetworkException)) + { + Logger.WriteDebug(e.Message); + } + + // throw the exception to the main method to stop before instantly exiting + throw e; + } + } + + await Task.WhenAll(config.Servers.Select(c => Init(c)).ToArray()); + + #endregion + Running = true; } diff --git a/Application/Misc/VPNCheck.cs b/Application/Misc/VPNCheck.cs index 6d0056f04..d21a19c22 100644 --- a/Application/Misc/VPNCheck.cs +++ b/Application/Misc/VPNCheck.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace IW4MAdmin.Application.Misc +namespace Application.Misc { public class VPNCheck { diff --git a/Application/Server.cs b/Application/Server.cs index 3c7f0622f..c82637f56 100644 --- a/Application/Server.cs +++ b/Application/Server.cs @@ -5,6 +5,7 @@ using System.IO; using System.Linq; using System.Threading.Tasks; using System.Text.RegularExpressions; +using System.Runtime.InteropServices; using SharedLibraryCore; using SharedLibraryCore.Interfaces; @@ -12,12 +13,12 @@ using SharedLibraryCore.Objects; using SharedLibraryCore.Database.Models; using SharedLibraryCore.Dtos; using SharedLibraryCore.Configuration; +using SharedLibraryCore.Exceptions; -using IW4MAdmin.Application.Misc; +using Application.Misc; using Application.RconParsers; using Application.EventParsers; -using SharedLibraryCore.Exceptions; -using System.Runtime.InteropServices; + namespace IW4MAdmin { @@ -612,23 +613,6 @@ namespace IW4MAdmin var logfile = await this.GetDvarAsync("g_log"); var logsync = await this.GetDvarAsync("g_logsync"); - Dvar onelog = null; - if (GameName == Game.IW4) - { - try - { - onelog = await this.GetDvarAsync("iw4x_onelog"); - } - - catch (Exception) - { - onelog = new Dvar("iw4x_onelog") - { - Value = -1 - }; - } - } - try { var website = await this.GetDvarAsync("_website"); @@ -662,9 +646,8 @@ namespace IW4MAdmin CustomCallback = await ScriptLoaded(); string mainPath = EventParser.GetGameDir(); - mainPath = (GameName == Game.IW4 && onelog.Value > 0) ? "main" : mainPath; #if DEBUG - basepath.Value = @"\\192.168.88.253\Call of Duty Black Ops II"; + // basepath.Value = @"\\192.168.88.253\Call of Duty Black Ops II"; #endif string logPath = game.Value == string.Empty ? $"{basepath.Value.Replace('\\', Path.DirectorySeparatorChar)}{Path.DirectorySeparatorChar}{mainPath}{Path.DirectorySeparatorChar}{logfile.Value}" : diff --git a/SharedLibraryCore/Configuration/ApplicationConfiguration.cs b/SharedLibraryCore/Configuration/ApplicationConfiguration.cs index ef9613ac0..e7a5b796c 100644 --- a/SharedLibraryCore/Configuration/ApplicationConfiguration.cs +++ b/SharedLibraryCore/Configuration/ApplicationConfiguration.cs @@ -7,6 +7,7 @@ namespace SharedLibraryCore.Configuration { public class ApplicationConfiguration : IBaseConfiguration { + public bool EnableWebFront { get; set; } public bool EnableMultipleOwners { get; set; } public bool EnableSteppedHierarchy { get; set; } public bool EnableClientVPNs { get; set; } @@ -23,6 +24,7 @@ namespace SharedLibraryCore.Configuration public IBaseConfiguration Generate() { + EnableWebFront = Utilities.PromptBool("Enable webfront"); EnableMultipleOwners = Utilities.PromptBool("Enable multiple owners"); EnableSteppedHierarchy = Utilities.PromptBool("Enable stepped privilege hierarchy"); EnableCustomSayName = Utilities.PromptBool("Enable custom say name"); diff --git a/WebfrontCore/Controllers/BaseController.cs b/WebfrontCore/Controllers/BaseController.cs index 7d5bdd2cc..044b78e1a 100644 --- a/WebfrontCore/Controllers/BaseController.cs +++ b/WebfrontCore/Controllers/BaseController.cs @@ -22,7 +22,7 @@ namespace WebfrontCore.Controllers { Manager = Program.Manager; - User = new EFClient() + User = User ?? new EFClient() { ClientId = -1 }; diff --git a/WebfrontCore/ViewComponents/PenaltyListViewComponent.cs b/WebfrontCore/ViewComponents/PenaltyListViewComponent.cs index 2c674f60b..d867d2ca7 100644 --- a/WebfrontCore/ViewComponents/PenaltyListViewComponent.cs +++ b/WebfrontCore/ViewComponents/PenaltyListViewComponent.cs @@ -4,7 +4,6 @@ using SharedLibraryCore.Dtos; using SharedLibraryCore.Objects; using System; using System.Linq; -using System.Security.Claims; using System.Threading.Tasks; namespace WebfrontCore.ViewComponents @@ -13,7 +12,7 @@ namespace WebfrontCore.ViewComponents { public async Task InvokeAsync(int offset) { - var penalties = await Program.Manager.GetPenaltyService().GetRecentPenalties(15, offset); + var penalties = await Program.Manager.GetPenaltyService().GetRecentPenalties(12, offset); var penaltiesDto = penalties.Select(p => new PenaltyInfo() { OffenderId = p.OffenderId, @@ -28,8 +27,7 @@ namespace WebfrontCore.ViewComponents Sensitive = p.Type == Penalty.PenaltyType.Flag }); - bool authorized = User.Identity.IsAuthenticated; - penaltiesDto = authorized ? penaltiesDto.ToList() : penaltiesDto.Where(p => !p.Sensitive).ToList(); + penaltiesDto = User.Identity.IsAuthenticated ? penaltiesDto.ToList() : penaltiesDto.Where(p => !p.Sensitive).ToList(); return View("_List", penaltiesDto); } diff --git a/WebfrontCore/Views/Penalty/List.cshtml b/WebfrontCore/Views/Penalty/List.cshtml index c76ad4fe1..5205f72d4 100644 --- a/WebfrontCore/Views/Penalty/List.cshtml +++ b/WebfrontCore/Views/Penalty/List.cshtml @@ -17,6 +17,7 @@
+ @section scripts { diff --git a/WebfrontCore/Views/Shared/_Layout.cshtml b/WebfrontCore/Views/Shared/_Layout.cshtml index 958a6c215..42910d12d 100644 --- a/WebfrontCore/Views/Shared/_Layout.cshtml +++ b/WebfrontCore/Views/Shared/_Layout.cshtml @@ -11,6 +11,8 @@ + + @@ -136,10 +138,6 @@ - - - - diff --git a/WebfrontCore/WebfrontCore.csproj b/WebfrontCore/WebfrontCore.csproj index e2937c846..9083ed1a7 100644 --- a/WebfrontCore/WebfrontCore.csproj +++ b/WebfrontCore/WebfrontCore.csproj @@ -33,10 +33,20 @@ + + + + + + + + + + - + diff --git a/WebfrontCore/bundleconfig.json b/WebfrontCore/bundleconfig.json index d1fda8153..38588e925 100644 --- a/WebfrontCore/bundleconfig.json +++ b/WebfrontCore/bundleconfig.json @@ -13,6 +13,10 @@ { "outputFileName": "wwwroot/js/global.min.js", "inputFiles": [ + "wwwroot/lib/jQuery/dist/jquery.min.js", + "wwwroot/lib/moment/min/moment.min.js", + "wwwroot/lib/moment-timezone/builds/moment-timezone.min.js", + "wwwroot/lib/bootstrap/dist/js/bootstrap.min.js", "wwwroot/js/action.js", "wwwroot/js/console.js", "wwwroot/js/penalty.js", diff --git a/WebfrontCore/wwwroot/_references.js b/WebfrontCore/wwwroot/_references.js deleted file mode 100644 index 53daa2bea..000000000 --- a/WebfrontCore/wwwroot/_references.js +++ /dev/null @@ -1,3 +0,0 @@ -/// -/// -/// \ No newline at end of file diff --git a/WebfrontCore/wwwroot/favicon.ico b/WebfrontCore/wwwroot/favicon.ico deleted file mode 100644 index 3edaf82e7..000000000 Binary files a/WebfrontCore/wwwroot/favicon.ico and /dev/null differ diff --git a/WebfrontCore/wwwroot/js/penalty.js b/WebfrontCore/wwwroot/js/penalty.js index 2d15024e2..064beeca0 100644 --- a/WebfrontCore/wwwroot/js/penalty.js +++ b/WebfrontCore/wwwroot/js/penalty.js @@ -1,16 +1,24 @@ -let offset = 15; +let offset = 12; +let isLoading = false; function loadMorePenalties() { + if (isLoading) { + return false; + } + showLoader(); + isLoading = true; $.get('/Penalty/ListAsync', { offset: offset }) .done(function (response) { $('#penalty_table').append(response); hideLoader(); + isLoading = false; }) .fail(function (jqxhr, statis, error) { errorLoader(); + isLoading = false; }); - offset += 15; + offset += 12; } if ($('#penalty_table').length === 1) { @@ -37,10 +45,13 @@ if ($('#penalty_table').length === 1) { var hasScrollBar = false; $document.ready(function () { - $window .off('scroll', ScrollHandler) .on('scroll', ScrollHandler); + + $('#load_penalties_button').hover(function () { + loadMorePenalties(); + }); }); function ScrollHandler(e) {