add help page to layout
This commit is contained in:
parent
32e1af0ffb
commit
344c3613b8
@ -48,5 +48,24 @@ namespace WebfrontCore.Controllers
|
|||||||
{
|
{
|
||||||
return View(statusCode);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ namespace WebfrontCore
|
|||||||
});
|
});
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
//mvcBuilder = mvcBuilder.AddRazorRuntimeCompilation();
|
mvcBuilder = mvcBuilder.AddRazorRuntimeCompilation();
|
||||||
services.Configure<RazorViewEngineOptions>(_options =>
|
services.Configure<RazorViewEngineOptions>(_options =>
|
||||||
{
|
{
|
||||||
_options.ViewLocationFormats.Add(@"/Views/Plugins/{1}/{0}" + RazorViewEngine.ViewExtension);
|
_options.ViewLocationFormats.Add(@"/Views/Plugins/{1}/{0}" + RazorViewEngine.ViewExtension);
|
||||||
|
75
WebfrontCore/Views/Home/Help.cshtml
Normal file
75
WebfrontCore/Views/Home/Help.cshtml
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
@model IEnumerable<(string, IEnumerable<Command>)>
|
||||||
|
@{
|
||||||
|
var loc = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex;
|
||||||
|
}
|
||||||
|
@foreach ((var pluginName, var commandList) in Model)
|
||||||
|
{
|
||||||
|
<h4 class="text-center">@pluginName</h4>
|
||||||
|
|
||||||
|
<!-- desktop -->
|
||||||
|
<table class="table table-striped border-bottom col-12 ml-auto mr-auto d-none d-lg-table">
|
||||||
|
<thead>
|
||||||
|
<tr class="bg-primary">
|
||||||
|
<th scope="col">@loc["WEBFRONT_HELP_COMMAND_DESC_NAME"]</th>
|
||||||
|
<th scope="col">@loc["WEBFRONT_HELP_COMMAND_DESC_ALIAS"]</th>
|
||||||
|
<th scope="col">@loc["WEBFRONT_HELP_COMMAND_DESC_DESCRIPTION"]</th>
|
||||||
|
<th scope="col">@loc["WEBFRONT_HELP_COMMAND_DESC_REQUIRES_TARGET"]</th>
|
||||||
|
<th scope="col">@loc["WEBFRONT_HELP_COMMAND_DESC_SYNTAX"]</th>
|
||||||
|
<th scope="col">@loc["WEBFRONT_HELP_COMMAND_DESC_REQUIRED_LEVEL"]</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var command in commandList)
|
||||||
|
{
|
||||||
|
<tr class="bg-dark">
|
||||||
|
<th scope="row">@command.Name</th>
|
||||||
|
<td>@command.Alias</td>
|
||||||
|
<td>@command.Description</td>
|
||||||
|
<td>@command.RequiresTarget</td>
|
||||||
|
<td>!@command.Syntax.Split('!')[1]</td>
|
||||||
|
<td>@command.Permission.ToLocalizedLevelName()</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<!-- mobile -->
|
||||||
|
<table class="table border-bottomb d-table d-lg-none">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col"></th>
|
||||||
|
<th scope="col"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var command in commandList)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td scope="row" class="bg-primary">@loc["WEBFRONT_HELP_COMMAND_DESC_NAME"]</td>
|
||||||
|
<td class="bg-dark text-light">@command.Name</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td scope="row" class="bg-primary">@loc["WEBFRONT_HELP_COMMAND_DESC_ALIAS"]</td>
|
||||||
|
<td class="bg-dark text-light">@command.Alias</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td scope="row" class="bg-primary">@loc["WEBFRONT_HELP_COMMAND_DESC_DESCRIPTION"]</td>
|
||||||
|
<td class="bg-dark text-light">@command.Description</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td scope="row" class="bg-primary">@loc["WEBFRONT_HELP_COMMAND_DESC_REQUIRES_TARGET"]</td>
|
||||||
|
<td class="bg-dark text-light">@command.RequiresTarget</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td scope="row" class="bg-primary">@loc["WEBFRONT_HELP_COMMAND_DESC_SYNTAX"]</td>
|
||||||
|
<td class="bg-dark text-light">!@command.Syntax.Split('!')[1]</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td scope="row" class="bg-primary" style="border-bottom: #222 1px solid;">@loc["WEBFRONT_HELP_COMMAND_DESC_REQUIRED_LEVEL"]</td>
|
||||||
|
<td class="bg-dark border-bottom @($"level-color-{(int)command.Permission}")">@command.Permission.ToLocalizedLevelName()</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
}
|
||||||
|
}
|
@ -36,6 +36,7 @@
|
|||||||
<li class="nav-item text-center text-lg-left">@Html.ActionLink(loc["WEBFRONT_NAV_HOME"], "Index", "Home", new { area = "" }, new { @class = "nav-link" })</li>
|
<li class="nav-item text-center text-lg-left">@Html.ActionLink(loc["WEBFRONT_NAV_HOME"], "Index", "Home", new { area = "" }, new { @class = "nav-link" })</li>
|
||||||
<li class="nav-item text-center text-lg-left">@Html.ActionLink(loc["WEBFRONT_NAV_PENALTIES"], "List", "Penalty", new { area = "" }, new { @class = "nav-link" })</li>
|
<li class="nav-item text-center text-lg-left">@Html.ActionLink(loc["WEBFRONT_NAV_PENALTIES"], "List", "Penalty", new { area = "" }, new { @class = "nav-link" })</li>
|
||||||
<li class="nav-item text-center text-lg-left">@Html.ActionLink(loc["WEBFRONT_NAV_PRIVILEGED"], "PrivilegedAsync", "Client", new { area = "" }, new { @class = "nav-link" })</li>
|
<li class="nav-item text-center text-lg-left">@Html.ActionLink(loc["WEBFRONT_NAV_PRIVILEGED"], "PrivilegedAsync", "Client", new { area = "" }, new { @class = "nav-link" })</li>
|
||||||
|
<li class="nav-item text-center text-lg-left">@Html.ActionLink(loc["WEBFRONT_NAV_HELP"], "Help", "Home", new { area = "" }, new { @class = "nav-link" })</li>
|
||||||
@foreach (var _page in ViewBag.Pages)
|
@foreach (var _page in ViewBag.Pages)
|
||||||
{
|
{
|
||||||
<li class="nav-item text-center text-lg-left">
|
<li class="nav-item text-center text-lg-left">
|
||||||
|
@ -66,6 +66,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="BuildBundlerMinifier" Version="3.2.435" />
|
<PackageReference Include="BuildBundlerMinifier" Version="3.2.435" />
|
||||||
<PackageReference Include="BuildWebCompiler" Version="1.12.405" />
|
<PackageReference Include="BuildWebCompiler" Version="1.12.405" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.1.0" />
|
||||||
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="2.0.96" />
|
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="2.0.96" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user