Skip to content

Commit

Permalink
MudBlazor 7 #531
Browse files Browse the repository at this point in the history
  • Loading branch information
Webreaper committed May 23, 2024
1 parent af4cc8d commit 42ef216
Show file tree
Hide file tree
Showing 23 changed files with 53 additions and 49 deletions.
3 changes: 2 additions & 1 deletion Damselfly.Core.DbModels/Interfaces/ITagService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Damselfly.Core.Models;

Expand Down Expand Up @@ -27,7 +28,7 @@ public interface IRecentTagService

public interface ITagSearchService
{
Task<ICollection<Tag>> SearchTags(string filterText);
Task<ICollection<Tag>> SearchTags(string filterText, CancellationToken token = default(CancellationToken));
Task<ICollection<Tag>> GetAllTags();
Task<Tag> GetTag( int tagId );
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public async Task<ICollection<string>> GetRecentTags()
return _recentTags;
}

public async Task<ICollection<Tag>> SearchTags(string filterText)
public async Task<ICollection<Tag>> SearchTags(string filterText, CancellationToken token)
{
return await httpClient.CustomGetFromJsonAsync<List<Tag>>($"/api/tags/search/{filterText}");
}
Expand Down
4 changes: 2 additions & 2 deletions Damselfly.Core.ScopedServices/Client Services/RestClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ private Exception GetRestException(Exception ex, string requestUrl)
return ex;
}

