add page list to manager so we can inject pages into the layout view
This commit is contained in:
parent
9d00d5a16a
commit
d0be08629d
@ -46,6 +46,7 @@ namespace IW4MAdmin.Application
|
||||
EventApi Api;
|
||||
GameEventHandler Handler;
|
||||
ManualResetEventSlim OnEvent;
|
||||
readonly IPageList PageList;
|
||||
|
||||
private ApplicationManager()
|
||||
{
|
||||
@ -63,6 +64,7 @@ namespace IW4MAdmin.Application
|
||||
ConfigHandler = new BaseConfigurationHandler<ApplicationConfiguration>("IW4MAdminSettings");
|
||||
StartTime = DateTime.UtcNow;
|
||||
OnEvent = new ManualResetEventSlim();
|
||||
PageList = new PageList();
|
||||
}
|
||||
|
||||
public IList<Server> GetServers()
|
||||
@ -519,5 +521,7 @@ namespace IW4MAdmin.Application
|
||||
}
|
||||
|
||||
public IList<Assembly> GetPluginAssemblies() => SharedLibraryCore.Plugins.PluginImporter.PluginAssemblies;
|
||||
|
||||
public IPageList GetPageList() => PageList;
|
||||
}
|
||||
}
|
||||
|
26
Application/PageList.cs
Normal file
26
Application/PageList.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using SharedLibraryCore.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace IW4MAdmin.Application
|
||||
{
|
||||
/// <summary>
|
||||
/// implementatin of IPageList that supports basic
|
||||
/// pages title and page location for webfront
|
||||
/// </summary>
|
||||
class PageList : IPageList
|
||||
{
|
||||
/// <summary>
|
||||
/// Pages dictionary
|
||||
/// Key = page name
|
||||
/// Value = page location (url)
|
||||
/// </summary>
|
||||
public IDictionary<string, string> Pages { get; set; }
|
||||
|
||||
public PageList()
|
||||
{
|
||||
Pages = new Dictionary<string, string>();
|
||||
}
|
||||
}
|
||||
}
|
@ -26,7 +26,7 @@ namespace IW4MAdmin
|
||||
{
|
||||
public class IW4MServer : Server
|
||||
{
|
||||
private static Index loc = Utilities.CurrentLocalization.LocalizationIndex;
|
||||
private static readonly Index loc = Utilities.CurrentLocalization.LocalizationIndex;
|
||||
private GameLogEvent LogEvent;
|
||||
private ClientAuthentication AuthQueue;
|
||||
|
||||
@ -170,8 +170,6 @@ namespace IW4MAdmin
|
||||
// we need to update their new ip and name to the virtual property
|
||||
client.Name = polledPlayer.Name;
|
||||
client.IPAddress = polledPlayer.IPAddress;
|
||||
|
||||
await Manager.GetClientService().Update(client);
|
||||
}
|
||||
|
||||
else
|
||||
@ -181,6 +179,8 @@ namespace IW4MAdmin
|
||||
client.Name = existingAlias.Name;
|
||||
client.IPAddress = existingAlias.IPAddress;
|
||||
}
|
||||
|
||||
await Manager.GetClientService().Update(client);
|
||||
player = client.AsPlayer();
|
||||
}
|
||||
|
||||
@ -288,7 +288,7 @@ namespace IW4MAdmin
|
||||
if (cNum >= 0 && Players[cNum] != null)
|
||||
{
|
||||
Player Leaving = Players[cNum];
|
||||
Logger.WriteInfo($"Client {Leaving} disconnecting...");
|
||||
Logger.WriteInfo($"Client {Leaving}, state {Leaving.State.ToString()} disconnecting...");
|
||||
|
||||
if (!Leaving.IsAuthenticated || Leaving.State != Player.ClientState.Connected)
|
||||
{
|
||||
|
@ -13,6 +13,8 @@ using SharedLibraryCore.Services;
|
||||
using IW4MAdmin.Plugins.Stats.Config;
|
||||
using IW4MAdmin.Plugins.Stats.Helpers;
|
||||
using IW4MAdmin.Plugins.Stats.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Routing;
|
||||
|
||||
namespace IW4MAdmin.Plugins.Stats
|
||||
{
|
||||
@ -104,6 +106,14 @@ namespace IW4MAdmin.Plugins.Stats
|
||||
await Config.Save();
|
||||
}
|
||||
|
||||
// register the topstats page
|
||||
// todo:generate the URL/Location instead of hardcoding
|
||||
manager.GetPageList()
|
||||
.Pages.Add(
|
||||
Utilities.CurrentLocalization.LocalizationIndex["PLUGINS_STATS_COMMANDS_TOP_TEXT"],
|
||||
"/Stats/TopPlayersAsync");
|
||||
|
||||
|
||||
// meta data info
|
||||
async Task<List<ProfileMeta>> getStats(int clientId)
|
||||
{
|
||||
|
@ -27,6 +27,8 @@ namespace SharedLibraryCore.Database
|
||||
|
||||
public DatabaseContext(DbContextOptions<DatabaseContext> opt) : base(opt) { }
|
||||
|
||||
public DatabaseContext() { }
|
||||
|
||||
public DatabaseContext(string connStr)
|
||||
{
|
||||
_ConnectionString = connStr;
|
||||
|
@ -35,5 +35,10 @@ namespace SharedLibraryCore.Interfaces
|
||||
void SetHasEvent();
|
||||
bool ShutdownRequested();
|
||||
IList<Assembly> GetPluginAssemblies();
|
||||
/// <summary>
|
||||
/// provides a page list to add and remove from
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
IPageList GetPageList();
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ using SharedLibraryCore.Database;
|
||||
using SharedLibraryCore.Database.Models;
|
||||
using SharedLibraryCore.Interfaces;
|
||||
using SharedLibraryCore.Objects;
|
||||
using WebfrontCore.ViewModels;
|
||||
|
||||
namespace WebfrontCore.Controllers
|
||||
{
|
||||
@ -19,7 +20,7 @@ namespace WebfrontCore.Controllers
|
||||
protected bool Authorized { get; set; }
|
||||
protected SharedLibraryCore.Localization.Index Localization { get; private set; }
|
||||
protected EFClient Client { get; private set; }
|
||||
private static byte[] LocalHost = { 127, 0, 0, 1 };
|
||||
private static readonly byte[] LocalHost = { 127, 0, 0, 1 };
|
||||
private static string SocialLink;
|
||||
private static string SocialTitle;
|
||||
|
||||
@ -89,6 +90,14 @@ namespace WebfrontCore.Controllers
|
||||
ViewBag.SocialLink = SocialLink ?? "";
|
||||
ViewBag.SocialTitle = SocialTitle;
|
||||
|
||||
// grab the pages from plugins
|
||||
ViewBag.Pages = Manager.GetPageList().Pages
|
||||
.Select(page => new Page
|
||||
{
|
||||
Name = page.Key,
|
||||
Location = page.Value
|
||||
}).ToList();
|
||||
|
||||
base.OnActionExecuting(context);
|
||||
}
|
||||
}
|
||||
|
13
WebfrontCore/ViewModels/Page.cs
Normal file
13
WebfrontCore/ViewModels/Page.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WebfrontCore.ViewModels
|
||||
{
|
||||
public class Page
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Location { get; set; }
|
||||
}
|
||||
}
|
@ -38,6 +38,12 @@
|
||||
<li class="nav-item text-center text-md-left">@Html.ActionLink(loc["WEBFRONT_NAV_HOME"], "Index", "Home", new { area = "" }, new { @class = "nav-link" })</li>
|
||||
<li class="nav-item text-center text-md-left">@Html.ActionLink(loc["WEBFRONT_NAV_PENALTIES"], "List", "Penalty", new { area = "" }, new { @class = "nav-link" })</li>
|
||||
<li class="nav-item text-center text-md-left">@Html.ActionLink(loc["WEBFRONT_NAV_PRIVILEGED"], "PrivilegedAsync", "Client", new { area = "" }, new { @class = "nav-link" })</li>
|
||||
@foreach (var _page in ViewBag.Pages)
|
||||
{
|
||||
<li class="nav-item text-center text-md-left">
|
||||
<a class="nav-link" href="@_page.Location">@_page.Name</a>
|
||||
</li>
|
||||
}
|
||||
<li class="nav-item text-center text-md-left"></li>
|
||||
@if (!string.IsNullOrEmpty(ViewBag.SocialLink))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user