Made webfront optional for decreased ram usage

initialization should be better asynced
clean up publish folder after publish
added chevron hover icon for loading more penalties
added T6M maps to config
This commit is contained in:
RaidMax 2018-04-16 15:31:14 -05:00
parent 2fc2109a2e
commit 9aea9e1c02
19 changed files with 255 additions and 86 deletions

View File

@ -48,4 +48,8 @@
<Exec Command="call $(ProjectDir)BuildScripts\PostBuild.bat $(SolutionDir) $(ProjectDir) $(TargetDir) $(OutDir)" />
</Target>
<Target Name="PostPublish" AfterTargets="Publish">
<Exec Command="call $(ProjectDir)BuildScripts\PostPublish.bat $(SolutionDir) $(ProjectDir) $(TargetDir) $(OutDir)" />
</Target>
</Project>

View File

@ -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"

View File

@ -1,6 +1,5 @@
using System;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using SharedLibraryCore;
using SharedLibraryCore.Interfaces;

View File

@ -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"
}
]
}
]
}

View File

@ -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);
}));
});
if (ServerManager.GetApplicationSettings().Configuration().EnableWebFront)
{
Task.Run(() => WebfrontCore.Program.Init(ServerManager));
}
ServerManager.Start();
ServerManager.Logger.WriteVerbose("Shutdown complete");

View File

@ -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;
}

View File

@ -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
{

View File

@ -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<string>("g_log");
var logsync = await this.GetDvarAsync<int>("g_logsync");
Dvar<int> onelog = null;
if (GameName == Game.IW4)
{
try
{
onelog = await this.GetDvarAsync<int>("iw4x_onelog");
}
catch (Exception)
{
onelog = new Dvar<int>("iw4x_onelog")
{
Value = -1
};
}
}
try
{
var website = await this.GetDvarAsync<string>("_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}" :

View File

@ -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");

View File

@ -22,7 +22,7 @@ namespace WebfrontCore.Controllers
{
Manager = Program.Manager;
User = new EFClient()
User = User ?? new EFClient()
{
ClientId = -1
};

View File

@ -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<IViewComponentResult> 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);
}

View File

@ -17,6 +17,7 @@
<table class="table d-table d-md-none">
<tbody></tbody>
</table>
<span id="load_penalties_button" class="oi oi-chevron-bottom text-center text-primary w-100 h3 pb-0 mb-0 d-none d-md-block"></span>
</div>
@section scripts {

View File

@ -11,6 +11,8 @@
<meta property="og:url" content="@ViewBag.Url">
<meta name="description" content="@ViewBag.Description">
<meta name="keywords" content="@ViewBag.Keywords">
<link rel="icon" type="image/png" href="~/images/icon.png">
<link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<environment include="Development">
<link rel="stylesheet" href="~/css/bootstrap-custom.css" />
@ -136,10 +138,6 @@
<script type="text/javascript" src="~/js/search.js"></script>
</environment>
<environment include="Production">
<script type="text/javascript" src="~/lib/jQuery/dist/jquery.min.js"></script>
<script type="text/javascript" src="~/lib/moment/min/moment.min.js"></script>
<script type="text/javascript" src="~/lib/moment-timezone/builds/moment-timezone.min.js"></script>
<script type="text/javascript" src="~/lib/bootstrap/dist/js/bootstrap.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/canvasjs/1.7.0/canvasjs.min.js"></script>
<script type="text/javascript" src="~/js/global.min.js"></script>
</environment>

View File

@ -33,10 +33,20 @@
<None Include="compilerconfig.json" />
</ItemGroup>
<ItemGroup>
<Content Update="wwwroot\**\*.*" CopyToPublishDirectory="Never" />
<None Include="wwwroot\css\global.min.css" CopyToPublishDirectory="Always" />
<None Include="wwwroot\js\global.min.js" CopyToPublishDirectory="Always" />
<None Include="wwwroot\images\icon.png" CopyToPublishDirectory="Always" />
<None Include="wwwroot\lib\open-iconic\font\fonts\open-iconic.ttf" CopyToPublishDirectory="Always" />
<None Include="wwwroot\lib\open-iconic\font\fonts\open-iconic.woff" CopyToPublishDirectory="Always" />
<None Include="wwwroot\lib\open-iconic\font\fonts\open-iconic.otf" CopyToPublishDirectory="Always" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Bower" Version="1.3.11" />
<PackageReference Include="BuildBundlerMinifier" Version="2.6.375" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.6" />
</ItemGroup>
<ItemGroup>

View File

@ -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",

View File

@ -1,3 +0,0 @@
/// <autosync enabled="true" />
/// <reference path="lib/bootstrap/dist/js/bootstrap.js" />
/// <reference path="lib/jquery/dist/jquery.js" />

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

View File

@ -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) {