public async Task<T?> CustomGetFromJsonAsync<T>(string? requestUri)
public async Task<T?> CustomGetFromJsonAsync<T>(string? requestUri, CancellationToken token = default( CancellationToken))
{
try
{
return await _restClient.GetFromJsonAsync<T>(requestUri, JsonOptions);
return await _restClient.GetFromJsonAsync<T>(requestUri, JsonOptions, token);
}
catch ( Exception ex )
{
Expand Down
4 changes: 3 additions & 1 deletion Damselfly.Core/Services/MetaDataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Damselfly.Core.Constants;
using Damselfly.Core.Database;
Expand Down Expand Up @@ -150,8 +151,9 @@ public Task<ICollection<Tag>> GetAllTags()
/// Search for a set of tags - used for autocomplete.
/// </summary>
/// <param name="text"></param>
/// <param name="token"></param>
/// <returns></returns>
public Task<ICollection<Tag>> SearchTags(string text)
public Task<ICollection<Tag>> SearchTags(string text, CancellationToken token = default(CancellationToken))
{
var results = new List<Tag>();
var searchText = text.Trim();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
@bind-DateRange="DateRange" Variant="UIConstants.MudVariant"
Color="Color.Tertiary">
<PickerActions>
<MudButton Class="mr-auto align-self-start" OnClick="@(() => _picker.Clear())">Clear</MudButton>
<MudButton Class="mr-auto align-self-start" OnClick="@(() => _picker.ClearAsync())">Clear</MudButton>
<select class="mr-auto align-self-start" @onchange="ShortCutChanged">
<option>Quick Dates</option>
@foreach( var choice in DateRanges )
{
<option value="@choice.Key">@choice.Key</option>
}
</select>
<MudButton OnClick="@(() => _picker.Close(false))">Cancel</MudButton>
<MudButton Color="Color.Primary" OnClick="@(() => _picker.Close())">Ok</MudButton>
<MudButton OnClick="@(() => _picker.CloseAsync(false))">Cancel</MudButton>
<MudButton Color="Color.Primary" OnClick="@(() => _picker.CloseAsync())">Ok</MudButton>
</PickerActions>
</MudDateRangePicker>
</div>
Expand Down Expand Up @@ -98,13 +98,13 @@
</MudSelect>
</div>
<div class="damselfly-dialogctrl">
<MudCheckBox @bind-Checked="@searchService.TagsOnly" Label="Exclude filenames/folders"/>
<MudCheckBox @bind-Value="@searchService.TagsOnly" Label="Exclude filenames/folders"/>
</div>
<div class="damselfly-dialogctrl">
<MudCheckBox @bind-Checked="@searchService.IncludeAITags" Label="Include AI tags"/>
<MudCheckBox @bind-Value="@searchService.IncludeAITags" Label="Include AI tags"/>
</div>
<div class="damselfly-dialogctrl">
<MudCheckBox @bind-Checked="@searchService.UntaggedImages" Label="Images without keywords"/>
<MudCheckBox @bind-Value="@searchService.UntaggedImages" Label="Images without keywords"/>
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ else
private async Task ShowRescanDialog()
{
var parameters = new DialogParameters { { "images", ContextSelection } };
var options = new DialogOptions { MaxWidth = MaxWidth.ExtraSmall, DisableBackdropClick = true };
var options = new DialogOptions { MaxWidth = MaxWidth.ExtraSmall, BackdropClick = false };
var dialog = DialogService.Show<RescanDialog>("Re-scan Images", parameters, options);
var result = await dialog.Result;
}
Expand Down
2 changes: 1 addition & 1 deletion Damselfly.Web.Client/Components/ImageViewer/AIObject.razor
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
}
}

private async Task<IEnumerable<string>> SearchNames(string text)
private async Task<IEnumerable<string>> SearchNames(string text, CancellationToken token)
{
var list = await peopleService.GetPeopleNames(text.Trim());
return list;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ of the visible image is updated which should update it instantly.
private async Task ShowRescanDialog()
{
var parameters = new DialogParameters { { "images", new List<Image> { Image } } };
var options = new DialogOptions { MaxWidth = MaxWidth.ExtraSmall, DisableBackdropClick = true };
var options = new DialogOptions { MaxWidth = MaxWidth.ExtraSmall, BackdropClick = false };
var dialog = DialogService.Show<RescanDialog>("Re-scan Images", parameters, options);
var result = await dialog.Result;
}
Expand Down
4 changes: 2 additions & 2 deletions Damselfly.Web.Client/Components/People/PeopleManager.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
<MudButton @onclick="@ClearFaceThumbs">Refresh Thumbs</MudButton>
</div>
<div class="title-section">
<MudRadioGroup @bind-SelectedOption="filterType">
<MudRadioGroup @bind-Value="filterType">
@foreach ( var choice in Enum.GetValues<FilterType>() )
{
<MudRadio Option="@choice" Color="Color.Primary">
<MudRadio Value="@choice" Color="Color.Primary">
@choice.ToString()
</MudRadio>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@
if (folder != null)
parameters = new DialogParameters { { "folder", folder }, { "count", folder.MetaData.ImageCount } };

var options = new DialogOptions { MaxWidth = MaxWidth.ExtraSmall, DisableBackdropClick = true };
var options = new DialogOptions { MaxWidth = MaxWidth.ExtraSmall, BackdropClick = false };
var dialog = DialogService.Show<RescanDialog>
("Re-scan Images", parameters, options);
var result = await dialog.Result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
}
}

private async Task<IEnumerable<string>> SearchTags(string text)
private async Task<IEnumerable<string>> SearchTags(string text, CancellationToken token)
{
var results = await tagSearchService.SearchTags(text);
var results = await tagSearchService.SearchTags(text, token);
return results.Select(x => x.Keyword);
}

Expand Down
6 changes: 3 additions & 3 deletions Damselfly.Web.Client/Pages/ImagePage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
</div>
</div>

<MudSwipeArea OnSwipe="OnSwipe">
<MudSwipeArea OnSwipeEnd="OnSwipe">
<ImagePreview @ref="theImagePreview" @key="@ImageID" Editing=Editing Image="@CurrentImage" />
</MudSwipeArea>
}
Expand Down Expand Up @@ -113,9 +113,9 @@
private bool CanZoomOut => ZoomRange > 1.0 && !ZoomDisabled;
private bool ZoomDisabled => ShowObjects;

