From 344c3613b87aa5057d00ca5f8c76593e1854676b Mon Sep 17 00:00:00 2001 From: RaidMax Date: Sat, 28 Dec 2019 20:44:39 -0600 Subject: [PATCH 1/2] add help page to layout --- WebfrontCore/Controllers/HomeController.cs | 19 ++++++ WebfrontCore/Startup.cs | 2 +- WebfrontCore/Views/Home/Help.cshtml | 75 ++++++++++++++++++++++ WebfrontCore/Views/Shared/_Layout.cshtml | 39 +++++------ WebfrontCore/WebfrontCore.csproj | 1 + 5 files changed, 116 insertions(+), 20 deletions(-) create mode 100644 WebfrontCore/Views/Home/Help.cshtml diff --git a/WebfrontCore/Controllers/HomeController.cs b/WebfrontCore/Controllers/HomeController.cs index 621a7a06..35674695 100644 --- a/WebfrontCore/Controllers/HomeController.cs +++ b/WebfrontCore/Controllers/HomeController.cs @@ -48,5 +48,24 @@ namespace WebfrontCore.Controllers { return View(statusCode); } + + public IActionResult Help() + { + ViewBag.IsFluid = true; + var excludedAssembly = typeof(BaseController).Assembly; + var commands = Manager.GetCommands() + .OrderByDescending(_cmd => _cmd.Permission) + .GroupBy(_cmd => + { + + var pluginType = _cmd.GetType().Assembly.GetTypes().FirstOrDefault(_type => _type.Assembly != excludedAssembly && typeof(IPlugin).IsAssignableFrom(_type)); + return pluginType == null ? + Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_HELP_COMMAND_NATIVE"] : + SharedLibraryCore.Plugins.PluginImporter.ActivePlugins.First(_plugin => _plugin.GetType() == pluginType).Name; + }) + .Select(_grp => (_grp.Key, _grp.AsEnumerable())); + + return View(commands); + } } } diff --git a/WebfrontCore/Startup.cs b/WebfrontCore/Startup.cs index 0d7abb76..04e76981 100644 --- a/WebfrontCore/Startup.cs +++ b/WebfrontCore/Startup.cs @@ -58,7 +58,7 @@ namespace WebfrontCore }); #if DEBUG - //mvcBuilder = mvcBuilder.AddRazorRuntimeCompilation(); + mvcBuilder = mvcBuilder.AddRazorRuntimeCompilation(); services.Configure(_options => { _options.ViewLocationFormats.Add(@"/Views/Plugins/{1}/{0}" + RazorViewEngine.ViewExtension); diff --git a/WebfrontCore/Views/Home/Help.cshtml b/WebfrontCore/Views/Home/Help.cshtml new file mode 100644 index 00000000..9270fcf3 --- /dev/null +++ b/WebfrontCore/Views/Home/Help.cshtml @@ -0,0 +1,75 @@ +@model IEnumerable<(string, IEnumerable)> +@{ + var loc = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex; +} +@foreach ((var pluginName, var commandList) in Model) +{ +

@pluginName

+ + + + + + + + + + + + + + + @foreach (var command in commandList) + { + + + + + + + + + } + +
@loc["WEBFRONT_HELP_COMMAND_DESC_NAME"]@loc["WEBFRONT_HELP_COMMAND_DESC_ALIAS"]@loc["WEBFRONT_HELP_COMMAND_DESC_DESCRIPTION"]@loc["WEBFRONT_HELP_COMMAND_DESC_REQUIRES_TARGET"]@loc["WEBFRONT_HELP_COMMAND_DESC_SYNTAX"]@loc["WEBFRONT_HELP_COMMAND_DESC_REQUIRED_LEVEL"]
@command.Name@command.Alias@command.Description@command.RequiresTarget!@command.Syntax.Split('!')[1]@command.Permission.ToLocalizedLevelName()
+ + + + + + + + + + + @foreach (var command in commandList) + { + + + + + + + + + + + + + + + + + + + + + + + + + } + +
@loc["WEBFRONT_HELP_COMMAND_DESC_NAME"]@command.Name
@loc["WEBFRONT_HELP_COMMAND_DESC_ALIAS"]@command.Alias
@loc["WEBFRONT_HELP_COMMAND_DESC_DESCRIPTION"]@command.Description
@loc["WEBFRONT_HELP_COMMAND_DESC_REQUIRES_TARGET"]@command.RequiresTarget
@loc["WEBFRONT_HELP_COMMAND_DESC_SYNTAX"]!@command.Syntax.Split('!')[1]
@loc["WEBFRONT_HELP_COMMAND_DESC_REQUIRED_LEVEL"]@command.Permission.ToLocalizedLevelName()
+} +} \ No newline at end of file diff --git a/WebfrontCore/Views/Shared/_Layout.cshtml b/WebfrontCore/Views/Shared/_Layout.cshtml index 0fb28aed..e8f07b5a 100644 --- a/WebfrontCore/Views/Shared/_Layout.cshtml +++ b/WebfrontCore/Views/Shared/_Layout.cshtml @@ -36,40 +36,41 @@ + @foreach (var _page in ViewBag.Pages) { - + } @if (!string.IsNullOrEmpty(ViewBag.SocialLink)) { - + } @if (ViewBag.Authorized) { - + @loc["WEBFRONT_ACTION_RECENT_CLIENTS"] + @loc["WEBFRONT_ACTION_TOKEN"] + @loc["WEBFRONT_NAV_LOGOUT"] + + } else { - + }
diff --git a/WebfrontCore/WebfrontCore.csproj b/WebfrontCore/WebfrontCore.csproj index 065701c7..29e97767 100644 --- a/WebfrontCore/WebfrontCore.csproj +++ b/WebfrontCore/WebfrontCore.csproj @@ -66,6 +66,7 @@ + From 902cd9953e5af1cc5f59d6a9902ef7f29e70e1bc Mon Sep 17 00:00:00 2001 From: RaidMax Date: Sun, 29 Dec 2019 11:32:36 -0600 Subject: [PATCH 2/2] finish help layout and show only on permission level --- WebfrontCore/Controllers/HomeController.cs | 10 +++++++--- WebfrontCore/Views/Home/Help.cshtml | 7 +++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/WebfrontCore/Controllers/HomeController.cs b/WebfrontCore/Controllers/HomeController.cs index 35674695..54e095ca 100644 --- a/WebfrontCore/Controllers/HomeController.cs +++ b/WebfrontCore/Controllers/HomeController.cs @@ -52,16 +52,20 @@ namespace WebfrontCore.Controllers public IActionResult Help() { ViewBag.IsFluid = true; + ViewBag.Title = Localization["WEBFRONT_NAV_HELP"]; + + // we don't need to the name of the shared library assembly var excludedAssembly = typeof(BaseController).Assembly; var commands = Manager.GetCommands() + .Where(_cmd => _cmd.Permission <= Client.Level) .OrderByDescending(_cmd => _cmd.Permission) .GroupBy(_cmd => { - + // we need the plugin type the command is defined in var pluginType = _cmd.GetType().Assembly.GetTypes().FirstOrDefault(_type => _type.Assembly != excludedAssembly && typeof(IPlugin).IsAssignableFrom(_type)); return pluginType == null ? - Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_HELP_COMMAND_NATIVE"] : - SharedLibraryCore.Plugins.PluginImporter.ActivePlugins.First(_plugin => _plugin.GetType() == pluginType).Name; + Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_HELP_COMMAND_NATIVE"] : + SharedLibraryCore.Plugins.PluginImporter.ActivePlugins.First(_plugin => _plugin.GetType() == pluginType).Name; // for now we're just returning the name of the plugin, maybe later we'll include more info }) .Select(_grp => (_grp.Key, _grp.AsEnumerable())); diff --git a/WebfrontCore/Views/Home/Help.cshtml b/WebfrontCore/Views/Home/Help.cshtml index 9270fcf3..5c3a25ab 100644 --- a/WebfrontCore/Views/Home/Help.cshtml +++ b/WebfrontCore/Views/Home/Help.cshtml @@ -4,12 +4,12 @@ } @foreach ((var pluginName, var commandList) in Model) { -

@pluginName

+

@pluginName

- +
- + @@ -71,5 +71,4 @@ }
@loc["WEBFRONT_HELP_COMMAND_DESC_NAME"] @loc["WEBFRONT_HELP_COMMAND_DESC_ALIAS"] @loc["WEBFRONT_HELP_COMMAND_DESC_DESCRIPTION"]
-} } \ No newline at end of file