Browse Source

Merge branch 'dev' into blazor-bundle-cli-command

pull/6034/head
Ilkay Ilknur 6 years ago
parent
commit
d463bda3f3
  1. 46
      docs/en/Community-Articles/2020-11-02-How-To-Add-New-Language/POST.md
  2. BIN
      docs/en/Community-Articles/2020-11-02-How-To-Add-New-Language/add-to-languages.png
  3. BIN
      docs/en/Community-Articles/2020-11-02-How-To-Add-New-Language/database-table.png
  4. BIN
      docs/en/Community-Articles/2020-11-02-How-To-Add-New-Language/language-target.png
  5. BIN
      docs/en/Community-Articles/2020-11-02-How-To-Add-New-Language/website-new-language.png
  6. 14
      framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LanguageSwitch.razor
  7. 22
      framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor
  8. 4
      framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/NavToolbar.razor
  9. 1
      framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/ExceptionHandling/UserExceptionInformer.cs
  10. 2
      framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/Messages/SimpleUiMessageService.cs
  11. 22
      framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/AbpComponentBase.cs
  12. 0
      framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/IUiMessageService.cs
  13. 0
      framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageEventArgs.cs
  14. 0
      framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageOptions.cs
  15. 0
      framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageType.cs
  16. 0
      framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/IUiNotificationService.cs
  17. 0
      framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/NullUiNotificationService.cs
  18. 0
      framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/UiNotificationEventArgs.cs
  19. 0
      framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/UiNotificationOptions.cs
  20. 0
      framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/UiNotificationType.cs
  21. 14
      framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/DefaultHttpExceptionStatusCodeFinder.cs
  22. 5
      framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs
  23. 14
      framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiNotificationService.cs
  24. 1
      framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor.cs
  25. 7
      framework/src/Volo.Abp.Core/Volo/Abp/ExceptionHandling/IHasHttpStatusCode.cs
  26. 4
      framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/AbpRemoteCallException.cs
  27. 16
      framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs
  28. 6
      framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/PropertyApiDescriptionModel.cs
  29. 11
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameBrandingProvider.cs

46
docs/en/Community-Articles/2020-11-02-How-To-Add-New-Language/POST.md

