diff --git a/.gitignore b/.gitignore index 5b8dfe9c11..b9576fda4c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ *.user *.userosscache *.sln.docstates +*.editorconfig # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs diff --git a/docs/en/API/Dynamic-CSharp-API-Clients.md b/docs/en/API/Dynamic-CSharp-API-Clients.md index 23ec336acf..d92846f5e8 100644 --- a/docs/en/API/Dynamic-CSharp-API-Clients.md +++ b/docs/en/API/Dynamic-CSharp-API-Clients.md @@ -1,4 +1,4 @@ -# Dynamic C# API Clients +# Dynamic C# API Client Proxies ABP can dynamically create C# API client proxies to call remote HTTP services (REST APIs). In this way, you don't need to deal with `HttpClient` and other low level HTTP features to call remote services and get results. diff --git a/docs/en/Background-Workers-Quartz.md b/docs/en/Background-Workers-Quartz.md index e1d8287019..ce82222c14 100644 --- a/docs/en/Background-Workers-Quartz.md +++ b/docs/en/Background-Workers-Quartz.md @@ -37,7 +37,7 @@ public class YourModule : AbpModule ```` > Quartz background worker integration provided `QuartzPeriodicBackgroundWorkerAdapter` to adapt `PeriodicBackgroundWorkerBase` and `AsyncPeriodicBackgroundWorkerBase` derived class. So, you can still fllow the [background workers document](Background-Workers.md) to define the background worker. -> `BackgroundJobWorker` checks todo jobs every 5 seconds, but quartz will not block when long time jobs are executing. So,after Added Quartz background worker integration, you also need to add [Quartz Background Jobs](Background-Jobs-Quartz.md) or [Hangfire Background Jobs](Background-Jobs-Hangfire.md) to avoid duplicate execution jobs. +> `BackgroundJobWorker` checks jobs every 5 seconds, but quartz will not block when long time jobs are executing. So,after Added Quartz background worker integration, you also need to add [Quartz Background Jobs](Background-Jobs-Quartz.md) or [Hangfire Background Jobs](Background-Jobs-Hangfire.md) to avoid duplicate execution jobs. ## Configuration diff --git a/docs/en/Domain-Driven-Design.md b/docs/en/Domain-Driven-Design.md index ce33295492..bbf22eab13 100644 --- a/docs/en/Domain-Driven-Design.md +++ b/docs/en/Domain-Driven-Design.md @@ -19,8 +19,12 @@ ABP follows DDD principles and patterns to achieve a layered application model w - **Domain Layer**: Includes business objects and the core (domain) business rules. This is the heart of the application. - **Infrastructure Layer**: Provides generic technical capabilities that support higher layers mostly using 3rd-party libraries. +DDD mostly interest in the **Domain** and the **Application** layers, rather than the Infrastructure and the Presentation layers. + ## Contents +See the following documents to learn what ABP Framework provides to you to implement DDD in your project. + * **Domain Layer** * [Entities & Aggregate Roots](Entities.md) * Value Objects @@ -30,4 +34,4 @@ ABP follows DDD principles and patterns to achieve a layered application model w * **Application Layer** * [Application Services](Application-Services.md) * [Data Transfer Objects (DTOs)](Data-Transfer-Objects.md) - * Unit of Work \ No newline at end of file + * [Unit of Work](Unit-Of-Work.md) \ No newline at end of file diff --git a/docs/en/Domain-Services.md b/docs/en/Domain-Services.md index 7eb6c917cd..9f4a5ee544 100644 --- a/docs/en/Domain-Services.md +++ b/docs/en/Domain-Services.md @@ -1,3 +1,3 @@ -# ABP Documentation +# Domain Services -TODO! \ No newline at end of file +TODO \ No newline at end of file diff --git a/docs/en/Themes/Basic.md b/docs/en/Themes/Basic.md index a0165c803a..819138de5f 100644 --- a/docs/en/Themes/Basic.md +++ b/docs/en/Themes/Basic.md @@ -1,3 +1,2 @@ -## Basic Theme +This document has been moved to [here](../UI/AspNetCore/Basic-Theme.md). -TODO \ No newline at end of file diff --git a/docs/en/UI/AspNetCore/Basic-Theme.md b/docs/en/UI/AspNetCore/Basic-Theme.md index 3435e94a8b..67977ffd4e 100644 --- a/docs/en/UI/AspNetCore/Basic-Theme.md +++ b/docs/en/UI/AspNetCore/Basic-Theme.md @@ -1,3 +1,90 @@ # ASP.NET Core MVC / Razor Pages: The Basic Theme -This document is in progress. See the [Theming](Theming.md) document. \ No newline at end of file +The Basic Theme is a theme implementation for the ASP.NET Core MVC / Razor Pages UI. It is a minimalist theme that doesn't add any styling on top of the plain [Bootstrap](https://getbootstrap.com/). You can take the Basic Theme as the **base theme** and build your own theme or styling on top of it. See the *Customization* section. + +The Basic Theme has RTL (Right-to-Left language) support. + +> If you are looking for a professional, enterprise ready theme, you can check the [Lepton Theme](https://commercial.abp.io/themes), which is a part of the [ABP Commercial](https://commercial.abp.io/). + +> See the [Theming document](Theming.md) to learn about themes. + +## Installation + +**This theme is already installed** when you create a new solution using the [startup templates](../../Startup-Templates/Index.md). If you need to manually install it, follow the steps below: + +* Install the [Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic](https://www.nuget.org/packages/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic) NuGet package to your web project. +* Add `AbpAspNetCoreMvcUiBasicThemeModule` into the `[DependsOn(...)]` attribute for your [module class](../../Module-Development-Basics.md) in the web project. +* Install the [@abp/aspnetcore.mvc.ui.theme.basic](https://www.npmjs.com/package/@abp/aspnetcore.mvc.ui.theme.basic) NPM package to your web project (e.g. `npm install @abp/aspnetcore.mvc.ui.theme.basic` or `yarn add @abp/aspnetcore.mvc.ui.theme.basic`). +* Run `gulp` command in a command line terminal in the web project's folder. + +## Layouts + +The Basic Theme implements the standard layouts. All the layouts implement the following parts; + +* Global [Bundles](Bundling-Minification.md) +* [Page Alerts](Page-Alerts.md) +* [Layout Hooks](Layout-Hooks.md) +* [Widget](Widgets.md) Resources + +### The Application Layout + +![basic-theme-application-layout](../../images/basic-theme-application-layout.png) + +Application Layout implements the following parts, in addition to the common parts mentioned above; + +* Branding +* Main [Menu](Navigation-Menu.md) +* Main [Toolbar](Toolbars.md) with Language Selection & User Menu + +### The Account Layout + +![basic-theme-account-layout](../../images/basic-theme-account-layout.png) + +Application Layout implements the following parts, in addition to the common parts mentioned above; + +* Branding +* Main [Menu](Navigation-Menu.md) +* Main [Toolbar](Toolbars.md) with Language Selection & User Menu +* Tenant Switch Area + +### Empty Layout + +Empty layout is empty, as its name stands for. However, it implements the common parts mentioned above. + +## Customization + +You have two options two customize this theme: + +### Overriding Styles/Components + +In this approach, you continue to use the the theme as NuGet and NPM packages and customize the parts you need to. There are several ways to customize it; + +#### Override the Styles + +1. Create a CSS file in the `wwwroot` folder of your project: + +![example-global-styles](../../images/example-global-styles.png) + +2. Add the style file to the global bundle, in the `ConfigureServices` method of your [module](../../Module-Development-Basics.md): + +````csharp +Configure(options => +{ + options.StyleBundles.Configure(BasicThemeBundles.Styles.Global, bundle => + { + bundle.AddFiles("/styles/global-styles.css"); + }); +}); +```` + +#### Override the Components + +See the [User Interface Customization Guide](Customization-User-Interface.md) to learn how you can replace components, customize and extend the user interface. + +### Copy & Customize + +You can download the [source code](https://github.com/abpframework/abp/tree/dev/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic) of the Basic Theme, copy the project content into your solution, re-arrange the package/module dependencies (see the Installation section above to understand how it was installed to the project) and freely customize the theme based on your application requirements. + +## See Also + +* [Theming](Theming.md) \ No newline at end of file diff --git a/docs/en/UI/AspNetCore/Branding.md b/docs/en/UI/AspNetCore/Branding.md new file mode 100644 index 0000000000..ee19cd5845 --- /dev/null +++ b/docs/en/UI/AspNetCore/Branding.md @@ -0,0 +1,45 @@ +# ASP.NET Core MVC / Razor Pages: Branding + +## IBrandingProvider + +`IBrandingProvider` is a simple interface that is used to show the application name and logo on the layout. + +The screenshot below shows *MyProject* as the application name: + +![branding-nobrand](../../images/branding-nobrand.png) + +You can implement the `IBrandingProvider` interface or inherit from the `DefaultBrandingProvider` to set the application name: + +````csharp +using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Components; +using Volo.Abp.DependencyInjection; + +namespace MyProject.Web +{ + [Dependency(ReplaceServices = true)] + public class MyProjectBrandingProvider : DefaultBrandingProvider + { + public override string AppName => "Book Store"; + } +} +```` + +The result will be like shown below: + +![branding-appname](../../images/branding-appname.png) + +`IBrandingProvider` has the following properties: + +* `AppName`: The application name. +* `LogoUrl`: A URL to show the application logo. +* `LogoReverseUrl`: A URL to show the application logo on a reverse color theme (dark, for example). + +> **Tip**: `IBrandingProvider` is used in every page refresh. For a multi-tenant application, you can return a tenant specific application name to customize it per tenant. + +## Overriding the Branding Area + +The [Basic Theme](Basic-Theme.md) doesn't implement the logos. However, you can see the [UI Customization Guide](Customization-User-Interface.md) to learn how you can replace the branding area with a custom view component. + +An example screenshot with an image is used in the branding area: + +![bookstore-added-logo](../../images/bookstore-added-logo.png) \ No newline at end of file diff --git a/docs/en/UI/AspNetCore/Breadcrumbs.md b/docs/en/UI/AspNetCore/Breadcrumbs.md deleted file mode 100644 index cc3bcd95be..0000000000 --- a/docs/en/UI/AspNetCore/Breadcrumbs.md +++ /dev/null @@ -1,3 +0,0 @@ -# Toolbars - -TODO \ No newline at end of file diff --git a/docs/en/UI/AspNetCore/Customization-User-Interface.md b/docs/en/UI/AspNetCore/Customization-User-Interface.md index b3e0ec33fb..bc8e15e8bb 100644 --- a/docs/en/UI/AspNetCore/Customization-User-Interface.md +++ b/docs/en/UI/AspNetCore/Customization-User-Interface.md @@ -128,11 +128,11 @@ The ABP Framework, pre-built themes and modules define some **re-usable view com ### Example -The screenshot below was taken from the **basic theme** comes with the application startup template. +The screenshot below was taken from the [Basic Theme](Basic-Theme.md) comes with the application startup template. ![bookstore-brand-area-highlighted](../../images/bookstore-brand-area-highlighted.png) -[The basic theme](../../Themes/Basic.md) defines some view components for the layout. For example, the highlighted area with the red rectangle above is called **Brand component**. You probably want to customize this component by adding your **own application logo**. Let's see how to do it. +The [Basic Theme](Basic-Theme.md) defines some view components for the layout. For example, the highlighted area with the red rectangle above is called **Brand component**. You probably want to customize this component by adding your **own application logo**. Let's see how to do it. First, create your logo and place under a folder in your web application. We used `wwwroot/logos/bookstore-logo.png` path. Then copy the Brand component's view ([from here](https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Brand/Default.cshtml)) from the basic theme files under the `Themes/Basic/Components/Brand` folder. The result should be similar the picture below: diff --git a/docs/en/UI/AspNetCore/Data-Tables.md b/docs/en/UI/AspNetCore/Data-Tables.md new file mode 100644 index 0000000000..79fd6a3be1 --- /dev/null +++ b/docs/en/UI/AspNetCore/Data-Tables.md @@ -0,0 +1,263 @@ +# ASP.NET Core MVC / Razor Pages: Data Tables + +A Data Table (aka Data Grid) is a UI component to show tabular data to the users. There are a lot of Data table components/libraries and **you can use any one you like** with the ABP Framework. However, the startup templates come with the [DataTables.Net](https://datatables.net/) library as **pre-installed and configured**. ABP Framework provides adapters for this library and make it easy to use with the API endpoints. + +An example screenshot from the user management page that shows the user list in a data table: + +![datatables-example](../../images/datatables-example.png) + +## DataTables.Net Integration + +First of all, you can follow the official documentation to understand how the [DataTables.Net](https://datatables.net/) works. This section will focus on the ABP addons & integration points rather than fully covering the usage of this library. + +### A Quick Example + +You can follow the [web application development tutorial](https://docs.abp.io/en/abp/latest/Tutorials/Part-1?UI=MVC) for a complete example application that uses the DataTables.Net as the Data Table. This section shows a minimalist example. + +You do nothing to add DataTables.Net library to the page since it is already added to the global [bundle](Bundling-Minification.md) by default. + +First, add an `abp-table` as shown below, with an `id`: + +````html + +```` + +> `abp-table` is a [Tag Helper](Tag-Helpers/Index.md) defined by the ABP Framework, but a simple `` tag would also work. + +Then call the `DataTable` plugin on the table selector: + +````js +var dataTable = $('#BooksTable').DataTable( + abp.libs.datatables.normalizeConfiguration({ + serverSide: true, + paging: true, + order: [[1, "asc"]], + searching: false, + ajax: abp.libs.datatables.createAjax(acme.bookStore.books.book.getList), + columnDefs: [ + { + title: l('Actions'), + rowAction: { + items: + [ + { + text: l('Edit'), + action: function (data) { + ///... + } + } + ] + } + }, + { + title: l('Name'), + data: "name" + }, + { + title: l('PublishDate'), + data: "publishDate", + render: function (data) { + return luxon + .DateTime + .fromISO(data, { + locale: abp.localization.currentCulture.name + }).toLocaleString(); + } + }, + { + title: l('Price'), + data: "price" + } + ] + }) +); +```` + +The example code above uses some ABP integration features those will be explained in the next sections. + +### Configuration Normalization + +`abp.libs.datatables.normalizeConfiguration` function takes a DataTables configuration and normalizes to simplify it; + +* Sets `scrollX` option to `true`, if not set. +* Sets `target` index for the column definitions. +* Sets the `language` option to [localize](../../Localization.md) the table in the current language. + +#### Default Configuration + +`normalizeConfiguration` uses the default configuration. You can change the default configuration using the `abp.libs.datatables.defaultConfigurations` object. Example: + +````js +abp.libs.datatables.defaultConfigurations.scrollX = false; +```` + +Here, the all configuration options; + +* `scrollX`: `false` by default. +* `dom`: Default value is `<"dataTable_filters"f>rt<"row dataTable_footer"<"col-auto"l><"col-auto"i><"col"p>>`. +* `language`: A function that returns the localization text using the current language. + +### AJAX Adapter + +DataTables.Net has its own expected data format while getting results of an AJAX call to the server to get the table data. They are especially related how paging and sorting parameters are sent and received. ABP Framework also offers its own conventions for the client-server [AJAX](JavaScript-API/Ajax.md) communication. + +The `abp.libs.datatables.createAjax` method (used in the example above) adapts request and response data format and perfectly works with the [Dynamic JavaScript Client Proxy](Dynamic-JavaScript-Client-Proxies.md) system. + +This works automatically, so most of the times you don't need to know how it works. See the [DTO document](../../Data-Transfer-Objects.md) if you want to learn more about `IPagedAndSortedResultRequest`, `IPagedResult` and other standard interfaces and base DTO classes those are used in client to server communication. + +### Row Actions + +`rowAction` is an option defined by the ABP Framework to the column definitions to show a drop down button to take actions for a row in the table. + +The example screenshot below shows the actions for each user in the user management table: + +![datatables-example](../../images/datatables-row-actions.png) + +`rowAction` is defined as a part of a column definition: + +````csharp +{ + title: l('Actions'), + rowAction: { + //TODO: CONFIGURATION + } +}, +```` + +**Example: Show *Edit* and *Delete* actions for a book row** + +````js +{ + title: l('Actions'), + rowAction: { + items: + [ + { + text: l('Edit'), + action: function (data) { + //TODO: Open a modal to edit the book + } + }, + { + text: l('Delete'), + confirmMessage: function (data) { + return "Are you sure to delete the book " + data.record.name; + }, + action: function (data) { + acme.bookStore.books.book + .delete(data.record.id) + .then(function() { + abp.notify.info("Successfully deleted!"); + data.table.ajax.reload(); + }); + } + } + ] + } +}, +```` + +#### Action Items + +`items` is an array of action definitions. An action definition can have the following options; + +* `text`: The text (a `string`) for this action to be shown in the actions drop down. +* `action`: A `function` that is executed when the user clicks to the action. The function takes a `data` argument that has the following fields; + * `data.record`: This is the data object related to the row. You can access the data fields like `data.record.id`, `data.record.name`... etc. + * `data.table`: The DataTables instance. +* `confirmMessage`: A `function` (see the example above) that returns a message (`string`) to show a dialog to get a confirmation from the user before executing the `action`. Example confirmation dialog: + +![datatables-row-actions-confirmation](../../images/datatables-row-actions-confirmation.png) + +You can use the [localization](JavaScript-API/Localization.md) system to show a localized message. + +* `visible`: A `bool` or a `function` that returns a `bool`. If the result is `false`, then the action is not shown in the actions dropdown. This is generally combined by the [authorization](JavaScript-API/Auth.md) system to hide the action if the user has no permission to take this action. Example: + +````js +visible: abp.auth.isGranted('BookStore.Books.Delete'); +```` + +If you define a `function`, then the `function` has two arguments: `record` (the data object of the related row) and the `table` (the DataTable instance). So, you can decide to show/hide the action dynamically, based on the row data and other conditions. + +* `iconClass`: Can be used to show a font-icon, like a [Font-Awesome](https://fontawesome.com/) icon (ex: `fas fa-trash-alt`), near to the action text. Example screenshot: + +![datatables-row-actions-confirmation](../../images/datatables-row-actions-icon.png) + +* `enabled`: A `function` that returns a `bool` to disable the action. The `function` takes a `data` object with two fields: `data.record` is the data object related to the row and `data.table` is the DataTables instance. +* `displayNameHtml`: Set this to `true` is the `text` value contains HTML tags. + +There are some rules with the action items; + +* If none of the action items is visible then the actions column is not rendered. + +### Data Format + +#### The Problem + +See the *Creation Time* column in the example below: + +````js +{ + title: l('CreationTime'), + data: "creationTime", + render: function (data) { + return luxon + .DateTime + .fromISO(data, { + locale: abp.localization.currentCulture.name + }).toLocaleString(luxon.DateTime.DATETIME_SHORT); + } +} +```` + +The `render` is a standard DataTables option to render the column content by a custom function. This example uses the [luxon](https://moment.github.io/luxon/) library (which is installed by default) to write a human readable value of the `creationTime` in the current user's language. Example output of the column: + +![datatables-custom-render-date](../../images/datatables-custom-render-date.png) + +If you don't define the render option, then the result will be ugly and not user friendly: + +![datatables-custom-render-date](../../images/datatables-default-render-date.png) + +However, rendering a `DateTime` is almost same and repeating the same rendering logic everywhere is against to the DRY (Don't Repeat Yourself!) principle. + +#### dataFormat Option + +`dataFormat` column option specifies the data format that is used to render the column data. The same output could be accomplished using the following column definition: + +````js +{ + title: l('CreationTime'), + data: "creationTime", + dataFormat: 'datetime' +} +```` + +`dataFormat: 'datetime'` specifies the data format for this column. There are a few pre-defined `dataFormat`s: + +* `boolean`: Shows a `check` icon for `true` and `times` icon for `false` value and useful to render `bool` values. +* `date`: Shows date part of a `DateTime` value, formatted based on the current culture. +* `datetime`: Shows date & time (excluding seconds) of a `DateTime` value, formatted based on the current culture. + +### Default Renderers + +`abp.libs.datatables.defaultRenderers` option allows you to define new data formats and set renderers for them. + +**Example: Render male / female icons based on the gender** + +````js +abp.libs.datatables.defaultRenderers['gender'] = function(value) { + if (value === 'f') { + return ''; + } else { + return ''; + } +}; +```` + +Assuming that the possible values for a column data is `f` and `m`, the `gender` data format shows female/male icons instead of `f` and `m` texts. You can now set `dataFormat: 'gender'` for a column definition that has the proper data values. + +> You can write the default renderers in a single JavaScript file and add it to the [Global Script Bundle](Bundling-Minification.md), so you can reuse them in all the pages. + +## Other Data Grids + +You can use any library you like. For example, [see this article](https://community.abp.io/articles/using-devextreme-components-with-the-abp-framework-zb8z7yqv) to learn how to use DevExtreme Data Grid in your applications. \ No newline at end of file diff --git a/docs/en/UI/AspNetCore/Dynamic-JavaScript-Proxies.md b/docs/en/UI/AspNetCore/Dynamic-JavaScript-Proxies.md index 391a63a910..3464d4bc68 100644 --- a/docs/en/UI/AspNetCore/Dynamic-JavaScript-Proxies.md +++ b/docs/en/UI/AspNetCore/Dynamic-JavaScript-Proxies.md @@ -1,3 +1,91 @@ -# Dynamic JavaScript HTTP API Proxies +# Dynamic JavaScript API Client Proxies -TODO \ No newline at end of file +It is typical to consume your HTTP APIs from your JavaScript code. To do that, you normally deal with low level AJAX calls, like $.ajax, or better [abp.ajax](JavaScript-API/Ajax.md). ABP Framework provides **a better way** to call your HTTP APIs from your JavaScript code: Dynamic JavaScript API Client Proxies! + +## A Quick Example + +Assume that you have an application service defined as shown below: + +````csharp +using System; +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; + +namespace Acme.BookStore.Authors +{ + public interface IAuthorAppService : IApplicationService + { + Task GetAsync(Guid id); + + Task> GetListAsync(GetAuthorListDto input); + + Task CreateAsync(CreateAuthorDto input); + + Task UpdateAsync(Guid id, UpdateAuthorDto input); + + Task DeleteAsync(Guid id); + } +} +```` + +> You can follow the [web application development tutorial](../../Tutorials/Part-1.md) to learn how to create [application services](../../Application-Services.md), expose them as [HTTP APIs](../../API/Auto-API-Controllers.md) and consume from the JavaScript code as a complete example. + +You can call any of the methods just like calling a JavaScript function. The JavaScript function has the identical function **name**, **parameters** and the **return value** with the C# method. + +**Example: Get the authors list** + +````js +acme.bookStore.authors.author.getList({ + maxResultCount: 10 +}).then(function(result){ + console.log(result.items); +}); +```` + +**Example: Delete an author** + +```js +acme.bookStore.authors.author + .delete('7245a066-5457-4941-8aa7-3004778775f0') //Get id from somewhere! + .then(function() { + abp.notify.info('Successfully deleted!'); + }); +``` + +## AJAX Details + +Dynamic JavaScript client proxy functions use the [abp.ajax](JavaScript-API/Ajax.md) under the hood. So, you have the same benefits like **automatic error handling**. Also, you can fully control the AJAX call by providing the options. + +### The Return Value + +Every function returns a [Deferred object](https://api.jquery.com/category/deferred-object/). That means you can chain with `then` to get the result, `catch` to handle the error, `always` to perform an action once the operation completes (success or failed). + +### AJAX Options + +Every function gets an additional **last parameter** after your own parameters. The last parameter is called as `ajaxParams`. It is an object that overrides the AJAX options. + +**Example: Set `type` and `dataType` AJAX options** + +````js +acme.bookStore.authors.author + .delete('7245a066-5457-4941-8aa7-3004778775f0', { + type: 'POST', + dataType: 'xml' + }) + .then(function() { + abp.notify.info('Successfully deleted!'); + }); +```` + +See the [jQuery.ajax](https://api.jquery.com/jQuery.ajax/) documentation for all the available options. + +## Service Proxy Script Endpoint + +The magic is done by the `/Abp/ServiceProxyScript` endpoint defined by the ABP Framework and automatically added to the layout. You can visit this endpoint in your application to see the client proxy function definitions. This script file is automatically generated by the ABP Framework based on the server side method definitions and the related HTTP endpoint details. + +## See Also + +* [Web Application Development Tutorial](../../Tutorials/Part-1.md) +* [Auto API Controllers](../../API/Auto-API-Controllers.md) +* [Dynamic C# API Client Proxies](../../API/Dynamic-CSharp-API-Clients.md) \ No newline at end of file diff --git a/docs/en/UI/AspNetCore/Layout-Hooks.md b/docs/en/UI/AspNetCore/Layout-Hooks.md index 7039749142..168454a7c2 100644 --- a/docs/en/UI/AspNetCore/Layout-Hooks.md +++ b/docs/en/UI/AspNetCore/Layout-Hooks.md @@ -1,4 +1,4 @@ -# ASP.NET Core MVC / Razor Pages Layout Hooks +# ASP.NET Core MVC / Razor Pages: Layout Hooks ABP Framework theming system places the page layout into the [theme](Theming.md) NuGet packages. That means the final application doesn't include a `Layout.cshtml`, so you can't directly change the layout code to customize it. diff --git a/docs/en/UI/AspNetCore/Libraries/DatatablesNet.md b/docs/en/UI/AspNetCore/Libraries/DatatablesNet.md deleted file mode 100644 index a5a66e9e19..0000000000 --- a/docs/en/UI/AspNetCore/Libraries/DatatablesNet.md +++ /dev/null @@ -1,3 +0,0 @@ -# ABP Datatables.Net Integration for ASP.NET Core UI - -TODO \ No newline at end of file diff --git a/docs/en/UI/AspNetCore/Navigation-Menu.md b/docs/en/UI/AspNetCore/Navigation-Menu.md index ddbfbbd857..13a6e1678c 100644 --- a/docs/en/UI/AspNetCore/Navigation-Menu.md +++ b/docs/en/UI/AspNetCore/Navigation-Menu.md @@ -83,7 +83,7 @@ Here, a few notes on the menu contributors; There are more options of a menu item (the constructor of the `ApplicationMenuItem` class). Here, the list of all available options; -* `name` (`string`, required): The unique name of the menu item. +* `name` (`string`, required): The **unique name** of the menu item. * `displayName` (`string`, required): Display name/text of the menu item. You can [localize](../../Localization.md) this as shown before. * `url` (`string`): The URL of the menu item. * `icon` (`string`): An icon name. Free [Font Awesome](https://fontawesome.com/) icon classes are supported out of the box. Example: `fa fa-book`. You can use any CSS font icon class as long as you include the necessary CSS files to your application. diff --git a/docs/en/UI/AspNetCore/Overall.md b/docs/en/UI/AspNetCore/Overall.md new file mode 100644 index 0000000000..a499cd93a3 --- /dev/null +++ b/docs/en/UI/AspNetCore/Overall.md @@ -0,0 +1,159 @@ +# ASP.NET Core MVC / Razor Pages UI + +## Introduction + +ABP Framework provides a convenient and comfortable way of creating web applications using the ASP.NET Core MVC / Razor Pages as the User Interface framework. + +> ABP doesn't offer a new/custom way of UI development. You can continue to use your current skills to create the UI. However, it offers a lot of features to make your development easier and have a more maintainable code base. + +### MVC vs Razor Pages + +ASP.NET Core provides two models for UI development: + +* **[MVC (Model-View-Controller)](https://docs.microsoft.com/en-us/aspnet/core/mvc/)** is the classic way that exists from the version 1.0. This model can be used to create UI pages/components and HTTP APIs. +* **[Razor Pages](https://docs.microsoft.com/en-us/aspnet/core/razor-pages/)** was introduced with the ASP.NET Core 2.0 as a new way to create web pages. + +**ABP Framework supports both** of the MVC and the Razor Pages models. However, it is suggested to create the **UI pages with Razor Pages** approach and use the **MVC model to build HTTP APIs**. So, all the pre-build modules, samples and the documentation is based on the Razor Pages for the UI development, while you can always apply the MVC pattern to create your own pages. + +### Modularity + +[Modularity](../../Module-Development-Basics.md) is one of the key goals of the ABP Framework. It is not different for the UI; It is possible to develop modular applications and reusable application modules with isolated and reusable UI pages and components. + +The [application startup template](../../Startup-Templates/Application.md) comes with some application modules pre-installed. These modules have their own UI pages embedded into their own NuGet packages. You don't see their code in your solution, but they work as expected on runtime. + +## Theme System + +ABP Framework provides a complete [Theming](Theming.md) system with the following goals: + +* Reusable [application modules](../../Modules/Index.md) are developed **theme-independent**, so they can work with any UI theme. +* UI theme is **decided by the final application**. +* The theme is distributed via NuGet/NPM packages, so it is **easily upgradable**. +* The final application can **customize** the selected theme. + +### Current Themes + +Currently, two themes are **officially provided**: + +* The [Basic Theme](Basic-Theme.md) is the minimalist theme with the plain Bootstrap style. It is **open source and free**. +* The [Lepton Theme](https://commercial.abp.io/themes) is a **commercial** theme developed by the core ABP team and is a part of the [ABP Commercial](https://commercial.abp.io/) license. + +There are also some community-driven themes for the ABP Framework (you can search on the web). + +### Base Libraries + +There are a set of standard JavaScript/CSS libraries that comes pre-installed and supported by all the themes: + +- [Twitter Bootstrap](https://getbootstrap.com/) as the fundamental HTML/CSS framework. +- [JQuery](https://jquery.com/) for DOM manipulation. +- [DataTables.Net](https://datatables.net/) for data grids. +- [JQuery Validation](https://jqueryvalidation.org/) for client side & [unobtrusive](https://github.com/aspnet/jquery-validation-unobtrusive) validation +- [FontAwesome](https://fontawesome.com/) as the fundamental CSS font library. +- [SweetAlert](https://sweetalert.js.org/) to show fancy alert message and confirmation dialogs. +- [Toastr](https://github.com/CodeSeven/toastr) to show toast notifications. +- [Lodesh](https://lodash.com/) as a utility library. +- [Luxon](https://moment.github.io/luxon/) for date/time operations. +- [JQuery Form](https://github.com/jquery-form/form) for AJAX forms. +- [bootstrap-datepicker](https://github.com/uxsolutions/bootstrap-datepicker) to show date pickers. +- [Select2](https://select2.org/) for better select/combo boxes. +- [Timeago](http://timeago.yarp.com/) to show automatically updating fuzzy timestamps. +- [malihu-custom-scrollbar-plugin](https://github.com/malihu/malihu-custom-scrollbar-plugin) for custom scrollbars. + +You can use these libraries directly in your applications, without needing to manually import your page. + +### Layouts + +The themes provide the standard layouts. So, you have responsive layouts with the standard features already implemented. The screenshot below has taken from the Application Layout of the [Basic Theme](Basic-Theme.md): + +![basic-theme-application-layout](../../images/basic-theme-application-layout.png) + +See the [Theming](Theming.md) document for more layout options and other details. + +### Layout Parts + +A typical layout consists of multiple parts. The [Theming](Theming.md) system provides [menus](Navigation-Menu.md), [toolbars](Toolbars.md), [layout hooks](Layout-Hooks.md) and more to dynamically control the layout by your application and the modules you are using. + +## Features + +This section highlights some of the features provided by the ABP Framework for the ASP.NET Core MVC / Razor Pages UI. + +### Dynamic JavaScript API Client Proxies + +Dynamic JavaScript API Client Proxy system allows you to consume your server side HTTP APIs from your JavaScript client code, just like calling local functions. + +**Example: Get a list of authors from the server** + +````js +acme.bookStore.authors.author.getList({ + maxResultCount: 10 +}).then(function(result){ + console.log(result.items); +}); +```` + +`acme.bookStore.authors.author.getList` is an auto-generated function that internally makes an AJAX call to the server. + +See the [Dynamic JavaScript API Client Proxies](Dynamic-JavaScript-Proxies.md) document for more. + +### Bootstrap Tag Helpers + +ABP makes it easier & type safe to write Bootstrap HTML. + +**Example: Render a Bootstrap modal** + +````html + + + + Woohoo, you're reading this text in a modal! + + + +```` + +See the [Tag Helpers](Tag-Helpers/Index.md) document for more. + +### Forms & Validation + +ABP provides `abp-dynamic-form` and `abp-input` tag helpers to dramatically simplify to create a fully functional form that automates localization, validation and AJAX submission. + +**Example: Use `abp-dynamic-form` to create a complete form based on a model** + +````html + +```` + +See the [Forms & Validation](Forms-Validation.md) document for details. + +### Bundling & Minification / Client Side Libraries + +ABP provides a flexible and modular Bundling & Minification system to create bundles and minify style/script files on runtime. + +````html + + + + + + +```` + +Also, Client Side Package Management system offers a modular and consistent way of managing 3rd-party library dependencies. + +See the [Bundling & Minification](Bundling-Minification.md) and [Client Side Package Management](Client-Side-Package-Management.md) documents. + +### JavaScript APIs + +[JavaScript APIs](JavaScript-API/Index.md) provides a strong abstractions to the server side localization, settings, permissions, features... etc. They also provide a simple way to show messages and **notifications** to the user. + +### Modals, Alerts, Widgets and More + +ABP Framework provides a lot of built-in solutions to common application requirements; + +* [Widget System](Widgets.md) can be used to create reusable widgets & create dashboards. +* [Page Alerts](Page-Alerts.md) makes it easy to show alerts to the user. +* [Modal Manager](Modals.md) provides a simple way to build and use modals. +* [Data Tables](Data-Tables.md) integration makes straightforward to create data grids. + +## Customization + +There are a lot of ways to customize the theme and the UIs of the pre-built modules. You can override components, pages, static resources, bundles and more. See the [User Interface Customization Guide](Customization-User-Interface.md). \ No newline at end of file diff --git a/docs/en/UI/AspNetCore/Page-Header.md b/docs/en/UI/AspNetCore/Page-Header.md new file mode 100644 index 0000000000..f6ec3074de --- /dev/null +++ b/docs/en/UI/AspNetCore/Page-Header.md @@ -0,0 +1,58 @@ +# ASP.NET Core MVC / Razor Pages: Page Header + +`IPageLayout` service can be used to set the page title, selected menu item and the breadcrumb items for a page. It's the [theme](Theming.md)'s responsibility to render these on the page. + +## IPageLayout + +`IPageLayout` can be injected in any page/view to set the page header properties. + +### Page Title + +Page Title can be set as shown in the example below: + +````csharp +@inject IPageLayout PageLayout +@{ + PageLayout.Content.Title = "Book List"; +} +```` + +* The Page Title is set to the HTML `title` tag (in addition to the [brand/application name](Branding.md)). +* The theme may render the Page Title before the Page Content (not implemented by the Basic Theme). + +### Breadcrumb + +> **The [Basic Theme](Basic-Theme.md) currently doesn't implement the breadcrumbs.** + +Breadcrumb items can be added to the `PageLayout.Content.BreadCrumb`. + +**Example: Add Language Management to the breadcrumb items.** + +```` +PageLayout.Content.BreadCrumb.Add("Language Management"); +```` + +The theme then renders the breadcrumb. An example render result can be: + +![breadcrumbs-example](../../images/breadcrumbs-example.png) + +* The Home icon is rendered by default. Set `PageLayout.Content.BreadCrumb.ShowHome` to `false` to hide it. +* Current Page name (got from the `PageLayout.Content.Title`) is added as the last by default. Set `PageLayout.Content.BreadCrumb.ShowCurrent` to `false` to hide it. + +Any item that you add is inserted between Home and Current Page items. You can add as many item as you need. `BreadCrumb.Add(...)` method gets three parameters: + +* `text`: The text to show for the breadcrumb item. +* `url` (optional): A URL to navigate to, if the user clicks to the breadcrumb item. +* `icon` (optional): An icon class (like `fas fa-user-tie` for Font-Awesome) to show with the `text`. + +### The Selected Menu Item + +> **The [Basic Theme](Basic-Theme.md) currently doesn't implement the selected menu item since it is not applicable to the top menu which is the only option for the Basic Theme for now.** + +You can set the Menu Item name related to this page: + +````csharp +PageLayout.Content.MenuItemName = "BookStore.Books"; +```` + +Menu item name should match a unique menu item name defined using the [Navigation / Menu](Navigation-Menu.md) system. In this case, it is expected from the theme to make the menu item "active" in the main menu. \ No newline at end of file diff --git a/docs/en/UI/AspNetCore/Tag-Helpers/Index.md b/docs/en/UI/AspNetCore/Tag-Helpers/Index.md index 54c37af688..f85edb5142 100644 --- a/docs/en/UI/AspNetCore/Tag-Helpers/Index.md +++ b/docs/en/UI/AspNetCore/Tag-Helpers/Index.md @@ -13,7 +13,7 @@ ABP Framework also adds some **useful features** to the standard bootstrap compo Here, the list of components those are wrapped by the ABP Framework: * [Alerts](Alerts.md) -* [Badges](Badges.md)) +* [Badges](Badges.md) * [Blockquote](Blockquote.md) * [Borders](Borders.md) * [Breadcrumb](Breadcrumb.md) @@ -42,4 +42,4 @@ Here, the list of components those are wrapped by the ABP Framework: ## Dynamic Forms -**Abp Tag helpers** offer an easy way to build complete **Bootstrap forms**. See [Dynamic Forms documentation](Dynamic-Forms.md). \ No newline at end of file +**Abp Tag helpers** offer an easy way to build complete **Bootstrap forms**. See [Dynamic Forms documentation](Dynamic-Forms.md). diff --git a/docs/en/UI/AspNetCore/Theming.md b/docs/en/UI/AspNetCore/Theming.md index 594a882821..8c680973b8 100644 --- a/docs/en/UI/AspNetCore/Theming.md +++ b/docs/en/UI/AspNetCore/Theming.md @@ -114,7 +114,7 @@ The [Lepton Theme](https://commercial.abp.io/themes) shows the application logo #### The Empty Layout -The empty layout provides an empty page, however it typically includes the following parts; +The empty layout provides an empty page. It typically includes the following parts; * [Page alerts](Page-Alerts.md) * The page content (aka `RenderBody()`) @@ -177,4 +177,260 @@ Configure(options => #### The IThemeSelector Service -ABP Framework allows to use multiple themes together. This is why `options.Themes` is a list. `IThemeSelector` service selects the theme on the runtime. The application developer can set the `AbpThemingOptions.DefaultThemeName` to set the theme to be used, or replace the `IThemeSelector` service implementation (the default implementation is `DefaultThemeSelector`) to completely control the theme selection on runtime. \ No newline at end of file +ABP Framework allows to use multiple themes together. This is why `options.Themes` is a list. `IThemeSelector` service selects the theme on the runtime. The application developer can set the `AbpThemingOptions.DefaultThemeName` to set the theme to be used, or replace the `IThemeSelector` service implementation (the default implementation is `DefaultThemeSelector`) to completely control the theme selection on runtime. + +### Bundles + +[Bundling system](Bundling-Minification.md) provides a standard way to import style & script files into pages. There are two standard bundles defined by the ABP Framework: + +* `StandardBundles.Styles.Global`: The global bundle that includes the style files used in all the pages. Typically, it includes the CSS files of the Base Libraries. +* `StandardBundles.Scripts.Global`: The global bundle that includes the script files used in all the pages. Typically, it includes the JavaScript files of the Base Libraries. + +A theme generally extends these standard bundles by adding theme specific CSS/JavaScript files. + +The best way to define new bundles, inherit from the standard bundles and add to the `AbpBundlingOptions` as shown below (this code is from the [Basic Theme](Basic-Theme.md)): + +````csharp +Configure(options => +{ + options + .StyleBundles + .Add(BasicThemeBundles.Styles.Global, bundle => + { + bundle + .AddBaseBundles(StandardBundles.Styles.Global) + .AddContributors(typeof(BasicThemeGlobalStyleContributor)); + }); + + options + .ScriptBundles + .Add(BasicThemeBundles.Scripts.Global, bundle => + { + bundle + .AddBaseBundles(StandardBundles.Scripts.Global) + .AddContributors(typeof(BasicThemeGlobalScriptContributor)); + }); +}); +```` + +`BasicThemeGlobalStyleContributor` and `BasicThemeGlobalScriptContributor` are bundle contributors. For example, `BasicThemeGlobalStyleContributor` is defined as shown below: + +```csharp +public class BasicThemeGlobalStyleContributor : BundleContributor +{ + public override void ConfigureBundle(BundleConfigurationContext context) + { + context.Files.Add("/themes/basic/layout.css"); + } +} +``` + +Then the theme can render these bundles in a layout. For example, you can render the Global Styles as shown below: + +````html + +```` + +See the [Bundle & Minification](Bundling-Minification.md) document to understand the Bundling system better. + +### Layout Parts + +A typical Layout consists of several parts. The theme should include the necessary parts in each layout. + +**Example: The Basic Theme has the following parts for the Application Layout** + +![basic-theme-application-layout-parts](../../images/basic-theme-application-layout-parts.png) + +The application code and the modules can only show contents in the Page Content part. If they need to change the other parts (to add a menu item, to add a toolbar item, to change the application name in the branding area...) they should use the ABP Framework APIs. + +The following sections explain the fundamental parts pre-defined by the ABP Framework and can be implemented by the themes. + +> It is a good practice to split the layout into components/partials, so the final application can override them partially for customization purpose. + +#### Branding + +`IBrandingProvider` service should be used to get the name and the logo URL of the application to render in the Branding part. + +The [Application Startup Template](../../Startup-Templates/Application.md) has an implementation of this interface to set the values by the application developer. + +#### Main Menu + +`IMenuManager` service is used to get the main menu items and render on the layout. + +**Example: Get the Main Menu to render in a view component** + +```csharp +public class MainNavbarMenuViewComponent : AbpViewComponent +{ + private readonly IMenuManager _menuManager; + + public MainNavbarMenuViewComponent(IMenuManager menuManager) + { + _menuManager = menuManager; + } + + public async Task InvokeAsync() + { + var menu = await _menuManager.GetAsync(StandardMenus.Main); + return View("~/Themes/Basic/Components/Menu/Default.cshtml", menu); + } +} +``` + +See the [Navigation / Menus](Navigation-Menu.md) document to learn more about the navigation system. + +#### Main Toolbar + +`IToolbarManager` service is used to get the Main Toolbar items and render on the layout. Each item of this toolbar is a View Component, so it may include any type of UI elements. Inject the `IToolbarManager` and use the `GetAsync` to get the toolbar items: + +````csharp +var toolbar = await _toolbarManager.GetAsync(StandardToolbars.Main); +```` + +> See the [Toolbars](Toolbars.md) document to learn more on the toolbar system. + +The theme has a responsibility to add two pre-defined items to the main toolbar: Language Selection and User Menu. To do that, create a class implementing the `IToolbarContributor` interface and add it to the `AbpToolbarOptions` as shown below: + +```csharp +Configure(options => +{ + options.Contributors.Add(new BasicThemeMainTopToolbarContributor()); +}); +``` + +##### Language Selection + +Language Selection toolbar item is generally a dropdown that is used to switch between languages. `ILanguageProvider` is used to get the list of available languages and `CultureInfo.CurrentUICulture` is used to learn the current language. + +`/Abp/Languages/Switch` endpoint can be used to switch the language This endpoint accepts the following query string parameters: + +* `culture`: The selected culture, like `en-US` or `en`. +* `uiCulture`: The selected UI culture, like `en-US` or `en`. +* `returnUrl` (optional): Can be used to return a given URL after switching the language. + +`culture` and `uiCulture` should match one of the available languages. ABP Framework sets a culture cookie in the `/Abp/Languages/Switch` endpoint. + +##### User Menu + +User menu includes links related to the user account. `IMenuManager` is used just like the Main Menu, but this time with `StandardMenus.User` parameter like shown below: + +````csharp +var menu = await _menuManager.GetAsync(StandardMenus.User); +```` + +[ICurrentUser](../../CurrentUser.md) and [ICurrentTenant](../../Multi-Tenancy.md) services can be used to obtain the current user and tenant names. + +#### Page Alerts + +`IAlertManager` service is used to get the current page alerts to render on the layout. Use the `Alerts` list of the `IAlertManager`. It is generally rendered just before the page content (`RenderBody()`). + +See the [Page Alerts](Page-Alerts.md) document to learn more. + +#### Layout Hooks + +Since the Layout is in the theme package, the final application or any module can't directly manipulate the layout content. The [Layout Hook](Layout-Hooks.md) system allows to inject components to some specific points of the layout. + +The theme is responsible to render the hooks in the correct place. + +**Example: Render the `LayoutHooks.Head.First` Hook in the Application Layout** + +````html + + @await Component.InvokeLayoutHookAsync(LayoutHooks.Head.First, StandardLayouts.Application) + ... +```` + +See the [Layout Hook](Layout-Hooks.md) document to learn the standard layout hooks. + +#### Script / Style Sections + +Every layout should render the following optional sections: + +* `styles` section is rendered in the end of the `head`, just before the `LayoutHooks.Head.Last`. +* `scripts` section is rendered in the end of the `body`, just before the `LayoutHooks.Body.Last`. + +In this way, the page can import styles and scripts to the layout. + +**Example: Render the `styles` section** + +````csharp +@await RenderSectionAsync("styles", required: false) +```` + +#### Content Toolbar Section + +Another pre-defined section is the Content Toolbar section which can be used by the pages to add code just before the page content. The Basic Theme renders it as shown below: + +````html +
+
+ @RenderSection("content_toolbar", false) +
+
+```` + +The container div's id must be `AbpContentToolbar`. This section should come before the `RenderBody()`. + +#### Widget Resources + +The [Widget System](Widgets.md) allows to define reusable widgets with their own style/script files. All the layouts should render the widget style and scripts. + +**Widget Styles** is rendered as shown below, just before the `styles` section, after the global style bundle: + +````csharp +@await Component.InvokeAsync(typeof(WidgetStylesViewComponent)) +```` + +**Widget Scripts** is rendered as shown below, just before the `scripts` section, after the global script bundle: + +````csharp +@await Component.InvokeAsync(typeof(WidgetScriptsViewComponent)) +```` + +#### ABP Scripts + +ABP has some special scripts those should be included into every layout. They are not included in the global bundles since they are dynamically created based on the current user. + +ABP scripts (`ApplicationConfigurationScript` and `ServiceProxyScript`) should be added just after the global script bundle, as shown below: + +````html + + +```` + +#### Page Title, Selected Menu Item and Breadcrumbs + +`IPageLayout` service can be injected by any page to set the Page Title, the selected menu item name and the breadcrumb items. Then the theme can use this service to get these values and render on the UI. + +The Basic Theme doesn't implement this service, but the Lepton Theme implements: + +![breadcrumbs-example](../../images/breadcrumbs-example.png) + +See the [Page Header](Page-Header.md) document for more. + +#### Tenant Switch + +The Account Layout should allow the user to switch the current tenant if the application is multi-tenant and the tenant was resolved from the cookies. See the [Basic Theme Account Layout](https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Account.cshtml) as an example implementation. + +### Layout Classes + +The Standard Layouts (`Application`, `Account` and `Empty`) should add the following CSS classes to the `body` tag: + +* `abp-application-layout` for the `Application` layout. +* `abp-account-layout` for the `Account` layout. +* `abp-empty-layout` for the `Empty` layout. + +In this way, applications or modules can have selectors based on the current layout. + +### RTL + +To support Right-To-Left languages, the Layout should check the current culture and add `dir="rtl"` to the `html` tag and `rtl` CSS class the the `body` tag. + +You can check `CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft` to understand if the current language is a RTL language. + +### The NPM Package + +A theme should have a NPM package that depends on the [@abp/aspnetcore.mvc.ui.theme.shared](https://www.npmjs.com/package/@abp/aspnetcore.mvc.ui.theme.shared) package. In this way, it inherits all the Base Libraries. If the theme requires additional libraries, then it should define these dependencies too. + +Applications use the [Client Side Package Management](Client-Side-Package-Management.md) system to add client side libraries to the project. So, if an application uses your theme, it should add dependency to your theme's NPM package as well as the NuGet package dependency. + diff --git a/docs/en/UI/AspNetCore/Toolbars.md b/docs/en/UI/AspNetCore/Toolbars.md index cc3bcd95be..3f1185f61b 100644 --- a/docs/en/UI/AspNetCore/Toolbars.md +++ b/docs/en/UI/AspNetCore/Toolbars.md @@ -1,3 +1,74 @@ -# Toolbars +# ASP.NET Core MVC / Razor Pages UI: Toolbars -TODO \ No newline at end of file +The Toolbar system is used to define **toolbars** on the user interface. Modules (or your application) can add **items** to a toolbar, then the [theme](Theming.md) renders the toolbar on the **layout**. + +There is only one **standard toolbar** named "Main" (defined as a constant: `StandardToolbars.Main`). The [Basic Theme](Basic-Theme) renders the main toolbar as shown below: + +![bookstore-toolbar-highlighted](../../images/bookstore-toolbar-highlighted.png) + +In the screenshot above, there are two items added to the main toolbar: Language switch component & user menu. You can add your own items here. + +## Example: Add a Notification Icon + +In this example, we will add a **notification (bell) icon** to the left of the language switch item. A item in the toolbar should be a **view component**. So, first, create a new view component in your project: + +![bookstore-notification-view-component](../../images/bookstore-notification-view-component.png) + +**NotificationViewComponent.cs** + +````csharp +public class NotificationViewComponent : AbpViewComponent +{ + public async Task InvokeAsync() + { + return View("/Pages/Shared/Components/Notification/Default.cshtml"); + } +} +```` + +**Default.cshtml** + +````xml +
+ +
+```` + +Now, we can create a class implementing the `IToolbarContributor` interface: + +````csharp +public class MyToolbarContributor : IToolbarContributor +{ + public Task ConfigureToolbarAsync(IToolbarConfigurationContext context) + { + if (context.Toolbar.Name == StandardToolbars.Main) + { + context.Toolbar.Items + .Insert(0, new ToolbarItem(typeof(NotificationViewComponent))); + } + + return Task.CompletedTask; + } +} +```` + +This class adds the `NotificationViewComponent` as the first item in the `Main` toolbar. + +Finally, you need to add this contributor to the `AbpToolbarOptions`, in the `ConfigureServices` of your [module](../../Module-Development-Basics.md): + +````csharp +Configure(options => +{ + options.Contributors.Add(new MyToolbarContributor()); +}); +```` + +That's all, you will see the notification icon on the toolbar when you run the application: + +![bookstore-notification-icon-on-toolbar](../../images/bookstore-notification-icon-on-toolbar.png) + +`NotificationViewComponent` in this sample simply returns a view without any data. In real life, you probably want to **query database** (or call an HTTP API) to get notifications and pass to the view. If you need, you can add a `JavaScript` or `CSS` file to the global [bundle](Bundling-Minification.md) for your toolbar item. + +## IToolbarManager + +`IToolbarManager` is used to render the toolbar. It returns the toolbar items by a toolbar name. This is generally used by the [themes](Theming.md) to render the toolbar on the layout. \ No newline at end of file diff --git a/docs/en/UI/Blazor/Localization.md b/docs/en/UI/Blazor/Localization.md index e6cf761ce3..23b31a5a24 100644 --- a/docs/en/UI/Blazor/Localization.md +++ b/docs/en/UI/Blazor/Localization.md @@ -1,3 +1,3 @@ -# Blazor UI: Localization +# Blazor: Localization Blazor applications can reuse the same `IStringLocalizer` service that is explained in the [localization document](../../Localization.md). All the localization resources and texts available in the server side are usable in the Blazor application. \ No newline at end of file diff --git a/docs/en/UI/Blazor/Message.md b/docs/en/UI/Blazor/Message.md new file mode 100644 index 0000000000..8373bd1d82 --- /dev/null +++ b/docs/en/UI/Blazor/Message.md @@ -0,0 +1,3 @@ +# Blazor: UI Message Service + +TODO \ No newline at end of file diff --git a/docs/en/UI/Blazor/Notification.md b/docs/en/UI/Blazor/Notification.md new file mode 100644 index 0000000000..ef8945347b --- /dev/null +++ b/docs/en/UI/Blazor/Notification.md @@ -0,0 +1,3 @@ +# Blazor: Notification + +`UiNotificationService` is used to show toastr style notifications on the user interface. The documentation is in progress... \ No newline at end of file diff --git a/docs/en/UI/Blazor/Overall.md b/docs/en/UI/Blazor/Overall.md index 74c469e3c4..8af0e2fd0d 100644 --- a/docs/en/UI/Blazor/Overall.md +++ b/docs/en/UI/Blazor/Overall.md @@ -1,6 +1,8 @@ # Blazor UI for the ABP Framework -The detailed documentation for the Blazor UI is in progress. However, you can follow the documents below to start with the Blazor UI today. +## Getting Started + +You can follow the documents below to start with the ABP Framework and the Blazor UI: * [Get started](https://docs.abp.io/en/abp/latest/Getting-Started?UI=Blazor) with the Blazor UI for the ABP Framework. * [Web Application Development Tutorial](https://docs.abp.io/en/abp/latest/Tutorials/Part-1?UI=Blazor) with the Blazor UI. \ No newline at end of file diff --git a/docs/en/UI/Blazor/Services/Notification.md b/docs/en/UI/Blazor/Services/Notification.md deleted file mode 100644 index 0e5ababa0e..0000000000 --- a/docs/en/UI/Blazor/Services/Notification.md +++ /dev/null @@ -1,3 +0,0 @@ -# Blazor UI Notification - -`UiNotificationService` is used to show toastr style notifications on the user interface. The documentation is in progress... \ No newline at end of file diff --git a/docs/en/UI/Blazor/Settings.md b/docs/en/UI/Blazor/Settings.md index 276462c411..ad03dce5e2 100644 --- a/docs/en/UI/Blazor/Settings.md +++ b/docs/en/UI/Blazor/Settings.md @@ -1,3 +1,3 @@ -# Blazor UI: Settings +# Blazor: Settings Blazor applications can reuse the same `ISettingProvider` service that is explained in the [settings document](../../Settings.md). \ No newline at end of file diff --git a/docs/en/docs-nav.json b/docs/en/docs-nav.json index 1f4e77541f..838e41d5be 100644 --- a/docs/en/docs-nav.json +++ b/docs/en/docs-nav.json @@ -404,8 +404,12 @@ "text": "User Interface", "items": [ { - "text": "ASP.NET Core MVC / Razor Pages", + "text": "MVC / Razor Pages", "items": [ + { + "text": "Overall", + "path": "UI/AspNetCore/Overall.md" + }, { "text": "Navigation / Menus", "path": "UI/AspNetCore/Navigation-Menu.md" @@ -418,10 +422,18 @@ "text": "Modals", "path": "UI/AspNetCore/Modals.md" }, + { + "text": "Data Tables", + "path": "UI/AspNetCore/Data-Tables.md" + }, { "text": "Page Alerts", "path": "UI/AspNetCore/Page-Alerts.md" }, + { + "text": "Dynamic JavaScript API Client Proxies", + "path": "UI/AspNetCore/Dynamic-JavaScript-Proxies.md" + }, { "text": "Client Side Package Management", "path": "UI/AspNetCore/Client-Side-Package-Management.md" @@ -448,13 +460,31 @@ "text": "Widgets", "path": "UI/AspNetCore/Widgets.md" }, + { + "text": "Toolbars", + "path": "UI/AspNetCore/Toolbars.md" + }, + { + "text": "Page Header", + "path": "UI/AspNetCore/Page-Header.md" + }, + { + "text": "Branding", + "path": "UI/AspNetCore/Branding.md" + }, { "text": "Layout Hooks", "path": "UI/AspNetCore/Layout-Hooks.md" }, { "text": "Theming", - "path": "UI/AspNetCore/Theming.md" + "path": "UI/AspNetCore/Theming.md", + "items": [ + { + "text": "The Basic Theme", + "path": "UI/AspNetCore/Basic-Theme.md" + } + ] }, { "text": "JavaScript API", @@ -534,8 +564,20 @@ "text": "Services", "items": [ { - "text": "Overall", - "path": "UI/Blazor/Services/Notification.md" + "text": "Localization", + "path": "UI/Blazor/Localization.md" + }, + { + "text": "Settings", + "path": "UI/Blazor/Settings.md" + }, + { + "text": "Notification", + "path": "UI/Blazor/Notification.md" + }, + { + "text": "Message", + "path": "UI/Blazor/Message.md" } ] } diff --git a/docs/en/images/basic-theme-application-layout-parts.png b/docs/en/images/basic-theme-application-layout-parts.png new file mode 100644 index 0000000000..5e8f9147a9 Binary files /dev/null and b/docs/en/images/basic-theme-application-layout-parts.png differ diff --git a/docs/en/images/branding-appname.png b/docs/en/images/branding-appname.png new file mode 100644 index 0000000000..9300ad2c7f Binary files /dev/null and b/docs/en/images/branding-appname.png differ diff --git a/docs/en/images/branding-nobrand.png b/docs/en/images/branding-nobrand.png new file mode 100644 index 0000000000..1fdf78472b Binary files /dev/null and b/docs/en/images/branding-nobrand.png differ diff --git a/docs/en/images/breadcrumbs-example.png b/docs/en/images/breadcrumbs-example.png new file mode 100644 index 0000000000..17ae5f8ba5 Binary files /dev/null and b/docs/en/images/breadcrumbs-example.png differ diff --git a/docs/en/images/datatables-custom-render-date.png b/docs/en/images/datatables-custom-render-date.png new file mode 100644 index 0000000000..344237aea7 Binary files /dev/null and b/docs/en/images/datatables-custom-render-date.png differ diff --git a/docs/en/images/datatables-default-render-date.png b/docs/en/images/datatables-default-render-date.png new file mode 100644 index 0000000000..430c889d2f Binary files /dev/null and b/docs/en/images/datatables-default-render-date.png differ diff --git a/docs/en/images/datatables-example.png b/docs/en/images/datatables-example.png new file mode 100644 index 0000000000..ef3e74576b Binary files /dev/null and b/docs/en/images/datatables-example.png differ diff --git a/docs/en/images/datatables-row-actions-confirmation.png b/docs/en/images/datatables-row-actions-confirmation.png new file mode 100644 index 0000000000..9be8433f9c Binary files /dev/null and b/docs/en/images/datatables-row-actions-confirmation.png differ diff --git a/docs/en/images/datatables-row-actions-icon.png b/docs/en/images/datatables-row-actions-icon.png new file mode 100644 index 0000000000..70111fc1ac Binary files /dev/null and b/docs/en/images/datatables-row-actions-icon.png differ diff --git a/docs/en/images/datatables-row-actions.png b/docs/en/images/datatables-row-actions.png new file mode 100644 index 0000000000..4eae0f098a Binary files /dev/null and b/docs/en/images/datatables-row-actions.png differ diff --git a/docs/en/images/example-global-styles.png b/docs/en/images/example-global-styles.png new file mode 100644 index 0000000000..04232aa62d Binary files /dev/null and b/docs/en/images/example-global-styles.png differ diff --git a/docs/zh-Hans/Entity-Framework-Core-Migrations.md b/docs/zh-Hans/Entity-Framework-Core-Migrations.md index c6f1086540..266c0f46b0 100644 --- a/docs/zh-Hans/Entity-Framework-Core-Migrations.md +++ b/docs/zh-Hans/Entity-Framework-Core-Migrations.md @@ -235,7 +235,7 @@ public static class BackgroundJobsDbContextModelCreatingExtensions } ```` -此u还获取选项用于更改此模块的数据库表前缀和模式,但在这里并不重要. +此扩展方法还提供了选项用于更改此模块的数据库表前缀和模式,但在这里并不重要. 最终的应用程序在 `MigrationsDbContext` 类中调用扩展方法, 因此它可以确定此 `MigrationsDbContext` 维护的数据库中包含哪些模块. 如果要创建第二个数据库并将某些模块表移动到第二个数据库,则需要有第二个`MigrationsDbContext` 类,该类仅调用相关模块的扩展方法. 下一部分将详细介绍该主题. @@ -883,4 +883,4 @@ public class BookStoreDbMigratorModule : AbpModule ## 结论 -本文档说明了如何拆分数据库以及管理Entity Framework Core解决方案的数据库迁移. 简而言之,你需要为每个不同的数据库创建一个单独的迁移项目. \ No newline at end of file +本文档说明了如何拆分数据库以及管理Entity Framework Core解决方案的数据库迁移. 简而言之,你需要为每个不同的数据库创建一个单独的迁移项目. diff --git a/docs/zh-Hans/Getting-Started-AspNetCore-Application.md b/docs/zh-Hans/Getting-Started-AspNetCore-Application.md index 0334609bd3..be5e50c2bd 100644 --- a/docs/zh-Hans/Getting-Started-AspNetCore-Application.md +++ b/docs/zh-Hans/Getting-Started-AspNetCore-Application.md @@ -1,194 +1,160 @@ -## 在AspNet Core MVC Web Application中使用ABP - -本教程将介绍如何开始以最少的依赖关系开始使用ABP开发. - -通常情况下你需要下载一个 ***[启动模板](Getting-Started-AspNetCore-MVC-Template.md)*** - -### 创建一个新项目 - -1. 使用Visual Studio创建一个空的AspNet Core Web Application: - -![](images/create-new-aspnet-core-application.png) - -2. 选择空模板 - -![](images/select-empty-web-application.png) - -你可以选择其它模板,但是我想要从一个简洁的项目演示它. - -### 安装 Volo.Abp.AspNetCore.Mvc 包 - -Volo.Abp.AspNetCore.Mvc是ABP集成AspNet Core MVC的包,请安装它到你项目中: - -```` -Install-Package Volo.Abp.AspNetCore.Mvc -```` - -### 创建ABP模块 - -ABP是一个模块化框架,它需要一个**启动 (根) 模块**继承自``AbpModule``: - -````C# -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.Hosting; -using Volo.Abp; -using Volo.Abp.AspNetCore.Mvc; -using Volo.Abp.Modularity; - -namespace BasicAspNetCoreApplication -{ - [DependsOn(typeof(AbpAspNetCoreMvcModule))] - public class AppModule : AbpModule - { - public override void OnApplicationInitialization( - ApplicationInitializationContext context) - { - var app = context.GetApplicationBuilder(); - var env = context.GetEnvironment(); - - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - else - { - app.UseExceptionHandler("/Error"); - } - - app.UseStaticFiles(); - app.UseRouting(); - app.UseConfiguredEndpoints(); - } - } -} -```` - -``AppModule`` 是应用程序启动模块的好名称(建议你的启动模块也使用这个命名). - -ABP的包定义了这个模块类,模块可以依赖其它模块.在上面的代码中 ``AppModule`` 依赖于 ``AbpAspNetCoreMvcModule`` (模块存在于Volo.Abp.AspNetCore.Mvc包中). 安装新的ABP的包后添加``DependsOn``是很常见的做法. - -我们在此模块类中配置ASP.NET Core管道,而不是Startup类中. - -### 启动类 - -接下来修改启动类集成ABP模块系统: - -````C# -using System; -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.DependencyInjection; - -namespace BasicAspNetCoreApplication -{ - public class Startup - { - public IServiceProvider ConfigureServices(IServiceCollection services) - { - services.AddApplication(); - - return services.BuildServiceProviderFromFactory(); - } - - public void Configure(IApplicationBuilder app) - { - app.InitializeApplication(); - } - } -} - -```` - -修改``ConfigureServices``方法的返回值为``IServiceProvider``(默认是``void``).这个修改允许我们替换AspNet Core的依赖注入框架. (参阅下面的Autofac集成部分). ``services.AddApplication()``添加了所有模块中定义的全部服务. - -``app.InitializeApplication()`` 调用 ``Configure`` 方法初始化并启动应用程序 - -### Hello World! - -上面的应用程序没有什么功能,让我们创建一个MVC控制器实现一些功能: - -````C# -using Microsoft.AspNetCore.Mvc; -using Volo.Abp.AspNetCore.Mvc; - -namespace BasicAspNetCoreApplication.Controllers -{ - public class HomeController : AbpController - { - public IActionResult Index() - { - return Content("Hello World!"); - } - } -} - -```` - -如果运行这个应用程序你会在页面中看到"Hello World!". - -Derived ``HomeController`` from ``AbpController`` instead of standard ``Controller`` class. This is not required, but ``AbpController`` class has useful base properties and methods to make your development easier. - -从``AbpController``派生``HomeController`` 而不是继承自``Controller``类.虽然这不是强制要求,但是``AbpController``类有很多有用的有属性和方法,使你的开发更容易. - -### 使用 Autofac 依赖注入框架 - -虽然AspNet Core的依赖注入(DI)系统适用于基本要求,但Autofac提供了属性注入和方法拦截等高级功能,这些功能是ABP执行高级应用程序框架功能所必需的. - -用Autofac取代AspNet Core的DI系统并集成到ABP非常简单. - -1. 安装 Volo.Abp.Autofac 包 - -```` -Install-Package Volo.Abp.Autofac -```` - -2. 添加 ``AbpAutofacModule`` 依赖 - -````C# -[DependsOn(typeof(AbpAspNetCoreMvcModule))] -[DependsOn(typeof(AbpAutofacModule))] // 在模块上添加依赖AbpAutofacModule -public class AppModule : AbpModule -{ - ... -} -```` - -3. 修改在``Startup``类下的``services.AddApplication();``如下所示: - -````C# -services.AddApplication(options => -{ - options.UseAutofac(); // 集成 Autofac -}); -```` - -4. 更新 `Program.cs`代码, 不再使用`WebHost.CreateDefaultBuilder()`方法(因为它使用默认的DI容器): - - ````csharp -public class Program -{ - public static void Main(string[] args) - { - /* - https://github.com/aspnet/AspNetCore/issues/4206#issuecomment-445612167 - CurrentDirectoryHelpers 文件位于: \framework\src\Volo.Abp.AspNetCore.Mvc\Microsoft\AspNetCore\InProcess\CurrentDirectoryHelpers.cs - 当升级到ASP.NET Core 3.0的时候将会删除这个类. - */ - CurrentDirectoryHelpers.SetCurrentDirectory(); - - BuildWebHostInternal(args).Run(); - } - public static IWebHost BuildWebHostInternal(string[] args) => - new WebHostBuilder() - .UseKestrel() - .UseContentRoot(Directory.GetCurrentDirectory()) - .UseIIS() - .UseIISIntegration() - .UseStartup() - .Build(); -} -```` - - -### 源码 - -从[此处](https://github.com/abpframework/abp-samples/tree/master/BasicAspNetCoreApplication)获取本教程中创建的示例项目的源代码. +# 在AspNet Core MVC Web Application中使用ABP + +本教程将介绍如何开始以最少的依赖关系开始使用ABP开发. + +通常情况下你需要下载一个 **[启动模板](Getting-Started-AspNetCore-MVC-Template.md)** + +## 创建一个新项目 + +1. 使用Visual Studio 2019 (16.4.0+)创建一个新的AspNet Core Web Application: + +![](images/create-new-aspnet-core-application-v2.png) + +2. 配置新的项目: + +![](images/select-empty-web-application-v2.png) + +3. 完成创建: + +![](images/create-aspnet-core-application.png) + + +## 安装 Volo.Abp.AspNetCore.Mvc 包 + +Volo.Abp.AspNetCore.Mvc是ABP集成AspNet Core MVC的包,请安装它到你项目中: + +```` +Install-Package Volo.Abp.AspNetCore.Mvc +```` + +## 创建ABP模块 + +ABP是一个模块化框架,它需要一个**启动 (根) 模块**继承自``AbpModule``: + +````C# +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.Hosting; +using Volo.Abp; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Modularity; + +namespace BasicAspNetCoreApplication +{ + [DependsOn(typeof(AbpAspNetCoreMvcModule))] + public class AppModule : AbpModule + { + public override void OnApplicationInitialization( + ApplicationInitializationContext context) + { + var app = context.GetApplicationBuilder(); + var env = context.GetEnvironment(); + + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + else + { + app.UseExceptionHandler("/Error"); + } + + app.UseStaticFiles(); + app.UseRouting(); + app.UseConfiguredEndpoints(); + } + } +} +```` + +``AppModule`` 是应用程序启动模块的好名称. + +ABP的包定义了这个模块类,模块可以依赖其它模块.在上面的代码中 ``AppModule`` 依赖于 ``AbpAspNetCoreMvcModule`` (模块存在于[Volo.Abp.AspNetCore.Mvc](https://www.nuget.org/packages/Volo.Abp.AspNetCore.Mvc)包中). 安装新的ABP的包后添加``DependsOn``是很常见的做法. + +我们在此模块类中配置ASP.NET Core管道,而不是Startup类中. + +### 启动类 + +接下来修改启动类集成ABP模块系统: + +````C# +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; + +namespace BasicAspNetCoreApplication +{ + public class Startup + { + public void ConfigureServices(IServiceCollection services) + { + services.AddApplication(); + } + + public void Configure(IApplicationBuilder app) + { + app.InitializeApplication(); + } + } +} + +```` + +``services.AddApplication()``添加了所有``AppModule``模块中定义的全部服务. + +``Configure``方法中的``app.InitializeApplication()``完成初始化并启动应用程序. + +## 运行应用程序! + +启动该应用,它将按预期运行. + +## 使用 Autofac 依赖注入框架 + +虽然AspNet Core的依赖注入(DI)系统适用于基本要求,但[Autofac](https://autofac.org/)提供了属性注入和方法拦截等高级功能,这些功能是ABP执行高级应用程序框架功能所必需的. + +用Autofac取代AspNet Core的DI系统并集成到ABP非常简单. + +1. 安装 [Volo.Abp.Autofac](https://www.nuget.org/packages/Volo.Abp.Autofac) 包 + +```` +Install-Package Volo.Abp.Autofac +```` + +2. 添加 ``AbpAutofacModule`` 依赖 + +````C# +[DependsOn(typeof(AbpAspNetCoreMvcModule))] +[DependsOn(typeof(AbpAutofacModule))] // 在模块上添加依赖AbpAutofacModule +public class AppModule : AbpModule +{ + ... +} +```` + +3. 修改``Program.cs``以使用Autofac: + +````C# +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; + +namespace BasicAspNetCoreApplication +{ + public class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }) + .UseAutofac(); // 添加这一行 + } +} +```` + +## 源码 + +从[此处](https://github.com/abpframework/abp-samples/tree/master/BasicAspNetCoreApplication)获取本教程中创建的示例项目的源代码. diff --git a/docs/zh-Hans/Startup-Templates/Application.md b/docs/zh-Hans/Startup-Templates/Application.md index 58287cef5a..534a26d8fb 100644 --- a/docs/zh-Hans/Startup-Templates/Application.md +++ b/docs/zh-Hans/Startup-Templates/Application.md @@ -59,20 +59,6 @@ abp new Acme.BookStore -d mongodb ### 指定移动应用程序框架 -此模板支持以下移动应用程序框架: - -- `react-native`: React Native - -使用 `-m` (或 `--mobile`) 选项指定移动应用程序框架: - -````bash -abp new Acme.BookStore -m react-native -```` - -如果未指定,不会创建移动应用程序. - -### 指定移动应用程序框架 - 该模板支持以下移动应用程序框架: - `react-native`: React Native diff --git a/docs/zh-Hans/Tutorials/Part-1.md b/docs/zh-Hans/Tutorials/Part-1.md index 99a7e3d9fb..e459c8b960 100644 --- a/docs/zh-Hans/Tutorials/Part-1.md +++ b/docs/zh-Hans/Tutorials/Part-1.md @@ -84,7 +84,7 @@ namespace Acme.BookStore.Books } ```` -* ABP为实体提供了两个基本的基类: `AggregateRoot`和`Entity`. **Aggregate Root**是**[领域驱动设计](./Domain-Driven-Design.md)** 概念之一. 可以视为直接查询和处理的根实体(请参阅[实体文档](./Entities.md)). +* ABP为实体提供了两个基本的基类: `AggregateRoot`和`Entity`. **Aggregate Root**是[**领域驱动设计**](./Domain-Driven-Design.md) 概念之一. 可以视为直接查询和处理的根实体(请参阅[实体文档](./Entities.md)). * `Book`实体继承了`AuditedAggregateRoot`,`AuditedAggregateRoot`类在`AggregateRoot`类的基础上添加了一些审计属性(`CreationTime`, `CreatorId`, `LastModificationTime` 等). ABP框架自动为你管理这些属性. * `Guid`是`Book`实体的主键类型. @@ -185,7 +185,7 @@ namespace Acme.BookStore.EntityFrameworkCore ### 添加数据迁移 -启动模板使用[EF Core Code First Migrations](https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/)创建和维护数据库架构. 打开菜单*工具 > NuGet包管理器*下的**程序包管理控制台 (PMC)**. +启动模板使用[EF Core Code First Migrations](https://docs.microsoft.com/zh-cn/ef/core/managing-schemas/migrations/)创建和维护数据库架构. 打开菜单*工具 > NuGet包管理器*下的**程序包管理控制台 (PMC)**. ![Open Package Manager Console](images/bookstore-open-package-manager-console.png) @@ -201,7 +201,7 @@ Add-Migration "Created_Book_Entity" 在更新数据库之前,请阅读下面的部分了解如何将一些初始数据插入到数据库. -> 如果你使用其他IDE而不是Visual Studio, 你可以使用 [`dotnet-ef]`(https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cli#create-a-migration) 工具. +> 如果你使用其他IDE而不是Visual Studio, 你可以使用 [`dotnet-ef`](https://docs.microsoft.com/zh-cn/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cli#create-a-migration) 工具. {{end}} @@ -262,7 +262,7 @@ namespace Acme.BookStore } ``` -* 如果数据库中当前没有图书,则此代码使用 `IRepository`(默认为[repository](../Repositories.md)将两本书插入数据库. +* 如果数据库中当前没有图书,则此代码使用 `IRepository`(默认为[repository](../Repositories.md))将两本书插入数据库. ### 更新数据库 @@ -276,7 +276,7 @@ namespace Acme.BookStore 应用程序层由两个分离的项目组成: -* `Acme.BookStore.Application.Contracts 包含你的[DTO](../Data-Transfer-Objects.md)和[应用服务](../Application-Services.md)接口. +* `Acme.BookStore.Application.Contracts` 包含你的[DTO](../Data-Transfer-Objects.md)和[应用服务](../Application-Services.md)接口. * `Acme.BookStore.Application` 包含你的应用服务实现. 在本部分中,你将创建一个应用程序服务,使用ABP Framework的 `CrudAppService` 基类来获取,创建,更新和删除书籍. diff --git a/framework/.editorconfig b/framework/.editorconfig deleted file mode 100644 index 9f20b90112..0000000000 --- a/framework/.editorconfig +++ /dev/null @@ -1,131 +0,0 @@ -# Rules in this file were initially inferred by Visual Studio IntelliCode from the D:\Projects\Volosoft\abp\framework codebase based on best match to current usage at 2.10.2020. -# You can modify the rules from these initially generated values to suit your own policies -# You can learn more about editorconfig here: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference -[*.cs] - - -#Core editorconfig formatting - indentation - -#use soft tabs (spaces) for indentation -indent_style = space - -#Formatting - indentation options - -#indent switch case contents. -csharp_indent_case_contents = true -#indent switch labels -csharp_indent_switch_labels = true - -#Formatting - new line options - -#place catch statements on a new line -csharp_new_line_before_catch = true -#place else statements on a new line -csharp_new_line_before_else = true -#require members of object intializers to be on separate lines -csharp_new_line_before_members_in_object_initializers = true -#require braces to be on a new line for accessors, methods, lambdas, object_collection_array_initializers, control_blocks, types, and properties (also known as "Allman" style) -csharp_new_line_before_open_brace = accessors, methods, lambdas, object_collection_array_initializers, control_blocks, types, properties - -#Formatting - organize using options - -#sort System.* using directives alphabetically, and place them before other usings -dotnet_sort_system_directives_first = true - -#Formatting - spacing options - -csharp_space_after_cast = false -csharp_space_after_colon_in_inheritance_clause = true -csharp_space_after_comma = true -csharp_space_after_dot = false -csharp_space_after_keywords_in_control_flow_statements = true -csharp_space_after_semicolon_in_for_statement = true -csharp_space_around_binary_operators = before_and_after -csharp_space_around_declaration_statements = false -csharp_space_before_colon_in_inheritance_clause = true -csharp_space_before_comma = false -csharp_space_before_dot = false -csharp_space_before_open_square_brackets = false -csharp_space_before_semicolon_in_for_statement = false -csharp_space_between_empty_square_brackets = false -csharp_space_between_method_call_empty_parameter_list_parentheses = false -csharp_space_between_method_call_name_and_opening_parenthesis = false -csharp_space_between_method_call_parameter_list_parentheses = false -csharp_space_between_method_declaration_empty_parameter_list_parentheses = false -csharp_space_between_method_declaration_name_and_open_parenthesis = false -csharp_space_between_method_declaration_parameter_list_parentheses = false -csharp_space_between_parentheses = false -csharp_space_between_square_brackets = false - -#Formatting - wrapping options - -#leave code block on single line -csharp_preserve_single_line_blocks = true - -#Style - Code block preferences - -#prefer curly braces even for one line of code -csharp_prefer_braces = true:suggestion - -#Style - expression bodied member options - -#prefer block bodies for constructors -csharp_style_expression_bodied_constructors = false:suggestion -#prefer block bodies for methods -csharp_style_expression_bodied_methods = false:suggestion -#prefer expression-bodied members for properties -csharp_style_expression_bodied_properties = true:suggestion - -#Style - expression level options - -#prefer out variables to be declared inline in the argument list of a method call when possible -csharp_style_inlined_variable_declaration = true:suggestion -#prefer the language keyword for member access expressions, instead of the type name, for types that have a keyword to represent them -dotnet_style_predefined_type_for_member_access = true:suggestion - -#Style - Expression-level preferences - -#prefer default over default(T) -csharp_prefer_simple_default_expression = true:suggestion -#prefer objects to be initialized using object initializers when possible -dotnet_style_object_initializer = true:suggestion -#prefer inferred tuple element names -dotnet_style_prefer_inferred_tuple_names = true:suggestion - -#Style - implicit and explicit types - -#prefer var over explicit type in all cases, unless overridden by another code style rule -csharp_style_var_elsewhere = true:suggestion -#prefer var is used to declare variables with built-in system types such as int -csharp_style_var_for_built_in_types = true:suggestion -#prefer var when the type is already mentioned on the right-hand side of a declaration expression -csharp_style_var_when_type_is_apparent = true:suggestion - -#Style - language keyword and framework type options - -#prefer the language keyword for local variables, method parameters, and class members, instead of the type name, for types that have a keyword to represent them -dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion - -#Style - modifier options - -#prefer accessibility modifiers to be declared except for public interface members. This will currently not differ from always and will act as future proofing for if C# adds default interface methods. -dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion - -#Style - Modifier preferences - -#when this rule is set to a list of modifiers, prefer the specified ordering. -csharp_preferred_modifier_order = public,protected,private,virtual,async,static,override,readonly,abstract:suggestion - -#Style - Pattern matching - -#prefer pattern matching instead of is expression with type casts -csharp_style_pattern_matching_over_as_with_null_check = true:suggestion - -#Style - qualification options - -#prefer fields not to be prefaced with this. or Me. in Visual Basic -dotnet_style_qualification_for_field = false:suggestion -#prefer methods not to be prefaced with this. or Me. in Visual Basic -dotnet_style_qualification_for_method = false:suggestion -#prefer properties not to be prefaced with this. or Me. in Visual Basic -dotnet_style_qualification_for_property = false:suggestion diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/MainLayout.razor b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/MainLayout.razor index 45496a7984..20b96bef45 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/MainLayout.razor +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/MainLayout.razor @@ -22,4 +22,5 @@ @Body + diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/IUiNotificationService.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/IUiNotificationService.cs index a9816dc325..753dad4dcd 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/IUiNotificationService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/IUiNotificationService.cs @@ -1,12 +1,13 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; namespace Volo.Abp.AspNetCore.Components.WebAssembly { public interface IUiNotificationService { - Task Info(string message); - Task Success(string message); - Task Warn(string message); - Task Error(string message); + Task Info(string message, string title = null, Action options = null); + Task Success(string message, string title = null, Action options = null); + Task Warn(string message, string title = null, Action options = null); + Task Error(string message, string title = null, Action options = null); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/NullUiNotificationService.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/NullUiNotificationService.cs index 85ee10287c..950cca3047 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/NullUiNotificationService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/NullUiNotificationService.cs @@ -1,25 +1,26 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; using Volo.Abp.DependencyInjection; namespace Volo.Abp.AspNetCore.Components.WebAssembly { public class NullUiNotificationService : IUiNotificationService, ITransientDependency { - public Task Info(string message) + public Task Info(string message, string title = null, Action options = null) { return Task.CompletedTask; } - public Task Success(string message) + public Task Success(string message, string title = null, Action options = null) { return Task.CompletedTask; } - public Task Warn(string message) + public Task Warn(string message, string title = null, Action options = null) { return Task.CompletedTask; } - public Task Error(string message) + public Task Error(string message, string title = null, Action options = null) { return Task.CompletedTask; } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/UiNotificationEventArgs.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/UiNotificationEventArgs.cs new file mode 100644 index 0000000000..402bfb329b --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/UiNotificationEventArgs.cs @@ -0,0 +1,23 @@ +using System; + +namespace Volo.Abp.AspNetCore.Components.WebAssembly +{ + public class UiNotificationEventArgs : EventArgs + { + public UiNotificationEventArgs(UiNotificationType notificationType, string message, string title, UiNotificationOptions options) + { + NotificationType = notificationType; + Message = message; + Title = title; + Options = options; + } + + public UiNotificationType NotificationType { get; set; } + + public string Message { get; } + + public string Title { get; } + + public UiNotificationOptions Options { get; } + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/UiNotificationOptions.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/UiNotificationOptions.cs new file mode 100644 index 0000000000..ae8a400368 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/UiNotificationOptions.cs @@ -0,0 +1,20 @@ +using Volo.Abp.Localization; + +namespace Volo.Abp.AspNetCore.Components.WebAssembly +{ + /// + /// Options to override notification appearance. + /// + public class UiNotificationOptions + { + /// + /// Custom text for the Ok button. + /// + public ILocalizableString OkButtonText { get; set; } + + /// + /// Custom icon for the Ok button. + /// + public object OkButtonIcon { get; set; } + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/UiNotificationType.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/UiNotificationType.cs new file mode 100644 index 0000000000..78f3a86bb5 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/UiNotificationType.cs @@ -0,0 +1,10 @@ +namespace Volo.Abp.AspNetCore.Components.WebAssembly +{ + public enum UiNotificationType + { + Info, + Success, + Warning, + Error, + } +} diff --git a/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs b/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs index a7c906f41c..eb9cab5a73 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs +++ b/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs @@ -186,6 +186,8 @@ namespace Volo.Abp.BlazoriseUI protected TUpdateViewModel EditingEntity; protected Modal CreateModal; protected Modal EditModal; + protected Validations CreateValidationsRef; + protected Validations EditValidationsRef; protected List BreadcrumbItems = new List(2); protected string CreatePolicyName { get; set; } @@ -279,12 +281,26 @@ namespace Volo.Abp.BlazoriseUI protected virtual async Task OpenCreateModalAsync() { + await OnOpeningCreateModalAsync(); + + CreateValidationsRef.ClearAll(); + await CheckCreatePolicyAsync(); NewEntity = new TCreateViewModel(); + + // Mapper will not notify Blazor that binded values are changed + // so we need to notify it manually by calling StateHasChanged + await InvokeAsync(() => StateHasChanged()); + CreateModal.Show(); } + protected virtual Task OnOpeningCreateModalAsync() + { + return Task.CompletedTask; + } + protected virtual Task CloseCreateModalAsync() { CreateModal.Hide(); @@ -293,14 +309,27 @@ namespace Volo.Abp.BlazoriseUI protected virtual async Task OpenEditModalAsync(TKey id) { + await OnOpeningEditModalAsync(id); + + EditValidationsRef.ClearAll(); + await CheckUpdatePolicyAsync(); var entityDto = await AppService.GetAsync(id); + EditingEntityId = id; EditingEntity = MapToEditingEntity(entityDto); + + await InvokeAsync(() => StateHasChanged()); + EditModal.Show(); } + protected virtual Task OnOpeningEditModalAsync(TKey id) + { + return Task.CompletedTask; + } + protected virtual TUpdateViewModel MapToEditingEntity(TGetOutputDto entityDto) { return ObjectMapper.Map(entityDto); @@ -334,20 +363,56 @@ namespace Volo.Abp.BlazoriseUI protected virtual async Task CreateEntityAsync() { - await CheckCreatePolicyAsync(); - var createInput = MapToCreateInput(NewEntity); - await AppService.CreateAsync(createInput); - await GetEntitiesAsync(); - CreateModal.Hide(); + if (CreateValidationsRef.ValidateAll()) + { + await OnCreatingEntityAsync(); + + await CheckCreatePolicyAsync(); + var createInput = MapToCreateInput(NewEntity); + await AppService.CreateAsync(createInput); + await GetEntitiesAsync(); + + await OnCreatedEntityAsync(); + + CreateModal.Hide(); + } + } + + protected virtual Task OnCreatingEntityAsync() + { + return Task.CompletedTask; + } + + protected virtual Task OnCreatedEntityAsync() + { + return Task.CompletedTask; } protected virtual async Task UpdateEntityAsync() { - await CheckUpdatePolicyAsync(); - var updateInput = MapToUpdateInput(EditingEntity); - await AppService.UpdateAsync(EditingEntityId, updateInput); - await GetEntitiesAsync(); - EditModal.Hide(); + if (EditValidationsRef.ValidateAll()) + { + await OnUpdatingEntityAsync(); + + await CheckUpdatePolicyAsync(); + var updateInput = MapToUpdateInput(EditingEntity); + await AppService.UpdateAsync(EditingEntityId, updateInput); + await GetEntitiesAsync(); + + await OnUpdatedEntityAsync(); + + EditModal.Hide(); + } + } + + protected virtual Task OnUpdatingEntityAsync() + { + return Task.CompletedTask; + } + + protected virtual Task OnUpdatedEntityAsync() + { + return Task.CompletedTask; } protected virtual async Task DeleteEntityAsync(TListViewModel entity) diff --git a/framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiNotificationService.cs b/framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiNotificationService.cs index 549a1f4d07..05c1cd5163 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiNotificationService.cs +++ b/framework/src/Volo.Abp.BlazoriseUI/BlazoriseUiNotificationService.cs @@ -1,40 +1,73 @@ -using System.Threading.Tasks; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Abstractions; +using System; +using System.Threading.Tasks; +using Localization.Resources.AbpUi; +using Microsoft.Extensions.Localization; using Volo.Abp.AspNetCore.Components.WebAssembly; using Volo.Abp.DependencyInjection; namespace Volo.Abp.BlazoriseUI { [Dependency(ReplaceServices = true)] - public class BlazoriseUiNotificationService : IUiNotificationService, ITransientDependency + public class BlazoriseUiNotificationService : IUiNotificationService, IScopedDependency { - public ILogger Logger { get; set; } + /// + /// An event raised after the notification is received. + /// + public event EventHandler NotificationReceived; - public BlazoriseUiNotificationService() + private readonly IStringLocalizer localizer; + + public BlazoriseUiNotificationService( + IStringLocalizer localizer) { - Logger = NullLogger.Instance; + this.localizer = localizer; } - public Task Info(string message) + public Task Info(string message, string title = null, Action options = null) { - Logger.LogInformation(message); + var uiNotificationOptions = CreateDefaultOptions(); + options?.Invoke(uiNotificationOptions); + + NotificationReceived?.Invoke(this, new UiNotificationEventArgs(UiNotificationType.Info, message, title, uiNotificationOptions)); + return Task.CompletedTask; } - public Task Success(string message) + public Task Success(string message, string title = null, Action options = null) { + var uiNotificationOptions = CreateDefaultOptions(); + options?.Invoke(uiNotificationOptions); + + NotificationReceived?.Invoke(this, new UiNotificationEventArgs(UiNotificationType.Success, message, title, uiNotificationOptions)); + return Task.CompletedTask; } - public Task Warn(string message) + public Task Warn(string message, string title = null, Action options = null) { + var uiNotificationOptions = CreateDefaultOptions(); + options?.Invoke(uiNotificationOptions); + + NotificationReceived?.Invoke(this, new UiNotificationEventArgs(UiNotificationType.Warning, message, title, uiNotificationOptions)); + return Task.CompletedTask; } - public Task Error(string message) + public Task Error(string message, string title = null, Action options = null) { + var uiNotificationOptions = CreateDefaultOptions(); + options?.Invoke(uiNotificationOptions); + + NotificationReceived?.Invoke(this, new UiNotificationEventArgs(UiNotificationType.Error, message, title, uiNotificationOptions)); + return Task.CompletedTask; } + + protected virtual UiNotificationOptions CreateDefaultOptions() + { + return new UiNotificationOptions + { + }; + } } } diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/UiNotificationAlert.razor b/framework/src/Volo.Abp.BlazoriseUI/Components/UiNotificationAlert.razor new file mode 100644 index 0000000000..349eee2c40 --- /dev/null +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/UiNotificationAlert.razor @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/UiNotificationAlert.razor.cs b/framework/src/Volo.Abp.BlazoriseUI/Components/UiNotificationAlert.razor.cs new file mode 100644 index 0000000000..67c890f922 --- /dev/null +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/UiNotificationAlert.razor.cs @@ -0,0 +1,76 @@ +using System; +using System.Threading.Tasks; +using Blazorise.Snackbar; +using Microsoft.AspNetCore.Components; +using Microsoft.Extensions.Localization; +using Volo.Abp.AspNetCore.Components.WebAssembly; + +namespace Volo.Abp.BlazoriseUI.Components +{ + public partial class UiNotificationAlert : ComponentBase, IDisposable + { + protected SnackbarStack SnackbarStack { get; set; } + + [Parameter] public UiNotificationType NotificationType { get; set; } + + [Parameter] public string Message { get; set; } + + [Parameter] public string Title { get; set; } + + [Parameter] public UiNotificationOptions Options { get; set; } + + [Parameter] public EventCallback Okayed { get; set; } + + [Parameter] public EventCallback Closed { get; set; } + + [Inject] protected BlazoriseUiNotificationService UiNotificationService { get; set; } + + [Inject] protected IStringLocalizerFactory StringLocalizerFactory { get; set; } + + protected virtual SnackbarColor GetSnackbarColor(UiNotificationType notificationType) + { + return notificationType switch + { + UiNotificationType.Info => SnackbarColor.Info, + UiNotificationType.Success => SnackbarColor.Success, + UiNotificationType.Warning => SnackbarColor.Warning, + UiNotificationType.Error => SnackbarColor.Danger, + _ => SnackbarColor.None, + }; + } + + protected override void OnInitialized() + { + base.OnInitialized(); + + UiNotificationService.NotificationReceived += OnNotificationReceived; + } + + protected virtual void OnNotificationReceived(object sender, UiNotificationEventArgs e) + { + NotificationType = e.NotificationType; + Message = e.Message; + Title = e.Title; + Options = e.Options; + + var okButtonText = Options?.OkButtonText?.Localize(StringLocalizerFactory); + + SnackbarStack.Push(Message, GetSnackbarColor( e.NotificationType ), okButtonText); + } + + public virtual void Dispose() + { + if (UiNotificationService != null) + { + UiNotificationService.NotificationReceived -= OnNotificationReceived; + } + } + + protected virtual Task OnSnackbarClosed(SnackbarClosedEventArgs eventArgs) + { + return eventArgs.CloseReason == SnackbarCloseReason.UserClosed + ? Okayed.InvokeAsync() + : Closed.InvokeAsync(); + } + } +} diff --git a/framework/src/Volo.Abp.BlazoriseUI/Volo.Abp.BlazoriseUI.csproj b/framework/src/Volo.Abp.BlazoriseUI/Volo.Abp.BlazoriseUI.csproj index e696a2f915..7a63fe11c0 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Volo.Abp.BlazoriseUI.csproj +++ b/framework/src/Volo.Abp.BlazoriseUI/Volo.Abp.BlazoriseUI.csproj @@ -12,8 +12,9 @@ - - + + + diff --git a/framework/src/Volo.Abp.BlazoriseUI/_Imports.razor b/framework/src/Volo.Abp.BlazoriseUI/_Imports.razor index 37be71828c..0aae8ed947 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/_Imports.razor +++ b/framework/src/Volo.Abp.BlazoriseUI/_Imports.razor @@ -1,2 +1,3 @@ @using Microsoft.AspNetCore.Components.Web -@using Blazorise \ No newline at end of file +@using Blazorise +@using Blazorise.Snackbar \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Http/CliHttpClient.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Http/CliHttpClient.cs index bd3037d830..3712d0be13 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Http/CliHttpClient.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Http/CliHttpClient.cs @@ -17,7 +17,8 @@ namespace Volo.Abp.Cli.Http { public static TimeSpan DefaultTimeout { get; set; } = TimeSpan.FromMinutes(1); - public CliHttpClient(TimeSpan? timeout = null) : base(new CliHttpClientHandler()) + public CliHttpClient(TimeSpan? timeout = null) + : base(new CliHttpClientHandler()) { Timeout = timeout ?? DefaultTimeout; @@ -98,4 +99,4 @@ namespace Volo.Abp.Cli.Http } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Core/System/AbpObjectExtensions.cs b/framework/src/Volo.Abp.Core/System/AbpObjectExtensions.cs index 958398e0c5..a3fd87188f 100644 --- a/framework/src/Volo.Abp.Core/System/AbpObjectExtensions.cs +++ b/framework/src/Volo.Abp.Core/System/AbpObjectExtensions.cs @@ -2,6 +2,7 @@ using System.ComponentModel; using System.Globalization; using System.Linq; +using System.Reflection; namespace System { diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor/AbpIdentityBlazorMessageLocalizerHelper.cs b/modules/identity/src/Volo.Abp.Identity.Blazor/AbpIdentityBlazorMessageLocalizerHelper.cs new file mode 100644 index 0000000000..5d858843b8 --- /dev/null +++ b/modules/identity/src/Volo.Abp.Identity.Blazor/AbpIdentityBlazorMessageLocalizerHelper.cs @@ -0,0 +1,41 @@ +using System.Collections.Generic; +using System.Linq; +using JetBrains.Annotations; +using Microsoft.Extensions.Localization; + +namespace Volo.Abp.Identity.Blazor +{ + public class AbpIdentityBlazorMessageLocalizerHelper + { + private readonly IStringLocalizer stringLocalizer; + + public AbpIdentityBlazorMessageLocalizerHelper(IStringLocalizer stringLocalizer) + { + this.stringLocalizer = stringLocalizer; + } + + public string Localize(string message, [CanBeNull] IEnumerable arguments) + { + try + { + return arguments?.Count() > 0 + ? stringLocalizer[message, LocalizeMessageArguments(arguments)?.ToArray()] + : stringLocalizer[message]; + } + catch + { + return stringLocalizer[message]; + } + } + + private IEnumerable LocalizeMessageArguments(IEnumerable arguments) + { + foreach (var argument in arguments) + { + yield return stringLocalizer[$"DisplayName:{argument}"] + ?? stringLocalizer[argument] + ?? argument; + } + } + } +} diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor/AbpIdentityBlazorModule.cs b/modules/identity/src/Volo.Abp.Identity.Blazor/AbpIdentityBlazorModule.cs index cebde068c3..7f11267132 100644 --- a/modules/identity/src/Volo.Abp.Identity.Blazor/AbpIdentityBlazorModule.cs +++ b/modules/identity/src/Volo.Abp.Identity.Blazor/AbpIdentityBlazorModule.cs @@ -32,6 +32,8 @@ namespace Volo.Abp.Identity.Blazor { options.AdditionalAssemblies.Add(typeof(AbpIdentityBlazorModule).Assembly); }); + + context.Services.AddSingleton(typeof(AbpIdentityBlazorMessageLocalizerHelper<>)); } } } diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor index 67e7e9290c..4639f81be2 100644 --- a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor +++ b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor @@ -1,17 +1,20 @@ @page "/identity/roles" -@attribute [Authorize(IdentityPermissions.Roles.Default)] +@attribute [Authorize( IdentityPermissions.Roles.Default )] @using Volo.Abp.Identity @using Microsoft.AspNetCore.Authorization +@using Microsoft.Extensions.Localization +@using Volo.Abp.Identity.Localization @using Volo.Abp.PermissionManagement.Blazor.Components @inherits RoleManagementBase - +@inject IStringLocalizer L +@inject AbpIdentityBlazorMessageLocalizerHelper LH @* ************************* PAGE HEADER ************************* *@ -

