Browse Source

Reduce the capacity of hold objects.

pull/786/head
Sebastian 4 years ago
parent
commit
1c9721d3a6
  1. 51
      backend/src/Squidex.Domain.Apps.Core.Model/Contents/GeoJsonValue.cs
  2. 5
      backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetDomainObject.cs
  3. 2
      backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentDomainObject.cs
  4. 4
      backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Extensions.cs
  5. 2
      backend/src/Squidex/Areas/Api/Controllers/Contents/ContentsController.cs
  6. 2
      backend/src/Squidex/Areas/IdentityServer/Controllers/Account/LoginModel.cs
  7. 2
      backend/src/Squidex/Areas/IdentityServer/Controllers/Profile/ChangePasswordModel.cs
  8. 2
      backend/src/Squidex/Areas/IdentityServer/Controllers/Profile/ChangeProfileModel.cs
  9. 2
      backend/src/Squidex/Areas/IdentityServer/Controllers/Profile/RemoveLoginModel.cs
  10. 2
      backend/src/Squidex/Areas/IdentityServer/Controllers/Profile/SetPasswordModel.cs
  11. 2
      backend/src/Squidex/Areas/IdentityServer/Controllers/Profile/UserProperty.cs
  12. 2
      backend/src/Squidex/Areas/IdentityServer/Controllers/Setup/CreateUserModel.cs
  13. 2
      frontend/app/shared/components/schema-category.component.scss

51
backend/src/Squidex.Domain.Apps.Core.Model/Contents/GeoJsonValue.cs

@ -17,47 +17,62 @@ namespace Squidex.Domain.Apps.Core.Contents
{ {
public static class GeoJsonValue public static class GeoJsonValue
{ {
public static GeoJsonParseResult TryParse(IJsonValue value, IJsonSerializer serializer, out GeoJSONObject geoJSON) public static GeoJsonParseResult TryParse(IJsonValue value, IJsonSerializer serializer, out GeoJSONObject? geoJSON)
{ {
Guard.NotNull(serializer, nameof(serializer)); Guard.NotNull(serializer, nameof(serializer));
Guard.NotNull(value, nameof(value)); Guard.NotNull(value, nameof(value));
geoJSON = null!; geoJSON = null!;
if (value is JsonObject geoObject) if (value is JsonObject obj)
{ {
try if (TryParseGeoJson(obj, serializer, out geoJSON))
{
using (var stream = DefaultPools.MemoryStream.GetStream())
{ {
serializer.Serialize(value, stream, true);
stream.Position = 0;
geoJSON = serializer.Deserialize<GeoJSONObject>(stream, null, true);
return GeoJsonParseResult.Success; return GeoJsonParseResult.Success;
} }
}
catch if (!obj.TryGetValue<JsonNumber>("latitude", out var lat) || !lat.Value.IsBetween(-90, 90))
{
if (!geoObject.TryGetValue<JsonNumber>("latitude", out var lat) || !lat.Value.IsBetween(-90, 90))
{ {
return GeoJsonParseResult.InvalidLatitude; return GeoJsonParseResult.InvalidLatitude;
} }
if (!geoObject.TryGetValue<JsonNumber>("longitude", out var lon) || !lon.Value.IsBetween(-180, 180)) if (!obj.TryGetValue<JsonNumber>("longitude", out var lon) || !lon.Value.IsBetween(-180, 180))
{ {
return GeoJsonParseResult.InvalidLongitude; return GeoJsonParseResult.InvalidLongitude;
} }
geoJSON = new Point(new Position(lat.Value, lon.Value)); geoJSON = new Point(new Position(lat.Value, lon.Value));
}
return GeoJsonParseResult.Success; return GeoJsonParseResult.InvalidValue;
} }
private static bool TryParseGeoJson(JsonObject obj, IJsonSerializer serializer, out GeoJSONObject? geoJSON)
{
geoJSON = null;
if (!obj.TryGetValue("type", out var type) || type is not JsonString)
{
return false;
} }
return GeoJsonParseResult.InvalidValue; try
{
using (var stream = DefaultPools.MemoryStream.GetStream())
{
serializer.Serialize(obj, stream, true);
stream.Position = 0;
geoJSON = serializer.Deserialize<GeoJSONObject>(stream, null, true);
return true;
}
}
catch
{
return false;
}
} }
} }
} }

5
backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetDomainObject.cs