@ -0,0 +1,46 @@
# How to add a new language to your ABP project?
Adding a new language to your ABP project is pretty simple. Let's add the German language to our ABP project:
1. Go to your solution's root folder and write the following CLI command. This command will generate an empty translation file from English.
```bash
abp translate -c de-DE
```
Check out for [the complete supported culture codes](https://docs.microsoft.com/en-us/bingmaps/rest-services/common-parameters-and-types/supported-culture-codes).
(For internal development `D:\Github\abp` and `D:\Github\volo\abp`)
2. Fill the `target` fields in your target language.
![Fill target fields](language-target.png)
3. Copy `abp-translation.json` your solution's root folder (Do not change the filename!)
4. Run the following command. This command will create the necessary `json` files.
```bash
abp translate --apply
```
5. Open your solution and add the new language to the language list. To do this;
* open `MyProjectNameDomainModule.cs` and in `ConfigureServices` you'll find `Configure<AbpLocalizationOptions>`. If you have `HttpApi.Host` project then you need to add this in `MyProjectNameHttpApiHostModule.cs`
```
options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsche", "de"));
```
![Add to languages](add-to-languages.png)
The last parameter is the flag icon. You can find the list of flag icons on https://flagicons.lipis.dev/
6. The last step is running the DbMigrator project. It will seed the database for the new language.
![The database table](database-table.png)
Close the IIS Express / Kestrel to invalidate the language cache and run the project. You will see the new language on your website.
![See the final result](website-new-language.png)

BIN
docs/en/Community-Articles/2020-11-02-How-To-Add-New-Language/add-to-languages.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
docs/en/Community-Articles/2020-11-02-How-To-Add-New-Language/database-table.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
docs/en/Community-Articles/2020-11-02-How-To-Add-New-Language/language-target.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

BIN
docs/en/Community-Articles/2020-11-02-How-To-Add-New-Language/website-new-language.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

14
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LanguageSwitch.razor

@ -5,17 +5,17 @@
@inject IJSRuntime JsRuntime
@if (_otherLanguages != null && _otherLanguages.Any())
{
<Dropdown>
<DropdownToggle Color="Color.None">
<BarDropdown>
<BarDropdownToggle>
@_currentLanguage.DisplayName
</DropdownToggle>
<DropdownMenu>
</BarDropdownToggle>
<BarDropdownMenu RightAligned="true">
@foreach (var language in _otherLanguages)
{
<DropdownItem Clicked="() => ChangeLanguageAsync(language)">@language.DisplayName</DropdownItem>
<BarDropdownItem Clicked="() => ChangeLanguageAsync(language)">@language.DisplayName</BarDropdownItem>
}
</DropdownMenu>
</Dropdown>
</BarDropdownMenu>
</BarDropdown>
}
@code {
private IReadOnlyList<LanguageInfo> _otherLanguages;

22
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor

@ -7,8 +7,8 @@
@inject SignOutSessionStateManager SignOutManager
<AuthorizeView>
<Authorized>
<Dropdown>
<DropdownToggle Color="Color.None">
<BarDropdown>
<BarDropdownToggle>
@if (CurrentTenant.Name != null)
{
<span><i>@CurrentTenant.Name</i>\@CurrentUser.UserName</span>
@ -17,25 +17,25 @@
{
<span>@CurrentUser.UserName</span>
}
</DropdownToggle>
<DropdownMenu>
</BarDropdownToggle>
<BarDropdownMenu RightAligned="true">
@if (Menu != null)
{
@foreach (var menuItem in Menu.Items)
{
<DropdownItem Clicked="@(() => NavigateTo(menuItem.Url))">@menuItem.DisplayName</DropdownItem>
<BarDropdownItem Clicked="@(() => NavigateTo(menuItem.Url))">@menuItem.DisplayName</BarDropdownItem>
}
}
<a class="dropdown-item" href="@ServerAccountUrl">
<BarDropdownItem To="@ServerAccountUrl">
@UiLocalizer["ManageYourAccount"]
</a>
</BarDropdownItem>
<DropdownDivider />
<DropdownItem Clicked="BeginSignOut">Logout</DropdownItem>
</DropdownMenu>
</Dropdown>
<BarDropdownItem Clicked="BeginSignOut">Logout</BarDropdownItem>
</BarDropdownMenu>
</BarDropdown>
</Authorized>
<NotAuthorized>
<a class="nav-link" href="authentication/login">Log in</a>
<BarLink To="authentication/login">Log in</BarLink>
</NotAuthorized>
</AuthorizeView>
@code{

4
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/NavToolbar.razor

@ -1,8 +1,8 @@
<ul class="navbar-nav">
@foreach (var render in ToolbarItemRenders)
{
<li class="nav-item">
<BarItem>
@render
</li>
</BarItem>
}
</ul>

1
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/ExceptionHandling/UserExceptionInformer.cs

@ -1,5 +1,4 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Volo.Abp.AspNetCore.ExceptionHandling;

2
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/SimpleUiMessageService.cs → framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/Messages/SimpleUiMessageService.cs

@ -3,7 +3,7 @@ using System.Threading.Tasks;
using Microsoft.JSInterop;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.AspNetCore.Components.WebAssembly
namespace Volo.Abp.AspNetCore.Components.WebAssembly.Messages
{
public class SimpleUiMessageService : IUiMessageService, ITransientDependency
{

22
framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/AbpComponentBase.cs

@ -5,6 +5,7 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Volo.Abp.AspNetCore.Components.WebAssembly;
using Volo.Abp.Localization;
using Volo.Abp.ObjectMapping;
using Volo.Abp.Users;
@ -53,6 +54,12 @@ namespace Volo.Abp.AspNetCore.Components
protected ICurrentUser CurrentUser => LazyGetRequiredService(ref _currentUser);
private ICurrentUser _currentUser;
protected IUiMessageService Message => LazyGetNonScopedRequiredService(ref _message);
private IUiMessageService _message;
protected IUiNotificationService Notify => LazyGetNonScopedRequiredService(ref _notify);
private IUiNotificationService _notify;
protected IObjectMapper ObjectMapper
{
get
@ -90,6 +97,21 @@ namespace Volo.Abp.AspNetCore.Components
return reference;
}
protected TService LazyGetNonScopedRequiredService<TService>(ref TService reference) => LazyGetNonScopedRequiredService(typeof(TService), ref reference);
protected TRef LazyGetNonScopedRequiredService<TRef>(Type serviceType, ref TRef reference)
{
if (reference == null)
{
reference = (TRef)NonScopedServices.GetRequiredService(serviceType);
}
return reference;
}
[Inject]
protected IServiceProvider NonScopedServices { get; set; }
protected virtual IStringLocalizer CreateLocalizer()
{
if (LocalizationResource != null)

0
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/IUiMessageService.cs → framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/IUiMessageService.cs

0
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/UiMessageEventArgs.cs → framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageEventArgs.cs

0
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/UiMessageOptions.cs → framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageOptions.cs

0
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/UiMessageType.cs → framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageType.cs

0
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/IUiNotificationService.cs → framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/IUiNotificationService.cs

0
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/NullUiNotificationService.cs → framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/NullUiNotificationService.cs

0
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/UiNotificationEventArgs.cs → framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/UiNotificationEventArgs.cs

0
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/UiNotificationOptions.cs → framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/UiNotificationOptions.cs

0
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/UiNotificationType.cs → framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/UiNotificationType.cs

14
framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/DefaultHttpExceptionStatusCodeFinder.cs

@ -22,7 +22,13 @@ namespace Volo.Abp.AspNetCore.ExceptionHandling
public virtual HttpStatusCode GetStatusCode(HttpContext httpContext, Exception exception)
{
if (exception is IHasErrorCode exceptionWithErrorCode &&
if (exception is IHasHttpStatusCode exceptionWithHttpStatusCode &&
exceptionWithHttpStatusCode.HttpStatusCode > 0)
{
return (HttpStatusCode) exceptionWithHttpStatusCode.HttpStatusCode;
}
if (exception is IHasErrorCode exceptionWithErrorCode &&
!exceptionWithErrorCode.Code.IsNullOrWhiteSpace())
{
if (Options.ErrorCodeToHttpStatusCodeMappings.TryGetValue(exceptionWithErrorCode.Code, out var status))
@ -39,7 +45,7 @@ namespace Volo.Abp.AspNetCore.ExceptionHandling
}
//TODO: Handle SecurityException..?
if (exception is AbpValidationException)
{
return HttpStatusCode.BadRequest;
@ -59,8 +65,8 @@ namespace Volo.Abp.AspNetCore.ExceptionHandling
{
return HttpStatusCode.Forbidden;
}
return HttpStatusCode.InternalServerError;
}
}
}
}

5
framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs

@ -172,7 +172,6 @@ namespace Volo.Abp.BlazoriseUI
{
[Inject] protected TAppService AppService { get; set; }
[Inject] protected IStringLocalizer<AbpUiResource> UiLocalizer { get; set; }
[Inject] protected IAuthorizationService AuthorizationService { get; set; }
protected virtual int PageSize { get; } = LimitedResultRequestDto.DefaultMaxResultCount;
@ -350,7 +349,7 @@ namespace Volo.Abp.BlazoriseUI
protected virtual async Task CreateEntityAsync()
{
if (CreateValidationsRef?.ValidateAll() ?? false)
if (CreateValidationsRef?.ValidateAll() ?? true)
{
await OnCreatingEntityAsync();
@ -377,7 +376,7 @@ namespace Volo.Abp.BlazoriseUI
protected virtual async Task UpdateEntityAsync()
{
if (EditValidationsRef?.ValidateAll() ?? false)
if (EditValidationsRef?.ValidateAll() ?? true)
{
await OnUpdatingEntityAsync();

14
framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiNotificationService.cs

@ -1,7 +1,5 @@
using System;
using System.Threading.Tasks;
using Localization.Resources.AbpUi;
using Microsoft.Extensions.Localization;
using Volo.Abp.AspNetCore.Components.WebAssembly;
using Volo.Abp.DependencyInjection;
@ -15,14 +13,6 @@ namespace Volo.Abp.BlazoriseUI
/// </summary>
public event EventHandler<UiNotificationEventArgs> NotificationReceived;
private readonly IStringLocalizer<AbpUiResource> localizer;
public BlazoriseUiNotificationService(
IStringLocalizer<AbpUiResource> localizer)
{
this.localizer = localizer;
}
public Task Info(string message, string title = null, Action<UiNotificationOptions> options = null)
{
var uiNotificationOptions = CreateDefaultOptions();
@ -65,9 +55,7 @@ namespace Volo.Abp.BlazoriseUI
protected virtual UiNotificationOptions CreateDefaultOptions()
{
return new UiNotificationOptions
{
};
return new UiNotificationOptions();
}
}
}

1
framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor.cs

@ -1,6 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Blazorise;
using Localization.Resources.AbpUi;
using Microsoft.AspNetCore.Components;

7
framework/src/Volo.Abp.Core/Volo/Abp/ExceptionHandling/IHasHttpStatusCode.cs

@ -0,0 +1,7 @@
namespace Volo.Abp.ExceptionHandling
{
public interface IHasHttpStatusCode
{
int HttpStatusCode { get; }
}
}

4
framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/AbpRemoteCallException.cs

@ -5,8 +5,10 @@ using Volo.Abp.ExceptionHandling;
namespace Volo.Abp.Http.Client
{
[Serializable]
public class AbpRemoteCallException : AbpException, IHasErrorCode, IHasErrorDetails
public class AbpRemoteCallException : AbpException, IHasErrorCode, IHasErrorDetails, IHasHttpStatusCode
{
public int HttpStatusCode { get; set; }
public string Code => Error?.Code;
public string Details => Error?.Details;

16
framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs

@ -252,10 +252,22 @@ namespace Volo.Abp.Http.Client.DynamicProxying
await response.Content.ReadAsStringAsync()
);
throw new AbpRemoteCallException(errorResponse.Error);
throw new AbpRemoteCallException(errorResponse.Error)
{
HttpStatusCode = (int) response.StatusCode
};
}
throw new AbpException($"Remote service returns error! HttpStatusCode: {response.StatusCode}, ReasonPhrase: {response.ReasonPhrase}");
throw new AbpRemoteCallException(
new RemoteServiceErrorInfo
{
Message = response.ReasonPhrase,
Code = response.StatusCode.ToString()
}
)
{
HttpStatusCode = (int) response.StatusCode
};
}
protected virtual CancellationToken GetCancellationToken()

6
framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/PropertyApiDescriptionModel.cs

@ -1,4 +1,5 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Reflection;
namespace Volo.Abp.Http.Modeling
@ -12,6 +13,8 @@ namespace Volo.Abp.Http.Modeling
public string TypeSimple { get; set; }
public bool IsRequired { get; set; }
//TODO: Validation rules for this property
public static PropertyApiDescriptionModel Create(PropertyInfo propertyInfo)
{
@ -19,7 +22,8 @@ namespace Volo.Abp.Http.Modeling
{
Name = propertyInfo.Name,
Type = ApiTypeNameHelper.GetTypeName(propertyInfo.PropertyType),
TypeSimple = ApiTypeNameHelper.GetSimpleTypeName(propertyInfo.PropertyType)
TypeSimple = ApiTypeNameHelper.GetSimpleTypeName(propertyInfo.PropertyType),
IsRequired = propertyInfo.IsDefined(typeof(RequiredAttribute), true)
};
}
}

11
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameBrandingProvider.cs

@ -0,0 +1,11 @@
using Volo.Abp.DependencyInjection;
using Volo.Abp.Ui.Branding;
namespace MyCompanyName.MyProjectName
{
[Dependency(ReplaceServices = true)]
public class MyProjectNameBrandingProvider : DefaultBrandingProvider
{
public override string AppName => "MyProjectName";
}
}
Loading…
Cancel
Save