private void OnSwipe( SwipeDirection direction )
private void OnSwipe( SwipeEventArgs args)
{
switch( direction )
switch( args.SwipeDirection )
{
case SwipeDirection.LeftToRight:
Next();
Expand Down
26 changes: 13 additions & 13 deletions Damselfly.Web.Client/Shared/Config.razor
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@
</p>
<div class="damselfly-configsetting">
<div class="damselfly-configfield">
<MudSwitch @bind-Checked="settingsModel.enableBackgroundThumbs" UnCheckedColor=Color.Tertiary Color="Color.Primary"
<MudSwitch @bind-Value="settingsModel.enableBackgroundThumbs" UncheckedColor=Color.Tertiary Color="Color.Primary"
Label="Enable Background Thumbnail Generation"/>
</div>
</div>
@if( Debugger.IsAttached )
{
<div class="damselfly-configsetting">
<div class="damselfly-configfield">
<MudSwitch @bind-Checked="settingsModel.enableImageEditing" UnCheckedColor=Color.Tertiary Color="Color.Primary"
<MudSwitch @bind-Value="settingsModel.enableImageEditing" UncheckedColor=Color.Tertiary Color="Color.Primary"
Label="Enable Image Editing (Experimental)"/>
</div>
</div>
Expand All @@ -79,24 +79,24 @@
<h2>SideCar Processing</h2>
<div class="damselfly-configsetting">
<div class="damselfly-configfield">
<MudCheckBox @bind-Checked="@settingsModel.importSidecarKeywords" Label="Write Sidecar (XMP/ON1) keywords to image files during indexing"/>
<MudCheckBox @bind-Value="@settingsModel.importSidecarKeywords" Label="Write Sidecar (XMP/ON1) keywords to image files during indexing"/>
</div>
</div>

<h2>Security</h2>
<div class="damselfly-configsetting">
<div class="damselfly-configfield">
<MudCheckBox @bind-Checked="@settingsModel.enableAuthAndRoles" Label="Enable Authentication, user IDs and roles (requires restart)"/>
<MudCheckBox @bind-Value="@settingsModel.enableAuthAndRoles" Label="Enable Authentication, user IDs and roles (requires restart)"/>
</div>
</div>
<div class="damselfly-configsetting">
<div class="damselfly-configfield">
<MudCheckBox @bind-Checked="@settingsModel.allowExternalRegistration" Disabled="@(!settingsModel.enableAuthAndRoles)" Label="Enable public registration page"/>
<MudCheckBox @bind-Value="@settingsModel.allowExternalRegistration" Disabled="@(!settingsModel.enableAuthAndRoles)" Label="Enable public registration page"/>
</div>
</div>
<div class="damselfly-configsetting">
<div class="damselfly-configfield">
<MudCheckBox @bind-Checked="@settingsModel.forceLogin" Disabled="@(!settingsModel.enableAuthAndRoles)" Label="Force users to login before accessing Damselfly"/>
<MudCheckBox @bind-Value="@settingsModel.forceLogin" Disabled="@(!settingsModel.enableAuthAndRoles)" Label="Force users to login before accessing Damselfly"/>
</div>
</div>

Expand Down Expand Up @@ -131,19 +131,19 @@

<div class="damselfly-configsetting">
<div class="damselfly-configfield">
<MudCheckBox @bind-Checked="@settingsModel.enableAIProcessing" Label="Scan images locally for objects/faces using AI (this will use a lot of CPU)"/>
<MudCheckBox @bind-Value="@settingsModel.enableAIProcessing" Label="Scan images locally for objects/faces using AI (this will use a lot of CPU)"/>
</div>
</div>

<div class="damselfly-configsetting">
<div class="damselfly-configfield">
<MudCheckBox @bind-Checked="@settingsModel.disableObjectDetector" Label="Disable object detection scanner"/>
<MudCheckBox @bind-Value="@settingsModel.disableObjectDetector" Label="Disable object detection scanner"/>
</div>
</div>

<div class="damselfly-configsetting">
<div class="damselfly-configfield">
<MudCheckBox @bind-Checked="@settingsModel.writeAITagsToImages" Label="Write recognised item keywords to image EXIF metadata"/>
<MudCheckBox @bind-Value="@settingsModel.writeAITagsToImages" Label="Write recognised item keywords to image EXIF metadata"/>
</div>
</div>

Expand All @@ -164,7 +164,7 @@

<div class="damselfly-configsetting">
<div class="damselfly-configfield">
<MudCheckBox @bind-Checked="@settingsModel.cpuSettings.EnableAltCPULevel"
<MudCheckBox @bind-Value="@settingsModel.cpuSettings.EnableAltCPULevel"
Label="Adjust CPU usage limits during these times."/>
<div class="damselfly-configsetting">
<MudTimePicker @bind-Time="settingsModel.cpuSettings.AltTimeStart" Disabled="@(!settingsModel.cpuSettings.EnableAltCPULevel)"
Expand Down Expand Up @@ -213,9 +213,9 @@
<h2>Email Settings for Password Reminders, etc.</h2>

<p>Reminder emails can be sent using SMTP or SendGrid (you can sign up for a free SendGrid account <a href="https://signup.sendgrid.com/" target="_blank">here).</a></p>
<MudRadioGroup @bind-SelectedOption="@settingsModel.useSmtp">
<MudRadio Option="@true">SMTP</MudRadio>
<MudRadio Option="@false">SendGrid</MudRadio>
<MudRadioGroup @bind-Value="@settingsModel.useSmtp">
<MudRadio Value="@true">SMTP</MudRadio>
<MudRadio Value="@false">SendGrid</MudRadio>
</MudRadioGroup>


Expand Down
2 changes: 1 addition & 1 deletion Damselfly.Web.Client/Shared/Dialogs/BasketDialog.razor
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<MudTextField @bind-Value="@model.BasketName" For="@(() => model.BasketName)" Label="Basket Name" ReadOnly="false" Variant="Variant.Filled" UserAttributes="@MudNoAutofill.noAutoFillAttr"/>
@if( configService.GetBool(ConfigSettings.EnablePoliciesAndRoles) )
{
<MudCheckBox @bind-Checked="@model.IsPublic" Label="Share this basket with other users"/>
<MudCheckBox @bind-Value="@model.IsPublic" Label="Share this basket with other users"/>
}
@if( !string.IsNullOrEmpty(errorMsg) )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</MudSelectItem>
}
</MudSelect>
<MudCheckBox @bind-Checked="@Config.KeepFolders" Label="Export with folder structure"/>
<MudCheckBox @bind-Value="@Config.KeepFolders" Label="Export with folder structure"/>
<MudTextField @bind-Value="@Config.WatermarkText" For="@(() => Config.WatermarkText)" Label="Watermark Text" ReadOnly="false" Variant="Variant.Filled" UserAttributes="@MudNoAutofill.noAutoFillAttr"/>
</EditForm>
</DialogContent>
Expand Down
2 changes: 1 addition & 1 deletion Damselfly.Web.Client/Shared/Dialogs/NameDialog.razor
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
}
}

