Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Webreaper committed Jul 11, 2023
2 parents 8c78f92 + 288654f commit 0bbaa05
Show file tree
Hide file tree
Showing 104 changed files with 969 additions and 521 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions .github/workflows/damselfly-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,14 @@ jobs:
uses: actions/download-artifact@v3
with:
name: Desktop-Dist
path: Damselfly.Web.Client/wwwroot/desktop

- name: Download Server Artifacts
if: github.ref == 'refs/heads/master'
uses: actions/download-artifact@v3
with:
name: Server-Dist
path: server

- name: Upload Server Artifacts
if: github.ref == 'refs/heads/master'
Expand Down
2 changes: 2 additions & 0 deletions Damselfly.Core.Constants/ConfigSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class ConfigSettings
public const string FlatView = "FlatView";
public const string FolderSortAscending = "FolderSortAscending";
public const string FolderSortMode = "FolderSortMode";
public const string IncludeChildFolders = "IncludeChildFolders";
public const string TrashcanFolderName = "TrashcanFolderName";

public const string WordpressURL = "WordpressURL";
public const string WordpressUser = "WordpressUser";
Expand Down
16 changes: 8 additions & 8 deletions Damselfly.Core.DbModels/Damselfly.Core.DbModels.csproj
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.0">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="7.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.9">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.0">
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.9">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.0" />
<PackageReference Include="FluentValidation" Version="11.2.2" />
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.9" />
<PackageReference Include="FluentValidation" Version="11.6.0" />
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="7.0.9" />
</ItemGroup>

<ItemGroup>
Expand Down
11 changes: 11 additions & 0 deletions Damselfly.Core.DbModels/Interfaces/IFileService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Threading.Tasks;
using Damselfly.Core.DbModels.Models.APIModels;

namespace Damselfly.Core.ScopedServices.Interfaces;

public interface IFileService
{
public Task<bool> MoveImages( ImageMoveRequest req );
public Task<bool> DeleteImages( MultiImageRequest req );
}

1 change: 1 addition & 0 deletions Damselfly.Core.DbModels/Interfaces/ISearchService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public interface ISearchService
bool TagsOnly { get; set; }
bool IncludeAITags { get; set; }
bool UntaggedImages { get; set; }
bool IncludeChildFolders { get; set; }
FaceSearchType? FaceSearch { get; set; }
GroupingType Grouping { get; set; }
SortOrderType SortOrder { get; set; }
Expand Down
16 changes: 16 additions & 0 deletions Damselfly.Core.DbModels/Models/API Models/ImageMoveRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Collections.Generic;
using Damselfly.Core.Models;

namespace Damselfly.Core.DbModels.Models.APIModels;

public class MultiImageRequest
{
public ICollection<int> ImageIDs { get; set; }
}

public class ImageMoveRequest : MultiImageRequest
{
public Folder Destination { get; set; }
public bool Move { get; set; }
}

5 changes: 4 additions & 1 deletion Damselfly.Core.DbModels/Models/Entities/SearchQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class SearchQuery
public bool TagsOnly { get; set; } = false;
public bool IncludeAITags { get; set; } = true;
public bool UntaggedImages { get; set; } = false;
public bool IncludeChildFolders { get; set; } = true;
public int? MaxSizeKB { get; set; } = null;
public int? MinSizeKB { get; set; } = null;
public int? CameraId { get; set; } = null;
Expand Down Expand Up @@ -42,6 +43,7 @@ public void Reset()
SearchText = string.Empty;
TagsOnly = false;
IncludeAITags = true;
IncludeChildFolders = true;
UntaggedImages = false;
MaxSizeKB = null;
MinSizeKB = null;
Expand All @@ -62,7 +64,7 @@ public void Reset()
public override string ToString()
{
return
$"Filter: T={SearchText}, F={Folder?.FolderId}, Tag={Tag?.TagId}, Max={MaxDate}, Min={MinDate}, Max={MaxSizeKB}KB, Rating={MinRating}, Min={MinSizeKB}KB, Tags={TagsOnly}, Grouping={Grouping}, Sort={SortOrder}, Face={FaceSearch}, Person={Person?.Name}, SimilarTo={SimilarToId}";
$"Filter: T={SearchText}, F={Folder?.FolderId}, ChildFolders={IncludeChildFolders}, Tag={Tag?.TagId}, Max={MaxDate}, Min={MinDate}, Max={MaxSizeKB}KB, Rating={MinRating}, Min={MinSizeKB}KB, Tags={TagsOnly}, Grouping={Grouping}, Sort={SortOrder}, Face={FaceSearch}, Person={Person?.Name}, SimilarTo={SimilarToId}";
}
}

