diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/AbpSettingManagementWebModule.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/AbpSettingManagementWebModule.cs index 387c7c3de9..b10d3c69c3 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/AbpSettingManagementWebModule.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/AbpSettingManagementWebModule.cs @@ -1,5 +1,8 @@ using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; using Volo.Abp.Modularity; +using Volo.Abp.SettingManagement.Web.Navigation; +using Volo.Abp.UI.Navigation; +using Volo.Abp.VirtualFileSystem; namespace Volo.Abp.SettingManagement.Web { @@ -8,6 +11,17 @@ namespace Volo.Abp.SettingManagement.Web )] public class AbpSettingManagementWebModule : AbpModule { + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.MenuContributors.Add(new SettingManagementMainMenuContributor()); + }); + Configure(options => + { + options.FileSets.AddEmbedded("Volo.Abp.SettingManagement.Web"); + }); + } } } diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Navigation/SettingManagementMainMenuContributor.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Navigation/SettingManagementMainMenuContributor.cs new file mode 100644 index 0000000000..9706ec4d15 --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Navigation/SettingManagementMainMenuContributor.cs @@ -0,0 +1,33 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using System.Linq; +using System.Threading.Tasks; +using Volo.Abp.SettingManagement.Web.Pages.SettingManagement; +using Volo.Abp.UI.Navigation; + +namespace Volo.Abp.SettingManagement.Web.Navigation +{ + public class SettingManagementMainMenuContributor : IMenuContributor + { + public Task ConfigureMenuAsync(MenuConfigurationContext context) + { + if (context.Menu.Name != StandardMenus.Main) + { + return Task.CompletedTask; + } + + var settingManagementPageOptions = context.ServiceProvider.GetRequiredService>().Value; + if (!settingManagementPageOptions.Contributors.Any()) + { + return Task.CompletedTask; + } + + //TODO: Localize + //var l = context.ServiceProvider.GetRequiredService>(); + + context.Menu.AddItem(new ApplicationMenuItem("Volo.Abp.SettingManagement", "Settings", "/SettingManagement", icon: "fa fa-cog", order: int.MaxValue - 1000)); + + return Task.CompletedTask; + } + } +} diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Index.cshtml.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Index.cshtml.cs index 057d929ebf..1fdba05707 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Index.cshtml.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Index.cshtml.cs @@ -1,3 +1,4 @@ +using System; using System.Threading.Tasks; using Microsoft.Extensions.Options; using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; @@ -9,15 +10,19 @@ namespace Volo.Abp.SettingManagement.Web.Pages.SettingManagement public SettingPageCreationContext SettingPageCreationContext { get; private set; } private readonly SettingManagementPageOptions _options; + private readonly IServiceProvider _serviceProvider; - public IndexModel(IOptions options) + public IndexModel( + IOptions options, + IServiceProvider serviceProvider) { + _serviceProvider = serviceProvider; _options = options.Value; } public async Task OnGetAsync() { - SettingPageCreationContext = new SettingPageCreationContext(); + SettingPageCreationContext = new SettingPageCreationContext(_serviceProvider); foreach (var contributor in _options.Contributors) { diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/SettingPageCreationContext.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/SettingPageCreationContext.cs index f67eda6e2c..b8979e9299 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/SettingPageCreationContext.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/SettingPageCreationContext.cs @@ -1,13 +1,19 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; +using Volo.Abp.DependencyInjection; namespace Volo.Abp.SettingManagement.Web.Pages.SettingManagement { - public class SettingPageCreationContext + public class SettingPageCreationContext : IServiceProviderAccessor { + public IServiceProvider ServiceProvider { get; } + public List Groups { get; } - public SettingPageCreationContext() + public SettingPageCreationContext(IServiceProvider serviceProvider) { + ServiceProvider = serviceProvider; + Groups = new List(); } } diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Volo.Abp.SettingManagement.Web.csproj b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Volo.Abp.SettingManagement.Web.csproj index 310ac9056a..d6398d1391 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Volo.Abp.SettingManagement.Web.csproj +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Volo.Abp.SettingManagement.Web.csproj @@ -10,4 +10,19 @@ + + + + + + + + + + + + + + +