private async Task<IEnumerable<string>> SearchNames(string text)
private async Task<IEnumerable<string>> SearchNames(string text, CancellationToken _)
{
var list = await peopleService.GetPeopleNames(text.Trim());
return list;
Expand Down
8 changes: 4 additions & 4 deletions Damselfly.Web.Client/Shared/Dialogs/RescanDialog.razor
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
<MudText>Re-scan @ImageText:</MudText>
}
<div>
<MudCheckBox @bind-Checked="@ReIndex" Label="Re-index image files"/>
<MudCheckBox @bind-Value="@ReIndex" Label="Re-index image files"/>
</div>
<div>
<MudCheckBox @bind-Checked="@RescanMetadata" Label="Re-scan metadata"/>
<MudCheckBox @bind-Value="@RescanMetadata" Label="Re-scan metadata"/>
</div>
<div>
<MudCheckBox @bind-Checked="@RegenThumbs" Label="Re-generate thumbnails"/>
<MudCheckBox @bind-Value="@RegenThumbs" Label="Re-generate thumbnails"/>
</div>
<div>
<MudCheckBox @bind-Checked="@RescanAI" Label="Re-scan for AI objects"/>
<MudCheckBox @bind-Value="@RescanAI" Label="Re-scan for AI objects"/>
</div>
</DialogContent>
<DialogActions>
Expand Down
2 changes: 1 addition & 1 deletion Damselfly.Web.Client/Shared/Login.razor
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<ValidationMessage For="@(() => loginModel.Password)" />
</div>
<div>
<MudCheckBox @bind-Checked="@loginModel.RememberMe" Label="Remember Me" />
<MudCheckBox @bind-Value="@loginModel.RememberMe" Label="Remember Me" />
</div>
<button type="submit" class="btn btn-primary">Login</button>
</EditForm>
Expand Down
3 changes: 2 additions & 1 deletion Damselfly.Web.Client/Shared/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
@implements IDisposable

