mirror of https://github.com/abpframework/abp.git
696 changed files with 41328 additions and 9767 deletions
@ -1,5 +1,7 @@ |
|||
{ |
|||
"culture": "tr", |
|||
"texts": { |
|||
"AbpTitle": "ABP Framework - Açık Kaynak Web Uygulama Çerçevesi", |
|||
"AbpDescription": "ABP, AspNet Core tabanlı web uygulaması geliştirmeye odaklanan açık kaynaklı bir uygulama çerçevesidir. Kendinizi tekrar etmeyin, kendi iş kodunuza odaklanın." |
|||
} |
|||
} |
|||
@ -0,0 +1,76 @@ |
|||
# ABP.IO Platform 6.0 Final Has Been Released! |
|||
|
|||
[ABP Framework](https://abp.io/) and [ABP Commercial](https://commercial.abp.io/) 6.0 versions have been released today. |
|||
|
|||
## What's New With 6.0? |
|||
|
|||
Since all the new features are already explained in details with the [6.0 RC Announcement Post](https://blog.abp.io/abp/ABP.IO-Platform-6.0-RC-Has-Been-Published), I will not repeat all the details again. See the [RC Blog Post](https://blog.abp.io/abp/ABP.IO-Platform-6.0-RC-Has-Been-Published) for all the features and enhancements. |
|||
|
|||
## Getting Started with 6.0 |
|||
|
|||
### Creating New Solutions |
|||
|
|||
You can create a new solution with the ABP Framework version 6.0 by either using the `abp new` command or using the **direct download** tab on the [get started page](https://abp.io/get-started). |
|||
|
|||
> See the [getting started document](https://docs.abp.io/en/abp/latest/Getting-Started) for more. |
|||
|
|||
### How to Upgrade an Existing Solution |
|||
|
|||
#### Install/Update the ABP CLI |
|||
|
|||
First of all, install the ABP CLI or upgrade to the latest version. |
|||
|
|||
If you haven't installed it yet: |
|||
|
|||
```bash |
|||
dotnet tool install -g Volo.Abp.Cli |
|||
``` |
|||
|
|||
To update an existing installation: |
|||
|
|||
```bash |
|||
dotnet tool update -g Volo.Abp.Cli |
|||
``` |
|||
|
|||
#### Upgrading Existing Solutions with the ABP Update Command |
|||
|
|||
[ABP CLI](https://docs.abp.io/en/abp/latest/CLI) provides a handy command to update all the ABP related NuGet and NPM packages in your solution with a single command: |
|||
|
|||
```bash |
|||
abp update |
|||
``` |
|||
|
|||
Run this command in the root folder of your solution. |
|||
|
|||
## Migration Guides |
|||
|
|||
Check the following migration guides for the applications with version 5.3 that are upgrading to version 6.0. |
|||
|
|||
* [ABP Framework 5.3 to 6.0 Migration Guide](https://docs.abp.io/en/abp/6.0/Migration-Guides/Abp-6_0) |
|||
* [ABP Commercial 5.3 to 6.0 Migration Guide](https://docs.abp.io/en/commercial/6.0/migration-guides/v6_0) |
|||
|
|||
## Community News |
|||
|
|||
### New ABP Community Posts |
|||
|
|||
Here are some of the recent posts added to the [ABP Community](https://community.abp.io/): |
|||
|
|||
* [Halil Ibrahim Kalkan](https://twitter.com/hibrahimkalkan) has created two new community articles: |
|||
* [Consuming gRPC Services from Blazor WebAssembly Application Using gRPC-Web](https://community.abp.io/posts/consuming-grpc-services-from-blazor-webassembly-application-using-grpcweb-dqjry3rv) |
|||
* [Using gRPC with the ABP Framework](https://community.abp.io/posts/using-grpc-with-the-abp-framework-2dgaxzw3) |
|||
* [Malik Masis](https://twitter.com/malikmasis) also has created two new community articles: |
|||
* [Consuming HTTP APIs from a .NET Client Using ABP's Client Proxy System](https://community.abp.io/posts/consuming-http-apis-from-a-.net-client-using-abps-client-proxy-system-xriqarrm) |
|||
* [Using MassTransit via eShopOnAbp](https://community.abp.io/posts/using-masstransit-via-eshoponabp-8amok6h8) |
|||
* [Xeevis](https://community.abp.io/members/Xeevis) has created her/his first community article, that shows [Prerendering in Blazor WASM applications](https://community.abp.io/posts/prerendering-blazor-wasm-application-with-abp-6.x-2v8590g3). |
|||
* [Don Boutwell](https://community.abp.io/members/dboutwell) has created two new community articles: |
|||
* [Logging to Datadog from ABP framework](https://community.abp.io/posts/logging-to-datadog-from-abp-framework-fm4ozds4) |
|||
* [Configuring Multiple DbContexts in an ABP Framework Project](https://community.abp.io/posts/configuring-multiple-dbcontexts-in-an-abp-framework-project-uoz5is3o) |
|||
* [Kirti Kulkarni](https://twitter.com/kirtimkulkarni) has created a new community article: [Deploying ABP angular application to Azure and App Insights integration](https://community.abp.io/posts/deploying-abp-angular-application-to-azure-and-app-insights-integration-4jrhtp01) |
|||
|
|||
Thanks to the ABP Community for all the contents they have published. You can also [post your ABP related (text or video) contents](https://community.abp.io/articles/submit) to the ABP Community. |
|||
|
|||
## About the Next Version |
|||
|
|||
The next feature version will be 7.0. It is planned to release the 7.0 RC (Release Candidate) on November 15 and the final version on December 13, 2022. You can follow the [release planning here](https://github.com/abpframework/abp/milestones). |
|||
|
|||
Please [submit an issue](https://github.com/abpframework/abp/issues/new) if you have any problems with this version. |
|||
@ -0,0 +1,244 @@ |
|||
# Using gRPC with the ABP Framework |
|||
|
|||
[gRPC](https://grpc.io/) defines itself as an open source, language agnostic, universal, high-performance **Remote Procedure Call (RPC)** framework. |
|||
|
|||
In this article, I will show you how to create a gRPC service and consume it from a console application with the ABP Framework. While the client application is console in this article, it can easily be a service consuming another service in a microservice system. |
|||
|
|||
> **This article will be a step by step tutorial.** I wrote the article based on Microsoft's [Code-first gRPC services and clients with .NET](https://docs.microsoft.com/en-us/aspnet/core/grpc/code-first) document. You can read that document for more details about gRPC and the code-first approach. |
|||
|
|||
## Creating the Application |
|||
|
|||
> I will use ABP version 6.0 for this article. I am using the 6.0.0-rc.4 version since the stable version hasn't been published at the time I am writing this article. If it is released while you're reading this, do not specify the `--version` and `--preview` parameters in the following commands. |
|||
|
|||
Install the [ABP CLI](https://docs.abp.io/en/abp/latest/CLI) if you haven't installed it yet: |
|||
|
|||
````bash |
|||
dotnet tool install -g Volo.Abp.Cli --version 6.0.0-rc.4 |
|||
```` |
|||
|
|||
or update to version 6.0.0-rc.4 if you've already installed a previous version: |
|||
|
|||
````bash |
|||
dotnet tool update Volo.Abp.Cli -g --version 6.0.0-rc.4 |
|||
```` |
|||
|
|||
Create an empty folder, open a command-line terminal and type the following command in the terminal window to create a new ABP solution using the ABP CLI: |
|||
|
|||
````bash |
|||
abp new ProductManagement -u blazor -t app --preview |
|||
```` |
|||
|
|||
I've created an application with the Blazor UI, but the UI is not important for this tutorial, you can select your favorite UI option. |
|||
|
|||
## Open the Solution |
|||
|
|||
Open the solution in your favorite IDE. I like [Rider](https://www.jetbrains.com/rider/), but Visual Studio, VS Code or any other IDE perfectly works. The following figure shows the solution structure in Rider: |
|||
|
|||
 |
|||
|
|||
Run the `ProductManagement.DbMigrator` project (a console application) to create the database and seed the initial data. |
|||
|
|||
## Defining the Service Contract |
|||
|
|||
We are starting by defining the service contract and DTO classes that will be shared between the server and the client applications. |
|||
|
|||
Create a `Products` folder in the `ProductManagement.Application.Contracts` project and add a new interface named `IProductAppService`: |
|||
|
|||
````csharp |
|||
using System.Collections.Generic; |
|||
using System.ServiceModel; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
namespace ProductManagement.Products; |
|||
|
|||
[ServiceContract] |
|||
public interface IProductAppService : IApplicationService |
|||
{ |
|||
Task<List<ProductDto>> GetListAsync(); |
|||
} |
|||
```` |
|||
|
|||
Your IDE will complain about the `[ServiceContract]` attribute, but it is necessary for the contract-first gRPC library we will be using later. So, add the [System.ServiceModel.Primitives](https://www.nuget.org/packages/System.ServiceModel.Primitives) NuGet package to the `ProductManagement.Application.Contracts` project, and it should be fixed. You can simply edit the `ProductManagement.Application.Contracts.csproj` file and add the following line in an `ItemGroup` tag: |
|||
|
|||
````xml |
|||
<PackageReference Include="System.ServiceModel.Primitives" Version="4.7.0" /> |
|||
```` |
|||
|
|||
Or you can use your IDE to find and add that NuGet package, it is up to you. |
|||
|
|||
I've also used the `ProductDto` class, but haven't defined it yet. Create a new class in the same folder with the `IProductAppService` file: |
|||
|
|||
````csharp |
|||
using System; |
|||
using System.Runtime.Serialization; |
|||
|
|||
namespace ProductManagement.Products; |
|||
|
|||
[DataContract] |
|||
public class ProductDto |
|||
{ |
|||
[DataMember(Order = 1)] |
|||
public Guid Id { get; set; } |
|||
|
|||
[DataMember(Order = 2)] |
|||
public string Name { get; set; } |
|||
} |
|||
```` |
|||
|
|||
The `[DataContract]` and `[DataMember]` properties are needed for serialization. In gRPC, property serialization orders are important, because property names are not transferred to the target application, to keep the serialized data small. |
|||
|
|||
After adding these classes, the `ProductManagement.Application.Contracts` project should look as in the following figure: |
|||
|
|||
 |
|||
|
|||
The contracts part is over. We actually didn't have any dependency to gRPC at that point. Our service and DTOs are pretty plain classes, except a few standard attributes, which are already defined in the .NET Core framework. Now, we can implement the `IProductAppService`. |
|||
|
|||
## Implementing the Service |
|||
|
|||
We are implementing the application services in the `ProductManagement.Application` project. So, add a new `Products` folder to that project and define a `ProductAppService` class inside it: |
|||
|
|||
````csharp |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace ProductManagement.Products; |
|||
|
|||
public class ProductAppService : ProductManagementAppService, IProductAppService |
|||
{ |
|||
public async Task<List<ProductDto>> GetListAsync() |
|||
{ |
|||
return new List<ProductDto> |
|||
{ |
|||
new ProductDto { Id = Guid.NewGuid(), Name = "Product 1" }, |
|||
new ProductDto { Id = Guid.NewGuid(), Name = "Product 2" }, |
|||
}; |
|||
} |
|||
} |
|||
```` |
|||
|
|||
This is a pretty standard, plain [application service ](https://docs.abp.io/en/abp/latest/Application-Services)class. All the ABP application service features (validation, audit logging, unit of work, etc.) are available. You can inject [repositories](https://docs.abp.io/en/abp/latest/Repositories) and perform database queries. To keep this article simple, I am returning hard-coded data from here. |
|||
|
|||
> `ProductManagementAppService` is a base class coming in the ABP startup template. While you don't have to inherit from it, it provides useful base properties and methods you typically need in an application service. |
|||
|
|||
The application service part is over. Again, we didn't write any gRPC specific code. Don't worry, we will write in the next section. |
|||
|
|||
## Configuring the gRPC Server |
|||
|
|||
In this solution, `ProductManagement.HttpApi.Host` is the project that configures and runs the server-side application. So, we will make changes in that project. |
|||
|
|||
First, add the [protobuf-net.Grpc.AspNetCore](https://www.nuget.org/packages/protobuf-net.Grpc.AspNetCore) NuGet package to the `ProductManagement.HttpApi.Host` project: |
|||
|
|||
````xml |
|||
<PackageReference Include="protobuf-net.Grpc.AspNetCore" Version="1.0.177" /> |
|||
```` |
|||
|
|||
Then open the `ProductManagementHttpApiHostModule.cs` file, find the `ConfigureServices` method and add the following line into this method: |
|||
|
|||
````csharp |
|||
context.Services.AddCodeFirstGrpc(); |
|||
```` |
|||
|
|||
This will register code-first gRPC services to the [dependency injection](https://docs.abp.io/en/abp/latest/Dependency-Injection) system. Then find the `app.UseConfiguredEndpoints()` line in the `OnApplicationInitialization` method and change it as shown below: |
|||
|
|||
````csharp |
|||
app.UseConfiguredEndpoints(endpoints => |
|||
{ |
|||
endpoints.MapGrpcService<IProductAppService>(); |
|||
}); |
|||
```` |
|||
|
|||
We've configured the `IProductAppService` to handle gRPC requests to that service. The following figure shows the whole change done in the `ProductManagementHttpApiHostModule` class: |
|||
|
|||
 |
|||
|
|||
gRPC handles requests with the HTTP/2 protocol and should listen an endpoint other than the default HTTP endpoint used by the application. We can easily configure the Kestrel server to listen two endpoints, one for our HTTP APIs, the other one for gRPC services. Add the following configuration inside the `appsettings.json` file of the `ProductManagement.HttpApi.Host` project: |
|||
|
|||
````json |
|||
"Kestrel": { |
|||
"Endpoints": { |
|||
"Https": { |
|||
"Url": "https://localhost:44388", |
|||
"Protocols": "Http1AndHttp2" |
|||
}, |
|||
"gRPC": { |
|||
"Url": "https://localhost:10042", |
|||
"Protocols": "Http2" |
|||
} |
|||
} |
|||
} |
|||
```` |
|||
|
|||
Note that `https://localhost:44388` may be different for your case, since ABP CLI assignes a random port while you're creating a new solution. You can check your port by running the `ProductManagement.HttpApi.Host` project and looking at the address bar on your browser. |
|||
|
|||
The server-side configuration is done. It is ready to receive gRPC requests. Now, we can change the client to consume the gRPC service we've created. |
|||
|
|||
## Implementing the Client Side |
|||
|
|||
The ABP startup solution template comes with a console application to test consuming your HTTP APIs. For this example, the project is named as `ProductManagement.HttpApi.Client.ConsoleTestApp` and located under the `test` folder in the solution. |
|||
|
|||
First, add the [Grpc.Net.Client](https://www.nuget.org/packages/Grpc.Net.Client) and the [protobuf-net.Grpc](https://www.nuget.org/packages/protobuf-net.Grpc) NuGet packages to the `ProductManagement.HttpApi.Client.ConsoleTestApp` project. |
|||
|
|||
````xml |
|||
<PackageReference Include="Grpc.Net.Client" Version="2.49.0-pre1" /> |
|||
<PackageReference Include="protobuf-net.Grpc" Version="1.0.177" /> |
|||
```` |
|||
|
|||
Now, open the `ClientDemoService.cs` file under the `ProductManagement.HttpApi.Client.ConsoleTestApp` project and change its contents with the following code block: |
|||
|
|||
````csharp |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Grpc.Net.Client; |
|||
using ProductManagement.Products; |
|||
using ProtoBuf.Grpc.Client; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace ProductManagement.HttpApi.Client.ConsoleTestApp; |
|||
|
|||
public class ClientDemoService : ITransientDependency |
|||
{ |
|||
public async Task RunAsync() |
|||
{ |
|||
using (var channel = GrpcChannel.ForAddress("https://localhost:10042")) |
|||
{ |
|||
var productAppService = channel.CreateGrpcService<IProductAppService>(); |
|||
var productDtos = await productAppService.GetListAsync(); |
|||
|
|||
foreach (var productDto in productDtos) |
|||
{ |
|||
Console.WriteLine($"[Product] Id = {productDto.Id}, Name = {productDto.Name}"); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
```` |
|||
|
|||
We are simply creating a gRPC channel, then creating a client proxy for the `IProductAppService` service. Then we can call its method just like local method calls. You can run the applications to test it. |
|||
|
|||
## Run the Applications |
|||
|
|||
First run the `ProductManagement.HttpApi.Host` application. It should show a Swagger UI as shown below: |
|||
|
|||
 |
|||
|
|||
If you see that page, it means your server-side is up and running. Now, you can run the `ProductManagement.HttpApi.Client.ConsoleTestApp` console application to call the gRPC service defined on the server. |
|||
|
|||
The test console application should produce an output as shown below: |
|||
|
|||
 |
|||
|
|||
As you see, products are returned from the server. That's all, you've done it! |
|||
|
|||
## Conclusion |
|||
|
|||
In this article, I've used the [code-first approach](https://docs.microsoft.com/en-us/aspnet/core/grpc/code-first) to implement a gRPC server and consume it in a client application. Code-first approach is very practical if both of your client and server applications are built with .NET. By the help of ABP's layered solution structure, we even didn't add any gRPC dependency into our server-side and contracts. We've just configured gRPC in the hosting side, with a small amount of code. |
|||
|
|||
gRPC on .NET has different approaches, features, configurations and more details. I suggest you to read [Microsoft's documentation](https://docs.microsoft.com/en-us/aspnet/core/grpc) to learn more about it. All the approaches can work with the ABP Framework. Enjoy coding! |
|||
|
|||
## The Source Code |
|||
|
|||
* You can find the completed source code here: https://github.com/abpframework/abp-samples/tree/master/GrpcDemo2 |
|||
|
|||
* You can also see all the changes I've done in this article here: https://github.com/abpframework/abp-samples/pull/200/files |
|||
|
After Width: | Height: | Size: 70 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 116 KiB |
|
After Width: | Height: | Size: 85 KiB |
|
After Width: | Height: | Size: 48 KiB |
@ -0,0 +1,121 @@ |
|||
# Consuming gRPC Services from Blazor WebAssembly Application Using gRPC-Web |
|||
|
|||
> **WARNING: I've demonstrated [Using gRPC with the ABP Framework](https://community.abp.io/posts/using-grpc-with-the-abp-framework-2dgaxzw3) in my latest post. If you haven't seen it, you should read it before this article, since this is a continuation of that article.** |
|||
|
|||
In this second part, I will show how to consume the gRPC service from the Blazor WebAssembly application, using the gRPC-Web technology. |
|||
|
|||
This will be a short article, based on Microsoft's [gRPC-Web in ASP.NET Core gRPC apps](https://learn.microsoft.com/en-us/aspnet/core/grpc/grpcweb) and [Code-first gRPC services and clients with .NET](https://learn.microsoft.com/en-us/aspnet/core/grpc/code-first) documents. For more information, I suggest to check these documents. Let's get started... |
|||
|
|||
## Configuring the Server Side |
|||
|
|||
First of all, the server-side should support gRPC-Web. Follow the steps below to enable it: |
|||
|
|||
### Add Grpc.AspNetCore.Web Package |
|||
|
|||
Add [Grpc.AspNetCore.Web](https://www.nuget.org/packages/Grpc.AspNetCore.Web) NuGet package to the `ProductManagement.HttpApi.Host` project. |
|||
|
|||
### Add GrpcWeb Middleware |
|||
|
|||
Add the following line just before the `app.UseConfiguredEndpoints(...)` line to add the GrpcWeb middleware to your ASP.NET Core request pipeline: |
|||
|
|||
````csharp |
|||
app.UseGrpcWeb(new GrpcWebOptions { DefaultEnabled = true }); |
|||
```` |
|||
|
|||
### Configure Cors |
|||
|
|||
ABP's startup template already configures Cors when you create a new solution. However, we need to allow some extra headers in our Cors configuration. |
|||
|
|||
Add the following line just after the `.WithAbpExposedHeaders()` line in the `OnApplicationInitialization` method of the `ProductManagementHttpApiHostModule` class: |
|||
|
|||
````csharp |
|||
.WithExposedHeaders("Grpc-Status", "Grpc-Message", "Grpc-Encoding", "Grpc-Accept-Encoding") |
|||
```` |
|||
|
|||
Finally, call `RequireCors` extension method just after the `MapGrpcService` calls: |
|||
|
|||
````csharp |
|||
app.UseConfiguredEndpoints(endpoints => |
|||
{ |
|||
endpoints |
|||
.MapGrpcService<IProductAppService>() |
|||
.RequireCors("__DefaultCorsPolicy"); // Configure Cors for the product service |
|||
}); |
|||
```` |
|||
|
|||
`__DefaultCorsPolicy` may seem a magic string here. Let me explain it: ABP startup template configures the default Cors policy with the `context.Services.AddCors(...)` method (you can see it in the source code). If we define a named policy, we should use the same name here. However, when we don't specify, ASP.NET Core uses `__DefaultCorsPolicy` as the policy name by default. If you don't want to use the magic string, you can resolve the `IOptions<CorsOptions>` service and get the `DefaultPolicyName` from the `CorsOption` object. |
|||
|
|||
Anyway, that's all on the server-side. We can work on he client now. |
|||
|
|||
## Configuring the Client Side |
|||
|
|||
`ProductManagement.Blazor` is the Blazor WebAssembly application in the solution I'd created in the [first article](https://community.abp.io/posts/using-grpc-with-the-abp-framework-2dgaxzw3). We will configure that project to be able to consume the server-side gRPC services from our Blazor application. |
|||
|
|||
### Add Client-side Nuget Packages |
|||
|
|||
Add [Grpc.Net.Client](https://www.nuget.org/packages/Grpc.Net.Client), [Grpc.Net.Client.Web](https://www.nuget.org/packages/Grpc.Net.Client.Web) and [protobuf-net.Grpc](https://www.nuget.org/packages/protobuf-net.Grpc) NuGet packages to the `ProductManagement.Blazor` project. We are ready to consume the gRPC services. |
|||
|
|||
### Consume the Product Service |
|||
|
|||
Change the `Pages/Index.razor.cs` file's content with the following code block: |
|||
|
|||
````csharp |
|||
using System.Collections.Generic; |
|||
using System.Net.Http; |
|||
using System.Threading.Tasks; |
|||
using Grpc.Net.Client; |
|||
using Grpc.Net.Client.Web; |
|||
using ProductManagement.Products; |
|||
using ProtoBuf.Grpc.Client; |
|||
|
|||
namespace ProductManagement.Blazor.Pages; |
|||
|
|||
public partial class Index |
|||
{ |
|||
private List<ProductDto> Products { get; set; } = new(); |
|||
|
|||
protected override async Task OnInitializedAsync() |
|||
{ |
|||
var channel = GrpcChannel.ForAddress("https://localhost:10042", new GrpcChannelOptions |
|||
{ |
|||
HttpHandler = new GrpcWebHandler(new HttpClientHandler()) |
|||
}); |
|||
|
|||
var productAppService = channel.CreateGrpcService<IProductAppService>(); |
|||
Products = await productAppService.GetListAsync(); |
|||
} |
|||
} |
|||
```` |
|||
|
|||
* We've created a gRPC channel for the server-side endpoint (surely, you get the address from a configuration) with channel options by specifying that we will use the `GrpcWebHandler`. |
|||
* We've created a service proxy object using the `CreateGrpcService` extension method that is defined by the [protobuf-net.Grpc](https://www.nuget.org/packages/protobuf-net.Grpc) NuGet package. |
|||
* We've used the service proxy object, `productAppService`, to consume remote endpoint just like a local service. |
|||
|
|||
That's all. If we want to show the products on the page, we can add the following markup into the `Pages/Index.razor` view: |
|||
|
|||
````xml |
|||
<h2>A list of products:</h2> |
|||
|
|||
<ul class="list-group"> |
|||
@foreach(var product in Products) |
|||
{ |
|||
<li class="list-group-item"> |
|||
@product.Name <br/> |
|||
<small>@product.Id.ToString()</small> |
|||
</li> |
|||
} |
|||
</ul> |
|||
```` |
|||
|
|||
Run the applications (first run the `ProductManagement.HttpApi.Host` project, then run the `ProductManagement.Blazor` project in the solution) to see it in action: |
|||
|
|||
 |
|||
|
|||
## Conclusion |
|||
|
|||
In the first part of this article, I'd demonstrated how to implement a gRPC service and consume it in a client application, using the [code-first approach](https://docs.microsoft.com/en-us/aspnet/core/grpc/code-first). In this article, I've demonstrated how to consume the same gRPC service from a Blazor WebAssembly application, using the [gRPC-Web](https://learn.microsoft.com/en-us/aspnet/core/grpc/grpcweb) technology. As you see in these two articles, using gRPC with the ABP Framework is straightforward. |
|||
|
|||
## The Source Code |
|||
|
|||
- You can find the completed source code here: https://github.com/abpframework/abp-samples/tree/master/GrpcDemo2 |
|||
- You can also see all the changes I've done in this article here: https://github.com/abpframework/abp-samples/pull/201/files |
|||
|
After Width: | Height: | Size: 10 KiB |
@ -0,0 +1,469 @@ |
|||
# ABP Dapr Integration |
|||
|
|||
> This document assumes that you are already familiar with [Dapr](https://dapr.io/) and you want to use it in your ABP based applications. |
|||
|
|||
[Dapr](https://dapr.io/) (Distributed Application Runtime) provides APIs that simplify microservice connectivity. It is an open source project that is mainly backed by Microsoft. It is also a CNCF (Cloud Native Computing Foundation) project and trusted by the community. |
|||
|
|||
ABP and Dapr have some intersecting features like service-to-service communication, distributed message bus and distributed locking. However their purposes are totally different. ABP's goal is to provide an end-to-end developer experience by offering an opinionated architecture and providing the necessary infrastructure libraries, reusable modules and tools to implement that architecture properly. Dapr's purpose, on the other hand, is to provide a runtime to decouple common microservice communication patterns from your application logic. |
|||
|
|||
ABP and Dapr can perfectly work together in the same application. ABP offers some packages to provide better integration where Dapr features intersect with ABP. You can use other Dapr features with no ABP integration packages based on [its own documentation](https://docs.dapr.io/). |
|||
|
|||
## ABP Dapr Integration Packages |
|||
|
|||
ABP provides the following NuGet packages for the Dapr integration: |
|||
|
|||
* [Volo.Abp.Dapr](https://www.nuget.org/packages/Volo.Abp.Dapr): The main Dapr integration package. All other packages depend on this package. |
|||
* [Volo.Abp.Http.Client.Dapr](https://www.nuget.org/packages/Volo.Abp.Http.Client.Dapr): Integration package for ABP's [dynamic](../API/Dynamic-CSharp-API-Clients.md) and [static](../API/Static-CSharp-API-Clients.md) C# API Client Proxies systems with Dapr's [service invocation](https://docs.dapr.io/developing-applications/building-blocks/service-invocation/service-invocation-overview/) building block. |
|||
* [Volo.Abp.EventBus.Dapr](https://www.nuget.org/packages/Volo.Abp.EventBus.Dapr): Implements ABP's distributed event bus with Dapr's [publish & subscribe](https://docs.dapr.io/developing-applications/building-blocks/pubsub/) building block. With this package, you can send events, but can not receive. |
|||
* [Volo.Abp.AspNetCore.Mvc.Dapr.EventBus](https://www.nuget.org/packages/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus): Provides the endpoints to receive events from Dapr's [publish & subscribe](https://docs.dapr.io/developing-applications/building-blocks/pubsub/) building block. Use this package to send and receive events. |
|||
* [Volo.Abp.DistributedLocking.Dapr](https://www.nuget.org/packages/Volo.Abp.DistributedLocking.Dapr): Uses Dapr's [distributed lock](https://docs.dapr.io/developing-applications/building-blocks/distributed-lock/) building block for [distributed locking](../Distributed-Locking.md) service of the ABP Framework. |
|||
|
|||
In the following sections, we will see how to use these packages to use Dapr in your ABP based solutions. |
|||
|
|||
## Basics |
|||
|
|||
### Installation |
|||
|
|||
> This section explains how to add [Volo.Abp.Dapr](https://www.nuget.org/packages/Volo.Abp.Dapr), the core Dapr integration package to your project. If you are using one of the other Dapr integration packages, you can skip this section since this package will be indirectly added. |
|||
|
|||
Use the ABP CLI to add the [Volo.Abp.Dapr](https://www.nuget.org/packages/Volo.Abp.Dapr) NuGet package to your project: |
|||
|
|||
* Install the [ABP CLI](https://docs.abp.io/en/abp/latest/CLI) if you haven't installed it before. |
|||
* Open a command line (terminal) in the directory of the `.csproj` file you want to add the `Volo.Abp.Dapr` package. |
|||
* Run the `abp add-package Volo.Abp.Dapr` command. |
|||
|
|||
If you want to do it manually, install the [Volo.Abp.Dapr](https://www.nuget.org/packages/Volo.Abp.Dapr) NuGet package to your project and add `[DependsOn(typeof(AbpDaprModule))]` to the [ABP module](../Module-Development-Basics.md) class inside your project. |
|||
|
|||
### AbpDaprOptions |
|||
|
|||
`AbpDaprOptions` is the main [options class](../Options.md) that you can configure the global Dapr settings with. **All settings are optional and you mostly don't need to configure them.** If you need, you can configure it in the `ConfigureServices` method of your [module class](../Module-Development-Basics.md): |
|||
|
|||
````csharp |
|||
Configure<AbpDaprOptions>(options => |
|||
{ |
|||
// ... |
|||
}); |
|||
```` |
|||
|
|||
Available properties of the `AbpDaprOptions` class: |
|||
|
|||
* `HttpEndpoint` (optional): HTTP endpoint that is used while creating a `DaprClient` object. If you don't specify, the default value is used. |
|||
* `GrpcEndpoint` (optional): The gRPC endpoint that is used while creating a `DaprClient` object. If you don't specify, the default value is used. |
|||
* `DaprApiToken` (optional): The [Dapr API token](https://docs.dapr.io/operations/security/api-token/) that is used while sending requests from the application to Dapr. It is filled from the `DAPR_API_TOKEN` environment variable by default (which is set by Dapr once it is configured). See the *Security* section in this document for details. |
|||
* `AppApiToken` (optional): The [App API token](https://docs.dapr.io/operations/security/app-api-token/) that is used to validate requests coming from Dapr. It is filled from the `APP_API_TOKEN` environment variable by default (which is set by Dapr once it is configured). See the *Security* section in this document for details. |
|||
|
|||
Alternatively, you can configure the options in the `Dapr` section of your `appsettings.json` file. Example: |
|||
|
|||
````csharp |
|||
"Dapr": { |
|||
"HttpEndpoint": "http://localhost:3500/" |
|||
} |
|||
```` |
|||
|
|||
### Injecting DaprClient |
|||
|
|||
ABP registers the `DaprClient` class to the [dependency injection](../Dependency-Injection.md) system. So, you can inject and use it whenever you need: |
|||
|
|||
````csharp |
|||
public class MyService : ITransientDependency |
|||
{ |
|||
private readonly DaprClient _daprClient; |
|||
|
|||
public MyService(DaprClient daprClient) |
|||
{ |
|||
_daprClient = daprClient; |
|||
} |
|||
|
|||
public async Task DoItAsync() |
|||
{ |
|||
// TODO: Use the injected _daprClient object |
|||
} |
|||
} |
|||
```` |
|||
|
|||
Injecting `DaprClient` is the recommended way of using it in your application code. When you inject it, the `IAbpDaprClientFactory` service is used to create it, which is explained in the next section. |
|||
|
|||
### IAbpDaprClientFactory |
|||
|
|||
`IAbpDaprClientFactory` can be used to create `DaprClient` or `HttpClient` objects to perform operations on Dapr. It uses `AbpDaprOptions`, so you can configure the settings in a central place. |
|||
|
|||
**Example usages:** |
|||
|
|||
````csharp |
|||
public class MyService : ITransientDependency |
|||
{ |
|||
private readonly IAbpDaprClientFactory _daprClientFactory; |
|||
|
|||
public MyService(IAbpDaprClientFactory daprClientFactory) |
|||
{ |
|||
_daprClientFactory = daprClientFactory; |
|||
} |
|||
|
|||
public async Task DoItAsync() |
|||
{ |
|||
// Create a DaprClient object with default options |
|||
DaprClient daprClient = await _daprClientFactory.CreateAsync(); |
|||
|
|||
/* Create a DaprClient object with configuring |
|||
* the DaprClientBuilder object */ |
|||
DaprClient daprClient2 = await _daprClientFactory |
|||
.CreateAsync(builder => |
|||
{ |
|||
builder.UseDaprApiToken("..."); |
|||
}); |
|||
|
|||
// Create an HttpClient object |
|||
HttpClient httpClient = await _daprClientFactory |
|||
.CreateHttpClientAsync("target-app-id"); |
|||
} |
|||
} |
|||
```` |
|||
|
|||
`CreateHttpClientAsync` method also gets optional `daprEndpoint` and `daprApiToken` parameters. |
|||
|
|||
> ABP uses `IAbpDaprClientFactory` when it needs to create a Dapr client. You can also use Dapr API to create client objects in your application. Using `IAbpDaprClientFactory` is recommended, but not required. |
|||
|
|||
## C# API Client Proxies Integration |
|||
|
|||
ABP can [dynamically](../API/Dynamic-CSharp-API-Clients.md) or [statically](../API/Static-CSharp-API-Clients.md) generate proxy classes to invoke your HTTP APIs from a Dotnet client application. It makes perfect sense to consume HTTP APIs in a distributed system. The [Volo.Abp.Http.Client.Dapr](https://www.nuget.org/packages/Volo.Abp.Http.Client.Dapr) package configures the client-side proxies system, so it uses Dapr's service invocation building block for the communication between your applications. |
|||
|
|||
### Installation |
|||
|
|||
Use the ABP CLI to add the [Volo.Abp.Http.Client.Dapr](https://www.nuget.org/packages/Volo.Abp.Http.Client.Dapr) NuGet package to your project (to the client side): |
|||
|
|||
* Install the [ABP CLI](https://docs.abp.io/en/abp/latest/CLI) if you haven't installed before. |
|||
* Open a command line (terminal) in the directory of the `.csproj` file you want to add the `Volo.Abp.Http.Client.Dapr` package to. |
|||
* Run the `abp add-package Volo.Abp.Http.Client.Dapr` command. |
|||
|
|||
If you want to do it manually, install the [Volo.Abp.Http.Client.Dapr](https://www.nuget.org/packages/Volo.Abp.Http.Client.Dapr) NuGet package to your project and add `[DependsOn(typeof(AbpHttpClientDaprModule))]` to the [ABP module](../Module-Development-Basics.md) class inside your project. |
|||
|
|||
### Configuration |
|||
|
|||
Once you install the [Volo.Abp.Http.Client.Dapr](https://www.nuget.org/packages/Volo.Abp.Http.Client.Dapr) NuGet package, all you need to do is to configure ABP's remote services option either in `appsettings.json` or using the `AbpRemoteServiceOptions` [options class](../Options.md). |
|||
|
|||
**Example:** |
|||
|
|||
````csharp |
|||
{ |
|||
"RemoteServices": { |
|||
"Default": { |
|||
"BaseUrl": "http://dapr-httpapi/" |
|||
} |
|||
} |
|||
} |
|||
```` |
|||
|
|||
`dapr-httpapi` in this example is the application id of the server application in your Dapr configuration. |
|||
|
|||
The remote service name (`Default` in this example) should match the remote service name specified in the `AddHttpClientProxies` call for dynamic client proxies or the `AddStaticHttpClientProxies` call for static client proxies. Using `Default` is fine if your client communicates to a single server. However, if your client uses multiple servers, you typically have multiple keys in the `RemoteServices` configuration. Once you configure the remote service endpoints as Dapr application ids, it will automatically work and make the HTTP calls through Dapr when you use ABP's client proxy system. |
|||
|
|||
> See the [dynamic](../API/Dynamic-CSharp-API-Clients.md) and [static](../API/Static-CSharp-API-Clients.md) client proxy documents for details about the ABP's client proxy system. |
|||
|
|||
## Distributed Event Bus Integration |
|||
|
|||
[ABP's distributed event bus](../Distributed-Event-Bus.md) system provides a convenient abstraction to allow applications to communicate asynchronously via events. ABP has integration packages with various distributed messaging systems, like RabbitMQ, Kafka, and Azure. Dapr also has a [publish & subscribe building block](https://docs.dapr.io/developing-applications/building-blocks/pubsub/pubsub-overview/) for the same purpose: distributed messaging / events. |
|||
|
|||
ABP's [Volo.Abp.EventBus.Dapr](https://www.nuget.org/packages/Volo.Abp.EventBus.Dapr) and [Volo.Abp.AspNetCore.Mvc.Dapr.EventBus](https://www.nuget.org/packages/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus) packages make it possible to use the Dapr infrastructure for ABP's distributed event bus. |
|||
|
|||
The [Volo.Abp.EventBus.Dapr](https://www.nuget.org/packages/Volo.Abp.EventBus.Dapr) package can be used by any type of application (e.g., a Console or ASP.NET Core application) to publish events through Dapr. To be able to receive messages (by subscribing to events), you need to have the [Volo.Abp.AspNetCore.Mvc.Dapr.EventBus](https://www.nuget.org/packages/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus) package installed, and your application should be an ASP.NET Core application. |
|||
|
|||
### Installation |
|||
|
|||
If your application is an ASP.NET Core application and you want to send and receive events, you need to install the [Volo.Abp.AspNetCore.Mvc.Dapr.EventBus](https://www.nuget.org/packages/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus) package as described below: |
|||
|
|||
* Install the [ABP CLI](https://docs.abp.io/en/abp/latest/CLI) if you haven't installed it before. |
|||
* Open a command line (terminal) in the directory of the `.csproj` file you want to add the `Volo.Abp.AspNetCore.Mvc.Dapr.EventBus` package to. |
|||
* Run the `abp add-package Volo.Abp.AspNetCore.Mvc.Dapr.EventBus` command. |
|||
|
|||
If you want to do it manually, install the [Volo.Abp.AspNetCore.Mvc.Dapr.EventBus](https://www.nuget.org/packages/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus) NuGet package to your project and add `[DependsOn(typeof(AbpAspNetCoreMvcDaprEventBusModule))]` to the [ABP module](../Module-Development-Basics.md) class inside your project. |
|||
|
|||
> **If you install the [Volo.Abp.AspNetCore.Mvc.Dapr.EventBus](https://www.nuget.org/packages/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus) package, you don't need to install the [Volo.Abp.EventBus.Dapr](https://www.nuget.org/packages/Volo.Abp.EventBus.Dapr) package, because the first one already has a reference to the latter one.** |
|||
|
|||
If your application is not an ASP.NET Core application, you can't receive events from Dapr, at least with ABP's integration packages (see [Dapr's document](https://docs.dapr.io/developing-applications/building-blocks/pubsub/howto-publish-subscribe/) if you want to receive events in a different type of application). However, you can still publish messages using the [Volo.Abp.EventBus.Dapr](https://www.nuget.org/packages/Volo.Abp.EventBus.Dapr) package. In this case, follow the steps below to install that package to your project: |
|||
|
|||
* Install the [ABP CLI](https://docs.abp.io/en/abp/latest/CLI) if you haven't installed it before. |
|||
* Open a command line (terminal) in the directory of the `.csproj` file you want to add the `Volo.Abp.EventBus.Dapr` package to. |
|||
* Run the `abp add-package Volo.Abp.EventBus.Dapr` command. |
|||
|
|||
If you want to do it manually, install the [Volo.Abp.EventBus.Dapr](https://www.nuget.org/packages/Volo.Abp.EventBus.Dapr) NuGet package to your project and add `[DependsOn(typeof(AbpEventBusDaprModule))]` to the [ABP module](../Module-Development-Basics.md) class inside your project. |
|||
|
|||
### Configuration |
|||
|
|||
You can configure the `AbpDaprEventBusOptions` [options class](../Options.md) for Dapr configuration: |
|||
|
|||
````csharp |
|||
Configure<AbpDaprEventBusOptions>(options => |
|||
{ |
|||
options.PubSubName = "pubsub"; |
|||
}); |
|||
```` |
|||
|
|||
Available properties of the `AbpDaprEventBusOptions` class: |
|||
|
|||
* `PubSubName` (optional): The `pubsubName` parameter while publishing messages through the `DaprClient.PublishEventAsync` method. Default value: `pubsub`. |
|||
|
|||
### The ABP Subscription Endpoints |
|||
|
|||
ABP provides the following endpoints to receive events from Dapr: |
|||
|
|||
* `dapr/subscribe`: Dapr uses this endpoint to get a list of subscriptions from the application. ABP automatically returns all the subscriptions for your distributed event handler classes and custom controller actions with the `Topic` attribute. |
|||
* `api/abp/dapr/event`: The unified endpoint to receive all the events from Dapr. ABP dispatches the events to your event handlers based on the topic name. |
|||
|
|||
> **Since ABP provides the standard `dapr/subscribe` endpoint, you should not manually call the `app.MapSubscribeHandler()` method of Dapr.** You can use the `app.UseCloudEvents()` middleware in your ASP.NET Core pipeline if you want to support the [CloudEvents](https://cloudevents.io/) standard. |
|||
|
|||
### Usage |
|||
|
|||
#### The ABP Way |
|||
|
|||
You can follow [ABP's distributed event bus documentation](../Distributed-Event-Bus.md) to learn how to publish and subscribe to events in the ABP way. No change required in your application code to use Dapr pub-sub. ABP will automatically subscribe to Dapr for your event handler classes (that implement the `IDistributedEventHandler` interface). |
|||
|
|||
ABP provides `api/abp/dapr/event` |
|||
|
|||
**Example: Publish an event using the `IDistributedEventBus` service** |
|||
|
|||
````csharp |
|||
public class MyService : ITransientDependency |
|||
{ |
|||
private readonly IDistributedEventBus _distributedEventBus; |
|||
|
|||
public MyService(IDistributedEventBus distributedEventBus) |
|||
{ |
|||
_distributedEventBus = distributedEventBus; |
|||
} |
|||
|
|||
public async Task DoItAsync() |
|||
{ |
|||
await _distributedEventBus.PublishAsync(new StockCountChangedEto |
|||
{ |
|||
ProductCode = "AT837234", |
|||
NewStockCount = 42 |
|||
}); |
|||
} |
|||
} |
|||
```` |
|||
|
|||
**Example: Subscribe to an event by implementing the `IDistributedEventHandler` interface** |
|||
|
|||
````csharp |
|||
public class MyHandler : |
|||
IDistributedEventHandler<StockCountChangedEto>, |
|||
ITransientDependency |
|||
{ |
|||
public async Task HandleEventAsync(StockCountChangedEto eventData) |
|||
{ |
|||
var productCode = eventData.ProductCode; |
|||
// ... |
|||
} |
|||
} |
|||
```` |
|||
|
|||
See [ABP's distributed event bus documentation](../Distributed-Event-Bus.md) to learn the details. |
|||
|
|||
#### Using the Dapr API |
|||
|
|||
In addition to ABP's standard distributed event bus system, you can also use Dapr's API to publish events. |
|||
|
|||
> If you directly use the Dapr API to publish events, you may not benefit from ABP's standard distributed event bus features, like the outbox/inbox pattern implementation. |
|||
|
|||
**Example: Publish an event using `DaprClient`** |
|||
|
|||
````csharp |
|||
public class MyService : ITransientDependency |
|||
{ |
|||
private readonly DaprClient _daprClient; |
|||
|
|||
public MyService(DaprClient daprClient) |
|||
{ |
|||
_daprClient = daprClient; |
|||
} |
|||
|
|||
public async Task DoItAsync() |
|||
{ |
|||
await _daprClient.PublishEventAsync( |
|||
"pubsub", // pubsub name |
|||
"StockChanged", // topic name |
|||
new StockCountChangedEto // event data |
|||
{ |
|||
ProductCode = "AT837234", |
|||
NewStockCount = 42 |
|||
} |
|||
); |
|||
} |
|||
} |
|||
```` |
|||
|
|||
**Example: Subscribe to an event by creating an ASP.NET Core controller** |
|||
|
|||
````csharp |
|||
public class MyController : AbpController |
|||
{ |
|||
[HttpPost("/stock-changed")] |
|||
[Topic("pubsub", "StockChanged")] |
|||
public async Task<IActionResult> TestRouteAsync( |
|||
[FromBody] StockCountChangedEto model) |
|||
{ |
|||
HttpContext.ValidateDaprAppApiToken(); |
|||
|
|||
// Do something with the event |
|||
return Ok(); |
|||
} |
|||
} |
|||
```` |
|||
|
|||
`HttpContext.ValidateDaprAppApiToken()` extension method is provided by ABP to check if the request is coming from Dapr. This is optional. You should configure Dapr to send the App API token to your application if you want to enable the validation. If not configured, `ValidateDaprAppApiToken()` does nothing. See [Dapr's App API Token document](https://docs.dapr.io/operations/security/app-api-token/) for more information. Also see the *AbpDaprOptions* and *Security* sections in this document. |
|||
|
|||
See the [Dapr documentation](https://docs.microsoft.com/en-us/dotnet/architecture/dapr-for-net-developers/publish-subscribe) to learn the details of sending & receiving events with the Dapr API. |
|||
|
|||
## Distributed Lock |
|||
|
|||
> Dapr's distributed lock feature is currently in the Alpha stage and may not be stable yet. It is not suggested to replace ABP's distributed lock with Dapr in that point. |
|||
|
|||
ABP provides a [Distributed Locking](../Distributed-Locking.md) abstraction to control access to a shared resource by multiple applications. Dapr also has a [distributed lock building block](https://docs.dapr.io/developing-applications/building-blocks/distributed-lock/). The [Volo.Abp.DistributedLocking.Dapr](https://www.nuget.org/packages/Volo.Abp.DistributedLocking.Dapr) package makes ABP use Dapr's distributed locking system. |
|||
|
|||
### Installation |
|||
|
|||
Use the ABP CLI to add the [Volo.Abp.DistributedLocking.Dapr](https://www.nuget.org/packages/Volo.Abp.DistributedLocking.Dapr) NuGet package to your project (to the client side): |
|||
|
|||
* Install the [ABP CLI](https://docs.abp.io/en/abp/latest/CLI) if you haven't installed it before. |
|||
* Open a command line (terminal) in the directory of the `.csproj` file you want to add the `Volo.Abp.DistributedLocking.Dapr` package to. |
|||
* Run the `abp add-package Volo.Abp.DistributedLocking.Dapr` command. |
|||
|
|||
If you want to do it manually, install the [Volo.Abp.DistributedLocking.Dapr](https://www.nuget.org/packages/Volo.Abp.DistributedLocking.Dapr) NuGet package to your project and add `[DependsOn(typeof(AbpDistributedLockingDaprModule))]` to the [ABP module](../Module-Development-Basics.md) class inside your project. |
|||
|
|||
### Configuration |
|||
|
|||
You can use the `AbpDistributedLockDaprOptions` options class in the `ConfigureServices` method of [your module](../Module-Development-Basics.md) to configure the Dapr distributed lock: |
|||
|
|||
````csharp |
|||
Configure<AbpDistributedLockDaprOptions>(options => |
|||
{ |
|||
options.StoreName = "mystore"; |
|||
}); |
|||
```` |
|||
|
|||
The following options are available: |
|||
|
|||
* **`StoreName`** (required): The store name used by Dapr. Lock key names are scoped in the same store. That means different applications can acquire the same lock name in different stores. Use the same store name for the same resources you want to control the access of. |
|||
* `Owner` (optional): The `owner` value used by the `DaprClient.Lock` method. If you don't specify, ABP uses a random value, which is fine in general. |
|||
* `DefaultExpirationTimeout` (optional): Default value of the time after which the lock gets expired. Default value: 2 minutes. |
|||
|
|||
### Usage |
|||
|
|||
You can inject and use the `IAbpDistributedLock` service, just like explained in the [Distributed Locking document](../Distributed-Locking.md). |
|||
|
|||
**Example:** |
|||
|
|||
````csharp |
|||
public class MyService : ITransientDependency |
|||
{ |
|||
private readonly IAbpDistributedLock _distributedLock; |
|||
|
|||
public MyService(IAbpDistributedLock distributedLock) |
|||
{ |
|||
_distributedLock = distributedLock; |
|||
} |
|||
|
|||
public async Task MyMethodAsync() |
|||
{ |
|||
await using (var handle = |
|||
await _distributedLock.TryAcquireAsync("MyLockName")) |
|||
{ |
|||
if (handle != null) |
|||
{ |
|||
// your code that access the shared resource |
|||
} |
|||
} |
|||
} |
|||
} |
|||
```` |
|||
|
|||
There are two points we should mention about the `TryAcquireAsync` method, as different from ABP's standard usage: |
|||
|
|||
* The `timeout` parameter is currently not used (even if you specify it), because Dapr doesn't support waiting to obtain the lock. |
|||
* Dapr uses the expiration timeout system (that means the lock is automatically released after that timeout even if you don't release the lock by disposing the handler). However, ABP's `TryAcquireAsync` method has no such a parameter. Currently, you can set `AbpDistributedLockDaprOptions.DefaultExpirationTimeout` as a global value in your application. |
|||
|
|||
As mentioned first, Dapr's distributed lock feature is currently in the Alpha stage and its API is a candidate to change. You should use it as is if you want, but be ready for the changes in the future. For now, we are recommending to use the [DistributedLock](https://github.com/madelson/DistributedLock) library as explained in ABP's [Distributed Locking document](../Distributed-Locking.md). |
|||
|
|||
## Security |
|||
|
|||
If you are using Dapr, most or all the incoming and outgoing requests in your application pass through Dapr. Dapr uses two kinds of API tokens to secure the communication between your application and Dapr. |
|||
|
|||
### Dapr API Token |
|||
|
|||
> This token is automatically set by default and generally you don't care about it. |
|||
|
|||
The [Enable API token authentication in Dapr](https://docs.dapr.io/operations/security/api-token/) document describes what the Dapr API token is and how it is configured. Please read that document if you want to enable it for your application. |
|||
|
|||
If you enable the Dapr API token, you should send that token in every request to Dapr from your application. `AbpDaprOptions` defines a `DaprApiToken` property as a central point to configure the Dapr API token in your application. |
|||
|
|||
The default value of the `DaprApiToken` property is set from the `DAPR_API_TOKEN` environment variable and that environment variable is set by Dapr when it runs. So, most of the time, you don't need to configure `AbpDaprOptions.DaprApiToken` in your application. However, if you need to configure (or override) it, you can do in the `ConfigureServices` method of your module class as shown in the following code block: |
|||
|
|||
````csharp |
|||
Configure<AbpDaprOptions>(options => |
|||
{ |
|||
options.DaprApiToken = "..."; |
|||
}); |
|||
```` |
|||
|
|||
Or you can set it in your `appsettings.json` file: |
|||
|
|||
````json |
|||
"Dapr": { |
|||
"DaprApiToken": "..." |
|||
} |
|||
```` |
|||
|
|||
Once you set it, it is used when you inject `DaprClient` or use `IAbpDaprClientFactory`. If you need that value in your application, you can inject `IDaprApiTokenProvider` and use its `GetDaprApiToken()` method. |
|||
|
|||
### App API Token |
|||
|
|||
> Enabling App API token validation is strongly recommended. Otherwise, for example, any client can directly call your event subscription endpoint, and your application acts like an event has occurred (if there is no other security policy in your event subscription endpoint). |
|||
|
|||
The [Authenticate requests from Dapr using token authentication](https://docs.dapr.io/operations/security/app-api-token/) document describes what the App API token is and how it is configured. Please read that document if you want to enable it for your application. |
|||
|
|||
If you enable the App API token, you can validate it to ensure that the request is coming from Dapr. ABP provides useful shortcuts to validate it. |
|||
|
|||
**Example: Validate the App API token in an event handling HTTP API** |
|||
|
|||
````csharp |
|||
public class MyController : AbpController |
|||
{ |
|||
[HttpPost("/stock-changed")] |
|||
[Topic("pubsub", "StockChanged")] |
|||
public async Task<IActionResult> TestRouteAsync( |
|||
[FromBody] StockCountChangedEto model) |
|||
{ |
|||
// Validate the App API token! |
|||
HttpContext.ValidateDaprAppApiToken(); |
|||
|
|||
// Do something with the event |
|||
return Ok(); |
|||
} |
|||
} |
|||
```` |
|||
|
|||
`HttpContext.ValidateDaprAppApiToken()` is an extension method provided by the ABP Framework. It throws an `AbpAuthorizationException` if the token was missing or wrong in the HTTP header (the header name is `dapr-api-token`). You can also inject `IDaprAppApiTokenValidator` and use its methods to validate the token in any service (not only in a controller class). |
|||
|
|||
You can configure `AbpDaprOptions.AppApiToken` if you want to set (or override) the App API token value. The default value is set by the `APP_API_TOKEN` environment variable. You can change it in the `ConfigureServices` method of your module class as shown in the following code block: |
|||
|
|||
````csharp |
|||
Configure<AbpDaprOptions>(options => |
|||
{ |
|||
options.AppApiToken = "..."; |
|||
}); |
|||
```` |
|||
|
|||
Or you can set it in your `appsettings.json` file: |
|||
|
|||
````json |
|||
"Dapr": { |
|||
"AppApiToken": "..." |
|||
} |
|||
```` |
|||
|
|||
If you need that value in your application, you can inject `IDaprApiTokenProvider` and use its `GetAppApiToken()` method. |
|||
|
|||
## See Also |
|||
|
|||
* [Dapr for .NET Developers](https://docs.microsoft.com/en-us/dotnet/architecture/dapr-for-net-developers/) |
|||
* [The Official Dapr Documentation](https://docs.dapr.io/) |
|||
@ -0,0 +1,469 @@ |
|||
# ABP Dpar 集成 |
|||
|
|||
> 这个文档假设你已经熟悉[Dapr](https://dapr.io/)并且想在你的ABP应用中使用它. |
|||
|
|||
[Dapr](https://dapr.io/) (分布式应用运行时)提供了简化微服务连接的API.它是一个开源项目,主要由微软支持.它也是CNCF(云原生计算基金会)项目,受到社区的信任. |
|||
|
|||
ABP和Dapr有一些相似的特性,如服务到服务通信,分布式消息总线和分布式锁.然而,它们的目的完全不同.ABP的目标是通过提供自以为是的架构并提供必要的基础架构库,可重用模块和工具来正确实现该架构来提供端到端的开发人员体验.另一方面,Dapr的目的是提供一个运行时,将常见的微服务通信模式与应用程序逻辑解耦. |
|||
|
|||
ABP和Dapr可以完美地在同一个应用程序中一起工作.ABP提供了一些包来提供更好的集成,其中Dapr功能与ABP相似.你可以根据[Dapr文档](https://docs.dapr.io/)使用其他Dapr功能,而不需要ABP集成包. |
|||
|
|||
## ABP Dpar 集成包 |
|||
|
|||
ABP提供了以下NuGet包用于Dapr集成: |
|||
|
|||
* [Volo.Abp.Dapr](https://www.nuget.org/packages/Volo.Abp.Dapr): 主要的Dapr集成包.所有其他包都依赖于此包. |
|||
* [Volo.Abp.Http.Client.Dapr](https://www.nuget.org/packages/Volo.Abp.Http.Client.Dapr): 与Dapr的[服务调用](https://docs.dapr.io/developing-applications/building-blocks/service-invocation/service-invocation-overview/)集成的ABP的[动态](../API/Dynamic-CSharp-API-Clients.md)和[静态](../API/Static-CSharp-API-Clients.md)C# API客户端代理系统集成包. |
|||
* [Volo.Abp.EventBus.Dapr](https://www.nuget.org/packages/Volo.Abp.EventBus.Dapr): 使用Dapr的[发布和订阅](https://docs.dapr.io/developing-applications/building-blocks/pubsub/)构建块实现ABP的分布式事件总线.使用此包,你可以发送事件,但不能接收. |
|||
* [Volo.Abp.AspNetCore.Mvc.Dapr.EventBus](https://www.nuget.org/packages/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus): 提供从Dapr的[发布和订阅](https://docs.dapr.io/developing-applications/building-blocks/pubsub/)构建块接收事件的端点.使用此包发送和接收事件. |
|||
* [Volo.Abp.DistributedLocking.Dapr](https://www.nuget.org/packages/Volo.Abp.DistributedLocking.Dapr): 使用Dapr的[分布式锁](https://docs.dapr.io/developing-applications/building-blocks/distributed-lock/)构建块为ABP框架的[分布式锁定](../Distributed-Locking.md)服务. |
|||
|
|||
在以下部分中,我们将看到如何使用这些包在ABP基础解决方案中使用Dapr. |
|||
|
|||
## 基础 |
|||
|
|||
### 安装 |
|||
|
|||
> 这个部分解释了如何将[Volo.Abp.Dapr](https://www.nuget.org/packages/Volo.Abp.Dapr)添加到你的项目中.如果你使用的是其他Dapr集成包,你可以跳过这个部分,因为这个包会被间接添加. |
|||
|
|||
使用ABP CLI将[Volo.Abp.Dapr](https://www.nuget.org/packages/Volo.Abp.Dapr) NuGet包添加到你的项目中: |
|||
|
|||
* 安装[ABP CLI](https://docs.abp.io/en/abp/latest/CLI)如果你之前没有安装过. |
|||
* 在你想要添加`Volo.Abp.Dapr`包的`.csproj`文件所在的目录中打开命令行(终端). |
|||
* 运行`abp add-package Volo.Abp.Dapr`命令. |
|||
|
|||
如果你想手动添加,安装 [Volo.Abp.Dapr](https://www.nuget.org/packages/Volo.Abp.Dapr) NuGet包到你的项目中,并在项目内的[ABP模块](../Module-Development-Basics.md)类中添加`[DependsOn(typeof(AbpDaprModule))]`. |
|||
|
|||
### AbpDaprOptions |
|||
|
|||
`AbpDaprOptions` 是配置全局Dapr设置的主要[选项类](../Options.md).**所有设置都是可选的,你大多数情况下不需要配置它们.** 如果你需要,你可以在[模块类](../Module-Development-Basics.md)的`ConfigureServices`方法中配置它: |
|||
|
|||
````csharp |
|||
Configure<AbpDaprOptions>(options => |
|||
{ |
|||
// ... |
|||
}); |
|||
```` |
|||
|
|||
可用的`AbpDaprOptions`类属性: |
|||
|
|||
* `HttpEndpoint` (可选):创建`DaprClient`对象时使用的HTTP端点.如果你没有指定,将使用默认值. |
|||
* `GrpcEndpoint` (可选):创建`DaprClient`对象时使用的gRPC端点.如果你没有指定,将使用默认值. |
|||
* `DaprApiToken` (可选):应用程序向Dapr发送请求时使用的[Dapr API token](https://docs.dapr.io/operations/security/api-token/).默认情况下,它从`DAPR_API_TOKEN`环境变量中填充(配置后由 Dapr 设置).有关详细信息,请参阅本文档的*安全*部分. |
|||
* `AppApiToken` (可选):用于验证来自Dapr的请求的[应用程序API token](https://docs.dapr.io/operations/security/app-api-token/).默认情况下,它从`APP_API_TOKEN`环境变量中填充(配置后由 Dapr 设置).有关详细信息,请参阅本文档的*安全*部分. |
|||
|
|||
或者, 你可以在 `appsettings.json` 文件的 `Dapr` 部分中配置选项.示例: |
|||
|
|||
````csharp |
|||
"Dapr": { |
|||
"HttpEndpoint": "http://localhost:3500/" |
|||
} |
|||
```` |
|||
|
|||
### 注入DaprClient |
|||
|
|||
ABP 将 `DaprClient` 类注册到 [依赖注入](../Dependency-Injection.md) 系统中.因此,你可以在需要时注入并使用它: |
|||
|
|||
````csharp |
|||
public class MyService : ITransientDependency |
|||
{ |
|||
private readonly DaprClient _daprClient; |
|||
|
|||
public MyService(DaprClient daprClient) |
|||
{ |
|||
_daprClient = daprClient; |
|||
} |
|||
|
|||
public async Task DoItAsync() |
|||
{ |
|||
// TODO: Use the injected _daprClient object |
|||
} |
|||
} |
|||
```` |
|||
|
|||
注入 `DaprClient` 是在应用程序代码中使用它的推荐方法.当你注入它时,将使用 `IAbpDaprClientFactory` 服务创建它,这会在下一节中将进行说明. |
|||
|
|||
### IAbpDaprClientFactory |
|||
|
|||
`IAbpDaprClientFactory` 可用于创建 `DaprClient` 或 `HttpClient` 对象来执行对 Dapr 的操作.它使用 `AbpDaprOptions`,因此你可以配置设置. |
|||
|
|||
**示例用法:** |
|||
|
|||
````csharp |
|||
public class MyService : ITransientDependency |
|||
{ |
|||
private readonly IAbpDaprClientFactory _daprClientFactory; |
|||
|
|||
public MyService(IAbpDaprClientFactory daprClientFactory) |
|||
{ |
|||
_daprClientFactory = daprClientFactory; |
|||
} |
|||
|
|||
public async Task DoItAsync() |
|||
{ |
|||
// Create a DaprClient object with default options |
|||
DaprClient daprClient = await _daprClientFactory.CreateAsync(); |
|||
|
|||
/* Create a DaprClient object with configuring |
|||
* the DaprClientBuilder object */ |
|||
DaprClient daprClient2 = await _daprClientFactory |
|||
.CreateAsync(builder => |
|||
{ |
|||
builder.UseDaprApiToken("..."); |
|||
}); |
|||
|
|||
// Create an HttpClient object |
|||
HttpClient httpClient = await _daprClientFactory |
|||
.CreateHttpClientAsync("target-app-id"); |
|||
} |
|||
} |
|||
```` |
|||
|
|||
`CreateHttpClientAsync` 方法还获取可选的 `daprEndpoint` 和 `daprApiToken` 参数. |
|||
|
|||
> ABP使用`IAbpDaprClientFactory`创建Dapr客户端.你也可以在应用程序中使用Dapr API创建客户端对象.推荐使用`IAbpDaprClientFactory`,但不是必需的. |
|||
|
|||
## C# API 客户端代理集成 |
|||
|
|||
ABP可以[动态](../API/Dynamic-CSharp-API-Clients.md)或[静态](../API/Static-CSharp-API-Clients.md)生成代理类,以便从Dotnet客户端应用程序调用HTTP API.在分布式系统中使用HTTP API是非常合理的.[Volo.Abp.Http.Client.Dapr](https://www.nuget.org/packages/Volo.Abp.Http.Client.Dapr)包配置了客户端代理系统,因此它使用Dapr的服务调用构建块进行应用程序之间的通信. |
|||
|
|||
### 安装 |
|||
|
|||
使用ABP CLI将[Volo.Abp.Http.Client.Dapr](https://www.nuget.org/packages/Volo.Abp.Http.Client.Dapr) NuGet包添加到项目(客户端): |
|||
|
|||
* 安装[ABP CLI](https://docs.abp.io/en/abp/latest/CLI)如果你之前没有安装过. |
|||
* 在你想要添加`Volo.Abp.Http.Client.Dapr`包的`.csproj`文件所在的目录中打开命令行(终端). |
|||
* 运行`abp add-package Volo.Abp.Http.Client.Dapr`命令. |
|||
|
|||
如果你想手动添加,安装 [Volo.Abp.Http.Client.Dapr](https://www.nuget.org/packages/Volo.Abp.Http.Client.Dapr) NuGet包到你的项目中,并在项目内的[ABP模块](../Module-Development-Basics.md)类中添加`[DependsOn(typeof(AbpHttpClientDaprModule))]`. |
|||
|
|||
### 配置 |
|||
|
|||
当你安装了[Volo.Abp.Http.Client.Dapr](https://www.nuget.org/packages/Volo.Abp.Http.Client.Dapr) NuGet 包,所有你需要做的就是在`appsettings.json`或使用`AbpRemoteServiceOptions`[选项类](../Options.md)中配置ABP的远程服务选项. |
|||
|
|||
**示例:** |
|||
|
|||
````csharp |
|||
{ |
|||
"RemoteServices": { |
|||
"Default": { |
|||
"BaseUrl": "http://dapr-httpapi/" |
|||
} |
|||
} |
|||
} |
|||
```` |
|||
|
|||
`dapr-httpapi` 在这个例子中是你的Dapr配置中服务器应用程序的应用程序ID. |
|||
|
|||
远程服务名称(示例中是`Default`)应该匹配动态客户端代理中`AddHttpClientProxies`调用或静态客户端代理中`AddStaticHttpClientProxies`调用中指定的远程服务名称.如果你的客户端只与一个服务器通信,使用`Default`是可以的.但是,如果你的客户端使用多个服务器,你通常在`RemoteServices`配置中有多个键. 你将远程服务端点配置为Dapr应用程序ID,在你使用ABP的客户端代理系统时它将自动工作并通过Dapr进行HTTP调用, |
|||
|
|||
> 参阅[动态](../API/Dynamic-CSharp-API-Clients.md) 和 [static](../API/Static-CSharp-API-Clients.md)客户端代理文档,了解ABP的客户端代理系统的详细信息. |
|||
|
|||
## 分布式事件总线集成 |
|||
|
|||
[ABP的分布式事件总线](../Distributed-Event-Bus.md)系统提供了一个方便的抽象,允许应用程序通过事件异步通信.ABP提供了各种分布式消息系统(如RabbitMQ,Kafka和Azure)的集成包.Dapr也有一个[发布和订阅构建块](https://docs.dapr.io/developing-applications/building-blocks/pubsub/pubsub-overview/),用于相同的目的:分布式消息/事件. |
|||
|
|||
ABP的[Volo.Abp.EventBus.Dapr](https://www.nuget.org/packages/Volo.Abp.EventBus.Dapr)和[Volo.Abp.AspNetCore.Mvc.Dapr.EventBus](https://www.nuget.org/packages/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus)包可以使用Dapr基础设施来实现ABP的分布式事件总线. |
|||
|
|||
任何类型的应用程序(例如,控制台或ASP.NET Core应用程序)都可以使用[Volo.Abp.EventBus.Dapr]包通过Dapr发布事件.为了能够接收消息(通过订阅事件),你需要安装[Volo.Abp.AspNetCore.Mvc.Dapr.EventBus]包,并且你的应用程序应该是ASP.NET Core应用程序. |
|||
|
|||
### 安装 |
|||
|
|||
如果你的应用程序是ASP.NET Core应用程序并且你想发送和接收事件,你需要按照下面的描述安装[Volo.Abp.AspNetCore.Mvc.Dapr.EventBus]包: |
|||
|
|||
* 安装[ABP CLI](https://docs.abp.io/en/abp/latest/CLI)如果你之前没有安装过. |
|||
* 在你想要添加`Volo.Abp.AspNetCore.Mvc.Dapr.EventBus`包的`.csproj`文件所在的目录中打开命令行(终端). |
|||
* 运行`abp add-package Volo.Abp.AspNetCore.Mvc.Dapr.EventBus`命令. |
|||
|
|||
如果你想手动添加,安装 [Volo.Abp.AspNetCore.Mvc.Dapr.EventBus](https://www.nuget.org/packages/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus) NuGet包到你的项目中,并在项目内的[ABP模块](../Module-Development-Basics.md)类中添加`[DependsOn(typeof(AbpAspNetCoreMvcDaprEventBusModule))]`. |
|||
|
|||
> **如果你安装了[Volo.Abp.AspNetCore.Mvc.Dapr.EventBus](https://www.nuget.org/packages/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus)包, 那么你不需要安装[Volo.Abp.EventBus.Dapr](https://www.nuget.org/packages/Volo.Abp.EventBus.Dapr)包,因为它已经由第一个包引用** |
|||
|
|||
如果你的应用程序不是ASP.NET Core应用程序,你不能从Dapr接收事件,至少使用ABP的集成包(如果你想在不同类型的应用程序中接收事件,请参阅[Dapr的文档](https://docs.dapr.io/developing-applications/building-blocks/pubsub/howto-publish-subscribe/)).但是你仍然可以使用[Volo.Abp.EventBus.Dapr](https://www.nuget.org/packages/Volo.Abp.EventBus.Dapr)包发布消息.在这种情况下,请按照下面的步骤将该包安装到你的项目中: |
|||
|
|||
* 安装[ABP CLI](https://docs.abp.io/en/abp/latest/CLI)如果你之前没有安装过. |
|||
* 在你想要添加`Volo.Abp.EventBus.Dapr`包的`.csproj`文件所在的目录中打开命令行(终端). |
|||
* 运行`abp add-package Volo.Abp.EventBus.Daprs`命令. |
|||
|
|||
如果你想手动添加,安装 [Volo.Abp.Http.Client.Dapr](https://www.nuget.org/packages/Volo.Abp.EventBus.Dapr) NuGet包到你的项目中,并在项目内的[ABP模块](../Module-Development-Basics.md)类中添加`[DependsOn(typeof(AbpEventBusDaprModule))]`. |
|||
|
|||
### 配置 |
|||
|
|||
你可以为Dapr配置`AbpDaprEventBusOptions`[选项类](../Options.md): |
|||
|
|||
````csharp |
|||
Configure<AbpDaprEventBusOptions>(options => |
|||
{ |
|||
options.PubSubName = "pubsub"; |
|||
}); |
|||
```` |
|||
|
|||
可用的`AbpDaprEventBusOptions`类的属性: |
|||
|
|||
* `PubSubName` (可选): 通过`DaprClient.PublishEventAsync`方法发布消息时的`pubsubName`参数.默认值:`pubsub`. |
|||
|
|||
### ABP订阅端点 |
|||
|
|||
ABP提供了以下端点来接收来自Dapr的事件: |
|||
|
|||
* `dapr/subscribe`: Dapr使用此端点从应用程序获取订阅列表.ABP会自动返回所有分布式事件处理程序类和具有`Topic`属性的自定义控制器操作的订阅. |
|||
* `api/abp/dapr/event`: 用于接收来自Dapr的所有事件的统一端点.ABP根据主题名称将事件分派给您的事件处理程序. |
|||
|
|||
> **由于ABP提供了标准的`dapr/subscribe`端点,所以你不应该手动调用Dapr的`app.MapSubscribeHandler()`方法.** 如果你想支持[CloudEvents](https://cloudevents.io/)标准,你可以在你的ASP.NET Core管道中使用`app.UseCloudEvents()`中间件. |
|||
|
|||
### 用法 |
|||
|
|||
#### ABP的方式 |
|||
|
|||
你可以按照[ABP的分布式事件总线文档](../Distributed-Event-Bus.md)来学习如何以ABP的方式发布和订阅事件.你的应用程序代码不需要做任何改变就可以使用Dapr的发布-订阅功能.ABP将自动为你的事件处理程序类(实现`IDistributedEventHandler`接口)订阅Dapr. |
|||
|
|||
ABP提供了 `api/abp/dapr/event` |
|||
|
|||
**示例:使用`IDistributedEventBus`服务发布事件** |
|||
|
|||
````csharp |
|||
public class MyService : ITransientDependency |
|||
{ |
|||
private readonly IDistributedEventBus _distributedEventBus; |
|||
|
|||
public MyService(IDistributedEventBus distributedEventBus) |
|||
{ |
|||
_distributedEventBus = distributedEventBus; |
|||
} |
|||
|
|||
public async Task DoItAsync() |
|||
{ |
|||
await _distributedEventBus.PublishAsync(new StockCountChangedEto |
|||
{ |
|||
ProductCode = "AT837234", |
|||
NewStockCount = 42 |
|||
}); |
|||
} |
|||
} |
|||
```` |
|||
|
|||
**示例:通过实现`IDistributedEventHandler`接口来订阅事件** |
|||
|
|||
````csharp |
|||
public class MyHandler : |
|||
IDistributedEventHandler<StockCountChangedEto>, |
|||
ITransientDependency |
|||
{ |
|||
public async Task HandleEventAsync(StockCountChangedEto eventData) |
|||
{ |
|||
var productCode = eventData.ProductCode; |
|||
// ... |
|||
} |
|||
} |
|||
```` |
|||
|
|||
参阅[ABP的分布式事件总线文档](../Distributed-Event-Bus.md)来了解细节. |
|||
|
|||
#### 使用Dapr API |
|||
|
|||
在ABP的标准分布式事件总线系统之外,你还可以使用Dapr的API来发布事件. |
|||
|
|||
> 如果你直接使用Dapr API来发布事件,你可能无法从ABP的标准分布式事件总线功能中受益,比如outbox/inbox模式的实现. |
|||
|
|||
**示例:使用`DaprClient`发布事件** |
|||
|
|||
````csharp |
|||
public class MyService : ITransientDependency |
|||
{ |
|||
private readonly DaprClient _daprClient; |
|||
|
|||
public MyService(DaprClient daprClient) |
|||
{ |
|||
_daprClient = daprClient; |
|||
} |
|||
|
|||
public async Task DoItAsync() |
|||
{ |
|||
await _daprClient.PublishEventAsync( |
|||
"pubsub", // pubsub name |
|||
"StockChanged", // topic name |
|||
new StockCountChangedEto // event data |
|||
{ |
|||
ProductCode = "AT837234", |
|||
NewStockCount = 42 |
|||
} |
|||
); |
|||
} |
|||
} |
|||
```` |
|||
|
|||
**示例:通过创建ASP.NET Core控制器来订阅事件** |
|||
|
|||
````csharp |
|||
public class MyController : AbpController |
|||
{ |
|||
[HttpPost("/stock-changed")] |
|||
[Topic("pubsub", "StockChanged")] |
|||
public async Task<IActionResult> TestRouteAsync( |
|||
[FromBody] StockCountChangedEto model) |
|||
{ |
|||
HttpContext.ValidateDaprAppApiToken(); |
|||
|
|||
// Do something with the event |
|||
return Ok(); |
|||
} |
|||
} |
|||
```` |
|||
|
|||
`HttpContext.ValidateDaprAppApiToken()` 扩展方法由ABP提供,用于检查请求是否来自Dapr.这是可选的.如果你想启用验证,你应该配置Dapr将App API令牌发送到你的应用程序.如果没有配置,`ValidateDaprAppApiToken()`不会执行任何操作.参阅[Dapr的App API令牌文档](https://docs.dapr.io/operations/security/app-api-token/)了解更多信息.还可以参阅本文档中的**AbpDaprOptions**和**安全**部分. |
|||
|
|||
参阅[Dapr的文档](https://docs.microsoft.com/en-us/dotnet/architecture/dapr-for-net-developers/publish-subscribe)来了解使用Dapr API发送和接收事件的细节. |
|||
|
|||
## 分布式锁 |
|||
|
|||
> Dapr的分布式锁功能目前处于Alpha阶段,可能还不稳定.在这一点上,不建议用Dapr来替换ABP的分布式锁. |
|||
|
|||
ABP提供了一个[分布式锁](../Distributed-Locking.md)抽象来控制多个应用程序对共享资源的访问.Dapr也有一个[分布式锁构建块](https://docs.dapr.io/developing-applications/building-blocks/distributed-lock/).[Volo.Abp.DistributedLocking.Dapr](https://www.nuget.org/packages/Volo.Abp.DistributedLocking.Dapr)包使ABP使用Dapr的分布式锁系统. |
|||
|
|||
### 安装 |
|||
|
|||
使用ABP CLI将[Volo.Abp.DistributedLocking.Dapr](https://www.nuget.org/packages/Volo.Abp.DistributedLocking.Dapr)NuGet包添加到项目(客户端): |
|||
|
|||
* 安装[ABP CLI](https://docs.abp.io/en/abp/latest/CLI)如果你之前没有安装过. |
|||
* 在你想要添加`Volo.Abp.DistributedLocking.Dapr`包的`.csproj`文件所在的目录中打开命令行(终端). |
|||
* 运行`abp add-package Volo.Abp.DistributedLocking.Dapr`命令. |
|||
|
|||
如果你想手动添加,安装 [Volo.Abp.DistributedLocking.Dapr](https://www.nuget.org/packages/Volo.Abp.AspNetCore.Mvc.Dapr.EventBus) NuGet包到你的项目中,并在项目内的[ABP模块](../Module-Development-Basics.md)类中添加`[DependsOn(typeof(AbpDistributedLockingDaprModule))]`. |
|||
|
|||
### 配置 |
|||
|
|||
你可以在[你的模块](../Module-Development-Basics.md)的`ConfigureServices`方法中使用`AbpDistributedLockDaprOptions`选项类来配置Dapr分布式锁: |
|||
|
|||
````csharp |
|||
Configure<AbpDistributedLockDaprOptions>(options => |
|||
{ |
|||
options.StoreName = "mystore"; |
|||
}); |
|||
```` |
|||
|
|||
以下选项可用: |
|||
|
|||
* **`StoreName`** (必需):Dapr使用的存储库名称.锁键名称在同一存储库中范围内.这意味着不同的应用程序可以在不同的存储库中获取相同的锁名称.对于要控制访问的相同资源,请使用相同的存储库名称. |
|||
* `Owner` (可选):`DaprClient.Lock`方法使用的`owner`值.如果你不指定,ABP使用一个随机值,这在一般情况下是可以的. |
|||
* `DefaultExpirationTimeout` (可选):锁过期后的默认值.默认值:2分钟. |
|||
|
|||
### 用法 |
|||
|
|||
你可以注入并使用`IAbpDistributedLock`服务,就像在[分布式锁文档](../Distributed-Locking.md)中解释的那样. |
|||
|
|||
**示例:** |
|||
|
|||
````csharp |
|||
public class MyService : ITransientDependency |
|||
{ |
|||
private readonly IAbpDistributedLock _distributedLock; |
|||
|
|||
public MyService(IAbpDistributedLock distributedLock) |
|||
{ |
|||
_distributedLock = distributedLock; |
|||
} |
|||
|
|||
public async Task MyMethodAsync() |
|||
{ |
|||
await using (var handle = |
|||
await _distributedLock.TryAcquireAsync("MyLockName")) |
|||
{ |
|||
if (handle != null) |
|||
{ |
|||
// your code that access the shared resource |
|||
} |
|||
} |
|||
} |
|||
} |
|||
```` |
|||
|
|||
这里有两点关于`TryAcquireAsync`方法我们应该提到,与ABP的标准用法不同: |
|||
|
|||
* `timeout` 参数目前没有使用(即使你指定了它),因为Dapr不支持等待获取锁. |
|||
* Dapr 使用过期超时系统(这意味着即使你不通过释放处理程序来释放锁,锁也会在超时后自动释放).但是,ABP的`TryAcquireAsync`方法没有这样的参数.目前,你可以在应用程序中将`AbpDistributedLockDaprOptions.DefaultExpirationTimeout`设置为全局值. |
|||
|
|||
Dapr的分布式锁功能目前处于Alpha阶段,其API是可能会改变的候选者.如果你想要使用它,你可以这样做,但是要准备好未来的变化.目前,我们建议使用ABP的[分布式锁文档](../Distributed-Locking.md)中提到的[DistributedLock](https://github.com/madelson/DistributedLock)库. |
|||
|
|||
## 安全 |
|||
|
|||
如果你使用Dapr,你的应用程序中的大部分或全部传入和传出请求都会通过Dapr.Dapr使用两种API令牌来保护应用程序与Dapr之间的通信. |
|||
|
|||
### Dapr API Token |
|||
|
|||
> 这个令牌默认情况下是自动设置的,通常你不需要关心它. |
|||
|
|||
[在Dapr中启用API令牌身份验证](https://docs.dapr.io/operations/security/api-token/)文档描述了Dapr API令牌是什么以及如何配置.如果你想为你的应用程序启用它,请阅读该文档. |
|||
|
|||
如果你启用了Dapr API令牌,你应该在你的应用程序中向Dapr发送该令牌.`AbpDaprOptions`定义了一个`DaprApiToken`属性,作为在你的应用程序中配置Dapr API令牌的中心点. |
|||
|
|||
`DaprApiToken`属性的默认值是从`DAPR_API_TOKEN`环境变量设置的,并且该环境变量是在Dapr运行时设置的.所以,大多数情况下,你不需要在你的应用程序中配置`AbpDaprOptions.DaprApiToken`.但是,如果你需要配置(或覆盖它),你可以在模块类的`ConfigureServices`方法中这样做,如下面的代码块所示: |
|||
|
|||
````csharp |
|||
Configure<AbpDaprOptions>(options => |
|||
{ |
|||
options.DaprApiToken = "..."; |
|||
}); |
|||
```` |
|||
|
|||
或者你可以在`appsettings.json`文件中设置它: |
|||
|
|||
````json |
|||
"Dapr": { |
|||
"DaprApiToken": "..." |
|||
} |
|||
```` |
|||
|
|||
一旦你设置了它,它就会在你注入`DaprClient`或使用`IAbpDaprClientFactory`时使用.如果你需要在应用程序中使用该值,你可以注入`IDaprApiTokenProvider`并使用其`GetDaprApiToken()`方法. |
|||
|
|||
### App API Token |
|||
|
|||
> 启用App API令牌验证是强烈推荐的.否则,例如,任何客户端都可以直接调用你的事件订阅端点,你的应用程序就像发生了事件一样(如果你的事件订阅端点中没有其他安全策略). |
|||
|
|||
[在Dapr中使用令牌身份验证请求身份验证](https://docs.dapr.io/operations/security/app-api-token/)文档描述了App API令牌是什么以及如何配置.如果你想为你的应用程序启用它,请阅读该文档. |
|||
|
|||
如果你启用了App API令牌,你可以验证它以确保请求来自Dapr.ABP提供了有用的快捷方式来验证它. |
|||
|
|||
**示例:在事件处理HTTP API中验证App API令牌** |
|||
|
|||
````csharp |
|||
public class MyController : AbpController |
|||
{ |
|||
[HttpPost("/stock-changed")] |
|||
[Topic("pubsub", "StockChanged")] |
|||
public async Task<IActionResult> TestRouteAsync( |
|||
[FromBody] StockCountChangedEto model) |
|||
{ |
|||
// Validate the App API token! |
|||
HttpContext.ValidateDaprAppApiToken(); |
|||
|
|||
// Do something with the event |
|||
return Ok(); |
|||
} |
|||
} |
|||
```` |
|||
|
|||
`HttpContext.ValidateDaprAppApiToken()` 是ABP框架提供的扩展方法.如果HTTP头中缺少或错误的令牌,则会抛出`AbpAuthorizationException`(头名称为`dapr-api-token`).你也可以注入`IDaprAppApiTokenValidator`并使用其方法在任何服务中验证令牌(不仅仅是在控制器类中). |
|||
|
|||
你可以配置`AbpDaprOptions.AppApiToken`,如果你想设置(或覆盖)App API令牌值.默认值由`APP_API_TOKEN`环境变量设置.你可以在模块类的`ConfigureServices`方法中这样做,如下面的代码块所示: |
|||
|
|||
````csharp |
|||
Configure<AbpDaprOptions>(options => |
|||
{ |
|||
options.AppApiToken = "..."; |
|||
}); |
|||
```` |
|||
|
|||
或者你可以在`appsettings.json`文件中设置它: |
|||
|
|||
````json |
|||
"Dapr": { |
|||
"AppApiToken": "..." |
|||
} |
|||
```` |
|||
|
|||
如果你需要在应用程序中使用该值,你可以注入`IDaprApiTokenProvider`并使用其`GetAppApiToken()`方法. |
|||
|
|||
## 另请参阅 |
|||
|
|||
* [Dapr for .NET Developers](https://docs.microsoft.com/en-us/dotnet/architecture/dapr-for-net-developers/) |
|||
* [Dapr官方文档](https://docs.dapr.io/) |
|||
@ -0,0 +1,75 @@ |
|||
using Microsoft.AspNetCore.Http; |
|||
using Microsoft.AspNetCore.SignalR; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Authorization; |
|||
using Volo.Abp.Dapr; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.Dapr; |
|||
|
|||
public class DaprAppApiTokenValidator : IDaprAppApiTokenValidator, ISingletonDependency |
|||
{ |
|||
protected IHttpContextAccessor HttpContextAccessor { get; } |
|||
protected HttpContext HttpContext => GetHttpContext(); |
|||
|
|||
public DaprAppApiTokenValidator(IHttpContextAccessor httpContextAccessor) |
|||
{ |
|||
HttpContextAccessor = httpContextAccessor; |
|||
} |
|||
|
|||
public virtual void CheckDaprAppApiToken() |
|||
{ |
|||
var expectedAppApiToken = GetConfiguredAppApiTokenOrNull(); |
|||
if (expectedAppApiToken.IsNullOrWhiteSpace()) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
var headerAppApiToken = GetDaprAppApiTokenOrNull(); |
|||
if (headerAppApiToken.IsNullOrWhiteSpace()) |
|||
{ |
|||
throw new AbpAuthorizationException("Expected Dapr App API Token is not provided! Dapr should set the 'dapr-api-token' HTTP header."); |
|||
} |
|||
|
|||
if (expectedAppApiToken != headerAppApiToken) |
|||
{ |
|||
throw new AbpAuthorizationException("The Dapr App API Token (provided in the 'dapr-api-token' HTTP header) doesn't match the expected value!"); |
|||
} |
|||
} |
|||
|
|||
public virtual bool IsValidDaprAppApiToken() |
|||
{ |
|||
var expectedAppApiToken = GetConfiguredAppApiTokenOrNull(); |
|||
if (expectedAppApiToken.IsNullOrWhiteSpace()) |
|||
{ |
|||
return true; |
|||
} |
|||
|
|||
var headerAppApiToken = GetDaprAppApiTokenOrNull(); |
|||
return expectedAppApiToken == headerAppApiToken; |
|||
} |
|||
|
|||
public virtual string? GetDaprAppApiTokenOrNull() |
|||
{ |
|||
string apiTokenHeader = HttpContext.Request.Headers["dapr-api-token"]; |
|||
if (string.IsNullOrEmpty(apiTokenHeader) || apiTokenHeader.Length < 1) |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
return apiTokenHeader; |
|||
} |
|||
|
|||
protected virtual string? GetConfiguredAppApiTokenOrNull() |
|||
{ |
|||
return HttpContext |
|||
.RequestServices |
|||
.GetRequiredService<IDaprApiTokenProvider>() |
|||
.GetAppApiToken(); |
|||
} |
|||
|
|||
protected virtual HttpContext GetHttpContext() |
|||
{ |
|||
return HttpContextAccessor.HttpContext ?? throw new AbpException("HttpContext is not available!"); |
|||
} |
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
using Microsoft.AspNetCore.Http; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.Dapr; |
|||
|
|||
public static class DaprHttpContextExtensions |
|||
{ |
|||
public static void ValidateDaprAppApiToken(this HttpContext httpContext) |
|||
{ |
|||
httpContext |
|||
.RequestServices |
|||
.GetRequiredService<IDaprAppApiTokenValidator>() |
|||
.CheckDaprAppApiToken(); |
|||
} |
|||
|
|||
public static bool IsValidDaprAppApiToken(this HttpContext httpContext) |
|||
{ |
|||
return httpContext |
|||
.RequestServices |
|||
.GetRequiredService<IDaprAppApiTokenValidator>() |
|||
.IsValidDaprAppApiToken(); |
|||
} |
|||
|
|||
public static string? GetDaprAppApiTokenOrNull(HttpContext httpContext) |
|||
{ |
|||
return httpContext |
|||
.RequestServices |
|||
.GetRequiredService<IDaprAppApiTokenValidator>() |
|||
.GetDaprAppApiTokenOrNull(); |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
namespace Volo.Abp.AspNetCore.Mvc.Dapr; |
|||
|
|||
public interface IDaprAppApiTokenValidator |
|||
{ |
|||
void CheckDaprAppApiToken(); |
|||
bool IsValidDaprAppApiToken(); |
|||
string? GetDaprAppApiTokenOrNull(); |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
using System.Collections.Generic; |
|||
using Microsoft.Extensions.Options; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Packages.JQuery; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Packages.Moment; |
|||
using Volo.Abp.Localization; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Packages.BootstrapDaterangepicker; |
|||
|
|||
[DependsOn(typeof(JQueryScriptContributor))] |
|||
[DependsOn(typeof(MomentScriptContributor))] |
|||
public class BootstrapDaterangepickerScriptContributor : BundleContributor |
|||
{ |
|||
public const string PackageName = "bootstrap-daterangepicker"; |
|||
|
|||
public override void ConfigureBundle(BundleConfigurationContext context) |
|||
{ |
|||
context.Files.AddIfNotContains("/libs/bootstrap-daterangepicker/daterangepicker.js"); |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using System.Collections.Generic; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Packages.BootstrapDaterangepicker; |
|||
|
|||
public class BootstrapDaterangepickerStyleContributor : BundleContributor |
|||
{ |
|||
public override void ConfigureBundle(BundleConfigurationContext context) |
|||
{ |
|||
context.Files.AddIfNotContains("/libs/bootstrap-daterangepicker/daterangepicker.css"); |
|||
} |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
using System.Collections.Generic; |
|||
using Microsoft.Extensions.Options; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Packages.JQuery; |
|||
using Volo.Abp.Localization; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Packages.Moment; |
|||
|
|||
public class MomentScriptContributor : BundleContributor |
|||
{ |
|||
public const string PackageName = "moment"; |
|||
|
|||
public override void ConfigureBundle(BundleConfigurationContext context) |
|||
{ |
|||
context.Files.AddIfNotContains("/libs/moment/moment.min.js"); |
|||
} |
|||
|
|||
public override void ConfigureDynamicResources(BundleConfigurationContext context) |
|||
{ |
|||
var fileName = context.LazyServiceProvider.LazyGetRequiredService<IOptions<AbpLocalizationOptions>>().Value.GetCurrentUICultureLanguageFilesMap(PackageName); |
|||
var filePath = $"/libs/moment/locale/{fileName}.js"; |
|||
if (context.FileProvider.GetFileInfo(filePath).Exists) |
|||
{ |
|||
context.Files.AddIfNotContains(filePath); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
namespace Volo.Abp.Cli.ProjectBuilding.Building.Steps; |
|||
|
|||
public class RemoveFilesStep : ProjectBuildPipelineStep |
|||
{ |
|||
private readonly string _filePath; |
|||
|
|||
public RemoveFilesStep(string filePath) |
|||
{ |
|||
_filePath = filePath; |
|||
} |
|||
|
|||
public override void Execute(ProjectBuildContext context) |
|||
{ |
|||
context.Files.RemoveAll(file => file.Name.Contains(_filePath)); |
|||
} |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
using System; |
|||
|
|||
namespace Volo.Abp; |
|||
|
|||
[Flags] |
|||
public enum ApplicationServiceTypes : byte |
|||
{ |
|||
/// <summary>
|
|||
/// Only application services without <see cref="IntegrationServiceAttribute"/>.
|
|||
/// </summary>
|
|||
ApplicationServices = 1, |
|||
|
|||
/// <summary>
|
|||
/// Application services with <see cref="IntegrationServiceAttribute"/>.
|
|||
/// </summary>
|
|||
IntegrationServices = 2, |
|||
|
|||
/// <summary>
|
|||
/// All application services.
|
|||
/// </summary>
|
|||
All = ApplicationServices | IntegrationServices |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
using Microsoft.Extensions.Options; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.Dapr; |
|||
|
|||
public class DaprApiTokenProvider : IDaprApiTokenProvider, ISingletonDependency |
|||
{ |
|||
protected AbpDaprOptions Options { get; } |
|||
|
|||
public DaprApiTokenProvider(IOptions<AbpDaprOptions> options) |
|||
{ |
|||
Options = options.Value; |
|||
} |
|||
|
|||
public virtual string? GetDaprApiToken() |
|||
{ |
|||
return Options.DaprApiToken; |
|||
} |
|||
|
|||
public virtual string? GetAppApiToken() |
|||
{ |
|||
return Options.AppApiToken; |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
using Dapr.Client; |
|||
|
|||
namespace Volo.Abp.Dapr; |
|||
|
|||
public interface IAbpDaprClientFactory |
|||
{ |
|||
DaprClient Create(Action<DaprClientBuilder>? builderAction = null); |
|||
|
|||
HttpClient CreateHttpClient( |
|||
string? appId = null, |
|||
string? daprEndpoint = null, |
|||
string? daprApiToken = null |
|||
); |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
namespace Volo.Abp.Dapr; |
|||
|
|||
public interface IDaprApiTokenProvider |
|||
{ |
|||
string? GetDaprApiToken(); |
|||
|
|||
string? GetAppApiToken(); |
|||
} |
|||
@ -0,0 +1,48 @@ |
|||
using Shouldly; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Abp; |
|||
|
|||
public class IntegrationServiceAttribute_Tests |
|||
{ |
|||
[Fact] |
|||
public static void IsDefinedOrInherited() |
|||
{ |
|||
// True cases
|
|||
|
|||
IntegrationServiceAttribute |
|||
.IsDefinedOrInherited<IMyIntegrationService1>() |
|||
.ShouldBeTrue(); |
|||
|
|||
IntegrationServiceAttribute |
|||
.IsDefinedOrInherited<MyIntegrationService1>() |
|||
.ShouldBeTrue(); |
|||
|
|||
IntegrationServiceAttribute |
|||
.IsDefinedOrInherited<MyIntegrationService2>() |
|||
.ShouldBeTrue(); |
|||
|
|||
// False cases
|
|||
|
|||
IntegrationServiceAttribute |
|||
.IsDefinedOrInherited<IMyIntegrationService2>() |
|||
.ShouldBeFalse(); |
|||
|
|||
IntegrationServiceAttribute |
|||
.IsDefinedOrInherited<MyApplicationService>() |
|||
.ShouldBeFalse(); |
|||
|
|||
} |
|||
|
|||
[IntegrationService] |
|||
private interface IMyIntegrationService1 { } |
|||
private class MyIntegrationService1 : IMyIntegrationService1 { } |
|||
|
|||
private interface IMyIntegrationService2 { } |
|||
[IntegrationService] |
|||
private class MyIntegrationService2 : IMyIntegrationService2 { } |
|||
|
|||
private interface IMyApplicationService { } |
|||
private class MyApplicationService : IMyApplicationService { } |
|||
} |
|||
|
|||
@ -1,6 +1,6 @@ |
|||
{ |
|||
"culture": "tr", |
|||
"texts": { |
|||
|
|||
"Volo.Abp.Http.DynamicProxying:10001": "Verilerle ilgili iş istisnası: {0}" |
|||
} |
|||
} |
|||
@ -1,6 +1,5 @@ |
|||
{ |
|||
"culture": "tr", |
|||
"texts": { |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,410 @@ |
|||
.daterangepicker { |
|||
position: absolute; |
|||
color: inherit; |
|||
background-color: #fff; |
|||
border-radius: 4px; |
|||
border: 1px solid #ddd; |
|||
width: 278px; |
|||
max-width: none; |
|||
padding: 0; |
|||
margin-top: 7px; |
|||
top: 100px; |
|||
left: 20px; |
|||
z-index: 3001; |
|||
display: none; |
|||
font-family: arial; |
|||
font-size: 15px; |
|||
line-height: 1em; |
|||
} |
|||
|
|||
.daterangepicker:before, .daterangepicker:after { |
|||
position: absolute; |
|||
display: inline-block; |
|||
border-bottom-color: rgba(0, 0, 0, 0.2); |
|||
content: ''; |
|||
} |
|||
|
|||
.daterangepicker:before { |
|||
top: -7px; |
|||
border-right: 7px solid transparent; |
|||
border-left: 7px solid transparent; |
|||
border-bottom: 7px solid #ccc; |
|||
} |
|||
|
|||
.daterangepicker:after { |
|||
top: -6px; |
|||
border-right: 6px solid transparent; |
|||
border-bottom: 6px solid #fff; |
|||
border-left: 6px solid transparent; |
|||
} |
|||
|
|||
.daterangepicker.opensleft:before { |
|||
right: 9px; |
|||
} |
|||
|
|||
.daterangepicker.opensleft:after { |
|||
right: 10px; |
|||
} |
|||
|
|||
.daterangepicker.openscenter:before { |
|||
left: 0; |
|||
right: 0; |
|||
width: 0; |
|||
margin-left: auto; |
|||
margin-right: auto; |
|||
} |
|||
|
|||
.daterangepicker.openscenter:after { |
|||
left: 0; |
|||
right: 0; |
|||
width: 0; |
|||
margin-left: auto; |
|||
margin-right: auto; |
|||
} |
|||
|
|||
.daterangepicker.opensright:before { |
|||
left: 9px; |
|||
} |
|||
|
|||
.daterangepicker.opensright:after { |
|||
left: 10px; |
|||
} |
|||
|
|||
.daterangepicker.drop-up { |
|||
margin-top: -7px; |
|||
} |
|||
|
|||
.daterangepicker.drop-up:before { |
|||
top: initial; |
|||
bottom: -7px; |
|||
border-bottom: initial; |
|||
border-top: 7px solid #ccc; |
|||
} |
|||
|
|||
.daterangepicker.drop-up:after { |
|||
top: initial; |
|||
bottom: -6px; |
|||
border-bottom: initial; |
|||
border-top: 6px solid #fff; |
|||
} |
|||
|
|||
.daterangepicker.single .daterangepicker .ranges, .daterangepicker.single .drp-calendar { |
|||
float: none; |
|||
} |
|||
|
|||
.daterangepicker.single .drp-selected { |
|||
display: none; |
|||
} |
|||
|
|||
.daterangepicker.show-calendar .drp-calendar { |
|||
display: block; |
|||
} |
|||
|
|||
.daterangepicker.show-calendar .drp-buttons { |
|||
display: block; |
|||
} |
|||
|
|||
.daterangepicker.auto-apply .drp-buttons { |
|||
display: none; |
|||
} |
|||
|
|||
.daterangepicker .drp-calendar { |
|||
display: none; |
|||
max-width: 270px; |
|||
} |
|||
|
|||
.daterangepicker .drp-calendar.left { |
|||
padding: 8px 0 8px 8px; |
|||
} |
|||
|
|||
.daterangepicker .drp-calendar.right { |
|||
padding: 8px; |
|||
} |
|||
|
|||
.daterangepicker .drp-calendar.single .calendar-table { |
|||
border: none; |
|||
} |
|||
|
|||
.daterangepicker .calendar-table .next span, .daterangepicker .calendar-table .prev span { |
|||
color: #fff; |
|||
border: solid black; |
|||
border-width: 0 2px 2px 0; |
|||
border-radius: 0; |
|||
display: inline-block; |
|||
padding: 3px; |
|||
} |
|||
|
|||
.daterangepicker .calendar-table .next span { |
|||
transform: rotate(-45deg); |
|||
-webkit-transform: rotate(-45deg); |
|||
} |
|||
|
|||
.daterangepicker .calendar-table .prev span { |
|||
transform: rotate(135deg); |
|||
-webkit-transform: rotate(135deg); |
|||
} |
|||
|
|||
.daterangepicker .calendar-table th, .daterangepicker .calendar-table td { |
|||
white-space: nowrap; |
|||
text-align: center; |
|||
vertical-align: middle; |
|||
min-width: 32px; |
|||
width: 32px; |
|||
height: 24px; |
|||
line-height: 24px; |
|||
font-size: 12px; |
|||
border-radius: 4px; |
|||
border: 1px solid transparent; |
|||
white-space: nowrap; |
|||
cursor: pointer; |
|||
} |
|||
|
|||
.daterangepicker .calendar-table { |
|||
border: 1px solid #fff; |
|||
border-radius: 4px; |
|||
background-color: #fff; |
|||
} |
|||
|
|||
.daterangepicker .calendar-table table { |
|||
width: 100%; |
|||
margin: 0; |
|||
border-spacing: 0; |
|||
border-collapse: collapse; |
|||
} |
|||
|
|||
.daterangepicker td.available:hover, .daterangepicker th.available:hover { |
|||
background-color: #eee; |
|||
border-color: transparent; |
|||
color: inherit; |
|||
} |
|||
|
|||
.daterangepicker td.week, .daterangepicker th.week { |
|||
font-size: 80%; |
|||
color: #ccc; |
|||
} |
|||
|
|||
.daterangepicker td.off, .daterangepicker td.off.in-range, .daterangepicker td.off.start-date, .daterangepicker td.off.end-date { |
|||
background-color: #fff; |
|||
border-color: transparent; |
|||
color: #999; |
|||
} |
|||
|
|||
.daterangepicker td.in-range { |
|||
background-color: #ebf4f8; |
|||
border-color: transparent; |
|||
color: #000; |
|||
border-radius: 0; |
|||
} |
|||
|
|||
.daterangepicker td.start-date { |
|||
border-radius: 4px 0 0 4px; |
|||
} |
|||
|
|||
.daterangepicker td.end-date { |
|||
border-radius: 0 4px 4px 0; |
|||
} |
|||
|
|||
.daterangepicker td.start-date.end-date { |
|||
border-radius: 4px; |
|||
} |
|||
|
|||
.daterangepicker td.active, .daterangepicker td.active:hover { |
|||
background-color: #357ebd; |
|||
border-color: transparent; |
|||
color: #fff; |
|||
} |
|||
|
|||
.daterangepicker th.month { |
|||
width: auto; |
|||
} |
|||
|
|||
.daterangepicker td.disabled, .daterangepicker option.disabled { |
|||
color: #999; |
|||
cursor: not-allowed; |
|||
text-decoration: line-through; |
|||
} |
|||
|
|||
.daterangepicker select.monthselect, .daterangepicker select.yearselect { |
|||
font-size: 12px; |
|||
padding: 1px; |
|||
height: auto; |
|||
margin: 0; |
|||
cursor: default; |
|||
} |
|||
|
|||
.daterangepicker select.monthselect { |
|||
margin-right: 2%; |
|||
width: 56%; |
|||
} |
|||
|
|||
.daterangepicker select.yearselect { |
|||
width: 40%; |
|||
} |
|||
|
|||
.daterangepicker select.hourselect, .daterangepicker select.minuteselect, .daterangepicker select.secondselect, .daterangepicker select.ampmselect { |
|||
width: 50px; |
|||
margin: 0 auto; |
|||
background: #eee; |
|||
border: 1px solid #eee; |
|||
padding: 2px; |
|||
outline: 0; |
|||
font-size: 12px; |
|||
} |
|||
|
|||
.daterangepicker .calendar-time { |
|||
text-align: center; |
|||
margin: 4px auto 0 auto; |
|||
line-height: 30px; |
|||
position: relative; |
|||
} |
|||
|
|||
.daterangepicker .calendar-time select.disabled { |
|||
color: #ccc; |
|||
cursor: not-allowed; |
|||
} |
|||
|
|||
.daterangepicker .drp-buttons { |
|||
clear: both; |
|||
text-align: right; |
|||
padding: 8px; |
|||
border-top: 1px solid #ddd; |
|||
display: none; |
|||
line-height: 12px; |
|||
vertical-align: middle; |
|||
} |
|||
|
|||
.daterangepicker .drp-selected { |
|||
display: inline-block; |
|||
font-size: 12px; |
|||
padding-right: 8px; |
|||
} |
|||
|
|||
.daterangepicker .drp-buttons .btn { |
|||
margin-left: 8px; |
|||
font-size: 12px; |
|||
font-weight: bold; |
|||
padding: 4px 8px; |
|||
} |
|||
|
|||
.daterangepicker.show-ranges.single.rtl .drp-calendar.left { |
|||
border-right: 1px solid #ddd; |
|||
} |
|||
|
|||
.daterangepicker.show-ranges.single.ltr .drp-calendar.left { |
|||
border-left: 1px solid #ddd; |
|||
} |
|||
|
|||
.daterangepicker.show-ranges.rtl .drp-calendar.right { |
|||
border-right: 1px solid #ddd; |
|||
} |
|||
|
|||
.daterangepicker.show-ranges.ltr .drp-calendar.left { |
|||
border-left: 1px solid #ddd; |
|||
} |
|||
|
|||
.daterangepicker .ranges { |
|||
float: none; |
|||
text-align: left; |
|||
margin: 0; |
|||
} |
|||
|
|||
.daterangepicker.show-calendar .ranges { |
|||
margin-top: 8px; |
|||
} |
|||
|
|||
.daterangepicker .ranges ul { |
|||
list-style: none; |
|||
margin: 0 auto; |
|||
padding: 0; |
|||
width: 100%; |
|||
} |
|||
|
|||
.daterangepicker .ranges li { |
|||
font-size: 12px; |
|||
padding: 8px 12px; |
|||
cursor: pointer; |
|||
} |
|||
|
|||
.daterangepicker .ranges li:hover { |
|||
background-color: #eee; |
|||
} |
|||
|
|||
.daterangepicker .ranges li.active { |
|||
background-color: #08c; |
|||
color: #fff; |
|||
} |
|||
|
|||
/* Larger Screen Styling */ |
|||
@media (min-width: 564px) { |
|||
.daterangepicker { |
|||
width: auto; |
|||
} |
|||
|
|||
.daterangepicker .ranges ul { |
|||
width: 140px; |
|||
} |
|||
|
|||
.daterangepicker.single .ranges ul { |
|||
width: 100%; |
|||
} |
|||
|
|||
.daterangepicker.single .drp-calendar.left { |
|||
clear: none; |
|||
} |
|||
|
|||
.daterangepicker.single .ranges, .daterangepicker.single .drp-calendar { |
|||
float: left; |
|||
} |
|||
|
|||
.daterangepicker { |
|||
direction: ltr; |
|||
text-align: left; |
|||
} |
|||
|
|||
.daterangepicker .drp-calendar.left { |
|||
clear: left; |
|||
margin-right: 0; |
|||
} |
|||
|
|||
.daterangepicker .drp-calendar.left .calendar-table { |
|||
border-right: none; |
|||
border-top-right-radius: 0; |
|||
border-bottom-right-radius: 0; |
|||
} |
|||
|
|||
.daterangepicker .drp-calendar.right { |
|||
margin-left: 0; |
|||
} |
|||
|
|||
.daterangepicker .drp-calendar.right .calendar-table { |
|||
border-left: none; |
|||
border-top-left-radius: 0; |
|||
border-bottom-left-radius: 0; |
|||
} |
|||
|
|||
.daterangepicker .drp-calendar.left .calendar-table { |
|||
padding-right: 8px; |
|||
} |
|||
|
|||
.daterangepicker .ranges, .daterangepicker .drp-calendar { |
|||
float: left; |
|||
} |
|||
} |
|||
|
|||
@media (min-width: 730px) { |
|||
.daterangepicker .ranges { |
|||
width: auto; |
|||
} |
|||
|
|||
.daterangepicker .ranges { |
|||
float: left; |
|||
} |
|||
|
|||
.daterangepicker.rtl .ranges { |
|||
float: right; |
|||
} |
|||
|
|||
.daterangepicker .drp-calendar.left { |
|||
clear: none !important; |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
@ -0,0 +1,82 @@ |
|||
//! moment.js locale configuration
|
|||
//! locale : Afrikaans [af]
|
|||
//! author : Werner Mollentze : https://github.com/wernerm
|
|||
|
|||
;(function (global, factory) { |
|||
typeof exports === 'object' && typeof module !== 'undefined' |
|||
&& typeof require === 'function' ? factory(require('../moment')) : |
|||
typeof define === 'function' && define.amd ? define(['../moment'], factory) : |
|||
factory(global.moment) |
|||
}(this, (function (moment) { 'use strict'; |
|||
|
|||
//! moment.js locale configuration
|
|||
|
|||
var af = moment.defineLocale('af', { |
|||
months: 'Januarie_Februarie_Maart_April_Mei_Junie_Julie_Augustus_September_Oktober_November_Desember'.split( |
|||
'_' |
|||
), |
|||
monthsShort: 'Jan_Feb_Mrt_Apr_Mei_Jun_Jul_Aug_Sep_Okt_Nov_Des'.split('_'), |
|||
weekdays: 'Sondag_Maandag_Dinsdag_Woensdag_Donderdag_Vrydag_Saterdag'.split( |
|||
'_' |
|||
), |
|||
weekdaysShort: 'Son_Maa_Din_Woe_Don_Vry_Sat'.split('_'), |
|||
weekdaysMin: 'So_Ma_Di_Wo_Do_Vr_Sa'.split('_'), |
|||
meridiemParse: /vm|nm/i, |
|||
isPM: function (input) { |
|||
return /^nm$/i.test(input); |
|||
}, |
|||
meridiem: function (hours, minutes, isLower) { |
|||
if (hours < 12) { |
|||
return isLower ? 'vm' : 'VM'; |
|||
} else { |
|||
return isLower ? 'nm' : 'NM'; |
|||
} |
|||
}, |
|||
longDateFormat: { |
|||
LT: 'HH:mm', |
|||
LTS: 'HH:mm:ss', |
|||
L: 'DD/MM/YYYY', |
|||
LL: 'D MMMM YYYY', |
|||
LLL: 'D MMMM YYYY HH:mm', |
|||
LLLL: 'dddd, D MMMM YYYY HH:mm', |
|||
}, |
|||
calendar: { |
|||
sameDay: '[Vandag om] LT', |
|||
nextDay: '[Môre om] LT', |
|||
nextWeek: 'dddd [om] LT', |
|||
lastDay: '[Gister om] LT', |
|||
lastWeek: '[Laas] dddd [om] LT', |
|||
sameElse: 'L', |
|||
}, |
|||
relativeTime: { |
|||
future: 'oor %s', |
|||
past: '%s gelede', |
|||
s: "'n paar sekondes", |
|||
ss: '%d sekondes', |
|||
m: "'n minuut", |
|||
mm: '%d minute', |
|||
h: "'n uur", |
|||
hh: '%d ure', |
|||
d: "'n dag", |
|||
dd: '%d dae', |
|||
M: "'n maand", |
|||
MM: '%d maande', |
|||
y: "'n jaar", |
|||
yy: '%d jaar', |
|||
}, |
|||
dayOfMonthOrdinalParse: /\d{1,2}(ste|de)/, |
|||
ordinal: function (number) { |
|||
return ( |
|||
number + |
|||
(number === 1 || number === 8 || number >= 20 ? 'ste' : 'de') |
|||
); // Thanks to Joris Röling : https://github.com/jjupiter
|
|||
}, |
|||
week: { |
|||
dow: 1, // Maandag is die eerste dag van die week.
|
|||
doy: 4, // Die week wat die 4de Januarie bevat is die eerste week van die jaar.
|
|||
}, |
|||
}); |
|||
|
|||
return af; |
|||
|
|||
}))); |
|||
@ -0,0 +1,167 @@ |
|||
//! moment.js locale configuration
|
|||
//! locale : Arabic (Algeria) [ar-dz]
|
|||
//! author : Amine Roukh: https://github.com/Amine27
|
|||
//! author : Abdel Said: https://github.com/abdelsaid
|
|||
//! author : Ahmed Elkhatib
|
|||
//! author : forabi https://github.com/forabi
|
|||
//! author : Noureddine LOUAHEDJ : https://github.com/noureddinem
|
|||
|
|||
;(function (global, factory) { |
|||
typeof exports === 'object' && typeof module !== 'undefined' |
|||
&& typeof require === 'function' ? factory(require('../moment')) : |
|||
typeof define === 'function' && define.amd ? define(['../moment'], factory) : |
|||
factory(global.moment) |
|||
}(this, (function (moment) { 'use strict'; |
|||
|
|||
//! moment.js locale configuration
|
|||
|
|||
var pluralForm = function (n) { |
|||
return n === 0 |
|||
? 0 |
|||
: n === 1 |
|||
? 1 |
|||
: n === 2 |
|||
? 2 |
|||
: n % 100 >= 3 && n % 100 <= 10 |
|||
? 3 |
|||
: n % 100 >= 11 |
|||
? 4 |
|||
: 5; |
|||
}, |
|||
plurals = { |
|||
s: [ |
|||
'أقل من ثانية', |
|||
'ثانية واحدة', |
|||
['ثانيتان', 'ثانيتين'], |
|||
'%d ثوان', |
|||
'%d ثانية', |
|||
'%d ثانية', |
|||
], |
|||
m: [ |
|||
'أقل من دقيقة', |
|||
'دقيقة واحدة', |
|||
['دقيقتان', 'دقيقتين'], |
|||
'%d دقائق', |
|||
'%d دقيقة', |
|||
'%d دقيقة', |
|||
], |
|||
h: [ |
|||
'أقل من ساعة', |
|||
'ساعة واحدة', |
|||
['ساعتان', 'ساعتين'], |
|||
'%d ساعات', |
|||
'%d ساعة', |
|||
'%d ساعة', |
|||
], |
|||
d: [ |
|||
'أقل من يوم', |
|||
'يوم واحد', |
|||
['يومان', 'يومين'], |
|||
'%d أيام', |
|||
'%d يومًا', |
|||
'%d يوم', |
|||
], |
|||
M: [ |
|||
'أقل من شهر', |
|||
'شهر واحد', |
|||
['شهران', 'شهرين'], |
|||
'%d أشهر', |
|||
'%d شهرا', |
|||
'%d شهر', |
|||
], |
|||
y: [ |
|||
'أقل من عام', |
|||
'عام واحد', |
|||
['عامان', 'عامين'], |
|||
'%d أعوام', |
|||
'%d عامًا', |
|||
'%d عام', |
|||
], |
|||
}, |
|||
pluralize = function (u) { |
|||
return function (number, withoutSuffix, string, isFuture) { |
|||
var f = pluralForm(number), |
|||
str = plurals[u][pluralForm(number)]; |
|||
if (f === 2) { |
|||
str = str[withoutSuffix ? 0 : 1]; |
|||
} |
|||
return str.replace(/%d/i, number); |
|||
}; |
|||
}, |
|||
months = [ |
|||
'جانفي', |
|||
'فيفري', |
|||
'مارس', |
|||
'أفريل', |
|||
'ماي', |
|||
'جوان', |
|||
'جويلية', |
|||
'أوت', |
|||
'سبتمبر', |
|||
'أكتوبر', |
|||
'نوفمبر', |
|||
'ديسمبر', |
|||
]; |
|||
|
|||
var arDz = moment.defineLocale('ar-dz', { |
|||
months: months, |
|||
monthsShort: months, |
|||
weekdays: 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'), |
|||
weekdaysShort: 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'), |
|||
weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'), |
|||
weekdaysParseExact: true, |
|||
longDateFormat: { |
|||
LT: 'HH:mm', |
|||
LTS: 'HH:mm:ss', |
|||
L: 'D/\u200FM/\u200FYYYY', |
|||
LL: 'D MMMM YYYY', |
|||
LLL: 'D MMMM YYYY HH:mm', |
|||
LLLL: 'dddd D MMMM YYYY HH:mm', |
|||
}, |
|||
meridiemParse: /ص|م/, |
|||
isPM: function (input) { |
|||
return 'م' === input; |
|||
}, |
|||
meridiem: function (hour, minute, isLower) { |
|||
if (hour < 12) { |
|||
return 'ص'; |
|||
} else { |
|||
return 'م'; |
|||
} |
|||
}, |
|||
calendar: { |
|||
sameDay: '[اليوم عند الساعة] LT', |
|||
nextDay: '[غدًا عند الساعة] LT', |
|||
nextWeek: 'dddd [عند الساعة] LT', |
|||
lastDay: '[أمس عند الساعة] LT', |
|||
lastWeek: 'dddd [عند الساعة] LT', |
|||
sameElse: 'L', |
|||
}, |
|||
relativeTime: { |
|||
future: 'بعد %s', |
|||
past: 'منذ %s', |
|||
s: pluralize('s'), |
|||
ss: pluralize('s'), |
|||
m: pluralize('m'), |
|||
mm: pluralize('m'), |
|||
h: pluralize('h'), |
|||
hh: pluralize('h'), |
|||
d: pluralize('d'), |
|||
dd: pluralize('d'), |
|||
M: pluralize('M'), |
|||
MM: pluralize('M'), |
|||
y: pluralize('y'), |
|||
yy: pluralize('y'), |
|||
}, |
|||
postformat: function (string) { |
|||
return string.replace(/,/g, '،'); |
|||
}, |
|||
week: { |
|||
dow: 0, // Sunday is the first day of the week.
|
|||
doy: 4, // The week that contains Jan 4th is the first week of the year.
|
|||
}, |
|||
}); |
|||
|
|||
return arDz; |
|||
|
|||
}))); |
|||
@ -0,0 +1,66 @@ |
|||
//! moment.js locale configuration
|
|||
//! locale : Arabic (Kuwait) [ar-kw]
|
|||
//! author : Nusret Parlak: https://github.com/nusretparlak
|
|||
|
|||
;(function (global, factory) { |
|||
typeof exports === 'object' && typeof module !== 'undefined' |
|||
&& typeof require === 'function' ? factory(require('../moment')) : |
|||
typeof define === 'function' && define.amd ? define(['../moment'], factory) : |
|||
factory(global.moment) |
|||
}(this, (function (moment) { 'use strict'; |
|||
|
|||
//! moment.js locale configuration
|
|||
|
|||
var arKw = moment.defineLocale('ar-kw', { |
|||
months: 'يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر'.split( |
|||
'_' |
|||
), |
|||
monthsShort: |
|||
'يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر'.split( |
|||
'_' |
|||
), |
|||
weekdays: 'الأحد_الإتنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'), |
|||
weekdaysShort: 'احد_اتنين_ثلاثاء_اربعاء_خميس_جمعة_سبت'.split('_'), |
|||
weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'), |
|||
weekdaysParseExact: true, |
|||
longDateFormat: { |
|||
LT: 'HH:mm', |
|||
LTS: 'HH:mm:ss', |
|||
L: 'DD/MM/YYYY', |
|||
LL: 'D MMMM YYYY', |
|||
LLL: 'D MMMM YYYY HH:mm', |
|||
LLLL: 'dddd D MMMM YYYY HH:mm', |
|||
}, |
|||
calendar: { |
|||
sameDay: '[اليوم على الساعة] LT', |
|||
nextDay: '[غدا على الساعة] LT', |
|||
nextWeek: 'dddd [على الساعة] LT', |
|||
lastDay: '[أمس على الساعة] LT', |
|||
lastWeek: 'dddd [على الساعة] LT', |
|||
sameElse: 'L', |
|||
}, |
|||
relativeTime: { |
|||
future: 'في %s', |
|||
past: 'منذ %s', |
|||
s: 'ثوان', |
|||
ss: '%d ثانية', |
|||
m: 'دقيقة', |
|||
mm: '%d دقائق', |
|||
h: 'ساعة', |
|||
hh: '%d ساعات', |
|||
d: 'يوم', |
|||
dd: '%d أيام', |
|||
M: 'شهر', |
|||
MM: '%d أشهر', |
|||
y: 'سنة', |
|||
yy: '%d سنوات', |
|||
}, |
|||
week: { |
|||
dow: 0, // Sunday is the first day of the week.
|
|||
doy: 12, // The week that contains Jan 12th is the first week of the year.
|
|||
}, |
|||
}); |
|||
|
|||
return arKw; |
|||
|
|||
}))); |
|||
@ -0,0 +1,182 @@ |
|||
//! moment.js locale configuration
|
|||
//! locale : Arabic (Libya) [ar-ly]
|
|||
//! author : Ali Hmer: https://github.com/kikoanis
|
|||
|
|||
;(function (global, factory) { |
|||
typeof exports === 'object' && typeof module !== 'undefined' |
|||
&& typeof require === 'function' ? factory(require('../moment')) : |
|||
typeof define === 'function' && define.amd ? define(['../moment'], factory) : |
|||
factory(global.moment) |
|||
}(this, (function (moment) { 'use strict'; |
|||
|
|||
//! moment.js locale configuration
|
|||
|
|||
var symbolMap = { |
|||
1: '1', |
|||
2: '2', |
|||
3: '3', |
|||
4: '4', |
|||
5: '5', |
|||
6: '6', |
|||
7: '7', |
|||
8: '8', |
|||
9: '9', |
|||
0: '0', |
|||
}, |
|||
pluralForm = function (n) { |
|||
return n === 0 |
|||
? 0 |
|||
: n === 1 |
|||
? 1 |
|||
: n === 2 |
|||
? 2 |
|||
: n % 100 >= 3 && n % 100 <= 10 |
|||
? 3 |
|||
: n % 100 >= 11 |
|||
? 4 |
|||
: 5; |
|||
}, |
|||
plurals = { |
|||
s: [ |
|||
'أقل من ثانية', |
|||
'ثانية واحدة', |
|||
['ثانيتان', 'ثانيتين'], |
|||
'%d ثوان', |
|||
'%d ثانية', |
|||
'%d ثانية', |
|||
], |
|||
m: [ |
|||
'أقل من دقيقة', |
|||
'دقيقة واحدة', |
|||
['دقيقتان', 'دقيقتين'], |
|||
'%d دقائق', |
|||
'%d دقيقة', |
|||
'%d دقيقة', |
|||
], |
|||
h: [ |
|||
'أقل من ساعة', |
|||
'ساعة واحدة', |
|||
['ساعتان', 'ساعتين'], |
|||
'%d ساعات', |
|||
'%d ساعة', |
|||
'%d ساعة', |
|||
], |
|||
d: [ |
|||
'أقل من يوم', |
|||
'يوم واحد', |
|||
['يومان', 'يومين'], |
|||
'%d أيام', |
|||
'%d يومًا', |
|||
'%d يوم', |
|||
], |
|||
M: [ |
|||
'أقل من شهر', |
|||
'شهر واحد', |
|||
['شهران', 'شهرين'], |
|||
'%d أشهر', |
|||
'%d شهرا', |
|||
'%d شهر', |
|||
], |
|||
y: [ |
|||
'أقل من عام', |
|||
'عام واحد', |
|||
['عامان', 'عامين'], |
|||
'%d أعوام', |
|||
'%d عامًا', |
|||
'%d عام', |
|||
], |
|||
}, |
|||
pluralize = function (u) { |
|||
return function (number, withoutSuffix, string, isFuture) { |
|||
var f = pluralForm(number), |
|||
str = plurals[u][pluralForm(number)]; |
|||
if (f === 2) { |
|||
str = str[withoutSuffix ? 0 : 1]; |
|||
} |
|||
return str.replace(/%d/i, number); |
|||
}; |
|||
}, |
|||
months = [ |
|||
'يناير', |
|||
'فبراير', |
|||
'مارس', |
|||
'أبريل', |
|||
'مايو', |
|||
'يونيو', |
|||
'يوليو', |
|||
'أغسطس', |
|||
'سبتمبر', |
|||
'أكتوبر', |
|||
'نوفمبر', |
|||
'ديسمبر', |
|||
]; |
|||
|
|||
var arLy = moment.defineLocale('ar-ly', { |
|||
months: months, |
|||
monthsShort: months, |
|||
weekdays: 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'), |
|||
weekdaysShort: 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'), |
|||
weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'), |
|||
weekdaysParseExact: true, |
|||
longDateFormat: { |
|||
LT: 'HH:mm', |
|||
LTS: 'HH:mm:ss', |
|||
L: 'D/\u200FM/\u200FYYYY', |
|||
LL: 'D MMMM YYYY', |
|||
LLL: 'D MMMM YYYY HH:mm', |
|||
LLLL: 'dddd D MMMM YYYY HH:mm', |
|||
}, |
|||
meridiemParse: /ص|م/, |
|||
isPM: function (input) { |
|||
return 'م' === input; |
|||
}, |
|||
meridiem: function (hour, minute, isLower) { |
|||
if (hour < 12) { |
|||
return 'ص'; |
|||
} else { |
|||
return 'م'; |
|||
} |
|||
}, |
|||
calendar: { |
|||
sameDay: '[اليوم عند الساعة] LT', |
|||
nextDay: '[غدًا عند الساعة] LT', |
|||
nextWeek: 'dddd [عند الساعة] LT', |
|||
lastDay: '[أمس عند الساعة] LT', |
|||
lastWeek: 'dddd [عند الساعة] LT', |
|||
sameElse: 'L', |
|||
}, |
|||
relativeTime: { |
|||
future: 'بعد %s', |
|||
past: 'منذ %s', |
|||
s: pluralize('s'), |
|||
ss: pluralize('s'), |
|||
m: pluralize('m'), |
|||
mm: pluralize('m'), |
|||
h: pluralize('h'), |
|||
hh: pluralize('h'), |
|||
d: pluralize('d'), |
|||
dd: pluralize('d'), |
|||
M: pluralize('M'), |
|||
MM: pluralize('M'), |
|||
y: pluralize('y'), |
|||
yy: pluralize('y'), |
|||
}, |
|||
preparse: function (string) { |
|||
return string.replace(/،/g, ','); |
|||
}, |
|||
postformat: function (string) { |
|||
return string |
|||
.replace(/\d/g, function (match) { |
|||
return symbolMap[match]; |
|||
}) |
|||
.replace(/,/g, '،'); |
|||
}, |
|||
week: { |
|||
dow: 6, // Saturday is the first day of the week.
|
|||
doy: 12, // The week that contains Jan 12th is the first week of the year.
|
|||
}, |
|||
}); |
|||
|
|||
return arLy; |
|||
|
|||
}))); |
|||
@ -0,0 +1,67 @@ |
|||
//! moment.js locale configuration
|
|||
//! locale : Arabic (Morocco) [ar-ma]
|
|||
//! author : ElFadili Yassine : https://github.com/ElFadiliY
|
|||
//! author : Abdel Said : https://github.com/abdelsaid
|
|||
|
|||
;(function (global, factory) { |
|||
typeof exports === 'object' && typeof module !== 'undefined' |
|||
&& typeof require === 'function' ? factory(require('../moment')) : |
|||
typeof define === 'function' && define.amd ? define(['../moment'], factory) : |
|||
factory(global.moment) |
|||
}(this, (function (moment) { 'use strict'; |
|||
|
|||
//! moment.js locale configuration
|
|||
|
|||
var arMa = moment.defineLocale('ar-ma', { |
|||
months: 'يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر'.split( |
|||
'_' |
|||
), |
|||
monthsShort: |
|||
'يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر'.split( |
|||
'_' |
|||
), |
|||
weekdays: 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'), |
|||
weekdaysShort: 'احد_اثنين_ثلاثاء_اربعاء_خميس_جمعة_سبت'.split('_'), |
|||
weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'), |
|||
weekdaysParseExact: true, |
|||
longDateFormat: { |
|||
LT: 'HH:mm', |
|||
LTS: 'HH:mm:ss', |
|||
L: 'DD/MM/YYYY', |
|||
LL: 'D MMMM YYYY', |
|||
LLL: 'D MMMM YYYY HH:mm', |
|||
LLLL: 'dddd D MMMM YYYY HH:mm', |
|||
}, |
|||
calendar: { |
|||
sameDay: '[اليوم على الساعة] LT', |
|||
nextDay: '[غدا على الساعة] LT', |
|||
nextWeek: 'dddd [على الساعة] LT', |
|||
lastDay: '[أمس على الساعة] LT', |
|||
lastWeek: 'dddd [على الساعة] LT', |
|||
sameElse: 'L', |
|||
}, |
|||
relativeTime: { |
|||
future: 'في %s', |
|||
past: 'منذ %s', |
|||
s: 'ثوان', |
|||
ss: '%d ثانية', |
|||
m: 'دقيقة', |
|||
mm: '%d دقائق', |
|||
h: 'ساعة', |
|||
hh: '%d ساعات', |
|||
d: 'يوم', |
|||
dd: '%d أيام', |
|||
M: 'شهر', |
|||
MM: '%d أشهر', |
|||
y: 'سنة', |
|||
yy: '%d سنوات', |
|||
}, |
|||
week: { |
|||
dow: 1, // Monday is the first day of the week.
|
|||
doy: 4, // The week that contains Jan 4th is the first week of the year.
|
|||
}, |
|||
}); |
|||
|
|||
return arMa; |
|||
|
|||
}))); |
|||
@ -0,0 +1,116 @@ |
|||
//! moment.js locale configuration
|
|||
//! locale : Arabic (Saudi Arabia) [ar-sa]
|
|||
//! author : Suhail Alkowaileet : https://github.com/xsoh
|
|||
|
|||
;(function (global, factory) { |
|||
typeof exports === 'object' && typeof module !== 'undefined' |
|||
&& typeof require === 'function' ? factory(require('../moment')) : |
|||
typeof define === 'function' && define.amd ? define(['../moment'], factory) : |
|||
factory(global.moment) |
|||
}(this, (function (moment) { 'use strict'; |
|||
|
|||
//! moment.js locale configuration
|
|||
|
|||
var symbolMap = { |
|||
1: '١', |
|||
2: '٢', |
|||
3: '٣', |
|||
4: '٤', |
|||
5: '٥', |
|||
6: '٦', |
|||
7: '٧', |
|||
8: '٨', |
|||
9: '٩', |
|||
0: '٠', |
|||
}, |
|||
numberMap = { |
|||
'١': '1', |
|||
'٢': '2', |
|||
'٣': '3', |
|||
'٤': '4', |
|||
'٥': '5', |
|||
'٦': '6', |
|||
'٧': '7', |
|||
'٨': '8', |
|||
'٩': '9', |
|||
'٠': '0', |
|||
}; |
|||
|
|||
var arSa = moment.defineLocale('ar-sa', { |
|||
months: 'يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split( |
|||
'_' |
|||
), |
|||
monthsShort: |
|||
'يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split( |
|||
'_' |
|||
), |
|||
weekdays: 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'), |
|||
weekdaysShort: 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'), |
|||
weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'), |
|||
weekdaysParseExact: true, |
|||
longDateFormat: { |
|||
LT: 'HH:mm', |
|||
LTS: 'HH:mm:ss', |
|||
L: 'DD/MM/YYYY', |
|||
LL: 'D MMMM YYYY', |
|||
LLL: 'D MMMM YYYY HH:mm', |
|||
LLLL: 'dddd D MMMM YYYY HH:mm', |
|||
}, |
|||
meridiemParse: /ص|م/, |
|||
isPM: function (input) { |
|||
return 'م' === input; |
|||
}, |
|||
meridiem: function (hour, minute, isLower) { |
|||
if (hour < 12) { |
|||
return 'ص'; |
|||
} else { |
|||
return 'م'; |
|||
} |
|||
}, |
|||
calendar: { |
|||
sameDay: '[اليوم على الساعة] LT', |
|||
nextDay: '[غدا على الساعة] LT', |
|||
nextWeek: 'dddd [على الساعة] LT', |
|||
lastDay: '[أمس على الساعة] LT', |
|||
lastWeek: 'dddd [على الساعة] LT', |
|||
sameElse: 'L', |
|||
}, |
|||
relativeTime: { |
|||
future: 'في %s', |
|||
past: 'منذ %s', |
|||
s: 'ثوان', |
|||
ss: '%d ثانية', |
|||
m: 'دقيقة', |
|||
mm: '%d دقائق', |
|||
h: 'ساعة', |
|||
hh: '%d ساعات', |
|||
d: 'يوم', |
|||
dd: '%d أيام', |
|||
M: 'شهر', |
|||
MM: '%d أشهر', |
|||
y: 'سنة', |
|||
yy: '%d سنوات', |
|||
}, |
|||
preparse: function (string) { |
|||
return string |
|||
.replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) { |
|||
return numberMap[match]; |
|||
}) |
|||
.replace(/،/g, ','); |
|||
}, |
|||
postformat: function (string) { |
|||
return string |
|||
.replace(/\d/g, function (match) { |
|||
return symbolMap[match]; |
|||
}) |
|||
.replace(/,/g, '،'); |
|||
}, |
|||
week: { |
|||
dow: 0, // Sunday is the first day of the week.
|
|||
doy: 6, // The week that contains Jan 6th is the first week of the year.
|
|||
}, |
|||
}); |
|||
|
|||
return arSa; |
|||
|
|||
}))); |
|||
@ -0,0 +1,66 @@ |
|||
//! moment.js locale configuration
|
|||
//! locale : Arabic (Tunisia) [ar-tn]
|
|||
//! author : Nader Toukabri : https://github.com/naderio
|
|||
|
|||
;(function (global, factory) { |
|||
typeof exports === 'object' && typeof module !== 'undefined' |
|||
&& typeof require === 'function' ? factory(require('../moment')) : |
|||
typeof define === 'function' && define.amd ? define(['../moment'], factory) : |
|||
factory(global.moment) |
|||
}(this, (function (moment) { 'use strict'; |
|||
|
|||
//! moment.js locale configuration
|
|||
|
|||
var arTn = moment.defineLocale('ar-tn', { |
|||
months: 'جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split( |
|||
'_' |
|||
), |
|||
monthsShort: |
|||
'جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split( |
|||
'_' |
|||
), |
|||
weekdays: 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'), |
|||
weekdaysShort: 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'), |
|||
weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'), |
|||
weekdaysParseExact: true, |
|||
longDateFormat: { |
|||
LT: 'HH:mm', |
|||
LTS: 'HH:mm:ss', |
|||
L: 'DD/MM/YYYY', |
|||
LL: 'D MMMM YYYY', |
|||
LLL: 'D MMMM YYYY HH:mm', |
|||
LLLL: 'dddd D MMMM YYYY HH:mm', |
|||
}, |
|||
calendar: { |
|||
sameDay: '[اليوم على الساعة] LT', |
|||
nextDay: '[غدا على الساعة] LT', |
|||
nextWeek: 'dddd [على الساعة] LT', |
|||
lastDay: '[أمس على الساعة] LT', |
|||
lastWeek: 'dddd [على الساعة] LT', |
|||
sameElse: 'L', |
|||
}, |
|||
relativeTime: { |
|||
future: 'في %s', |
|||
past: 'منذ %s', |
|||
s: 'ثوان', |
|||
ss: '%d ثانية', |
|||
m: 'دقيقة', |
|||
mm: '%d دقائق', |
|||
h: 'ساعة', |
|||
hh: '%d ساعات', |
|||
d: 'يوم', |
|||
dd: '%d أيام', |
|||
M: 'شهر', |
|||
MM: '%d أشهر', |
|||
y: 'سنة', |
|||
yy: '%d سنوات', |
|||
}, |
|||
week: { |
|||
dow: 1, // Monday is the first day of the week.
|
|||
doy: 4, // The week that contains Jan 4th is the first week of the year.
|
|||
}, |
|||
}); |
|||
|
|||
return arTn; |
|||
|
|||
}))); |
|||
@ -0,0 +1,200 @@ |
|||
//! moment.js locale configuration
|
|||
//! locale : Arabic [ar]
|
|||
//! author : Abdel Said: https://github.com/abdelsaid
|
|||
//! author : Ahmed Elkhatib
|
|||
//! author : forabi https://github.com/forabi
|
|||
|
|||
;(function (global, factory) { |
|||
typeof exports === 'object' && typeof module !== 'undefined' |
|||
&& typeof require === 'function' ? factory(require('../moment')) : |
|||
typeof define === 'function' && define.amd ? define(['../moment'], factory) : |
|||
factory(global.moment) |
|||
}(this, (function (moment) { 'use strict'; |
|||
|
|||
//! moment.js locale configuration
|
|||
|
|||
var symbolMap = { |
|||
1: '١', |
|||
2: '٢', |
|||
3: '٣', |
|||
4: '٤', |
|||
5: '٥', |
|||
6: '٦', |
|||
7: '٧', |
|||
8: '٨', |
|||
9: '٩', |
|||
0: '٠', |
|||
}, |
|||
numberMap = { |
|||
'١': '1', |
|||
'٢': '2', |
|||
'٣': '3', |
|||
'٤': '4', |
|||
'٥': '5', |
|||
'٦': '6', |
|||
'٧': '7', |
|||
'٨': '8', |
|||
'٩': '9', |
|||
'٠': '0', |
|||
}, |
|||
pluralForm = function (n) { |
|||
return n === 0 |
|||
? 0 |
|||
: n === 1 |
|||
? 1 |
|||
: n === 2 |
|||
? 2 |
|||
: n % 100 >= 3 && n % 100 <= 10 |
|||
? 3 |
|||
: n % 100 >= 11 |
|||
? 4 |
|||
: 5; |
|||
}, |
|||
plurals = { |
|||
s: [ |
|||
'أقل من ثانية', |
|||
'ثانية واحدة', |
|||
['ثانيتان', 'ثانيتين'], |
|||
'%d ثوان', |
|||
'%d ثانية', |
|||
'%d ثانية', |
|||
], |
|||
m: [ |
|||
'أقل من دقيقة', |
|||
'دقيقة واحدة', |
|||
['دقيقتان', 'دقيقتين'], |
|||
'%d دقائق', |
|||
'%d دقيقة', |
|||
'%d دقيقة', |
|||
], |
|||
h: [ |
|||
'أقل من ساعة', |
|||
'ساعة واحدة', |
|||
['ساعتان', 'ساعتين'], |
|||
'%d ساعات', |
|||
'%d ساعة', |
|||
'%d ساعة', |
|||
], |
|||
d: [ |
|||
'أقل من يوم', |
|||
'يوم واحد', |
|||
['يومان', 'يومين'], |
|||
'%d أيام', |
|||
'%d يومًا', |
|||
'%d يوم', |
|||
], |
|||
M: [ |
|||
'أقل من شهر', |
|||
'شهر واحد', |
|||
['شهران', 'شهرين'], |
|||
'%d أشهر', |
|||
'%d شهرا', |
|||
'%d شهر', |
|||
], |
|||
y: [ |
|||
'أقل من عام', |
|||
'عام واحد', |
|||
['عامان', 'عامين'], |
|||
'%d أعوام', |
|||
'%d عامًا', |
|||
'%d عام', |
|||
], |
|||
}, |
|||
pluralize = function (u) { |
|||
return function (number, withoutSuffix, string, isFuture) { |
|||
var f = pluralForm(number), |
|||
str = plurals[u][pluralForm(number)]; |
|||
if (f === 2) { |
|||
str = str[withoutSuffix ? 0 : 1]; |
|||
} |
|||
return str.replace(/%d/i, number); |
|||
}; |
|||
}, |
|||
months = [ |
|||
'يناير', |
|||
'فبراير', |
|||
'مارس', |
|||
'أبريل', |
|||
'مايو', |
|||
'يونيو', |
|||
'يوليو', |
|||
'أغسطس', |
|||
'سبتمبر', |
|||
'أكتوبر', |
|||
'نوفمبر', |
|||
'ديسمبر', |
|||
]; |
|||
|
|||
var ar = moment.defineLocale('ar', { |
|||
months: months, |
|||
monthsShort: months, |
|||
weekdays: 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'), |
|||
weekdaysShort: 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'), |
|||
weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'), |
|||
weekdaysParseExact: true, |
|||
longDateFormat: { |
|||
LT: 'HH:mm', |
|||
LTS: 'HH:mm:ss', |
|||
L: 'D/\u200FM/\u200FYYYY', |
|||
LL: 'D MMMM YYYY', |
|||
LLL: 'D MMMM YYYY HH:mm', |
|||
LLLL: 'dddd D MMMM YYYY HH:mm', |
|||
}, |
|||
meridiemParse: /ص|م/, |
|||
isPM: function (input) { |
|||
return 'م' === input; |
|||
}, |
|||
meridiem: function (hour, minute, isLower) { |
|||
if (hour < 12) { |
|||
return 'ص'; |
|||
} else { |
|||
return 'م'; |
|||
} |
|||
}, |
|||
calendar: { |
|||
sameDay: '[اليوم عند الساعة] LT', |
|||
nextDay: '[غدًا عند الساعة] LT', |
|||
nextWeek: 'dddd [عند الساعة] LT', |
|||
lastDay: '[أمس عند الساعة] LT', |
|||
lastWeek: 'dddd [عند الساعة] LT', |
|||
sameElse: 'L', |
|||
}, |
|||
relativeTime: { |
|||
future: 'بعد %s', |
|||
past: 'منذ %s', |
|||
s: pluralize('s'), |
|||
ss: pluralize('s'), |
|||
m: pluralize('m'), |
|||
mm: pluralize('m'), |
|||
h: pluralize('h'), |
|||
hh: pluralize('h'), |
|||
d: pluralize('d'), |
|||
dd: pluralize('d'), |
|||
M: pluralize('M'), |
|||
MM: pluralize('M'), |
|||
y: pluralize('y'), |
|||
yy: pluralize('y'), |
|||
}, |
|||
preparse: function (string) { |
|||
return string |
|||
.replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) { |
|||
return numberMap[match]; |
|||
}) |
|||
.replace(/،/g, ','); |
|||
}, |
|||
postformat: function (string) { |
|||
return string |
|||
.replace(/\d/g, function (match) { |
|||
return symbolMap[match]; |
|||
}) |
|||
.replace(/,/g, '،'); |
|||
}, |
|||
week: { |
|||
dow: 6, // Saturday is the first day of the week.
|
|||
doy: 12, // The week that contains Jan 12th is the first week of the year.
|
|||
}, |
|||
}); |
|||
|
|||
return ar; |
|||
|
|||
}))); |
|||
@ -0,0 +1,113 @@ |
|||
//! moment.js locale configuration
|
|||
//! locale : Azerbaijani [az]
|
|||
//! author : topchiyev : https://github.com/topchiyev
|
|||
|
|||
;(function (global, factory) { |
|||
typeof exports === 'object' && typeof module !== 'undefined' |
|||
&& typeof require === 'function' ? factory(require('../moment')) : |
|||
typeof define === 'function' && define.amd ? define(['../moment'], factory) : |
|||
factory(global.moment) |
|||
}(this, (function (moment) { 'use strict'; |
|||
|
|||
//! moment.js locale configuration
|
|||
|
|||
var suffixes = { |
|||
1: '-inci', |
|||
5: '-inci', |
|||
8: '-inci', |
|||
70: '-inci', |
|||
80: '-inci', |
|||
2: '-nci', |
|||
7: '-nci', |
|||
20: '-nci', |
|||
50: '-nci', |
|||
3: '-üncü', |
|||
4: '-üncü', |
|||
100: '-üncü', |
|||
6: '-ncı', |
|||
9: '-uncu', |
|||
10: '-uncu', |
|||
30: '-uncu', |
|||
60: '-ıncı', |
|||
90: '-ıncı', |
|||
}; |
|||
|
|||
var az = moment.defineLocale('az', { |
|||
months: 'yanvar_fevral_mart_aprel_may_iyun_iyul_avqust_sentyabr_oktyabr_noyabr_dekabr'.split( |
|||
'_' |
|||
), |
|||
monthsShort: 'yan_fev_mar_apr_may_iyn_iyl_avq_sen_okt_noy_dek'.split('_'), |
|||
weekdays: |
|||
'Bazar_Bazar ertəsi_Çərşənbə axşamı_Çərşənbə_Cümə axşamı_Cümə_Şənbə'.split( |
|||
'_' |
|||
), |
|||
weekdaysShort: 'Baz_BzE_ÇAx_Çər_CAx_Cüm_Şən'.split('_'), |
|||
weekdaysMin: 'Bz_BE_ÇA_Çə_CA_Cü_Şə'.split('_'), |
|||
weekdaysParseExact: true, |
|||
longDateFormat: { |
|||
LT: 'HH:mm', |
|||
LTS: 'HH:mm:ss', |
|||
L: 'DD.MM.YYYY', |
|||
LL: 'D MMMM YYYY', |
|||
LLL: 'D MMMM YYYY HH:mm', |
|||
LLLL: 'dddd, D MMMM YYYY HH:mm', |
|||
}, |
|||
calendar: { |
|||
sameDay: '[bugün saat] LT', |
|||
nextDay: '[sabah saat] LT', |
|||
nextWeek: '[gələn həftə] dddd [saat] LT', |
|||
lastDay: '[dünən] LT', |
|||
lastWeek: '[keçən həftə] dddd [saat] LT', |
|||
sameElse: 'L', |
|||
}, |
|||
relativeTime: { |
|||
future: '%s sonra', |
|||
past: '%s əvvəl', |
|||
s: 'bir neçə saniyə', |
|||
ss: '%d saniyə', |
|||
m: 'bir dəqiqə', |
|||
mm: '%d dəqiqə', |
|||
h: 'bir saat', |
|||
hh: '%d saat', |
|||
d: 'bir gün', |
|||
dd: '%d gün', |
|||
M: 'bir ay', |
|||
MM: '%d ay', |
|||
y: 'bir il', |
|||
yy: '%d il', |
|||
}, |
|||
meridiemParse: /gecə|səhər|gündüz|axşam/, |
|||
isPM: function (input) { |
|||
return /^(gündüz|axşam)$/.test(input); |
|||
}, |
|||
meridiem: function (hour, minute, isLower) { |
|||
if (hour < 4) { |
|||
return 'gecə'; |
|||
} else if (hour < 12) { |
|||
return 'səhər'; |
|||
} else if (hour < 17) { |
|||
return 'gündüz'; |
|||
} else { |
|||
return 'axşam'; |
|||
} |
|||
}, |
|||
dayOfMonthOrdinalParse: /\d{1,2}-(ıncı|inci|nci|üncü|ncı|uncu)/, |
|||
ordinal: function (number) { |
|||
if (number === 0) { |
|||
// special case for zero
|
|||
return number + '-ıncı'; |
|||
} |
|||
var a = number % 10, |
|||
b = (number % 100) - a, |
|||
c = number >= 100 ? 100 : null; |
|||
return number + (suffixes[a] || suffixes[b] || suffixes[c]); |
|||
}, |
|||
week: { |
|||
dow: 1, // Monday is the first day of the week.
|
|||
doy: 7, // The week that contains Jan 7th is the first week of the year.
|
|||
}, |
|||
}); |
|||
|
|||
return az; |
|||
|
|||
}))); |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue