Browse Source

Merge branch 'dev' into Docs-module-improvments-12661

pull/13566/head
malik masis 4 years ago
parent
commit
de5198ae61
  1. 2
      abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/zh-Hans.json
  2. 2
      docs/en/UI/Angular/Config-State-Service.md
  3. 5
      framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/AbpAspNetCoreMvcClientModule.cs
  4. 15
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs
  5. 30
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/ChangeThemeStep.cs
  6. 35
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs
  7. 11
      framework/src/Volo.Abp.Json/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToEnumConverter.cs
  8. 18
      framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpStringToEnum_Tests.cs
  9. 10
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Index.cshtml
  10. 12
      npm/ng-packs/packages/schematics/src/commands/api/files-service/proxy/__namespace@dir__/__name@kebab__.service.ts.template
  11. 1
      npm/ng-packs/packages/schematics/src/constants/volo.ts
  12. 8
      npm/ng-packs/packages/schematics/src/models/method.ts
  13. 12
      npm/ng-packs/packages/schematics/src/utils/service.ts

2
abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/zh-Hans.json

@ -565,7 +565,7 @@
"PrePayment_IyzicoRedirectionInfo": "您将被重定向到 Iyzico 支付网关以安全地完成您的购买。",
"PrePayment_IyzicoAcceptVisaAndMasterCard": "Iyzico 接受 Visa 和 MasterCard。",
"Purchase": "购买",
"AcceptTermsAndConditions": "我已阅读、理解并接受<a href=\"{0}\" target=\"_blank\" class=\"text-primary\" rel=\"noopener\">隐私政策</a>, <a href=\"{1}\" target=\"_blank\" class=\"text-primary\" rel=\"noopener\">条款和条件</a>和<a href=\"{ 2}\" target=\"_blank\" class=\"text-primary\"> EULA。</a>",
"AcceptTermsAndConditions": "我已阅读、理解并接受<a href=\"{0}\" target=\"_blank\" class=\"text-primary\" rel=\"noopener\">隐私政策</a>, <a href=\"{1}\" target=\"_blank\" class=\"text-primary\" rel=\"noopener\">条款和条件</a>和<a href=\"{2}\" target=\"_blank\" class=\"text-primary\"> EULA。</a>",
"AcceptTermsAndConditionsWarningMessage": "请接受隐私政策和条款和条件",
"SelectGatewayToContinue": "请选择一个网关以继续!",
"GatewaySelection_SelectGateway": "选择支付网关",

2
docs/en/UI/Angular/Config-State-Service.md

@ -120,7 +120,7 @@ Please refer to `ApplicationConfigurationDto` type for all the properties you ca
You can get the application configuration response and set the `ConfigStateService` state value as shown below:
```js
import {ApplicationConfigurationService, ConfigStateService} from '@abp/ng.core';
import {AbpApplicationConfigurationService, ConfigStateService} from '@abp/ng.core';
constructor(private abpApplicationConfigurationService: AbpApplicationConfigurationService, private config: ConfigStateService) {
this.abpApplicationConfigurationService.get().subscribe(config => {

5
framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/AbpAspNetCoreMvcClientModule.cs

@ -1,6 +1,5 @@
using System.Threading.Tasks;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.DependencyInjection;
using Volo.Abp.EventBus;
using Volo.Abp.Modularity;
using Volo.Abp.Threading;
@ -20,6 +19,6 @@ public class AbpAspNetCoreMvcClientModule : AbpModule
public async override Task OnApplicationInitializationAsync(ApplicationInitializationContext context)
{
await context.ServiceProvider.GetRequiredService<IClientScopeServiceProviderAccessor>().ServiceProvider.GetRequiredService<MvcCachedApplicationConfigurationClient>().InitializeAsync();
await context.ServiceProvider.GetRequiredService<MvcCachedApplicationConfigurationClient>().InitializeAsync();
}
}

15
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs

@ -103,18 +103,6 @@ public abstract class ProjectCreationCommandBase
Logger.LogInformation("UI Framework: " + uiFramework);
}
var theme = uiFramework == UiFramework.None ? (Theme?)null : GetThemeByTemplateOrNull(commandLineArgs, template);
if (theme.HasValue)
{
Logger.LogInformation("Theme: " + theme);
}
var themeStyle = theme.HasValue ? GetThemeStyleOrNull(commandLineArgs, theme.Value) : (ThemeStyle?)null;
if(themeStyle.HasValue)
{
Logger.LogInformation("Theme Style: " + themeStyle);
}
var publicWebSite = uiFramework != UiFramework.None && commandLineArgs.Options.ContainsKey(Options.PublicWebSite.Long);
if (publicWebSite)
{
@ -210,6 +198,9 @@ public abstract class ProjectCreationCommandBase
}
commandLineArgs.Options.Add(CliConsts.Command, commandLineArgs.Command);
var theme = uiFramework == UiFramework.None ? (Theme?)null : GetThemeByTemplateOrNull(commandLineArgs, template);
var themeStyle = theme.HasValue ? GetThemeStyleOrNull(commandLineArgs, theme.Value) : (ThemeStyle?)null;
return new ProjectBuildArgs(
solutionName,

30
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/ChangeThemeStep.cs

@ -141,6 +141,13 @@ public class ChangeThemeStep : ProjectBuildPipelineStep
"AbpAspNetCoreComponentsWebAssemblyLeptonThemeModule"
);
ChangeNamespace(
context,
"/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorModule.cs",
"Volo.Abp.AspNetCore.Components.WebAssembly.LeptonXTheme",
"Volo.Abp.AspNetCore.Components.WebAssembly.LeptonTheme"
);
#endregion
#region MyCompanyName.MyProjectName.Blazor.Server && MyCompanyName.MyProjectName.Blazor.Server.Tiered
@ -210,7 +217,7 @@ public class ChangeThemeStep : ProjectBuildPipelineStep
}
AddProjectReference(file, $@"..\..\..\..\lepton-theme\src\Volo.Abp.LeptonTheme.Management.{projectName}\Volo.Abp.LeptonTheme.Management.{projectName}.csproj");
AddModuleDependency(moduleFile, $"LeptonThemeManagement{ConvertProjectNameToModuleName($"{projectName}")}Module");
AddModuleDependency(moduleFile, projectName, $"LeptonThemeManagement{ConvertProjectNameToModuleName($"{projectName}")}Module");
}
}
@ -325,21 +332,22 @@ public class ChangeThemeStep : ProjectBuildPipelineStep
AddProjectReference(projectFile, reference);
AddModuleDependency(moduleFile, $"LeptonThemeManagement{ConvertProjectNameToModuleName(projectInfo.Key)}Module",
AddModuleDependency(moduleFile, projectInfo.Key, $"LeptonThemeManagement{ConvertProjectNameToModuleName(projectInfo.Key)}Module",
underManagementFolder: projectInfo.Key != "HttpApi");
}
private void AddModuleDependency(FileEntry moduleFile, string dependency, bool underManagementFolder = true)
private void AddModuleDependency(FileEntry moduleFile, string projectName, string dependency, bool underManagementFolder = true)
{
var lines = moduleFile.GetLines();
var projectNames = new[] { "Blazor", "Blazor.Server", "Blazor.WebAssembly" };
var lines = moduleFile.GetLines();
for (var i = 0; i < lines.Length; i++)
{
if (lines[i].Contains("namespace MyCompanyName.MyProjectName"))
{
lines[i - 1] = lines[i - 1] + "using Volo.Abp.LeptonTheme" + (underManagementFolder ? ".Management" : "").EnsureEndsWith(';') + Environment.NewLine;
lines[i - 1] = lines[i - 1] + ("using Volo.Abp.LeptonTheme" + (underManagementFolder ? ".Management." : ".") + (projectNames.Any(p => p == projectName) ? projectName : "")).TrimEnd('.').EnsureEndsWith(';') + Environment.NewLine;
}
if (lines[i].Contains("public class MyProjectName") && lines[i-1].Contains(")]"))
{
lines[i - 2] = lines[i - 2] + "," + Environment.NewLine + $"\ttypeof({dependency})";
@ -584,9 +592,7 @@ public class ChangeThemeStep : ProjectBuildPipelineStep
.Replace(".csproj", "Module")
.Replace(".", "");
fileName = ConvertProjectNameToModuleName(fileName);
return context.Files.FirstOrDefault(f => f.Name.Contains(splittedProjectFileName.Last() + "/" + fileName));
return context.Files.FirstOrDefault(f => f.Name.Contains(splittedProjectFileName.Last() + "/" + fileName) && f.Name.EndsWith("Module.cs"));
}
private static string ConvertProjectNameToModuleName(string moduleName)
@ -796,6 +802,12 @@ public class ChangeThemeStep : ProjectBuildPipelineStep
"BlazorLeptonXThemeBundles.Scripts.Global",
"BlazorLeptonThemeBundles.Scripts.Global"
);
RemoveLinesByStatement(
context,
$"/MyCompanyName.MyProjectName.{projectName}/MyProjectNameBlazorModule.cs",
"Volo.Abp.LeptonX.Shared;"
);
}
}

35
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs

@ -71,6 +71,8 @@ public class TemplateProjectBuilder : IProjectBuilder, ITransientDependency
args.ExtraProperties.ContainsKey(NewCommand.Options.Preview.Long)
);
ConfigureThemeOptions(args, templateFile.Version);
DeveloperApiKeyResult apiKeyResult = null;
#if DEBUG
@ -207,4 +209,37 @@ public class TemplateProjectBuilder : IProjectBuilder, ITransientDependency
return TemplateInfoProvider.Get(args.TemplateName);
}
}
private bool IsThemeOptionEnabled(ProjectBuildArgs args, string templateVersion)
{
var version = string.IsNullOrWhiteSpace(args.Version)
? templateVersion
: args.Version;
if (!SemanticVersion.TryParse(version, out var semanticVersion))
{
return false;
}
return semanticVersion >= SemanticVersion.Parse("6.0.0-rc.1");
}
private void ConfigureThemeOptions(ProjectBuildArgs args, string templateVersion)
{
if (!IsThemeOptionEnabled(args, templateVersion))
{
args.Theme = null;
args.ThemeStyle = null;
}
if (args.Theme.HasValue)
{
Logger.LogInformation("Theme: " + args.Theme);
}
if(args.ThemeStyle.HasValue)
{
Logger.LogInformation("Theme Style: " + args.ThemeStyle);
}
}
}

11
framework/src/Volo.Abp.Json/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToEnumConverter.cs

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
@ -48,4 +47,14 @@ public class AbpStringToEnumConverter<T> : JsonConverter<T>
JsonSerializer.Serialize(writer, value, _writeJsonSerializerOptions);
}
public override T ReadAsPropertyName(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
return (T)Enum.Parse(typeToConvert, reader.GetString());
}
public override void WriteAsPropertyName(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
{
writer.WritePropertyName(Enum.GetName(typeof(T), value));
}
}

18
framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpStringToEnum_Tests.cs

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text.Json;
using Shouldly;
using Volo.Abp.Json.SystemTextJson.JsonConverters;
@ -26,6 +27,16 @@ namespace Volo.Abp.Json
testClass = JsonSerializer.Deserialize<TestClass>("{\"Day\": 1}", options);
testClass.ShouldNotBeNull();
testClass.Day.ShouldBe(DayOfWeek.Monday);
var dictionary = JsonSerializer.Deserialize<Dictionary<DayOfWeek, string>>("{\"Monday\":\"Mo\"}", options);
dictionary.ShouldNotBeNull();
dictionary.Keys.ShouldContain(DayOfWeek.Monday);
dictionary.Values.ShouldContain("Mo");
dictionary = JsonSerializer.Deserialize<Dictionary<DayOfWeek, string>>("{\"1\":\"Mo\"}", options);
dictionary.ShouldNotBeNull();
dictionary.Keys.ShouldContain(DayOfWeek.Monday);
dictionary.Values.ShouldContain("Mo");
}
[Fact]
@ -45,6 +56,13 @@ namespace Volo.Abp.Json
});
testClassJson.ShouldBe("{\"Day\":1}");
testClassJson = JsonSerializer.Serialize(new Dictionary<DayOfWeek, string>
{
{DayOfWeek.Monday, "Mo"}
}, options);
testClassJson.ShouldBe("{\"Monday\":\"Mo\"}");
}
class TestClass

10
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Index.cshtml

@ -37,7 +37,7 @@
<abp-card-body>
<div id="CmsKitCommentsWrapper">
<form id="CmsKitCommentsFilterForm" method="post">
<abp-row>
<abp-row class="align-items-end">
<abp-column size-lg="_4" size-md="_12">
<abp-row class="input-daterange">
<abp-column size-lg="_6" size-md="_6">
@ -58,11 +58,9 @@
</abp-column>
<abp-column size-lg="_2" size-md="_6">
<div class="d-grid gap-2">
<abp-button class="mt-md-4" button-type="Primary" type="submit" style="margin-top: 1.75rem !important;">
<i class="fa fa-search" aria-hidden="true"></i>
</abp-button>
</div>
<abp-button class="w-100 mb-3" button-type="Primary" type="submit">
<i class="fa fa-search" aria-hidden="true"></i>
</abp-button>
</abp-column>
</abp-row>
</form>

12
npm/ng-packs/packages/schematics/src/commands/api/files-service/proxy/__namespace@dir__/__name@kebab__.service.ts.template

@ -7,12 +7,18 @@
export class <%= name %>Service {
apiName = '<%= apiName %>';<%
for (let {body, signature} of methods) { %>
<%
const isBlob = body.isBlobMethod() ;
const responseType = isBlob ? "Blob":body.responseType;
%>
<%= camel(signature.name) %> = (<%= serializeParameters(signature.parameters) %>) =>
this.restService.request<<%= body.requestType %>, <%= body.responseType %>>({
method: '<%= body.method %>',<%
this.restService.request<<%= body.requestType %>, <%= responseType %>>({
method: '<%= body.method %>',<%
if (body.responseType === 'string') { %>
responseType: 'text',<% } %>
responseType: 'text',<% } %><%
if (isBlob) { %>
responseType: 'blob',<% } %>
url: <%= body.url %>,<%
if (body.params.length) { %>
params: { <%= body.params.join(', ') %> },<% }

1
npm/ng-packs/packages/schematics/src/constants/volo.ts

@ -1 +1,2 @@
export const VOLO_REGEX = /^Volo\.Abp\.(Application\.Dtos|ObjectExtending)/;
export const VOLO_REMOTE_STREAM_CONTENT = 'Volo.Abp.Content.IRemoteStreamContent'

8
npm/ng-packs/packages/schematics/src/models/method.ts

@ -4,6 +4,7 @@ import { getParamName } from '../utils/methods';
import { ParameterInBody } from './api-definition';
import { Property } from './model';
import { Omissible } from './util';
import {VOLO_REMOTE_STREAM_CONTENT} from "../constants";
// eslint-disable-next-line @typescript-eslint/no-var-requires
const shouldQuote = require('should-quote');
@ -39,6 +40,7 @@ export class Body {
body?: string;
method: string;
params: string[] = [];
responseTypeWithNamespace: string;
requestType = 'any';
responseType: string;
url: string;
@ -77,6 +79,10 @@ export class Body {
this.setUrlQuotes();
}
isBlobMethod(){
return this.responseTypeWithNamespace === VOLO_REMOTE_STREAM_CONTENT
}
private setUrlQuotes() {
this.url = /{/.test(this.url) ? `\`/${this.url}\`` : `'/${this.url}'`;
}
@ -84,5 +90,5 @@ export class Body {
export type BodyOptions = Omissible<
Omit<Body, 'registerActionParameter'>,
'params' | 'requestType'
'params' | 'requestType' | 'isBlobMethod'
>;

12
npm/ng-packs/packages/schematics/src/utils/service.ts

@ -22,6 +22,7 @@ import {
} from './type';
import { eBindingSourceId } from '../enums';
import { camelizeHyphen } from './text';
import {VOLO_REMOTE_STREAM_CONTENT} from "../constants";
export function serializeParameters(parameters: Property[]) {
return parameters.map(p => p.name + p.optional + ': ' + p.type + p.default, '').join(', ');
@ -38,7 +39,8 @@ export function createControllerToServiceMapper({
const name = controller.controllerName;
const namespace = parseNamespace(solution, controller.type);
const actions = Object.values(controller.actions);
const imports = actions.reduce(createActionToImportsReducer(solution, types, namespace), []);
const typeWithoutIRemoteStreamContent = getTypesWithoutIRemoteStreamContent(types)
const imports = actions.reduce(createActionToImportsReducer(solution, typeWithoutIRemoteStreamContent, namespace), []);
imports.push(new Import({ path: '@abp/ng.core', specifiers: ['RestService'] }));
imports.push(new Import({ path: '@angular/core', specifiers: ['Injectable'] }));
sortImports(imports);
@ -48,6 +50,11 @@ export function createControllerToServiceMapper({
};
}
function getTypesWithoutIRemoteStreamContent(types: Record<string, Type>) {
const newType = {...types}
delete newType[VOLO_REMOTE_STREAM_CONTENT]
return newType
}
function sortMethods(methods: Method[]) {
methods.sort((a, b) => (a.signature.name > b.signature.name ? 1 : -1));
}
@ -68,7 +75,8 @@ export function createActionToBodyMapper() {
return ({ httpMethod, parameters, returnValue, url }: Action) => {
const responseType = adaptType(returnValue.typeSimple);
const body = new Body({ method: httpMethod, responseType, url });
const responseTypeWithNamespace = returnValue.typeSimple;
const body = new Body({ method: httpMethod, responseType, url ,responseTypeWithNamespace});
parameters.forEach(body.registerActionParameter);

Loading…
Cancel
Save