From 52fc9f4a7217388a13ed69b8321f5245b531b187 Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 19 Mar 2020 18:17:37 +0800 Subject: [PATCH 01/21] Encode the returnUrl parameter. Resolve #3202 --- .../Basic/Components/Toolbar/LanguageSwitch/Default.cshtml | 3 ++- .../FodyWeavers.xml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/LanguageSwitch/Default.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/LanguageSwitch/Default.cshtml index ae3255abbf..65ca8d940e 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/LanguageSwitch/Default.cshtml +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/LanguageSwitch/Default.cshtml @@ -1,4 +1,5 @@ @using System.Linq +@using Microsoft.AspNetCore.Http.Extensions @using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Themes.Basic.Components.Toolbar.LanguageSwitch @model LanguageSwitchViewComponentModel @if (Model.OtherLanguages.Any()) @@ -11,7 +12,7 @@ diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Demo/FodyWeavers.xml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Demo/FodyWeavers.xml index 00e1d9a1c1..be0de3a908 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Demo/FodyWeavers.xml +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Demo/FodyWeavers.xml @@ -1,3 +1,3 @@  - + \ No newline at end of file From d8f8589a051dea1920b7ca2f415d6a21e5e0f4ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20=C3=87otur?= Date: Thu, 19 Mar 2020 19:42:37 +0300 Subject: [PATCH 02/21] etos' implemented --- .../Volo.Blogging.Domain.csproj | 1 + .../Blogging/BloggingDomainMappingProfile.cs | 19 ++++++++++++ .../Volo/Blogging/BloggingDomainModule.cs | 16 +++++++++- .../Volo/Blogging/Blogs/BlogEto.cs | 19 ++++++++++++ .../Volo/Blogging/Comments/CommentEto.cs | 15 ++++++++++ .../Volo/Blogging/Posts/PostEto.cs | 29 +++++++++++++++++++ .../Volo/Blogging/Tagging/TagEto.cs | 19 ++++++++++++ 7 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/BloggingDomainMappingProfile.cs create mode 100644 modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Blogs/BlogEto.cs create mode 100644 modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Comments/CommentEto.cs create mode 100644 modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Posts/PostEto.cs create mode 100644 modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Tagging/TagEto.cs diff --git a/modules/blogging/src/Volo.Blogging.Domain/Volo.Blogging.Domain.csproj b/modules/blogging/src/Volo.Blogging.Domain/Volo.Blogging.Domain.csproj index a7cbc2c7c6..73cf0498c5 100644 --- a/modules/blogging/src/Volo.Blogging.Domain/Volo.Blogging.Domain.csproj +++ b/modules/blogging/src/Volo.Blogging.Domain/Volo.Blogging.Domain.csproj @@ -13,6 +13,7 @@ + diff --git a/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/BloggingDomainMappingProfile.cs b/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/BloggingDomainMappingProfile.cs new file mode 100644 index 0000000000..da36b39049 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/BloggingDomainMappingProfile.cs @@ -0,0 +1,19 @@ +using AutoMapper; +using Volo.Blogging.Blogs; +using Volo.Blogging.Comments; +using Volo.Blogging.Posts; +using Volo.Blogging.Tagging; + +namespace Volo.Blogging +{ + public class BloggingDomainMappingProfile : Profile + { + public BloggingDomainMappingProfile() + { + CreateMap(); + CreateMap(); + CreateMap(); + CreateMap(); + } + } +} \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/BloggingDomainModule.cs b/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/BloggingDomainModule.cs index 4690546a7e..5a853cf894 100644 --- a/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/BloggingDomainModule.cs +++ b/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/BloggingDomainModule.cs @@ -1,5 +1,10 @@ using Volo.Abp.Domain; +using Volo.Abp.EventBus.Distributed; using Volo.Abp.Modularity; +using Volo.Blogging.Blogs; +using Volo.Blogging.Comments; +using Volo.Blogging.Posts; +using Volo.Blogging.Tagging; namespace Volo.Blogging { @@ -8,6 +13,15 @@ namespace Volo.Blogging typeof(AbpDddDomainModule))] public class BloggingDomainModule : AbpModule { - + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.EtoMappings.Add(); + options.EtoMappings.Add(); + options.EtoMappings.Add(); + options.EtoMappings.Add(); + }); + } } } diff --git a/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Blogs/BlogEto.cs b/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Blogs/BlogEto.cs new file mode 100644 index 0000000000..3fb3af4e08 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Blogs/BlogEto.cs @@ -0,0 +1,19 @@ +using System; +using JetBrains.Annotations; + +namespace Volo.Blogging.Blogs +{ + public class BlogEto + { + public Guid Id { get; set; } + + [NotNull] + public string Name { get; set; } + + [NotNull] + public string ShortName { get; set; } + + [CanBeNull] + public string Description { get; set; } + } +} \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Comments/CommentEto.cs b/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Comments/CommentEto.cs new file mode 100644 index 0000000000..fff54780be --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Comments/CommentEto.cs @@ -0,0 +1,15 @@ +using System; + +namespace Volo.Blogging.Comments +{ + public class CommentEto + { + public Guid Id { get; set; } + + public Guid PostId { get; set; } + + public Guid? RepliedCommentId { get; set; } + + public string Text { get; set; } + } +} \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Posts/PostEto.cs b/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Posts/PostEto.cs new file mode 100644 index 0000000000..d3ef0d0f76 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Posts/PostEto.cs @@ -0,0 +1,29 @@ +using JetBrains.Annotations; +using System; +using System.Collections.Generic; + +namespace Volo.Blogging.Posts +{ + public class PostEto + { + public Guid Id { get; set; } + + public Guid BlogId { get; set; } + + [NotNull] + public string Url { get; set; } + + [NotNull] + public string CoverImage { get; set; } + + [NotNull] + public string Title { get; set; } + + [CanBeNull] + public string Content { get; set; } + + public int ReadCount { get; set; } + + public ICollection Tags { get; set; } + } +} \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Tagging/TagEto.cs b/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Tagging/TagEto.cs new file mode 100644 index 0000000000..3a83631885 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Tagging/TagEto.cs @@ -0,0 +1,19 @@ +using System; +using JetBrains.Annotations; + +namespace Volo.Blogging.Tagging +{ + public class TagEto + { + public Guid Id { get; set; } + + public Guid BlogId { get; set; } + + [NotNull] + public string Name { get; set; } + + public string Description { get; set; } + + public int UsageCount { get; set; } + } +} \ No newline at end of file From 7c8166ce379f24d02c8c792be2f595717bd6fca4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20=C3=87otur?= Date: Thu, 19 Mar 2020 19:49:47 +0300 Subject: [PATCH 03/21] Update BloggingDomainModule.cs --- .../Volo/Blogging/BloggingDomainModule.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/BloggingDomainModule.cs b/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/BloggingDomainModule.cs index 5a853cf894..81c3cd3a3c 100644 --- a/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/BloggingDomainModule.cs +++ b/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/BloggingDomainModule.cs @@ -1,4 +1,5 @@ -using Volo.Abp.Domain; +using Volo.Abp.AutoMapper; +using Volo.Abp.Domain; using Volo.Abp.EventBus.Distributed; using Volo.Abp.Modularity; using Volo.Blogging.Blogs; @@ -22,6 +23,11 @@ namespace Volo.Blogging options.EtoMappings.Add(); options.EtoMappings.Add(); }); + + Configure(options => + { + options.AddProfile(validate: true); + }); } } } From 47fb18c19871d849d3aace070cdabeb45d0fa3f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20=C3=87otur?= Date: Thu, 19 Mar 2020 19:56:40 +0300 Subject: [PATCH 04/21] put files in correct place --- .../Volo/Blogging/Blogs/BlogEto.cs | 0 .../Volo/Blogging/Comments/CommentEto.cs | 0 .../Volo/Blogging/Posts/PostEto.cs | 0 .../Volo/Blogging/Tagging/TagEto.cs | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename modules/blogging/src/{Volo.Blogging.Domain => Volo.Blogging.Domain.Shared}/Volo/Blogging/Blogs/BlogEto.cs (100%) rename modules/blogging/src/{Volo.Blogging.Domain => Volo.Blogging.Domain.Shared}/Volo/Blogging/Comments/CommentEto.cs (100%) rename modules/blogging/src/{Volo.Blogging.Domain => Volo.Blogging.Domain.Shared}/Volo/Blogging/Posts/PostEto.cs (100%) rename modules/blogging/src/{Volo.Blogging.Domain => Volo.Blogging.Domain.Shared}/Volo/Blogging/Tagging/TagEto.cs (100%) diff --git a/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Blogs/BlogEto.cs b/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Blogs/BlogEto.cs similarity index 100% rename from modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Blogs/BlogEto.cs rename to modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Blogs/BlogEto.cs diff --git a/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Comments/CommentEto.cs b/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Comments/CommentEto.cs similarity index 100% rename from modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Comments/CommentEto.cs rename to modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Comments/CommentEto.cs diff --git a/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Posts/PostEto.cs b/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Posts/PostEto.cs similarity index 100% rename from modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Posts/PostEto.cs rename to modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Posts/PostEto.cs diff --git a/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Tagging/TagEto.cs b/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Tagging/TagEto.cs similarity index 100% rename from modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Tagging/TagEto.cs rename to modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Tagging/TagEto.cs From d56e1613b592c8b3da63f34fef737780e9336160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20=C3=87otur?= Date: Thu, 19 Mar 2020 19:58:30 +0300 Subject: [PATCH 05/21] Update PostEto.cs --- .../Volo.Blogging.Domain.Shared/Volo/Blogging/Posts/PostEto.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Posts/PostEto.cs b/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Posts/PostEto.cs index d3ef0d0f76..d01293b025 100644 --- a/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Posts/PostEto.cs +++ b/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Posts/PostEto.cs @@ -1,6 +1,7 @@ using JetBrains.Annotations; using System; using System.Collections.Generic; +using Volo.Blogging.Tagging; namespace Volo.Blogging.Posts { @@ -24,6 +25,6 @@ namespace Volo.Blogging.Posts public int ReadCount { get; set; } - public ICollection Tags { get; set; } + public ICollection Tags { get; set; } } } \ No newline at end of file From 0fce3b672ea557d2477ef29c64b3ea888b98cabb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20=C3=87otur?= Date: Thu, 19 Mar 2020 20:18:40 +0300 Subject: [PATCH 06/21] etos' added --- .../Volo/Docs/Documents/DocumentEto.cs | 40 +++++++++++++++++++ .../Volo/Docs/Projects/ProjectEto.cs | 29 ++++++++++++++ .../Volo.Docs.Domain/Volo.Docs.Domain.csproj | 1 + .../Volo/Docs/DocsDomainMappingProfile.cs | 15 +++++++ .../Volo/Docs/DocsDomainModule.cs | 15 +++++++ 5 files changed, 100 insertions(+) create mode 100644 modules/docs/src/Volo.Docs.Domain.Shared/Volo/Docs/Documents/DocumentEto.cs create mode 100644 modules/docs/src/Volo.Docs.Domain.Shared/Volo/Docs/Projects/ProjectEto.cs create mode 100644 modules/docs/src/Volo.Docs.Domain/Volo/Docs/DocsDomainMappingProfile.cs diff --git a/modules/docs/src/Volo.Docs.Domain.Shared/Volo/Docs/Documents/DocumentEto.cs b/modules/docs/src/Volo.Docs.Domain.Shared/Volo/Docs/Documents/DocumentEto.cs new file mode 100644 index 0000000000..342ad59bcb --- /dev/null +++ b/modules/docs/src/Volo.Docs.Domain.Shared/Volo/Docs/Documents/DocumentEto.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; + +namespace Volo.Docs.Documents +{ + public class DocumentEto + { + public Guid Id { get; set; } + + public Guid ProjectId { get; set; } + + public string Name { get; set; } + + public string Version { get; set; } + + public string LanguageCode { get; set; } + + public string FileName { get; set; } + + public string Content { get; set; } + + public string Format { get; set; } + + public string EditLink { get; set; } + + public string RootUrl { get; set; } + + public string RawRootUrl { get; set; } + + public string LocalDirectory { get; set; } + + public DateTime CreationTime { get; set; } + + public DateTime LastUpdatedTime { get; set; } + + public DateTime? LastSignificantUpdateTime { get; set; } + + public DateTime LastCachedTime { get; set; } + } +} \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.Domain.Shared/Volo/Docs/Projects/ProjectEto.cs b/modules/docs/src/Volo.Docs.Domain.Shared/Volo/Docs/Projects/ProjectEto.cs new file mode 100644 index 0000000000..110e497b43 --- /dev/null +++ b/modules/docs/src/Volo.Docs.Domain.Shared/Volo/Docs/Projects/ProjectEto.cs @@ -0,0 +1,29 @@ +using System; + +namespace Volo.Docs.Projects +{ + public class ProjectEto + { + public Guid Id { get; set; } + + public string Name { get; set; } + + public string ShortName { get; set; } + + public string Format { get; set; } + + public string DefaultDocumentName { get; set; } + + public string NavigationDocumentName { get; set; } + + public string ParametersDocumentName { get; set; } + + public string MinimumVersion { get; set; } + + public string DocumentStoreType { get; set; } + + public string MainWebsiteUrl { get; set; } + + public string LatestVersionBranchName { get; set; } + } +} \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.Domain/Volo.Docs.Domain.csproj b/modules/docs/src/Volo.Docs.Domain/Volo.Docs.Domain.csproj index c2540754a3..3fc2eafb9d 100644 --- a/modules/docs/src/Volo.Docs.Domain/Volo.Docs.Domain.csproj +++ b/modules/docs/src/Volo.Docs.Domain/Volo.Docs.Domain.csproj @@ -25,6 +25,7 @@ + diff --git a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/DocsDomainMappingProfile.cs b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/DocsDomainMappingProfile.cs new file mode 100644 index 0000000000..74f7224ea6 --- /dev/null +++ b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/DocsDomainMappingProfile.cs @@ -0,0 +1,15 @@ +using AutoMapper; +using Volo.Docs.Documents; +using Volo.Docs.Projects; + +namespace Volo.Docs +{ + public class DocsDomainMappingProfile : Profile + { + public DocsDomainMappingProfile() + { + CreateMap(); + CreateMap(); + } + } +} \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/DocsDomainModule.cs b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/DocsDomainModule.cs index ba2ee6018d..f392ca8875 100644 --- a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/DocsDomainModule.cs +++ b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/DocsDomainModule.cs @@ -2,7 +2,9 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Volo.Abp; +using Volo.Abp.AutoMapper; using Volo.Abp.Domain; +using Volo.Abp.EventBus.Distributed; using Volo.Abp.Localization; using Volo.Abp.Modularity; using Volo.Abp.Threading; @@ -12,6 +14,7 @@ using Volo.Docs.Documents.FullSearch.Elastic; using Volo.Docs.FileSystem.Documents; using Volo.Docs.GitHub.Documents; using Volo.Docs.Localization; +using Volo.Docs.Projects; namespace Volo.Docs { @@ -23,6 +26,18 @@ namespace Volo.Docs { public override void ConfigureServices(ServiceConfigurationContext context) { + Configure(options => + { + options.EtoMappings.Add(); + options.EtoMappings.Add(); + }); + + + Configure(options => + { + options.AddProfile(validate: true); + }); + Configure(options => { options.FileSets From 5655ce433189efd6d93a58fe3719fd32164eb88d Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Fri, 20 Mar 2020 14:00:00 +0300 Subject: [PATCH 07/21] feat(core): add a utility function that checks if a value is undefined or empty string --- .../core/src/lib/tests/common-utils.spec.ts | 18 +++++++++++++++++- .../core/src/lib/utils/common-utils.ts | 4 ++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/npm/ng-packs/packages/core/src/lib/tests/common-utils.spec.ts b/npm/ng-packs/packages/core/src/lib/tests/common-utils.spec.ts index 98c6614987..60280e396b 100644 --- a/npm/ng-packs/packages/core/src/lib/tests/common-utils.spec.ts +++ b/npm/ng-packs/packages/core/src/lib/tests/common-utils.spec.ts @@ -1,4 +1,4 @@ -import { noop } from '../utils'; +import { isUndefinedOrEmptyString, noop } from '../utils'; describe('CommonUtils', () => { describe('#noop', () => { @@ -7,4 +7,20 @@ describe('CommonUtils', () => { expect(noop()()).toBeUndefined(); }); }); + + describe('#isUndefinedOrEmptyString', () => { + test.each` + value | expected + ${null} | ${false} + ${0} | ${false} + ${true} | ${false} + ${'x'} | ${false} + ${{}} | ${false} + ${[]} | ${false} + ${undefined} | ${true} + ${''} | ${true} + `('should return $expected when given parameter is $value', ({ value, expected }) => { + expect(isUndefinedOrEmptyString(value)).toBe(expected); + }); + }); }); diff --git a/npm/ng-packs/packages/core/src/lib/utils/common-utils.ts b/npm/ng-packs/packages/core/src/lib/utils/common-utils.ts index 756d3a34dd..b8609be130 100644 --- a/npm/ng-packs/packages/core/src/lib/utils/common-utils.ts +++ b/npm/ng-packs/packages/core/src/lib/utils/common-utils.ts @@ -3,3 +3,7 @@ export function noop() { const fn = function() {}; return fn; } + +export function isUndefinedOrEmptyString(value: unknown): boolean { + return value === undefined || value === ''; +} From ddf286d47760be173d1e14097c5c8a2f7c49e579 Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Fri, 20 Mar 2020 14:22:58 +0300 Subject: [PATCH 08/21] refactor(core): change internals of request method of RestService --- .../core/src/lib/services/rest.service.ts | 42 ++++++++--------- .../core/src/lib/tests/rest.service.spec.ts | 46 ++++++++----------- 2 files changed, 36 insertions(+), 52 deletions(-) diff --git a/npm/ng-packs/packages/core/src/lib/services/rest.service.ts b/npm/ng-packs/packages/core/src/lib/services/rest.service.ts index 15cc13cf50..eaebecf994 100644 --- a/npm/ng-packs/packages/core/src/lib/services/rest.service.ts +++ b/npm/ng-packs/packages/core/src/lib/services/rest.service.ts @@ -2,10 +2,11 @@ import { HttpClient, HttpRequest } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Store } from '@ngxs/store'; import { Observable, throwError } from 'rxjs'; -import { catchError, take, tap } from 'rxjs/operators'; +import { catchError } from 'rxjs/operators'; import { RestOccurError } from '../actions/rest.actions'; import { Rest } from '../models/rest'; import { ConfigState } from '../states/config.state'; +import { isUndefinedOrEmptyString } from '../utils'; @Injectable({ providedIn: 'root', @@ -13,47 +14,40 @@ import { ConfigState } from '../states/config.state'; export class RestService { constructor(private http: HttpClient, private store: Store) {} + private getApiFromStore(apiName: string): string { + return this.store.selectSnapshot(ConfigState.getApiUrl(apiName)); + } + handleError(err: any): Observable { this.store.dispatch(new RestOccurError(err)); - console.error(err); return throwError(err); } + // TODO: Deprecate service or improve interface in v3.0 request( request: HttpRequest | Rest.Request, config?: Rest.Config, api?: string, ): Observable { config = config || ({} as Rest.Config); - const { observe = Rest.Observe.Body, skipHandleError } = config; - const url = - (api || this.store.selectSnapshot(ConfigState.getApiUrl(config.apiName))) + request.url; + api = api || this.getApiFromStore(config.apiName); const { method, params, ...options } = request; + const { observe = Rest.Observe.Body, skipHandleError } = config; return this.http - .request(method, url, { + .request(method, api + request.url, { observe, ...(params && { - params: Object.keys(params).reduce( - (acc, key) => ({ - ...acc, - ...(typeof params[key] !== 'undefined' && - params[key] !== '' && { [key]: params[key] }), - }), - {}, - ), + params: Object.keys(params).reduce((acc, key) => { + const value = params[key]; + + if (!isUndefinedOrEmptyString(value)) acc[key] = value; + + return acc; + }, {}), }), ...options, } as any) - .pipe( - observe === Rest.Observe.Body ? take(1) : tap(), - catchError(err => { - if (skipHandleError) { - return throwError(err); - } - - return this.handleError(err); - }), - ); + .pipe(catchError(err => (skipHandleError ? throwError(err) : this.handleError(err)))); } } diff --git a/npm/ng-packs/packages/core/src/lib/tests/rest.service.spec.ts b/npm/ng-packs/packages/core/src/lib/tests/rest.service.spec.ts index ecc8e9dce8..8251bcabb4 100644 --- a/npm/ng-packs/packages/core/src/lib/tests/rest.service.spec.ts +++ b/npm/ng-packs/packages/core/src/lib/tests/rest.service.spec.ts @@ -1,9 +1,8 @@ import { ConfigState } from '@abp/ng.core'; import { createHttpFactory, HttpMethod, SpectatorHttp, SpyObject } from '@ngneat/spectator/jest'; import { NgxsModule, Store } from '@ngxs/store'; -import { interval, of, Subscription, throwError, timer } from 'rxjs'; +import { of, throwError } from 'rxjs'; import { catchError } from 'rxjs/operators'; -import { RestOccurError } from '../actions'; import { Rest } from '../models'; import { RestService } from '../services/rest.service'; @@ -36,6 +35,10 @@ describe('HttpClient testing', () => { }); }); + afterEach(() => { + spectator.controller.verify(); + }); + test('should send a GET request with params', () => { spectator.service .request({ method: HttpMethod.GET, url: '/test', params: { id: 1 } }) @@ -66,34 +69,16 @@ describe('HttpClient testing', () => { spectator.expectOne('bar' + '/test', HttpMethod.GET); }); - test('should close the subscriber when observe equal to body', done => { - jest.spyOn(spectator.httpClient, 'request').mockReturnValue(interval(50)); + test('should complete upon successful request', done => { + const complete = jest.fn(done); - const subscriber: Subscription = spectator.service - .request({ method: HttpMethod.GET, url: '/test' }, { observe: Rest.Observe.Body }) - .subscribe(); + spectator.service.request({ method: HttpMethod.GET, url: '/test' }).subscribe({ complete }); - timer(51).subscribe(() => { - expect(subscriber.closed).toBe(true); - done(); - }); - }); - - test('should open the subscriber when observe not equal to body', done => { - jest.spyOn(spectator.httpClient, 'request').mockReturnValue(interval(50)); - - const subscriber: Subscription = spectator.service - .request({ method: HttpMethod.GET, url: '/test' }, { observe: Rest.Observe.Events }) - .subscribe(); - - timer(51).subscribe(() => { - expect(subscriber.closed).toBe(false); - done(); - }); + const req = spectator.expectOne(api + '/test', HttpMethod.GET); + spectator.flushAll([req], [{}]); }); test('should handle the error', () => { - jest.spyOn(spectator.httpClient, 'request').mockReturnValue(throwError('Testing error')); const spy = jest.spyOn(store, 'dispatch'); spectator.service @@ -101,15 +86,17 @@ describe('HttpClient testing', () => { .pipe( catchError(err => { expect(err).toBeTruthy(); - expect(spy.mock.calls[0][0] instanceof RestOccurError).toBe(true); + expect(spy).toHaveBeenCalled(); return of(null); }), ) .subscribe(); + + const req = spectator.expectOne(api + '/test', HttpMethod.GET); + spectator.flushAll([req], [throwError('Testing error')]); }); test('should not handle the error when skipHandleError is true', () => { - jest.spyOn(spectator.httpClient, 'request').mockReturnValue(throwError('Testing error')); const spy = jest.spyOn(store, 'dispatch'); spectator.service @@ -120,10 +107,13 @@ describe('HttpClient testing', () => { .pipe( catchError(err => { expect(err).toBeTruthy(); - expect(spy.mock.calls).toHaveLength(0); + expect(spy).toHaveBeenCalledTimes(0); return of(null); }), ) .subscribe(); + + const req = spectator.expectOne(api + '/test', HttpMethod.GET); + spectator.flushAll([req], [throwError('Testing error')]); }); }); From f596896aba613964f95c7c7ddeb040c0dcf2e579 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20=C3=87otur?= Date: Fri, 20 Mar 2020 14:45:34 +0300 Subject: [PATCH 09/21] eto's mapping updated --- .../Volo/Docs/Documents/DocumentEto.cs | 1 + .../Volo/Docs/Projects/ProjectEto.cs | 1 + .../Volo/Docs/DocsDomainModule.cs | 16 +++++++++------- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/modules/docs/src/Volo.Docs.Domain.Shared/Volo/Docs/Documents/DocumentEto.cs b/modules/docs/src/Volo.Docs.Domain.Shared/Volo/Docs/Documents/DocumentEto.cs index 342ad59bcb..12f62f8b6d 100644 --- a/modules/docs/src/Volo.Docs.Domain.Shared/Volo/Docs/Documents/DocumentEto.cs +++ b/modules/docs/src/Volo.Docs.Domain.Shared/Volo/Docs/Documents/DocumentEto.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; namespace Volo.Docs.Documents { + [Serializable] public class DocumentEto { public Guid Id { get; set; } diff --git a/modules/docs/src/Volo.Docs.Domain.Shared/Volo/Docs/Projects/ProjectEto.cs b/modules/docs/src/Volo.Docs.Domain.Shared/Volo/Docs/Projects/ProjectEto.cs index 110e497b43..dae1affae4 100644 --- a/modules/docs/src/Volo.Docs.Domain.Shared/Volo/Docs/Projects/ProjectEto.cs +++ b/modules/docs/src/Volo.Docs.Domain.Shared/Volo/Docs/Projects/ProjectEto.cs @@ -2,6 +2,7 @@ namespace Volo.Docs.Projects { + [Serializable] public class ProjectEto { public Guid Id { get; set; } diff --git a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/DocsDomainModule.cs b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/DocsDomainModule.cs index f392ca8875..5e53b858ce 100644 --- a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/DocsDomainModule.cs +++ b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/DocsDomainModule.cs @@ -20,24 +20,26 @@ namespace Volo.Docs { [DependsOn( typeof(DocsDomainSharedModule), - typeof(AbpDddDomainModule) + typeof(AbpDddDomainModule), + typeof(AbpAutoMapperModule) )] public class DocsDomainModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { - Configure(options => - { - options.EtoMappings.Add(); - options.EtoMappings.Add(); - }); - + context.Services.AddAutoMapperObjectMapper(); Configure(options => { options.AddProfile(validate: true); }); + Configure(options => + { + options.EtoMappings.Add(typeof(DocsDomainModule)); + options.EtoMappings.Add(typeof(DocsDomainModule)); + }); + Configure(options => { options.FileSets From 5a68a226e1da18fa5a77f3847afed24ed4fc2b74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20=C3=87otur?= Date: Fri, 20 Mar 2020 14:55:02 +0300 Subject: [PATCH 10/21] eto's and mapping updated --- .../Volo/Blogging/Blogs/BlogEto.cs | 1 + .../Volo/Blogging/Comments/CommentEto.cs | 1 + .../Volo/Blogging/Posts/PostEto.cs | 3 +-- .../Volo/Blogging/Tagging/TagEto.cs | 1 + .../Volo/Blogging/BloggingDomainModule.cs | 22 +++++++++++-------- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Blogs/BlogEto.cs b/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Blogs/BlogEto.cs index 3fb3af4e08..ceb0b977cf 100644 --- a/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Blogs/BlogEto.cs +++ b/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Blogs/BlogEto.cs @@ -3,6 +3,7 @@ using JetBrains.Annotations; namespace Volo.Blogging.Blogs { + [Serializable] public class BlogEto { public Guid Id { get; set; } diff --git a/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Comments/CommentEto.cs b/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Comments/CommentEto.cs index fff54780be..dd1b5ccb41 100644 --- a/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Comments/CommentEto.cs +++ b/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Comments/CommentEto.cs @@ -2,6 +2,7 @@ namespace Volo.Blogging.Comments { + [Serializable] public class CommentEto { public Guid Id { get; set; } diff --git a/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Posts/PostEto.cs b/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Posts/PostEto.cs index d01293b025..90a88833c7 100644 --- a/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Posts/PostEto.cs +++ b/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Posts/PostEto.cs @@ -5,6 +5,7 @@ using Volo.Blogging.Tagging; namespace Volo.Blogging.Posts { + [Serializable] public class PostEto { public Guid Id { get; set; } @@ -24,7 +25,5 @@ namespace Volo.Blogging.Posts public string Content { get; set; } public int ReadCount { get; set; } - - public ICollection Tags { get; set; } } } \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Tagging/TagEto.cs b/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Tagging/TagEto.cs index 3a83631885..0f461a0281 100644 --- a/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Tagging/TagEto.cs +++ b/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Tagging/TagEto.cs @@ -3,6 +3,7 @@ using JetBrains.Annotations; namespace Volo.Blogging.Tagging { + [Serializable] public class TagEto { public Guid Id { get; set; } diff --git a/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/BloggingDomainModule.cs b/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/BloggingDomainModule.cs index 81c3cd3a3c..f39c4c88fb 100644 --- a/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/BloggingDomainModule.cs +++ b/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/BloggingDomainModule.cs @@ -1,4 +1,5 @@ -using Volo.Abp.AutoMapper; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.AutoMapper; using Volo.Abp.Domain; using Volo.Abp.EventBus.Distributed; using Volo.Abp.Modularity; @@ -11,23 +12,26 @@ namespace Volo.Blogging { [DependsOn( typeof(BloggingDomainSharedModule), - typeof(AbpDddDomainModule))] + typeof(AbpDddDomainModule), + typeof(AbpAutoMapperModule))] public class BloggingDomainModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { - Configure(options => - { - options.EtoMappings.Add(); - options.EtoMappings.Add(); - options.EtoMappings.Add(); - options.EtoMappings.Add(); - }); + context.Services.AddAutoMapperObjectMapper(); Configure(options => { options.AddProfile(validate: true); }); + + Configure(options => + { + options.EtoMappings.Add(typeof(BloggingDomainModule)); + options.EtoMappings.Add(typeof(BloggingDomainModule)); + options.EtoMappings.Add(typeof(BloggingDomainModule)); + options.EtoMappings.Add(typeof(BloggingDomainModule)); + }); } } } From acffd839a91b3797268b4cd10e917608f1cf3d5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20=C3=87otur?= Date: Fri, 20 Mar 2020 15:11:02 +0300 Subject: [PATCH 11/21] eto's added --- .../ApiResources/ApiResourceEto.cs | 20 +++++ .../Abp/IdentityServer/Clients/ClientEto.cs | 84 +++++++++++++++++++ .../Devices/DeviceFlowCodesEto.cs | 22 +++++ .../Grants/PersistedGrantEto.cs | 24 ++++++ .../IdentityResources/IdentityResourceEto.cs | 24 ++++++ .../AbpIdentityServerDomainModule.cs | 14 ++++ .../IdentityServerAutoMapperProfile.cs | 7 ++ 7 files changed, 195 insertions(+) create mode 100644 modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiResources/ApiResourceEto.cs create mode 100644 modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Clients/ClientEto.cs create mode 100644 modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Devices/DeviceFlowCodesEto.cs create mode 100644 modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Grants/PersistedGrantEto.cs create mode 100644 modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/IdentityResources/IdentityResourceEto.cs diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiResources/ApiResourceEto.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiResources/ApiResourceEto.cs new file mode 100644 index 0000000000..1130b0bc92 --- /dev/null +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/ApiResources/ApiResourceEto.cs @@ -0,0 +1,20 @@ +using System; +using JetBrains.Annotations; + +namespace Volo.Abp.IdentityServer.ApiResources +{ + [Serializable] + public class ApiResourceEto + { + public Guid Id { get; set; } + + [NotNull] + public string Name { get; set; } + + public string DisplayName { get; set; } + + public string Description { get; set; } + + public bool Enabled { get; set; } + } +} \ No newline at end of file diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Clients/ClientEto.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Clients/ClientEto.cs new file mode 100644 index 0000000000..e5957eef5a --- /dev/null +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Clients/ClientEto.cs @@ -0,0 +1,84 @@ +using System; + +namespace Volo.Abp.IdentityServer.Clients +{ + [Serializable] + public class ClientEto + { + public Guid Id { get; set; } + + public string ClientId { get; set; } + + public string ClientName { get; set; } + + public string Description { get; set; } + + public string ClientUri { get; set; } + + public string LogoUri { get; set; } + + public bool Enabled { get; set; } = true; + + public string ProtocolType { get; set; } + + public bool RequireClientSecret { get; set; } + + public bool RequireConsent { get; set; } + + public bool AllowRememberConsent { get; set; } + + public bool AlwaysIncludeUserClaimsInIdToken { get; set; } + + public bool RequirePkce { get; set; } + + public bool AllowPlainTextPkce { get; set; } + + public bool AllowAccessTokensViaBrowser { get; set; } + + public string FrontChannelLogoutUri { get; set; } + + public bool FrontChannelLogoutSessionRequired { get; set; } + + public string BackChannelLogoutUri { get; set; } + + public bool BackChannelLogoutSessionRequired { get; set; } + + public bool AllowOfflineAccess { get; set; } + + public int IdentityTokenLifetime { get; set; } + + public int AccessTokenLifetime { get; set; } + + public int AuthorizationCodeLifetime { get; set; } + + public int? ConsentLifetime { get; set; } + + public int AbsoluteRefreshTokenLifetime { get; set; } + + public int SlidingRefreshTokenLifetime { get; set; } + + public int RefreshTokenUsage { get; set; } + + public bool UpdateAccessTokenClaimsOnRefresh { get; set; } + + public int RefreshTokenExpiration { get; set; } + + public int AccessTokenType { get; set; } + + public bool EnableLocalLogin { get; set; } + + public bool IncludeJwtId { get; set; } + + public bool AlwaysSendClientClaims { get; set; } + + public string ClientClaimsPrefix { get; set; } + + public string PairWiseSubjectSalt { get; set; } + + public int? UserSsoLifetime { get; set; } + + public string UserCodeType { get; set; } + + public int DeviceCodeLifetime { get; set; } + } +} \ No newline at end of file diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Devices/DeviceFlowCodesEto.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Devices/DeviceFlowCodesEto.cs new file mode 100644 index 0000000000..f82af68bbf --- /dev/null +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Devices/DeviceFlowCodesEto.cs @@ -0,0 +1,22 @@ +using System; + +namespace Volo.Abp.IdentityServer.Devices +{ + [Serializable] + public class DeviceFlowCodesEto + { + public Guid Id { get; set; } + + public string DeviceCode { get; set; } + + public string UserCode { get; set; } + + public string SubjectId { get; set; } + + public string ClientId { get; set; } + + public DateTime? Expiration { get; set; } + + public string Data { get; set; } + } +} \ No newline at end of file diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Grants/PersistedGrantEto.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Grants/PersistedGrantEto.cs new file mode 100644 index 0000000000..9d5db878f7 --- /dev/null +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Grants/PersistedGrantEto.cs @@ -0,0 +1,24 @@ +using System; + +namespace Volo.Abp.IdentityServer.Grants +{ + [Serializable] + public class PersistedGrantEto + { + public Guid Id { get; set; } + + public string Key { get; set; } + + public string Type { get; set; } + + public string SubjectId { get; set; } + + public string ClientId { get; set; } + + public DateTime CreationTime { get; set; } + + public DateTime? Expiration { get; set; } + + public string Data { get; set; } + } +} \ No newline at end of file diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/IdentityResources/IdentityResourceEto.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/IdentityResources/IdentityResourceEto.cs new file mode 100644 index 0000000000..c382642a9f --- /dev/null +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/IdentityResources/IdentityResourceEto.cs @@ -0,0 +1,24 @@ +using System; + +namespace Volo.Abp.IdentityServer.IdentityResources +{ + [Serializable] + public class IdentityResourceEto + { + public Guid Id { get; set; } + + public string Name { get; set; } + + public string DisplayName { get; set; } + + public string Description { get; set; } + + public bool Enabled { get; set; } + + public bool Required { get; set; } + + public bool Emphasize { get; set; } + + public bool ShowInDiscoveryDocument { get; set; } + } +} \ No newline at end of file diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerDomainModule.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerDomainModule.cs index 0ff798e7fd..ef1969fe24 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerDomainModule.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerDomainModule.cs @@ -6,7 +6,13 @@ using Microsoft.Extensions.Options; using Volo.Abp.AutoMapper; using Volo.Abp.BackgroundWorkers; using Volo.Abp.Caching; +using Volo.Abp.EventBus.Distributed; using Volo.Abp.Identity; +using Volo.Abp.IdentityServer.ApiResources; +using Volo.Abp.IdentityServer.Clients; +using Volo.Abp.IdentityServer.Devices; +using Volo.Abp.IdentityServer.Grants; +using Volo.Abp.IdentityServer.IdentityResources; using Volo.Abp.IdentityServer.Tokens; using Volo.Abp.Modularity; using Volo.Abp.Security; @@ -34,6 +40,14 @@ namespace Volo.Abp.IdentityServer options.AddProfile(validate: true); }); + Configure(options => + { + options.EtoMappings.Add(typeof(AbpIdentityServerDomainModule)); + options.EtoMappings.Add(typeof(AbpIdentityServerDomainModule)); + options.EtoMappings.Add(typeof(AbpIdentityServerDomainModule)); + options.EtoMappings.Add(typeof(AbpIdentityServerDomainModule)); + }); + AddIdentityServer(context.Services); } diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityServerAutoMapperProfile.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityServerAutoMapperProfile.cs index ba1f44953c..e576d9413e 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityServerAutoMapperProfile.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityServerAutoMapperProfile.cs @@ -3,6 +3,7 @@ using System.Security.Claims; using AutoMapper; using Volo.Abp.IdentityServer.ApiResources; using Volo.Abp.IdentityServer.Clients; +using Volo.Abp.IdentityServer.Devices; using Volo.Abp.IdentityServer.Grants; using Volo.Abp.IdentityServer.IdentityResources; @@ -82,6 +83,12 @@ namespace Volo.Abp.IdentityServer CreateMap(MemberList.Destination) .ForMember(dest => dest.Type, opt => opt.Condition(srs => srs != null)) .ReverseMap(); + + CreateMap(); + CreateMap(); + CreateMap(); + CreateMap(); + CreateMap(); } } } From fe98008518586f6b9950a99624409d815de83f1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 20 Mar 2020 15:35:24 +0300 Subject: [PATCH 12/21] Resolved #3264: Allow a controller to set the remote service name to be used by clients --- .../AspNetCoreApiDescriptionModelProvider.cs | 18 ++++++++++++- .../AbpConventionalControllerOptions.cs | 11 ++++++-- .../ConventionalControllerSetting.cs | 25 ++++++++++++++----- .../Volo/Abp/RemoteServiceAttribute.cs | 7 ++++++ .../ApplicationApiDescriptionModel.cs | 4 +-- .../Modeling/ModuleApiDescriptionModel.cs | 14 ++++++++--- 6 files changed, 65 insertions(+), 14 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs index aefad0f02e..f957fd894f 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs @@ -73,7 +73,7 @@ namespace Volo.Abp.AspNetCore.Mvc var controllerType = apiDescription.ActionDescriptor.AsControllerActionDescriptor().ControllerTypeInfo.AsType(); var setting = FindSetting(controllerType); - var moduleModel = applicationModel.GetOrAddModule(GetRootPath(controllerType, setting)); + var moduleModel = applicationModel.GetOrAddModule(GetRootPath(controllerType, setting), GetRemoteServiceName(controllerType, setting)); var controllerModel = moduleModel.GetOrAddController(controllerType.FullName, CalculateControllerName(controllerType, setting), controllerType, _modelOptions.IgnoredInterfaces); @@ -289,6 +289,22 @@ namespace Volo.Abp.AspNetCore.Mvc return ModuleApiDescriptionModel.DefaultRootPath; } + private string GetRemoteServiceName(Type controllerType, [CanBeNull] ConventionalControllerSetting setting) + { + if (setting != null) + { + return setting.RemoteServiceName; + } + + var remoteServiceAttr = controllerType.GetCustomAttributes().OfType().FirstOrDefault(); + if (remoteServiceAttr?.Name != null) + { + return remoteServiceAttr.Name; + } + + return ModuleApiDescriptionModel.DefaultRemoteServiceName; + } + [CanBeNull] private ConventionalControllerSetting FindSetting(Type controllerType) { diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/AbpConventionalControllerOptions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/AbpConventionalControllerOptions.cs index e28ff37717..e21e6ee939 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/AbpConventionalControllerOptions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/AbpConventionalControllerOptions.cs @@ -23,9 +23,16 @@ namespace Volo.Abp.AspNetCore.Mvc.Conventions }; } - public AbpConventionalControllerOptions Create(Assembly assembly, [CanBeNull] Action optionsAction = null) + public AbpConventionalControllerOptions Create( + Assembly assembly, + [CanBeNull] Action optionsAction = null) { - var setting = new ConventionalControllerSetting(assembly, ModuleApiDescriptionModel.DefaultRootPath); + var setting = new ConventionalControllerSetting( + assembly, + ModuleApiDescriptionModel.DefaultRootPath, + ModuleApiDescriptionModel.DefaultRemoteServiceName + ); + optionsAction?.Invoke(setting); setting.Initialize(); ConventionalControllerSettings.Add(setting); diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/ConventionalControllerSetting.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/ConventionalControllerSetting.cs index fac627d182..bae2522d20 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/ConventionalControllerSetting.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/ConventionalControllerSetting.cs @@ -30,6 +30,18 @@ namespace Volo.Abp.AspNetCore.Mvc.Conventions } private string _rootPath; + [NotNull] + public string RemoteServiceName + { + get => _remoteServiceName; + set + { + Check.NotNull(value, nameof(value)); + _remoteServiceName = value; + } + } + private string _remoteServiceName; + [CanBeNull] public Func TypePredicate { get; set; } @@ -46,15 +58,16 @@ namespace Volo.Abp.AspNetCore.Mvc.Conventions public Action ApiVersionConfigurer { get; set; } - public ConventionalControllerSetting([NotNull] Assembly assembly, [NotNull] string rootPath) + public ConventionalControllerSetting( + [NotNull] Assembly assembly, + [NotNull] string rootPath, + [NotNull] string remoteServiceName) { - Check.NotNull(assembly, rootPath); - - Assembly = assembly; - RootPath = rootPath; + Assembly = Check.NotNull(assembly, nameof(assembly)); + RootPath = Check.NotNull(rootPath, nameof(rootPath)); + RemoteServiceName = Check.NotNull(remoteServiceName, nameof(remoteServiceName)); ControllerTypes = new HashSet(); - ApiVersions = new List(); } diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/RemoteServiceAttribute.cs b/framework/src/Volo.Abp.Core/Volo/Abp/RemoteServiceAttribute.cs index e866022437..84e46e2709 100644 --- a/framework/src/Volo.Abp.Core/Volo/Abp/RemoteServiceAttribute.cs +++ b/framework/src/Volo.Abp.Core/Volo/Abp/RemoteServiceAttribute.cs @@ -17,6 +17,13 @@ namespace Volo.Abp /// public bool IsMetadataEnabled { get; set; } + /// + /// Group name of the remote service. + /// Group names of all services of a module expected to be the same. + /// This name is also used to distinguish the service endpoint of this group. + /// + public string Name { get; set; } + public RemoteServiceAttribute(bool isEnabled = true) { IsEnabled = isEnabled; diff --git a/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ApplicationApiDescriptionModel.cs b/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ApplicationApiDescriptionModel.cs index fad94b3745..cc09b7a153 100644 --- a/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ApplicationApiDescriptionModel.cs +++ b/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ApplicationApiDescriptionModel.cs @@ -36,9 +36,9 @@ namespace Volo.Abp.Http.Modeling return Modules[module.RootPath] = module; } - public ModuleApiDescriptionModel GetOrAddModule(string rootPath) + public ModuleApiDescriptionModel GetOrAddModule(string rootPath, string remoteServiceName) { - return Modules.GetOrAdd(rootPath, () => ModuleApiDescriptionModel.Create(rootPath)); + return Modules.GetOrAdd(rootPath, () => ModuleApiDescriptionModel.Create(rootPath, remoteServiceName)); } public ApplicationApiDescriptionModel CreateSubModel(string[] modules = null, string[] controllers = null, string[] actions = null) diff --git a/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ModuleApiDescriptionModel.cs b/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ModuleApiDescriptionModel.cs index 44967fa50c..b879b90135 100644 --- a/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ModuleApiDescriptionModel.cs +++ b/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ModuleApiDescriptionModel.cs @@ -11,10 +11,17 @@ namespace Volo.Abp.Http.Modeling /// /// "app". /// - public const string DefaultRootPath = "app"; + public const string DefaultRootPath = "app"; + /// + /// "Default". + /// + public const string DefaultRemoteServiceName = "Default"; + public string RootPath { get; set; } + public string RemoteServiceName { get; set; } + public IDictionary Controllers { get; set; } private ModuleApiDescriptionModel() @@ -22,11 +29,12 @@ namespace Volo.Abp.Http.Modeling } - public static ModuleApiDescriptionModel Create(string rootPath) + public static ModuleApiDescriptionModel Create(string rootPath, string remoteServiceName) { return new ModuleApiDescriptionModel { RootPath = rootPath, + RemoteServiceName = remoteServiceName, Controllers = new Dictionary() }; } @@ -48,7 +56,7 @@ namespace Volo.Abp.Http.Modeling public ModuleApiDescriptionModel CreateSubModel(string[] controllers, string[] actions) { - var subModel = Create(RootPath); + var subModel = Create(RootPath, RemoteServiceName); foreach (var controller in Controllers.Values) { From 5d22dc773206bc8c0ec25ab7e6addfb89969cdc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 20 Mar 2020 15:36:26 +0300 Subject: [PATCH 13/21] #3265 Set remote service name for the identity module --- .../Volo/Abp/Identity/IdentityRemoteServiceConsts.cs | 7 +++++++ .../Volo/Abp/Identity/AbpIdentityHttpApiClientModule.cs | 4 +--- .../Volo/Abp/Identity/IdentityRoleController.cs | 3 +-- .../Volo/Abp/Identity/IdentityUserController.cs | 2 +- .../Volo/Abp/Identity/IdentityUserLookupController.cs | 2 +- .../Volo/Abp/Identity/ProfileController.cs | 2 +- 6 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityRemoteServiceConsts.cs diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityRemoteServiceConsts.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityRemoteServiceConsts.cs new file mode 100644 index 0000000000..2e151f54b7 --- /dev/null +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityRemoteServiceConsts.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.Identity +{ + public static class IdentityRemoteServiceConsts + { + public const string RemoteServiceName = "AbpIdentity"; + } +} diff --git a/modules/identity/src/Volo.Abp.Identity.HttpApi.Client/Volo/Abp/Identity/AbpIdentityHttpApiClientModule.cs b/modules/identity/src/Volo.Abp.Identity.HttpApi.Client/Volo/Abp/Identity/AbpIdentityHttpApiClientModule.cs index ed830a1212..d4283e06f5 100644 --- a/modules/identity/src/Volo.Abp.Identity.HttpApi.Client/Volo/Abp/Identity/AbpIdentityHttpApiClientModule.cs +++ b/modules/identity/src/Volo.Abp.Identity.HttpApi.Client/Volo/Abp/Identity/AbpIdentityHttpApiClientModule.cs @@ -9,13 +9,11 @@ namespace Volo.Abp.Identity typeof(AbpHttpClientModule))] public class AbpIdentityHttpApiClientModule : AbpModule { - public const string RemoteServiceName = "AbpIdentity"; - public override void ConfigureServices(ServiceConfigurationContext context) { context.Services.AddHttpClientProxies( typeof(AbpIdentityApplicationContractsModule).Assembly, - RemoteServiceName + IdentityRemoteServiceConsts.RemoteServiceName ); } } diff --git a/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityRoleController.cs b/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityRoleController.cs index 451e4d49f7..5d563b127e 100644 --- a/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityRoleController.cs +++ b/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityRoleController.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Volo.Abp.Application.Dtos; @@ -7,7 +6,7 @@ using Volo.Abp.AspNetCore.Mvc; namespace Volo.Abp.Identity { - [RemoteService] + [RemoteService(Name = IdentityRemoteServiceConsts.RemoteServiceName)] [Area("identity")] [ControllerName("Role")] [Route("api/identity/roles")] diff --git a/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityUserController.cs b/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityUserController.cs index 43bdf844d7..b9b02a7150 100644 --- a/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityUserController.cs +++ b/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityUserController.cs @@ -6,7 +6,7 @@ using Volo.Abp.AspNetCore.Mvc; namespace Volo.Abp.Identity { - [RemoteService] + [RemoteService(Name = IdentityRemoteServiceConsts.RemoteServiceName)] [Area("identity")] [ControllerName("User")] [Route("api/identity/users")] diff --git a/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityUserLookupController.cs b/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityUserLookupController.cs index 6bd3bec020..2f8011bf7f 100644 --- a/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityUserLookupController.cs +++ b/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityUserLookupController.cs @@ -6,7 +6,7 @@ using Volo.Abp.Users; namespace Volo.Abp.Identity { - [RemoteService] + [RemoteService(Name = IdentityRemoteServiceConsts.RemoteServiceName)] [Area("identity")] [ControllerName("UserLookup")] [Route("api/identity/users/lookup")] diff --git a/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/ProfileController.cs b/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/ProfileController.cs index d6ed67a7b8..91b1bc8325 100644 --- a/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/ProfileController.cs +++ b/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/ProfileController.cs @@ -4,7 +4,7 @@ using Volo.Abp.AspNetCore.Mvc; namespace Volo.Abp.Identity { - [RemoteService] + [RemoteService(Name = IdentityRemoteServiceConsts.RemoteServiceName)] [Area("identity")] [ControllerName("Profile")] [Route("/api/identity/my-profile")] From 30ece769f0591110d03cc786b76eb8651d0e2ec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20=C3=87otur?= Date: Fri, 20 Mar 2020 16:15:33 +0300 Subject: [PATCH 14/21] remote service name implemented --- .../Volo/Abp/Account/AccountRemoteServiceConsts.cs | 7 +++++++ .../Volo/Abp/Account/AbpAccountHttpApiClientModule.cs | 5 ++--- .../Volo/Abp/Account/AccountController.cs | 2 +- .../Areas/Account/Controllers/AccountController.cs | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/AccountRemoteServiceConsts.cs diff --git a/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/AccountRemoteServiceConsts.cs b/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/AccountRemoteServiceConsts.cs new file mode 100644 index 0000000000..43e5ca15fa --- /dev/null +++ b/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/AccountRemoteServiceConsts.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.Account +{ + public static class AccountRemoteServiceConsts + { + public const string RemoteServiceName = "AbpAccount"; + } +} \ No newline at end of file diff --git a/modules/account/src/Volo.Abp.Account.HttpApi.Client/Volo/Abp/Account/AbpAccountHttpApiClientModule.cs b/modules/account/src/Volo.Abp.Account.HttpApi.Client/Volo/Abp/Account/AbpAccountHttpApiClientModule.cs index 2cfba522cb..a1eb2f9263 100644 --- a/modules/account/src/Volo.Abp.Account.HttpApi.Client/Volo/Abp/Account/AbpAccountHttpApiClientModule.cs +++ b/modules/account/src/Volo.Abp.Account.HttpApi.Client/Volo/Abp/Account/AbpAccountHttpApiClientModule.cs @@ -9,11 +9,10 @@ namespace Volo.Abp.Account typeof(AbpHttpClientModule))] public class AbpAccountHttpApiClientModule : AbpModule { - public const string RemoteServiceName = "Account"; - public override void ConfigureServices(ServiceConfigurationContext context) { - context.Services.AddHttpClientProxies(typeof(AbpAccountApplicationContractsModule).Assembly, RemoteServiceName); + context.Services.AddHttpClientProxies(typeof(AbpAccountApplicationContractsModule).Assembly, + AccountRemoteServiceConsts.RemoteServiceName); } } } \ No newline at end of file diff --git a/modules/account/src/Volo.Abp.Account.HttpApi/Volo/Abp/Account/AccountController.cs b/modules/account/src/Volo.Abp.Account.HttpApi/Volo/Abp/Account/AccountController.cs index e175607842..fa479568aa 100644 --- a/modules/account/src/Volo.Abp.Account.HttpApi/Volo/Abp/Account/AccountController.cs +++ b/modules/account/src/Volo.Abp.Account.HttpApi/Volo/Abp/Account/AccountController.cs @@ -5,7 +5,7 @@ using Volo.Abp.Identity; namespace Volo.Abp.Account { - [RemoteService] + [RemoteService(Name = AccountRemoteServiceConsts.RemoteServiceName)] [Area("account")] [Route("api/account")] public class AccountController : AbpController, IAccountAppService diff --git a/modules/account/src/Volo.Abp.Account.Web/Areas/Account/Controllers/AccountController.cs b/modules/account/src/Volo.Abp.Account.Web/Areas/Account/Controllers/AccountController.cs index 4a1689e8e9..1cfc96091a 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Areas/Account/Controllers/AccountController.cs +++ b/modules/account/src/Volo.Abp.Account.Web/Areas/Account/Controllers/AccountController.cs @@ -15,7 +15,7 @@ using IdentityUser = Volo.Abp.Identity.IdentityUser; namespace Volo.Abp.Account.Web.Areas.Account.Controllers { - [RemoteService] + [RemoteService(Name = AccountRemoteServiceConsts.RemoteServiceName)] [Controller] [ControllerName("Login")] [Area("Account")] From 6b15fbe1de064dcb055c995f85ef8a47b03db314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20=C3=87otur?= Date: Fri, 20 Mar 2020 16:23:22 +0300 Subject: [PATCH 15/21] blogging module updated --- .../Volo/Blogging/BloggingRemoteServiceConsts.cs | 7 +++++++ .../Volo/Blogging/BloggingHttpApiClientModule.cs | 5 ++--- .../Volo/Blogging/BlogFilesController.cs | 2 +- .../Volo.Blogging.HttpApi/Volo/Blogging/BlogsController.cs | 2 +- .../Volo/Blogging/CommentsController.cs | 2 +- .../Volo.Blogging.HttpApi/Volo/Blogging/PostsController.cs | 2 +- .../Volo.Blogging.HttpApi/Volo/Blogging/TagsController.cs | 2 +- 7 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/BloggingRemoteServiceConsts.cs diff --git a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/BloggingRemoteServiceConsts.cs b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/BloggingRemoteServiceConsts.cs new file mode 100644 index 0000000000..e11f75adfb --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/BloggingRemoteServiceConsts.cs @@ -0,0 +1,7 @@ +namespace Volo.Blogging +{ + public static class BloggingRemoteServiceConsts + { + public const string RemoteServiceName = "Blogging"; + } +} diff --git a/modules/blogging/src/Volo.Blogging.HttpApi.Client/Volo/Blogging/BloggingHttpApiClientModule.cs b/modules/blogging/src/Volo.Blogging.HttpApi.Client/Volo/Blogging/BloggingHttpApiClientModule.cs index 7e1418cbb0..0b33ff3367 100644 --- a/modules/blogging/src/Volo.Blogging.HttpApi.Client/Volo/Blogging/BloggingHttpApiClientModule.cs +++ b/modules/blogging/src/Volo.Blogging.HttpApi.Client/Volo/Blogging/BloggingHttpApiClientModule.cs @@ -9,11 +9,10 @@ namespace Volo.Blogging typeof(AbpHttpClientModule))] public class BloggingHttpApiClientModule : AbpModule { - public const string RemoteServiceName = "Blogging"; - public override void ConfigureServices(ServiceConfigurationContext context) { - context.Services.AddHttpClientProxies(typeof(BloggingApplicationContractsModule).Assembly, RemoteServiceName); + context.Services.AddHttpClientProxies(typeof(BloggingApplicationContractsModule).Assembly, + BloggingRemoteServiceConsts.RemoteServiceName); } } diff --git a/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/BlogFilesController.cs b/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/BlogFilesController.cs index 818435a78c..f71a0af6c2 100644 --- a/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/BlogFilesController.cs +++ b/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/BlogFilesController.cs @@ -10,7 +10,7 @@ using Volo.Blogging.Files; namespace Volo.Blogging { - [RemoteService] + [RemoteService(Name = BloggingRemoteServiceConsts.RemoteServiceName)] [Area("blogging")] [Route("api/blogging/files")] public class BlogFilesController : AbpController, IFileAppService diff --git a/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/BlogsController.cs b/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/BlogsController.cs index 084afb958a..cb67ac3fb7 100644 --- a/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/BlogsController.cs +++ b/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/BlogsController.cs @@ -9,7 +9,7 @@ using Volo.Blogging.Blogs.Dtos; namespace Volo.Blogging { - [RemoteService] + [RemoteService(Name = BloggingRemoteServiceConsts.RemoteServiceName)] [Area("blogging")] [Route("api/blogging/blogs")] public class BlogsController : AbpController, IBlogAppService diff --git a/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/CommentsController.cs b/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/CommentsController.cs index 270d8f1e13..caea1cfa2f 100644 --- a/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/CommentsController.cs +++ b/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/CommentsController.cs @@ -9,7 +9,7 @@ using Volo.Blogging.Comments.Dtos; namespace Volo.Blogging { - [RemoteService] + [RemoteService(Name = BloggingRemoteServiceConsts.RemoteServiceName)] [Area("blogging")] [Route("api/blogging/comments")] public class CommentsController : AbpController, ICommentAppService diff --git a/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/PostsController.cs b/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/PostsController.cs index 332f60c256..f7a1c01703 100644 --- a/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/PostsController.cs +++ b/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/PostsController.cs @@ -8,7 +8,7 @@ using Volo.Blogging.Posts; namespace Volo.Blogging { - [RemoteService] + [RemoteService(Name = BloggingRemoteServiceConsts.RemoteServiceName)] [Area("blogging")] [Route("api/blogging/posts")] public class PostsController : AbpController, IPostAppService diff --git a/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/TagsController.cs b/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/TagsController.cs index ede42dd264..6f17623a5e 100644 --- a/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/TagsController.cs +++ b/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/TagsController.cs @@ -9,7 +9,7 @@ using Volo.Blogging.Tagging.Dtos; namespace Volo.Blogging { - [RemoteService] + [RemoteService(Name = BloggingRemoteServiceConsts.RemoteServiceName)] [Area("blogging")] [Route("api/blogging/tags")] public class TagsController : AbpController, ITagAppService From a2049e19490920ae0e1009f60a4a98e72a3249a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20=C3=87otur?= Date: Fri, 20 Mar 2020 16:32:22 +0300 Subject: [PATCH 16/21] feature management module updated --- .../FeatureManagementRemoteServiceConsts.cs | 7 +++++++ .../AbpFeatureManagementHttpApiClientModule.cs | 4 +--- .../Volo/Abp/FeatureManagement/FeaturesController.cs | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 modules/feature-management/src/Volo.Abp.FeatureManagement.Application.Contracts/Volo/Abp/FeatureManagement/FeatureManagementRemoteServiceConsts.cs diff --git a/modules/feature-management/src/Volo.Abp.FeatureManagement.Application.Contracts/Volo/Abp/FeatureManagement/FeatureManagementRemoteServiceConsts.cs b/modules/feature-management/src/Volo.Abp.FeatureManagement.Application.Contracts/Volo/Abp/FeatureManagement/FeatureManagementRemoteServiceConsts.cs new file mode 100644 index 0000000000..749805da05 --- /dev/null +++ b/modules/feature-management/src/Volo.Abp.FeatureManagement.Application.Contracts/Volo/Abp/FeatureManagement/FeatureManagementRemoteServiceConsts.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.FeatureManagement +{ + public class FeatureManagementRemoteServiceConsts + { + public const string RemoteServiceName = "FeatureManagement"; + } +} \ No newline at end of file diff --git a/modules/feature-management/src/Volo.Abp.FeatureManagement.HttpApi.Client/Volo/Abp/FeatureManagement/AbpFeatureManagementHttpApiClientModule.cs b/modules/feature-management/src/Volo.Abp.FeatureManagement.HttpApi.Client/Volo/Abp/FeatureManagement/AbpFeatureManagementHttpApiClientModule.cs index 002a7c3a9a..1bfd2a752c 100644 --- a/modules/feature-management/src/Volo.Abp.FeatureManagement.HttpApi.Client/Volo/Abp/FeatureManagement/AbpFeatureManagementHttpApiClientModule.cs +++ b/modules/feature-management/src/Volo.Abp.FeatureManagement.HttpApi.Client/Volo/Abp/FeatureManagement/AbpFeatureManagementHttpApiClientModule.cs @@ -9,13 +9,11 @@ namespace Volo.Abp.FeatureManagement typeof(AbpHttpClientModule))] public class AbpFeatureManagementHttpApiClientModule : AbpModule { - public const string RemoteServiceName = "AbpFeatureManagement"; - public override void ConfigureServices(ServiceConfigurationContext context) { context.Services.AddHttpClientProxies( typeof(AbpFeatureManagementApplicationContractsModule).Assembly, - RemoteServiceName + FeatureManagementRemoteServiceConsts.RemoteServiceName ); } } diff --git a/modules/feature-management/src/Volo.Abp.FeatureManagement.HttpApi/Volo/Abp/FeatureManagement/FeaturesController.cs b/modules/feature-management/src/Volo.Abp.FeatureManagement.HttpApi/Volo/Abp/FeatureManagement/FeaturesController.cs index a56ff24275..e3eda46033 100644 --- a/modules/feature-management/src/Volo.Abp.FeatureManagement.HttpApi/Volo/Abp/FeatureManagement/FeaturesController.cs +++ b/modules/feature-management/src/Volo.Abp.FeatureManagement.HttpApi/Volo/Abp/FeatureManagement/FeaturesController.cs @@ -4,7 +4,7 @@ using Volo.Abp.AspNetCore.Mvc; namespace Volo.Abp.FeatureManagement { - [RemoteService] + [RemoteService(Name = FeatureManagementRemoteServiceConsts.RemoteServiceName)] [Area("abp")] public class FeaturesController : AbpController, IFeatureAppService { From 4844ca8b53252e64e158804e43ffd33b1b5eaac5 Mon Sep 17 00:00:00 2001 From: Mehmet Erim <34455572+mehmet-erim@users.noreply.github.com> Date: Fri, 20 Mar 2020 16:44:00 +0300 Subject: [PATCH 17/21] Update rest.service.ts --- npm/ng-packs/packages/core/src/lib/services/rest.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npm/ng-packs/packages/core/src/lib/services/rest.service.ts b/npm/ng-packs/packages/core/src/lib/services/rest.service.ts index eaebecf994..936bc2a768 100644 --- a/npm/ng-packs/packages/core/src/lib/services/rest.service.ts +++ b/npm/ng-packs/packages/core/src/lib/services/rest.service.ts @@ -6,7 +6,7 @@ import { catchError } from 'rxjs/operators'; import { RestOccurError } from '../actions/rest.actions'; import { Rest } from '../models/rest'; import { ConfigState } from '../states/config.state'; -import { isUndefinedOrEmptyString } from '../utils'; +import { isUndefinedOrEmptyString } from '../utils/common-utils'; @Injectable({ providedIn: 'root', From 2c63877a889836895c4caf89575a34b0d9fa1f1d Mon Sep 17 00:00:00 2001 From: Arkat Erol Date: Fri, 20 Mar 2020 16:50:38 +0300 Subject: [PATCH 18/21] apiName added for generate proxy --- .../Volo/Abp/Cli/Commands/GenerateProxyCommand.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs index 17fe2d3781..12fc5af525 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs @@ -67,7 +67,8 @@ namespace Volo.Abp.Cli.Commands var data = JObject.Parse(json); Logger.LogInformation("Modules are combining"); - var moduleList = GetCombinedModules(data, module); + var apiNameList = new Dictionary(); + var moduleList = GetCombinedModules(data, module, out apiNameList); if (moduleList.Count < 1) { @@ -85,6 +86,7 @@ namespace Volo.Abp.Cli.Commands var moduleValue = JObject.Parse(moduleItem.Value); var rootPath = moduleItem.Key; + var apiName = apiNameList.Where(p => p.Key == rootPath).Select(p => p.Value).FirstOrDefault(); Logger.LogInformation($"{rootPath} directory is creating"); @@ -105,6 +107,8 @@ namespace Volo.Abp.Cli.Commands serviceFileText.AppendLine(""); serviceFileText.AppendLine("@Injectable({providedIn: 'root'})"); serviceFileText.AppendLine("export class [controllerName]Service {"); + serviceFileText.AppendLine(" apiName = '"+ apiName + "';"); + serviceFileText.AppendLine(""); serviceFileText.AppendLine(" constructor(private restService: RestService) {}"); serviceFileText.AppendLine(""); @@ -309,8 +313,8 @@ namespace Volo.Abp.Cli.Commands serviceFileText.AppendLine( url.Contains("${") - ? $" return this.restService.request({{ url: `/{url}`, method: '{httpMethod}'{bodyExtra}{modelBindingExtra} }});" - : $" return this.restService.request({{ url: '/{url}', method: '{httpMethod}'{bodyExtra}{modelBindingExtra} }});"); + ? $" return this.restService.request({{ url: `/{url}`, method: '{httpMethod}'{bodyExtra}{modelBindingExtra} }},{{ apiName: this.apiName }});" + : $" return this.restService.request({{ url: '/{url}', method: '{httpMethod}'{bodyExtra}{modelBindingExtra} }},{{ apiName: this.apiName }});"); serviceFileText.AppendLine(" }"); @@ -369,13 +373,15 @@ namespace Volo.Abp.Cli.Commands Logger.LogInformation("Completed!"); } - private Dictionary GetCombinedModules(JToken data, string module) + private Dictionary GetCombinedModules(JToken data, string module, out Dictionary apiNameList) { var moduleList = new Dictionary(); + apiNameList = new Dictionary(); foreach (var moduleItem in data["modules"]) { var rootPath = ((string)moduleItem.First["rootPath"]).ToLower(); + var apiName = (string)moduleItem.First["remoteServiceName"]; if (moduleList.Any(p => p.Key == rootPath)) { @@ -385,6 +391,7 @@ namespace Volo.Abp.Cli.Commands } else { + apiNameList.Add(rootPath, apiName); moduleList.Add(rootPath, moduleItem.First["controllers"].ToString()); } } From 8277fd06fff75e278cd0a01e32e2bfae16a3f8cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20=C3=87otur?= Date: Fri, 20 Mar 2020 16:56:40 +0300 Subject: [PATCH 19/21] permission management module updated --- .../PermissionManagementRemoteServiceConsts.cs | 7 +++++++ .../AbpPermissionManagementHttpApiClientModule.cs | 4 +--- .../Volo/Abp/PermissionManagement/PermissionsController.cs | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 modules/permission-management/src/Volo.Abp.PermissionManagement.Application.Contracts/Volo/Abp/PermissionManagement/PermissionManagementRemoteServiceConsts.cs diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Application.Contracts/Volo/Abp/PermissionManagement/PermissionManagementRemoteServiceConsts.cs b/modules/permission-management/src/Volo.Abp.PermissionManagement.Application.Contracts/Volo/Abp/PermissionManagement/PermissionManagementRemoteServiceConsts.cs new file mode 100644 index 0000000000..4a9644b061 --- /dev/null +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Application.Contracts/Volo/Abp/PermissionManagement/PermissionManagementRemoteServiceConsts.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.PermissionManagement +{ + public class PermissionManagementRemoteServiceConsts + { + public const string RemoteServiceName = "AbpPermissionManagement"; + } +} \ No newline at end of file diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.HttpApi.Client/Volo/Abp/PermissionManagement/AbpPermissionManagementHttpApiClientModule.cs b/modules/permission-management/src/Volo.Abp.PermissionManagement.HttpApi.Client/Volo/Abp/PermissionManagement/AbpPermissionManagementHttpApiClientModule.cs index 6bdc958780..35932bba56 100644 --- a/modules/permission-management/src/Volo.Abp.PermissionManagement.HttpApi.Client/Volo/Abp/PermissionManagement/AbpPermissionManagementHttpApiClientModule.cs +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.HttpApi.Client/Volo/Abp/PermissionManagement/AbpPermissionManagementHttpApiClientModule.cs @@ -9,13 +9,11 @@ namespace Volo.Abp.PermissionManagement typeof(AbpHttpClientModule))] public class AbpPermissionManagementHttpApiClientModule : AbpModule { - public const string RemoteServiceName = "AbpPermissionManagement"; - public override void ConfigureServices(ServiceConfigurationContext context) { context.Services.AddHttpClientProxies( typeof(AbpPermissionManagementApplicationContractsModule).Assembly, - RemoteServiceName + PermissionManagementRemoteServiceConsts.RemoteServiceName ); } } diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.HttpApi/Volo/Abp/PermissionManagement/PermissionsController.cs b/modules/permission-management/src/Volo.Abp.PermissionManagement.HttpApi/Volo/Abp/PermissionManagement/PermissionsController.cs index 2dacd79d1f..2ed9a4d044 100644 --- a/modules/permission-management/src/Volo.Abp.PermissionManagement.HttpApi/Volo/Abp/PermissionManagement/PermissionsController.cs +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.HttpApi/Volo/Abp/PermissionManagement/PermissionsController.cs @@ -4,7 +4,7 @@ using Volo.Abp.AspNetCore.Mvc; namespace Volo.Abp.PermissionManagement { - [RemoteService] + [RemoteService(Name = PermissionManagementRemoteServiceConsts.RemoteServiceName)] [Area("abp")] public class PermissionsController : AbpController, IPermissionAppService { From c1429f1f09727d211a358ac8d6860f78240d33e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20=C3=87otur?= Date: Fri, 20 Mar 2020 17:01:41 +0300 Subject: [PATCH 20/21] tenant management module updated --- .../TenantManagementRemoteServiceConsts.cs | 7 +++++++ .../AbpTenantManagementHttpApiClientModule.cs | 4 +--- .../Volo/Abp/TenantManagement/TenantController.cs | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 modules/tenant-management/src/Volo.Abp.TenantManagement.Application.Contracts/Volo/Abp/TenantManagement/TenantManagementRemoteServiceConsts.cs diff --git a/modules/tenant-management/src/Volo.Abp.TenantManagement.Application.Contracts/Volo/Abp/TenantManagement/TenantManagementRemoteServiceConsts.cs b/modules/tenant-management/src/Volo.Abp.TenantManagement.Application.Contracts/Volo/Abp/TenantManagement/TenantManagementRemoteServiceConsts.cs new file mode 100644 index 0000000000..c820c1bd49 --- /dev/null +++ b/modules/tenant-management/src/Volo.Abp.TenantManagement.Application.Contracts/Volo/Abp/TenantManagement/TenantManagementRemoteServiceConsts.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.TenantManagement +{ + public class TenantManagementRemoteServiceConsts + { + public const string RemoteServiceName = "AbpTenantManagement"; + } +} \ No newline at end of file diff --git a/modules/tenant-management/src/Volo.Abp.TenantManagement.HttpApi.Client/Volo/Abp/TenantManagement/AbpTenantManagementHttpApiClientModule.cs b/modules/tenant-management/src/Volo.Abp.TenantManagement.HttpApi.Client/Volo/Abp/TenantManagement/AbpTenantManagementHttpApiClientModule.cs index 1cbdb36a10..7be0b53a72 100644 --- a/modules/tenant-management/src/Volo.Abp.TenantManagement.HttpApi.Client/Volo/Abp/TenantManagement/AbpTenantManagementHttpApiClientModule.cs +++ b/modules/tenant-management/src/Volo.Abp.TenantManagement.HttpApi.Client/Volo/Abp/TenantManagement/AbpTenantManagementHttpApiClientModule.cs @@ -9,13 +9,11 @@ namespace Volo.Abp.TenantManagement typeof(AbpHttpClientModule))] public class AbpTenantManagementHttpApiClientModule : AbpModule { - public const string RemoteServiceName = "AbpTenantManagement"; - public override void ConfigureServices(ServiceConfigurationContext context) { context.Services.AddHttpClientProxies( typeof(AbpTenantManagementApplicationContractsModule).Assembly, - RemoteServiceName + TenantManagementRemoteServiceConsts.RemoteServiceName ); } } diff --git a/modules/tenant-management/src/Volo.Abp.TenantManagement.HttpApi/Volo/Abp/TenantManagement/TenantController.cs b/modules/tenant-management/src/Volo.Abp.TenantManagement.HttpApi/Volo/Abp/TenantManagement/TenantController.cs index 5b821fbc71..317e7e62d0 100644 --- a/modules/tenant-management/src/Volo.Abp.TenantManagement.HttpApi/Volo/Abp/TenantManagement/TenantController.cs +++ b/modules/tenant-management/src/Volo.Abp.TenantManagement.HttpApi/Volo/Abp/TenantManagement/TenantController.cs @@ -7,7 +7,7 @@ using Volo.Abp.AspNetCore.Mvc; namespace Volo.Abp.TenantManagement { [Controller] - [RemoteService] + [RemoteService(Name = TenantManagementRemoteServiceConsts.RemoteServiceName)] [Area("multi-tenancy")] [Route("api/multi-tenancy/tenants")] public class TenantController : AbpController, ITenantAppService //TODO: Throws exception on validation if we inherit from Controller From 5d191c3e6fb2276f5a9bb33ed7d9a95d080f8f06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ak=C4=B1n=20Sabri=20=C3=87am?= Date: Fri, 20 Mar 2020 17:39:44 +0300 Subject: [PATCH 21/21] added localization keys for abpio admin and commercial --- .../AbpIoLocalization/Admin/Localization/Resources/en.json | 1 + .../AbpIoLocalization/Commercial/Localization/Resources/en.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/en.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/en.json index 5ebdf0b2eb..cb79af1665 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/en.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/en.json @@ -81,6 +81,7 @@ "LastSeenDate": "Last seen date", "{0}Computer{1}WillBeRemovedFromRecords": "Computer of {0} ({1}) will be removed from records", "OrganizationDeletionWarningMessage": "Organization will be deleted", + "DeletingLastOwnerWarningMessage": "An organization must have at least one owner! Therefore you cannot remove this owner", "This{0}AlreadyExistInThisOrganization": "This {0} already exist in this organization", "AreYouSureYouWantToDeleteAllComputers": "Are you sure you want to delete all computers?", "DeleteAll": "Delete all", diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json index 3df70437b4..2a57c6b25d 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json @@ -29,7 +29,7 @@ "ApiKey": "API key", "UserNameNotFound": "There is no user with username {0}", "SuccessfullyAddedToNewsletter": "Thanks you for subscribing to our newsletter!", - "ManageProfile": "Manage your profile", + "MyProfile": "My profile", "EmailNotValid": "Please enter a valid email address." } } \ No newline at end of file