Browse Source

Improve Web.Host for the service template.

pull/1159/head
Halil ibrahim Kalkan 7 years ago
parent
commit
79ccfcaff5
  1. 1
      templates/service/host/MyCompanyName.MyProjectName.IdentityServer/MyCompanyName.MyProjectName.IdentityServer.csproj
  2. 2
      templates/service/host/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs
  3. 34
      templates/service/host/MyCompanyName.MyProjectName.Web.Host/Menus/MyProjectNameMenuContributor.cs
  4. 1
      templates/service/host/MyCompanyName.MyProjectName.Web.Host/MyCompanyName.MyProjectName.Web.Host.csproj
  5. 19
      templates/service/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs
  6. 18
      templates/service/host/MyCompanyName.MyProjectName.Web.Host/Pages/Index.cshtml
  7. 3
      templates/service/host/MyCompanyName.MyProjectName.Web.Host/Pages/Index.css
  8. 3
      templates/service/host/MyCompanyName.MyProjectName.Web.Host/Pages/Index.js

1
templates/service/host/MyCompanyName.MyProjectName.IdentityServer/MyCompanyName.MyProjectName.IdentityServer.csproj

@ -29,6 +29,7 @@
<ProjectReference Include="..\..\..\..\modules\identity\src\Volo.Abp.Identity.EntityFrameworkCore\Volo.Abp.Identity.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\..\..\modules\identity\src\Volo.Abp.Identity.Application\Volo.Abp.Identity.Application.csproj" />
<ProjectReference Include="..\..\..\..\modules\identity\src\Volo.Abp.Identity.HttpApi\Volo.Abp.Identity.HttpApi.csproj" />
<ProjectReference Include="..\..\..\..\modules\identity\src\Volo.Abp.PermissionManagement.Domain.Identity\Volo.Abp.PermissionManagement.Domain.Identity.csproj" />
<ProjectReference Include="..\..\..\..\modules\tenant-management\src\Volo.Abp.TenantManagement.EntityFrameworkCore\Volo.Abp.TenantManagement.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\..\..\modules\tenant-management\src\Volo.Abp.TenantManagement.Application\Volo.Abp.TenantManagement.Application.csproj" />
<ProjectReference Include="..\..\..\..\modules\tenant-management\src\Volo.Abp.TenantManagement.HttpApi\Volo.Abp.TenantManagement.HttpApi.csproj" />

2
templates/service/host/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs

@ -25,6 +25,7 @@ using Volo.Abp.Modularity;
using Volo.Abp.PermissionManagement;
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.PermissionManagement.HttpApi;
using Volo.Abp.PermissionManagement.Identity;
using Volo.Abp.SettingManagement.EntityFrameworkCore;
using Volo.Abp.TenantManagement;
using Volo.Abp.TenantManagement.EntityFrameworkCore;
@ -45,6 +46,7 @@ namespace MyCompanyName.MyProjectName
typeof(AbpIdentityApplicationModule),
typeof(AbpIdentityHttpApiModule),
typeof(AbpIdentityServerEntityFrameworkCoreModule),
typeof(AbpPermissionManagementDomainIdentityModule),
typeof(AbpPermissionManagementEntityFrameworkCoreModule),
typeof(AbpPermissionManagementApplicationModule),
typeof(AbpPermissionManagementHttpApiModule),

34
templates/service/host/MyCompanyName.MyProjectName.Web.Host/Menus/MyProjectNameMenuContributor.cs

@ -1,34 +0,0 @@
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization;
using MyCompanyName.MyProjectName.Localization;
using MyCompanyName.MyProjectName.MultiTenancy;
using Volo.Abp.TenantManagement.Web.Navigation;
using Volo.Abp.UI.Navigation;
namespace MyCompanyName.MyProjectName.Menus
{
public class MyProjectNameMenuContributor : IMenuContributor
{
public async Task ConfigureMenuAsync(MenuConfigurationContext context)
{
if (context.Menu.Name == StandardMenus.Main)
{
await ConfigureMainMenuAsync(context);
}
}
private async Task ConfigureMainMenuAsync(MenuConfigurationContext context)
{
if (!MultiTenancyConsts.IsEnabled)
{
var administration = context.Menu.GetAdministration();
administration.TryRemoveMenuItem(TenantManagementMenuNames.GroupName);
}
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<MyProjectNameResource>>();
context.Menu.Items.Insert(0, new ApplicationMenuItem("MyProjectName.Home", l["Menu:Home"], "/"));
}
}
}

1
templates/service/host/MyCompanyName.MyProjectName.Web.Host/MyCompanyName.MyProjectName.Web.Host.csproj