Expand All @@ -76,6 +78,7 @@ public class SearchQueryDTO
public bool TagsOnly { get; set; } = false;
public bool IncludeAITags { get; set; } = true;
public bool UntaggedImages { get; set; } = false;
public bool IncludeChildFolders { get; set; } = true;
public int? MaxSizeKB { get; set; } = null;
public int? MinSizeKB { get; set; } = null;
public int? CameraId { get; set; } = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Damselfly.Core\Damselfly.Core.csproj"/>
<ProjectReference Include="..\Damselfly.Core.Interfaces\Damselfly.Core.Interfaces.csproj"/>
<ProjectReference Include="..\Damselfly.Core.Utils\Damselfly.Core.Utils.csproj"/>
<ProjectReference Include="..\Damselfly.Core\Damselfly.Core.csproj" />
<ProjectReference Include="..\Damselfly.Core.Interfaces\Damselfly.Core.Interfaces.csproj" />
<ProjectReference Include="..\Damselfly.Core.Utils\Damselfly.Core.Utils.csproj" />
</ItemGroup>
<ItemGroup>
<None Remove="SixLabors.ImageSharp"/>
<None Remove="SixLabors.Fonts"/>
<None Remove="SixLabors.ImageSharp" />
<None Remove="SixLabors.Fonts" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.3"/>
<PackageReference Include="SixLabors.Fonts" Version="1.0.0-beta16"/>
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.1" />
<PackageReference Include="SixLabors.Fonts" Version="1.0.0-beta16" />
</ItemGroup>
</Project>
20 changes: 15 additions & 5 deletions Damselfly.Core.ImageProcessing/ImageSharpProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
using Damselfly.Core.Interfaces;
using Damselfly.Core.Utils;
using Damselfly.Shared.Utils;
using Org.BouncyCastle.Utilities.Zlib;
using SixLabors.Fonts;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Drawing.Processing;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
Expand Down Expand Up @@ -62,9 +64,15 @@ public async Task<IImageProcessResult> CreateThumbs(FileInfo source, IDictionary
IImageProcessResult result = new ImageProcessResult();
var load = new Stopwatch("ImageSharpLoad");

var largest = destFiles.Values
.OrderByDescending( x => x.width )
.First();

DecoderOptions options = new() { TargetSize = new( width: largest.width, height: largest.height ) };

// Image.Load(string path) is a shortcut for our default type.
// Other pixel formats use Image.Load<TPixel>(string path))
using var image = await Image.LoadAsync<Rgba32>(source.FullName);
using var image = await Image.LoadAsync<Rgba32>(options, source.FullName);

load.Stop();

Expand Down Expand Up @@ -120,7 +128,7 @@ public async Task GetCroppedFile(FileInfo source, int x, int y, int width, int h

// Image.Load(string path) is a shortcut for our default type.
// Other pixel formats use Image.Load<TPixel>(string path))
using var image = Image.Load<Rgba32>(source.FullName);
using var image = await Image.LoadAsync<Rgba32>(source.FullName);

var rect = new Rectangle(x, y, width, height);
image.Mutate(x => x.AutoOrient());
Expand All @@ -136,7 +144,7 @@ public async Task CropImage(FileInfo source, int x, int y, int width, int height

// Image.Load(string path) is a shortcut for our default type.
// Other pixel formats use Image.Load<TPixel>(string path))
using var image = Image.Load<Rgba32>(source.FullName);
using var image = await Image.LoadAsync<Rgba32>(source.FullName);

var rect = new Rectangle(x, y, width, height);
image.Mutate(x => x.AutoOrient());
Expand All @@ -157,7 +165,9 @@ public async Task TransformDownloadImage(string input, Stream output, IExportSet
{
Logging.Log($" Running image transform for Watermark: {config.WatermarkText}");

using var img = Image.Load(input, out var fmt);
DecoderOptions options = new() { TargetSize = new( width: config.MaxImageSize, height: config.MaxImageSize ) };

using var img = await Image.LoadAsync(options, input);

if ( config.Size != ExportSize.FullRes )
{
Expand Down Expand Up @@ -188,7 +198,7 @@ public async Task TransformDownloadImage(string input, Stream output, IExportSet
img.Mutate(context => ApplyWaterMark(context, font, config.WatermarkText, Color.White));
}

await img.SaveAsync(output, fmt);
await img.SaveAsync( output, img.Metadata.DecodedImageFormat );
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Damselfly.Core.Interfaces/Damselfly.Core.Interfaces.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<None Remove="Interfaces\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.0">
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.9">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion Damselfly.Core.ScopedServices/BaseConfigService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void Set(string name, string value)
SetSetting(name, new ConfigSetting { Name = name, Value = value });
}

public string Get(string name, string defaultIfNotExists = null)
public string Get(string name, string? defaultIfNotExists = null)
{
var existing = GetSetting(name);

Expand Down
20 changes: 18 additions & 2 deletions Damselfly.Core.ScopedServices/BaseSearchService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public bool TagsOnly
}
}
}

public bool IncludeAITags
{
get => Query.IncludeAITags;
Expand All @@ -138,6 +138,19 @@ public bool IncludeAITags
}
}

public bool IncludeChildFolders
{
get => Query.IncludeChildFolders;
set
{
if( Query.IncludeChildFolders != value )
{
Query.IncludeChildFolders = value;
QueryChanged();
}
}
}

public bool UntaggedImages
{
get => Query.UntaggedImages;
Expand Down Expand Up @@ -368,7 +381,10 @@ public string SearchBreadcrumbs
hints.Add($"Lens: {lens.Model}");
}

if ( hints.Any() )
if( !IncludeChildFolders )
hints.Add( $"Exclude child folders" );

if( hints.Any() )
return string.Join(", ", hints);

return "No Filter";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,32 +54,38 @@ private IEnumerable<Claim> ParseClaimsFromJwt(string jwt)
var jsonBytes = ParseBase64WithoutPadding(payload);
var keyValuePairs = JsonSerializer.Deserialize<Dictionary<string, object>>(jsonBytes);

keyValuePairs.TryGetValue(ClaimTypes.Role, out var roles);

if ( roles != null )
if( keyValuePairs != null )
{
if ( roles.ToString().Trim().StartsWith("[") )
{
var parsedRoles = JsonSerializer.Deserialize<string[]>(roles.ToString());
keyValuePairs.TryGetValue( ClaimTypes.Role, out var roles );

_logger.LogInformation("Parsed roles from JWT:");
foreach ( var parsedRole in parsedRoles )
if( roles != null )
{
if( roles.ToString().Trim().StartsWith( "[" ) )
{
claims.Add(new Claim(ClaimTypes.Role, parsedRole));
_logger.LogTrace($" [{roles}]");
var parsedRoles = JsonSerializer.Deserialize<string[]>( roles.ToString() );

if( parsedRoles != null )
{
_logger.LogInformation( "Parsed roles from JWT:" );
foreach( var parsedRole in parsedRoles )
{
claims.Add( new Claim( ClaimTypes.Role, parsedRole ) );
_logger.LogTrace( $" [{roles}]" );
}
}
}
}
else
{
claims.Add(new Claim(ClaimTypes.Role, roles.ToString()));
_logger.LogTrace($"Parsed role from JWT: [{roles}]");
else
{
claims.Add( new Claim( ClaimTypes.Role, roles.ToString() ) );
_logger.LogTrace( $"Parsed role from JWT: [{roles}]" );
}

keyValuePairs.Remove( ClaimTypes.Role );
}

keyValuePairs.Remove(ClaimTypes.Role);
claims.AddRange( keyValuePairs.Select( kvp => new Claim( kvp.Key, kvp.Value.ToString() ) ) );
}

claims.AddRange(keyValuePairs.Select(kvp => new Claim(kvp.Key, kvp.Value.ToString())));

_logger.LogTrace(
$"Parsed Claims from JWT: {string.Join(", ", keyValuePairs.Select(x => $"{x.Key} = {x.Value}"))}");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public async Task<LoginResult> Login(LoginModel loginModel)
var loginResult = await _httpClient.CustomPostAsJsonAsync<LoginModel, LoginResult>("api/Login", loginModel);
var provider = _authenticationStateProvider as ApiAuthenticationStateProvider;

if ( loginResult.Successful )
if ( loginResult != null && provider != null &&loginResult.Successful )
{
await _localStorage.SetItemAsync("authToken", loginResult.Token);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,22 @@ public async Task<Basket> SwitchToBasket(int basketId)
}
catch ( Exception ex )
{
_logger.LogError($"Attempted to switch to unknown basket ID {basketId}");
_logger.LogError($"Attempted to switch to unknown basket ID {basketId}: {ex}");
throw;
}
}

public async Task<Basket> SwitchToDefaultBasket(int? userId)
{
Basket basket;
Basket? basket;

if ( userId is null )
basket = await httpClient.CustomGetFromJsonAsync<Basket>("/api/basketdefault");
else
basket = await httpClient.CustomGetFromJsonAsync<Basket>($"/api/basketdefault/{userId}");

await SetCurrentBasket(basket);
if( basket != null )
await SetCurrentBasket(basket);

return basket;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected override async Task PersistSetting(ConfigSetRequest saveRequest)

protected override async Task<List<ConfigSetting>> LoadAllSettings()
{
List<ConfigSetting> allSettings;
List<ConfigSetting>? allSettings;
try
{
if ( _userId.HasValue )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ public class ClientDataService : ICachedDataService
private readonly List<Lens> _lenses = new();
private readonly ILogger<ClientDataService> _logger;
private readonly RestClient httpClient;
private StaticData _staticData;
private StaticData? _staticData;

public ClientDataService(RestClient client, ILogger<ClientDataService> logger)
{
httpClient = client;
_logger = logger;
}

public string ImagesRootFolder => _staticData.ImagesRootFolder;
public string ExifToolVer => _staticData.ExifToolVer;
public string ImagesRootFolder => _staticData?.ImagesRootFolder;
public string ExifToolVer => _staticData?.ExifToolVer;
public ICollection<Camera> Cameras => _cameras;
public ICollection<Lens> Lenses => _lenses;

Expand Down
Loading

0 comments on commit 0bbaa05

Please sign in to comment.