@L["Roles"]

+ @L["Roles"]
- @if (HasCreatePermission) + @if ( HasCreatePermission ) { @@ -28,7 +31,7 @@ ShowPager="true" PageSize="PageSize"> - @if (ShouldShowEntityActions) + @if ( ShouldShowEntityActions ) { @@ -37,15 +40,15 @@ @L["Actions"] - @if (HasUpdatePermission) + @if ( HasUpdatePermission ) { @L["Edit"] } - @if (HasManagePermissionsPermission) + @if ( HasManagePermissionsPermission ) { @L["Permissions"] } - @if (HasDeletePermission) + @if ( HasDeletePermission ) { @L["Delete"] } @@ -57,11 +60,11 @@ @(context.As().Name) - @if (context.As().IsDefault) + @if ( context.As().IsDefault ) { @L["DisplayName:IsDefault"] } - @if (context.As().IsPublic) + @if ( context.As().IsPublic ) { @L["DisplayName:IsPublic"] } @@ -71,56 +74,68 @@ @* ************************* CREATE MODAL ************************* *@ -@if (HasCreatePermission) +@if ( HasCreatePermission ) { - + @L["NewRole"] - - - @L["DisplayName:RoleName"] - - + + + + @L["DisplayName:RoleName"] + + + + + + + - @L["DisplayName:IsDefault"] - @L["DisplayName:IsPublic"] + @L["DisplayName:IsDefault"] + @L["DisplayName:IsPublic"] - + - + } @* ************************* EDIT MODAL ************************* *@ -@if (HasUpdatePermission) +@if ( HasUpdatePermission ) { - + @L["Edit"] - + + + + @L["DisplayName:RoleName"] + + + + + + + - @L["DisplayName:RoleName"] - - - - @L["DisplayName:IsDefault"] - @L["DisplayName:IsPublic"] + @L["DisplayName:IsDefault"] + @L["DisplayName:IsPublic"] - + @@ -130,4 +145,4 @@ } - + diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor.cs b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor.cs index c316125ad5..d6ed07cf0b 100644 --- a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor.cs +++ b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor.cs @@ -1,5 +1,6 @@ using System; using System.Threading.Tasks; +using Blazorise; using Microsoft.AspNetCore.Authorization; using Volo.Abp.BlazoriseUI; using Volo.Abp.Identity.Localization; diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor index 991b8d1606..93e0ccaa85 100644 --- a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor +++ b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor @@ -1,16 +1,19 @@ @page "/identity/users" -@attribute [Authorize(IdentityPermissions.Users.Default)] +@attribute [Authorize( IdentityPermissions.Users.Default )] @using Microsoft.AspNetCore.Authorization +@using Microsoft.Extensions.Localization +@using Volo.Abp.Identity.Localization @using Volo.Abp.PermissionManagement.Blazor.Components @inherits UserManagementBase - +@inject IStringLocalizer L +@inject AbpIdentityBlazorMessageLocalizerHelper LH @* ************************* PAGE HEADER ************************* *@

@L["Users"]

- @if (HasCreatePermission) + @if ( HasCreatePermission ) { @@ -27,7 +30,7 @@ ShowPager="true" PageSize="PageSize"> - @if (ShouldShowEntityActions) + @if ( ShouldShowEntityActions ) { @@ -36,17 +39,17 @@ @L["Actions"] - @if (HasUpdatePermission) + @if ( HasUpdatePermission ) { @L["Edit"] } - @if (HasManagePermissionsPermission) + @if ( HasManagePermissionsPermission ) { @L["Permissions"] } - @if (HasDeletePermission) + @if ( HasDeletePermission ) { - + @L["Delete"] } @@ -73,17 +76,17 @@ @* ************************* CREATE MODAL ************************* *@ -@if (HasCreatePermission) +@if ( HasCreatePermission ) { - - + + @L["NewUser"] - + - + @L["UserInformations"] @@ -91,71 +94,107 @@ + + + @L["DisplayName:UserName"] + + + + + + + + + + @L["DisplayName:Name"] + + + + + + + + + + @L["DisplayName:Surname"] + + + + + + + + + + @L["DisplayName:Password"] + + + + + + + + + + @L["DisplayName:Email"] + + + + + + + + + + @L["DisplayName:PhoneNumber"] + + + + + + + - @L["DisplayName:UserName"] - - - - @L["DisplayName:Name"] - - - - @L["DisplayName:Surname"] - - - - @L["DisplayName:Password"] - - - - @L["DisplayName:Email"] - - - - @L["DisplayName:PhoneNumber"] - - - - @L["DisplayName:LockoutEnabled"] + @L["DisplayName:LockoutEnabled"] - @if (NewUserRoles != null) + @if ( NewUserRoles != null ) { - @foreach (var role in NewUserRoles) + @foreach ( var role in NewUserRoles ) { - - @role.Name + + @role.Name } } - + - + } @* ************************* EDIT MODAL ************************* *@ -@if (HasUpdatePermission) +@if ( HasUpdatePermission ) { - - + + @L["Edit"] - + - - + + @@ -164,56 +203,92 @@ + + + @L["DisplayName:UserName"] + + + + + + + + + + @L["DisplayName:Name"] + + + + + + + + + + @L["DisplayName:Surname"] + + + + + + + + + + @L["DisplayName:Password"] + + + + + + + + + + @L["DisplayName:Email"] + + + + + + + + + + @L["DisplayName:PhoneNumber"] + + + + + + + - @L["DisplayName:UserName"] - - - - @L["DisplayName:Name"] - - - - @L["DisplayName:Surname"] - - - - @L["DisplayName:Password"] - - - - @L["DisplayName:Email"] - - - - @L["DisplayName:PhoneNumber"] - - - - @L["DisplayName:LockoutEnabled"] + @L["DisplayName:LockoutEnabled"] - @if (EditUserRoles != null) + @if ( EditUserRoles != null ) { - @foreach (var role in EditUserRoles) + @foreach ( var role in EditUserRoles ) { - - @role.Name + + @role.Name } } - + - + } - + \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs index 93f1536fca..b47998f55d 100644 --- a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs +++ b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Blazorise; using Microsoft.AspNetCore.Authorization; using Volo.Abp.BlazoriseUI; using Volo.Abp.Identity.Localization; @@ -60,24 +61,25 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity HasManagePermissionsPermission; } - protected override Task OpenCreateModalAsync() + protected override async Task OnOpeningCreateModalAsync() { CreateModalSelectedTab = DefaultSelectedTab; NewUserRoles = Roles.Select(x => new AssignedRoleViewModel - { - Name = x.Name, - IsAssigned = x.IsDefault - }).ToArray(); + { + Name = x.Name, + IsAssigned = x.IsDefault + }).ToArray(); - return base.OpenCreateModalAsync(); + await base.OnOpeningCreateModalAsync(); } - protected override Task CreateEntityAsync() + protected override Task OnCreatingEntityAsync() { + // apply roles before saving NewEntity.RoleNames = NewUserRoles.Where(x => x.IsAssigned).Select(x => x.Name).ToArray(); - return base.CreateEntityAsync(); + return base.OnCreatingEntityAsync(); } protected async override Task OpenEditModalAsync(Guid id) @@ -87,19 +89,20 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity var userRoleNames = (await AppService.GetRolesAsync(id)).Items.Select(r => r.Name).ToList(); EditUserRoles = Roles.Select(x => new AssignedRoleViewModel - { - Name = x.Name, - IsAssigned = userRoleNames.Contains(x.Name) - }).ToArray(); + { + Name = x.Name, + IsAssigned = userRoleNames.Contains(x.Name) + }).ToArray(); - await base.OpenEditModalAsync(id); + await base.OnOpeningEditModalAsync(id); } - protected override Task UpdateEntityAsync() + protected override Task OnUpdatingEntityAsync() { + // apply roles before saving EditingEntity.RoleNames = EditUserRoles.Where(x => x.IsAssigned).Select(x => x.Name).ToArray(); - return base.UpdateEntityAsync(); + return base.OnUpdatingEntityAsync(); } } diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/AbpIdentityDomainSharedModule.cs b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/AbpIdentityDomainSharedModule.cs index e14ce5e3f4..80d039b7d7 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/AbpIdentityDomainSharedModule.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/AbpIdentityDomainSharedModule.cs @@ -1,4 +1,5 @@ -using Volo.Abp.Features; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Features; using Volo.Abp.Identity.Localization; using Volo.Abp.Localization; using Volo.Abp.Localization.ExceptionHandling; diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs index eb6d424c16..f63109f1f1 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs @@ -193,8 +193,6 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore b.Property(x => x.DisplayName).HasMaxLength(IdentityResourceConsts.DisplayNameMaxLength); b.Property(x => x.Description).HasMaxLength(IdentityResourceConsts.DescriptionMaxLength); - b.HasIndex(x => x.Name).IsUnique(); - b.HasMany(x => x.UserClaims).WithOne().HasForeignKey(x => x.IdentityResourceId).IsRequired(); b.HasMany(x => x.Properties).WithOne().HasForeignKey(x => x.IdentityResourceId).IsRequired(); }); @@ -236,8 +234,6 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore b.ConfigureByConvention(); - b.HasIndex(x => x.Name).IsUnique(); - b.Property(x => x.Name).HasMaxLength(ApiResourceConsts.NameMaxLength).IsRequired(); b.Property(x => x.DisplayName).HasMaxLength(ApiResourceConsts.DisplayNameMaxLength); b.Property(x => x.Description).HasMaxLength(ApiResourceConsts.DescriptionMaxLength); @@ -320,8 +316,6 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore b.Property(x => x.DisplayName).HasMaxLength(ApiScopeConsts.DisplayNameMaxLength); b.Property(x => x.Description).HasMaxLength(ApiScopeConsts.DescriptionMaxLength); - b.HasIndex(x => x.Name).IsUnique(); - b.HasMany(x => x.UserClaims).WithOne().HasForeignKey(x => x.ApiScopeId).IsRequired(); b.HasMany(x => x.Properties).WithOne().HasForeignKey(x => x.ApiScopeId).IsRequired(); }); diff --git a/templates/app/aspnet-core/NuGet.Config b/templates/app/aspnet-core/NuGet.Config new file mode 100644 index 0000000000..be8a1ece10 --- /dev/null +++ b/templates/app/aspnet-core/NuGet.Config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyCompanyName.MyProjectName.Blazor.csproj b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyCompanyName.MyProjectName.Blazor.csproj index cfaf51eee7..6a3f216d47 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyCompanyName.MyProjectName.Blazor.csproj +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyCompanyName.MyProjectName.Blazor.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/wwwroot/index.html b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/wwwroot/index.html index c9a25182e4..bf8c9d7902 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/wwwroot/index.html +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/wwwroot/index.html @@ -12,6 +12,7 @@ + diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20201019020935_Initial.Designer.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20201028014149_Initial.Designer.cs similarity index 99% rename from templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20201019020935_Initial.Designer.cs rename to templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20201028014149_Initial.Designer.cs index 7e948c753c..748f6c7638 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20201019020935_Initial.Designer.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20201028014149_Initial.Designer.cs @@ -11,7 +11,7 @@ using Volo.Abp.EntityFrameworkCore; namespace MyCompanyName.MyProjectName.Migrations { [DbContext(typeof(MyProjectNameMigrationsDbContext))] - [Migration("20201019020935_Initial")] + [Migration("20201028014149_Initial")] partial class Initial { protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -1042,9 +1042,6 @@ namespace MyCompanyName.MyProjectName.Migrations b.HasKey("Id"); - b.HasIndex("Name") - .IsUnique(); - b.ToTable("IdentityServerApiResources"); }); @@ -1192,9 +1189,6 @@ namespace MyCompanyName.MyProjectName.Migrations b.HasKey("Id"); - b.HasIndex("Name") - .IsUnique(); - b.ToTable("IdentityServerApiScopes"); }); @@ -1770,9 +1764,6 @@ namespace MyCompanyName.MyProjectName.Migrations b.HasKey("Id"); - b.HasIndex("Name") - .IsUnique(); - b.ToTable("IdentityServerIdentityResources"); }); diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20201019020935_Initial.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20201028014149_Initial.cs similarity index 99% rename from templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20201019020935_Initial.cs rename to templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20201028014149_Initial.cs index dfa2b7fbd5..af7fb7ee1b 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20201019020935_Initial.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20201028014149_Initial.cs @@ -1181,18 +1181,6 @@ namespace MyCompanyName.MyProjectName.Migrations table: "AbpUsers", column: "UserName"); - migrationBuilder.CreateIndex( - name: "IX_IdentityServerApiResources_Name", - table: "IdentityServerApiResources", - column: "Name", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_IdentityServerApiScopes_Name", - table: "IdentityServerApiScopes", - column: "Name", - unique: true); - migrationBuilder.CreateIndex( name: "IX_IdentityServerClients_ClientId", table: "IdentityServerClients", @@ -1214,12 +1202,6 @@ namespace MyCompanyName.MyProjectName.Migrations table: "IdentityServerDeviceFlowCodes", column: "UserCode"); - migrationBuilder.CreateIndex( - name: "IX_IdentityServerIdentityResources_Name", - table: "IdentityServerIdentityResources", - column: "Name", - unique: true); - migrationBuilder.CreateIndex( name: "IX_IdentityServerPersistedGrants_Expiration", table: "IdentityServerPersistedGrants", diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/MyProjectNameMigrationsDbContextModelSnapshot.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/MyProjectNameMigrationsDbContextModelSnapshot.cs index 657232cff2..82d01f075c 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/MyProjectNameMigrationsDbContextModelSnapshot.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/MyProjectNameMigrationsDbContextModelSnapshot.cs @@ -1040,9 +1040,6 @@ namespace MyCompanyName.MyProjectName.Migrations b.HasKey("Id"); - b.HasIndex("Name") - .IsUnique(); - b.ToTable("IdentityServerApiResources"); }); @@ -1190,9 +1187,6 @@ namespace MyCompanyName.MyProjectName.Migrations b.HasKey("Id"); - b.HasIndex("Name") - .IsUnique(); - b.ToTable("IdentityServerApiScopes"); }); @@ -1768,9 +1762,6 @@ namespace MyCompanyName.MyProjectName.Migrations b.HasKey("Id"); - b.HasIndex("Name") - .IsUnique(); - b.ToTable("IdentityServerIdentityResources"); }); diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameHttpApiHostModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameHttpApiHostModule.cs index 873f97d96a..2bc5c64d21 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameHttpApiHostModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameHttpApiHostModule.cs @@ -16,6 +16,8 @@ using Volo.Abp.Account.Web; using Volo.Abp.AspNetCore.Authentication.JwtBearer; using Volo.Abp.AspNetCore.MultiTenancy; using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc.UI.Bundling; +using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; using Volo.Abp.AspNetCore.Serilog; using Volo.Abp.Autofac; @@ -46,6 +48,7 @@ namespace MyCompanyName.MyProjectName var configuration = context.Services.GetConfiguration(); var hostingEnvironment = context.Services.GetHostingEnvironment(); + ConfigureBundles(); ConfigureUrls(configuration); ConfigureConventionalControllers(); ConfigureAuthentication(context, configuration); @@ -55,6 +58,20 @@ namespace MyCompanyName.MyProjectName ConfigureSwaggerServices(context); } + private void ConfigureBundles() + { + Configure(options => + { + options.StyleBundles.Configure( + BasicThemeBundles.Styles.Global, + bundle => + { + bundle.AddFiles("/global-styles.css"); + } + ); + }); + } + private void ConfigureUrls(IConfiguration configuration) { Configure(options => @@ -200,4 +217,4 @@ namespace MyCompanyName.MyProjectName app.UseConfiguredEndpoints(); } } -} \ No newline at end of file +} diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/wwwroot/global-styles.css b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/wwwroot/global-styles.css new file mode 100644 index 0000000000..e5d20ea346 --- /dev/null +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/wwwroot/global-styles.css @@ -0,0 +1 @@ +/* Your Global Styles */ diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs index ee0d6d7473..e67b25769f 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs @@ -16,7 +16,9 @@ using Volo.Abp.Account; using Volo.Abp.Account.Web; using Volo.Abp.AspNetCore.Mvc.UI; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap; +using Volo.Abp.AspNetCore.Mvc.UI.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic; +using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; using Volo.Abp.AspNetCore.Serilog; using Volo.Abp.Auditing; @@ -70,6 +72,17 @@ namespace MyCompanyName.MyProjectName options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文")); }); + Configure(options => + { + options.StyleBundles.Configure( + BasicThemeBundles.Styles.Global, + bundle => + { + bundle.AddFiles("/global-styles.css"); + } + ); + }); + Configure(options => { //options.IsEnabledForGetRequests = true; diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/wwwroot/libs/global-styles.css b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/wwwroot/libs/global-styles.css new file mode 100644 index 0000000000..e5d20ea346 --- /dev/null +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/wwwroot/libs/global-styles.css @@ -0,0 +1 @@ +/* Your Global Styles */ diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs index 958f39ea0e..bbff4ef4a7 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs @@ -18,7 +18,9 @@ using Volo.Abp.AspNetCore.Mvc.Client; using Volo.Abp.AspNetCore.Mvc.Localization; using Volo.Abp.AspNetCore.Mvc.UI; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap; +using Volo.Abp.AspNetCore.Mvc.UI.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic; +using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars; using Volo.Abp.AspNetCore.Serilog; @@ -76,6 +78,7 @@ namespace MyCompanyName.MyProjectName.Web var hostingEnvironment = context.Services.GetHostingEnvironment(); var configuration = context.Services.GetConfiguration(); + ConfigureBundles(); ConfigureCache(configuration); ConfigureRedis(context, configuration, hostingEnvironment); ConfigureUrls(configuration); @@ -87,6 +90,20 @@ namespace MyCompanyName.MyProjectName.Web ConfigureSwaggerServices(context.Services); } + private void ConfigureBundles() + { + Configure(options => + { + options.StyleBundles.Configure( + BasicThemeBundles.Styles.Global, + bundle => + { + bundle.AddFiles("/global-styles.css"); + } + ); + }); + } + private void ConfigureCache(IConfiguration configuration) { Configure(options => diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/wwwroot/global-styles.css b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/wwwroot/global-styles.css new file mode 100644 index 0000000000..e5d20ea346 --- /dev/null +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/wwwroot/global-styles.css @@ -0,0 +1 @@ +/* Your Global Styles */ diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs index 5b7a147345..1483e94a57 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs @@ -17,8 +17,10 @@ using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.Localization; using Volo.Abp.AspNetCore.Mvc.UI; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap; +using Volo.Abp.AspNetCore.Mvc.UI.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic; +using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; using Volo.Abp.AspNetCore.Serilog; using Volo.Abp.Autofac; @@ -73,6 +75,7 @@ namespace MyCompanyName.MyProjectName.Web var configuration = context.Services.GetConfiguration(); ConfigureUrls(configuration); + ConfigureBundles(); ConfigureAuthentication(context, configuration); ConfigureAutoMapper(); ConfigureVirtualFileSystem(hostingEnvironment); @@ -90,6 +93,20 @@ namespace MyCompanyName.MyProjectName.Web }); } + private void ConfigureBundles() + { + Configure(options => + { + options.StyleBundles.Configure( + BasicThemeBundles.Styles.Global, + bundle => + { + bundle.AddFiles("/global-styles.css"); + } + ); + }); + } + private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) { context.Services.AddAuthentication() diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/wwwroot/global-styles.css b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/wwwroot/global-styles.css new file mode 100644 index 0000000000..e5d20ea346 --- /dev/null +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/wwwroot/global-styles.css @@ -0,0 +1 @@ +/* Your Global Styles */ diff --git a/templates/module/aspnet-core/NuGet.Config b/templates/module/aspnet-core/NuGet.Config new file mode 100644 index 0000000000..be8a1ece10 --- /dev/null +++ b/templates/module/aspnet-core/NuGet.Config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyCompanyName.MyProjectName.Blazor.Host.csproj b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyCompanyName.MyProjectName.Blazor.Host.csproj index 9d0ce4f54d..a72215c320 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyCompanyName.MyProjectName.Blazor.Host.csproj +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyCompanyName.MyProjectName.Blazor.Host.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Migrations/20201019021120_Initial.Designer.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Migrations/20201028014236_Initial.Designer.cs similarity index 99% rename from templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Migrations/20201019021120_Initial.Designer.cs rename to templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Migrations/20201028014236_Initial.Designer.cs index 0f3b3b90b9..bda1f6108d 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Migrations/20201019021120_Initial.Designer.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Migrations/20201028014236_Initial.Designer.cs @@ -11,7 +11,7 @@ using Volo.Abp.EntityFrameworkCore; namespace MyCompanyName.MyProjectName.Migrations { [DbContext(typeof(IdentityServerHostMigrationsDbContext))] - [Migration("20201019021120_Initial")] + [Migration("20201028014236_Initial")] partial class Initial { protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -984,9 +984,6 @@ namespace MyCompanyName.MyProjectName.Migrations b.HasKey("Id"); - b.HasIndex("Name") - .IsUnique(); - b.ToTable("IdentityServerApiResources"); }); @@ -1134,9 +1131,6 @@ namespace MyCompanyName.MyProjectName.Migrations b.HasKey("Id"); - b.HasIndex("Name") - .IsUnique(); - b.ToTable("IdentityServerApiScopes"); }); @@ -1712,9 +1706,6 @@ namespace MyCompanyName.MyProjectName.Migrations b.HasKey("Id"); - b.HasIndex("Name") - .IsUnique(); - b.ToTable("IdentityServerIdentityResources"); }); diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Migrations/20201019021120_Initial.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Migrations/20201028014236_Initial.cs similarity index 99% rename from templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Migrations/20201019021120_Initial.cs rename to templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Migrations/20201028014236_Initial.cs index 2296a18f25..78dcb6359e 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Migrations/20201019021120_Initial.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Migrations/20201028014236_Initial.cs @@ -1155,18 +1155,6 @@ namespace MyCompanyName.MyProjectName.Migrations table: "AbpUsers", column: "UserName"); - migrationBuilder.CreateIndex( - name: "IX_IdentityServerApiResources_Name", - table: "IdentityServerApiResources", - column: "Name", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_IdentityServerApiScopes_Name", - table: "IdentityServerApiScopes", - column: "Name", - unique: true); - migrationBuilder.CreateIndex( name: "IX_IdentityServerClients_ClientId", table: "IdentityServerClients", @@ -1188,12 +1176,6 @@ namespace MyCompanyName.MyProjectName.Migrations table: "IdentityServerDeviceFlowCodes", column: "UserCode"); - migrationBuilder.CreateIndex( - name: "IX_IdentityServerIdentityResources_Name", - table: "IdentityServerIdentityResources", - column: "Name", - unique: true); - migrationBuilder.CreateIndex( name: "IX_IdentityServerPersistedGrants_Expiration", table: "IdentityServerPersistedGrants", diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Migrations/IdentityServerHostMigrationsDbContextModelSnapshot.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Migrations/IdentityServerHostMigrationsDbContextModelSnapshot.cs index beb40e7827..29deeab756 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Migrations/IdentityServerHostMigrationsDbContextModelSnapshot.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Migrations/IdentityServerHostMigrationsDbContextModelSnapshot.cs @@ -982,9 +982,6 @@ namespace MyCompanyName.MyProjectName.Migrations b.HasKey("Id"); - b.HasIndex("Name") - .IsUnique(); - b.ToTable("IdentityServerApiResources"); }); @@ -1132,9 +1129,6 @@ namespace MyCompanyName.MyProjectName.Migrations b.HasKey("Id"); - b.HasIndex("Name") - .IsUnique(); - b.ToTable("IdentityServerApiScopes"); }); @@ -1710,9 +1704,6 @@ namespace MyCompanyName.MyProjectName.Migrations b.HasKey("Id"); - b.HasIndex("Name") - .IsUnique(); - b.ToTable("IdentityServerIdentityResources"); }); diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Migrations/20201019021101_Initial.Designer.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Migrations/20201028014311_Initial.Designer.cs similarity index 99% rename from templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Migrations/20201019021101_Initial.Designer.cs rename to templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Migrations/20201028014311_Initial.Designer.cs index cd2f885a7d..4958727637 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Migrations/20201019021101_Initial.Designer.cs +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Migrations/20201028014311_Initial.Designer.cs @@ -11,7 +11,7 @@ using Volo.Abp.EntityFrameworkCore; namespace MyCompanyName.MyProjectName.Migrations { [DbContext(typeof(UnifiedDbContext))] - [Migration("20201019021101_Initial")] + [Migration("20201028014311_Initial")] partial class Initial { protected override void BuildTargetModel(ModelBuilder modelBuilder) diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Migrations/20201019021101_Initial.cs b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Migrations/20201028014311_Initial.cs similarity index 100% rename from templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Migrations/20201019021101_Initial.cs rename to templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Migrations/20201028014311_Initial.cs diff --git a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/MyProjectName/Index.razor b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/MyProjectName/Index.razor index d54a229594..2d155b021c 100644 --- a/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/MyProjectName/Index.razor +++ b/templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/MyProjectName/Index.razor @@ -1,6 +1,6 @@ -@page "/MyProjectName" +@page "/MyProjectName" @using Microsoft.Extensions.Localization -@using MyCompanyName.MyProjectName.Localization +@using global::MyCompanyName.MyProjectName.Localization @inject IStringLocalizer L @{ }