@ -24,6 +24,7 @@
<ProjectReference Include="..\..\..\..\modules\identity\src\Volo.Abp.Identity.HttpApi.Client\Volo.Abp.Identity.HttpApi.Client.csproj" />
<ProjectReference Include="..\..\..\..\modules\tenant-management\src\Volo.Abp.TenantManagement.Web\Volo.Abp.TenantManagement.Web.csproj" />
<ProjectReference Include="..\..\..\..\modules\tenant-management\src\Volo.Abp.TenantManagement.HttpApi.Client\Volo.Abp.TenantManagement.HttpApi.Client.csproj" />
<ProjectReference Include="..\..\..\..\modules\permission-management\src\Volo.Abp.PermissionManagement.HttpApi.Client\Volo.Abp.PermissionManagement.HttpApi.Client.csproj" />
</ItemGroup>
<ItemGroup>

19
templates/service/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs

@ -5,7 +5,7 @@ using Microsoft.Extensions.DependencyInjection;
using MyCompanyName.MyProjectName.Menus;
using Swashbuckle.AspNetCore.Swagger;
using System.IO;
using Microsoft.AspNetCore.Authentication.OAuth.Claims;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.Extensions.Configuration;
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
@ -27,7 +27,9 @@ using Volo.Abp.Identity;
using Volo.Abp.Identity.Web;
using Volo.Abp.Modularity;
using Volo.Abp.MultiTenancy;
using Volo.Abp.PermissionManagement;
using Volo.Abp.PermissionManagement.Web;
using Volo.Abp.Security.Claims;
using Volo.Abp.TenantManagement;
using Volo.Abp.TenantManagement.Web;
using Volo.Abp.Ui.Navigation.Urls;
@ -48,7 +50,8 @@ namespace MyCompanyName.MyProjectName
typeof(AbpIdentityWebModule),
typeof(AbpIdentityHttpApiClientModule),
typeof(AbpTenantManagementWebModule),
typeof(AbpTenantManagementHttpApiClientModule)
typeof(AbpTenantManagementHttpApiClientModule),
typeof(AbpPermissionManagementHttpApiClientModule)
)]
public class MyProjectNameWebModule : AbpModule
{
@ -74,7 +77,6 @@ namespace MyCompanyName.MyProjectName
ConfigureAuthentication(context, configuration);
ConfigureAutoMapper();
ConfigureVirtualFileSystem(hostingEnvironment);
ConfigureNavigationServices();
ConfigureSwaggerServices(context.Services);
ConfigureMultiTenancy();
ConfigureRedis(context, configuration, hostingEnvironment);
@ -125,7 +127,8 @@ namespace MyCompanyName.MyProjectName
options.Scope.Add("phone");
options.Scope.Add("MyProjectName");
options.ClaimActions.MapAbpClaimTypes();
options.ClaimActions.MapJsonKey(AbpClaimTypes.UserName, "name");
options.ClaimActions.DeleteClaim("name");
});
}
@ -163,14 +166,6 @@ namespace MyCompanyName.MyProjectName
}
}
private void ConfigureNavigationServices()
{
Configure<NavigationOptions>(options =>
{
options.MenuContributors.Add(new MyProjectNameMenuContributor());
});
}
private void ConfigureSwaggerServices(IServiceCollection services)
{
services.AddSwaggerGen(

18
templates/service/host/MyCompanyName.MyProjectName.Web.Host/Pages/Index.cshtml

@ -2,26 +2,20 @@
@using MyCompanyName.MyProjectName.Pages
@inherits MyProjectNamePageBase
@model IndexModel
@section styles {
<abp-style-bundle>
<abp-style src="/Pages/Index.css" />
</abp-style-bundle>
}
@section scripts {
<abp-script-bundle>
<abp-script src="/Pages/Index.js" />
</abp-script-bundle>
}
<abp-card>
<abp-card-header>@L["Welcome"]</abp-card-header>
<abp-card-header>Welcome</abp-card-header>
<abp-card-body>
<p>@L["LongWelcomeMessage"]</p>
@if (!CurrentUser.IsAuthenticated)
{
<form method="POST">
<input type="submit" asp-page-handler="Login" value="LOGIN" class="btn btn-login" />
</form>
}
else
{
<strong>Claims</strong><br />
@Html.Raw(CurrentUser.GetAllClaims().Select(c => $"{c.Type}={c.Value}").OrderBy(x => x).JoinAsString(" <br /> "))
}
<hr />
<p class="text-right"><a href="https://abp.io?ref=tmpl" target="_blank">abp.io</a></p>
</abp-card-body>

3
templates/service/host/MyCompanyName.MyProjectName.Web.Host/Pages/Index.css

@ -1,3 +0,0 @@
body {
}

3
templates/service/host/MyCompanyName.MyProjectName.Web.Host/Pages/Index.js

@ -1,3 +0,0 @@
$(function () {
abp.log.debug('Index.js initialized!');
});
Loading…
Cancel
Save