@ -24,12 +24,13 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject
{ {
private readonly IServiceProvider serviceProvider; private readonly IServiceProvider serviceProvider;
public AssetDomainObject(IPersistenceFactory<AssetDomainObject.State> factory, ISemanticLog log, public AssetDomainObject(IPersistenceFactory<State> factory, ISemanticLog log,
IServiceProvider serviceProvider) IServiceProvider serviceProvider)
: base(factory, log) : base(factory, log)
{ {
Capacity = int.MaxValue;
this.serviceProvider = serviceProvider; this.serviceProvider = serviceProvider;
Capacity = 2;
} }
protected override bool IsDeleted() protected override bool IsDeleted()

2
backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentDomainObject.cs

@ -35,7 +35,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
{ {
this.serviceProvider = serviceProvider; this.serviceProvider = serviceProvider;
Capacity = int.MaxValue; Capacity = 5;
} }
protected override bool IsDeleted() protected override bool IsDeleted()

4
backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Extensions.cs

@ -27,7 +27,9 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text
{ {
foreach (var (key, jsonValue) in value) foreach (var (key, jsonValue) in value)
{ {
if (GeoJsonValue.TryParse(jsonValue, jsonSerializer, out var geoJson) == GeoJsonParseResult.Success) GeoJsonValue.TryParse(jsonValue, jsonSerializer, out var geoJson);
if (geoJson != null)
{ {
result ??= new Dictionary<string, GeoJSONObject>(); result ??= new Dictionary<string, GeoJSONObject>();
result[$"{field}.{key}"] = geoJson; result[$"{field}.{key}"] = geoJson;

2
backend/src/Squidex/Areas/Api/Controllers/Contents/ContentsController.cs

@ -23,7 +23,7 @@ using Squidex.Web.GraphQL;
namespace Squidex.Areas.Api.Controllers.Contents namespace Squidex.Areas.Api.Controllers.Contents
{ {
[SchemaMustBePublishedAttribute] [SchemaMustBePublished]
public sealed class ContentsController : ApiController public sealed class ContentsController : ApiController
{ {
private readonly IContentQueryService contentQuery; private readonly IContentQueryService contentQuery;

2
backend/src/Squidex/Areas/IdentityServer/Controllers/Account/LoginModel.cs

@ -14,7 +14,7 @@ namespace Squidex.Areas.IdentityServer.Controllers.Account
[LocalizedRequired] [LocalizedRequired]
public string Email { get; set; } public string Email { get; set; }
[LocalizedRequiredAttribute] [LocalizedRequired]
public string Password { get; set; } public string Password { get; set; }
} }
} }

2
backend/src/Squidex/Areas/IdentityServer/Controllers/Profile/ChangePasswordModel.cs

@ -14,7 +14,7 @@ namespace Squidex.Areas.IdentityServer.Controllers.Profile
[LocalizedRequired] [LocalizedRequired]
public string OldPassword { get; set; } public string OldPassword { get; set; }
[LocalizedRequiredAttribute] [LocalizedRequired]
public string Password { get; set; } public string Password { get; set; }
[LocalizedCompare(nameof(Password))] [LocalizedCompare(nameof(Password))]

2
backend/src/Squidex/Areas/IdentityServer/Controllers/Profile/ChangeProfileModel.cs

@ -15,7 +15,7 @@ namespace Squidex.Areas.IdentityServer.Controllers.Profile
[LocalizedRequired] [LocalizedRequired]
public string Email { get; set; } public string Email { get; set; }
[LocalizedRequiredAttribute] [LocalizedRequired]
public string DisplayName { get; set; } public string DisplayName { get; set; }
public bool IsHidden { get; set; } public bool IsHidden { get; set; }

2
backend/src/Squidex/Areas/IdentityServer/Controllers/Profile/RemoveLoginModel.cs

@ -14,7 +14,7 @@ namespace Squidex.Areas.IdentityServer.Controllers.Profile
[LocalizedRequired] [LocalizedRequired]
public string LoginProvider { get; set; } public string LoginProvider { get; set; }
[LocalizedRequiredAttribute] [LocalizedRequired]
public string ProviderKey { get; set; } public string ProviderKey { get; set; }
} }
} }

2
backend/src/Squidex/Areas/IdentityServer/Controllers/Profile/SetPasswordModel.cs

@ -14,7 +14,7 @@ namespace Squidex.Areas.IdentityServer.Controllers.Profile
[LocalizedRequired] [LocalizedRequired]
public string Password { get; set; } public string Password { get; set; }
[LocalizedRequiredAttribute] [LocalizedRequired]
public string PasswordConfirm { get; set; } public string PasswordConfirm { get; set; }
} }
} }

2
backend/src/Squidex/Areas/IdentityServer/Controllers/Profile/UserProperty.cs

@ -14,7 +14,7 @@ namespace Squidex.Areas.IdentityServer.Controllers.Profile
[LocalizedRequired] [LocalizedRequired]
public string Name { get; set; } public string Name { get; set; }
[LocalizedRequiredAttribute] [LocalizedRequired]
public string Value { get; set; } public string Value { get; set; }
public (string Name, string Value) ToTuple() public (string Name, string Value) ToTuple()

2
backend/src/Squidex/Areas/IdentityServer/Controllers/Setup/CreateUserModel.cs

@ -17,7 +17,7 @@ namespace Squidex.Areas.IdentityServer.Controllers.Setup
[LocalizedRequired] [LocalizedRequired]
public string Password { get; set; } public string Password { get; set; }
[LocalizedRequiredAttribute] [LocalizedRequired]
public string PasswordConfirm { get; set; } public string PasswordConfirm { get; set; }
} }
} }

2
frontend/app/shared/components/schema-category.component.scss

@ -77,7 +77,7 @@ $drag-margin: -8px;
:host { :host {
&:first-child { &:first-child {
.nav-light { .nav-light {
margin-top: 1rem; margin-top: 0;
} }
} }
} }

Loading…
Cancel
Save