<MudDialogProvider FullWidth="true" MaxWidth="MaxWidth.Small"/>
<MudPopoverProvider/>
<RadzenContextMenu/>
<UIStateMonitor/>

Expand Down Expand Up @@ -90,7 +91,7 @@
if( await peopleService.NeedsAIMigration() )
{
var parameters = new DialogParameters();
var options = new MudBlazor.DialogOptions { MaxWidth = MaxWidth.Small, DisableBackdropClick = true };
var options = new MudBlazor.DialogOptions { MaxWidth = MaxWidth.Small, BackdropClick = false };
var dialog = dialogService.Show<AIMigrationDialog>("AI Migration", parameters, options);
var result = await dialog.Result;
}
Expand Down
4 changes: 2 additions & 2 deletions Damselfly.Web.Client/Shared/ThemeSwitcher.razor
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
{
return new MudTheme
{
Palette = new Palette
PaletteLight = new PaletteLight()
{
Black = CreateMudColor(theme.Black),
Primary = CreateMudColor(theme.Primary),
Expand All @@ -75,7 +75,7 @@
ActionDisabledBackground = CreateMudColor(theme.ActionDisabledBackground),
ActionDisabled = CreateMudColor(theme.ActionDisabled),
Background = CreateMudColor(theme.Background),
BackgroundGrey = CreateMudColor(theme.BackgroundGrey),
BackgroundGray = CreateMudColor(theme.BackgroundGrey),
DrawerBackground = CreateMudColor(theme.DrawerBackground),
DrawerText = CreateMudColor(theme.DrawerText),
DrawerIcon = CreateMudColor(theme.DrawerIcon),
Expand Down
2 changes: 1 addition & 1 deletion Damselfly.Web.Client/wwwroot/version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
const CACHE_VERSION='4.1.3-20240416210120'
const CACHE_VERSION='4.1.3-20240523214158'
2 changes: 1 addition & 1 deletion Damselfly.Web.Server/Controllers/ExportController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public async Task CreateConfig(ExportConfig config, [FromServices] ImageContext
{
try
{
if ( db.DownloadConfigs.Any(x => x.Name.Equals(config.Name)) )
if ( db.DownloadConfigs.Any(x => x.Name != null && x.Name.Equals(config.Name)) )
throw new ArgumentException($"Config {config.Name} already exists!");

db.DownloadConfigs.Add(config);
Expand Down
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<PackageVersion Include="Microsoft.ML.OnnxRuntime.Managed" Version="1.17.3" />
<PackageVersion Include="Microsoft.ML.TensorFlow" Version="3.0.1" />
<PackageVersion Include="Microsoft.ML.TensorFlow.Redist" Version="0.14.0" />
<PackageVersion Include="MudBlazor" Version="6.19.1" />
<PackageVersion Include="MudBlazor" Version="7.0.0-preview.3" />
<PackageVersion Include="Radzen.Blazor" Version="4.29.7" />
<PackageVersion Include="SendGrid" Version="9.29.3" />
<PackageVersion Include="Serilog" Version="3.1.1" />
Expand Down

0 comments on commit 42ef216

Please sign in to comment.