Skip to content

Commit 489d97b

Browse files
committed
On This Day...
1 parent 1bdc91d commit 489d97b

File tree

12 files changed

+57
-7
lines changed

12 files changed

+57
-7
lines changed

Damselfly.Core.DbModels/Interfaces/ISearchService.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public interface ISearchService
2121
int? SimilarToId { get; set; }
2222
int? LensId { get; set; }
2323
IEnumerable<int>? Months { get; set; }
24+
DateTime? OnThisDay { get; set; }
2425
int? MinRating { get; set; }
2526
int? MaxSizeKB { get; set; }
2627
int? MinSizeKB { get; set; }

Damselfly.Core.DbModels/Models/Entities/SearchQuery.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class SearchQuery
2121
public int? CameraId { get; set; } = null;
2222
public int? LensId { get; set; } = null;
2323
public IEnumerable<int>? Months { get; set; } = null;
24+
public DateTime? OnThisDay { get; set; } = null;
2425
public int? MinRating { get; set; } = null;
2526
public int? SimilarToId { get; set; } = null;
2627
public Folder? Folder { get; set; } = null;
@@ -85,6 +86,7 @@ public class SearchQueryDTO
8586
public int? CameraId { get; set; } = null;
8687
public int? LensId { get; set; } = null;
8788
public IEnumerable<int>? Months { get; set; } = null;
89+
public DateTime? OnThisDay { get; set; } = null;
8890
public int? MinRating { get; set; } = null;
8991
public int? SimilarToId { get; set; }
9092
public int? FolderId { get; set; }

Damselfly.Core.ImageProcessing/SkiaSharpProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public Task<IImageProcessResult> CreateThumbs(FileInfo source, IDictionary<FileI
9191
Logging.Log(
9292
$"{pair.Value.size} thumb created for {source.Name} [load: {load.ElapsedTime}ms, scale: {scale.ElapsedTime}ms, save: {save.ElapsedTime}ms]");
9393
}
94-
94+
9595
thumbs.Stop();
9696
}
9797
catch ( Exception ex )

Damselfly.Core.ScopedServices/BaseSearchService.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,21 @@ public IEnumerable<int>? Months
206206
}
207207
}
208208

209+
public DateTime? OnThisDay
210+
{
211+
get => Query.OnThisDay;
212+
set
213+
{
214+
if ( (value == null && Query.OnThisDay != null) ||
215+
(value != null && Query.OnThisDay == null) ||
216+
(value != null && Query.OnThisDay != null && Query.OnThisDay != value ) )
217+
{
218+
Query.OnThisDay = value;
219+
QueryChanged();
220+
}
221+
}
222+
}
223+
209224
public int? MinRating
210225
{
211226
get => Query.MinRating;
@@ -405,6 +420,11 @@ public IEnumerable<ISearchHint> SearchHints
405420
hints.Add( new SearchHint { Description = $"During: {monthText}", Clear = () => Months = null } );
406421
}
407422

423+
if( OnThisDay != null )
424+
{
425+
hints.Add( new SearchHint { Description = $"On This Day: {OnThisDay.Value:dd-MMM}", Clear = () => OnThisDay = null } );
426+
}
427+
408428
if ( CameraId > 0 )
409429
{
410430
var cam = _service.Cameras.FirstOrDefault(x => x.CameraId == CameraId);
@@ -472,6 +492,12 @@ public virtual void Refresh()
472492
QueryChanged();
473493
}
474494

495+
public void SetOnThisDay(DateTime? date)
496+
{
497+
Query.OnThisDay = date;
498+
QueryChanged();
499+
}
500+
475501
public void SetDateRange(DateTime? min, DateTime? max)
476502
{
477503
if ( Query.MinDate != min || Query.MaxDate != max )

Damselfly.Core.ScopedServices/Client Services/ClientSearchService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ protected override async Task<SearchResponse> GetQueryImagesAsync( int count = D
7373

7474
return response;
7575
}
76-
76+
7777
public void Refresh()
7878
{
7979
base.Refresh();

Damselfly.Core/ScopedServices/CachedDataService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public async Task<NewVersionResponse> CheckForNewVersion()
6969
newVersionState.ReleaseUrl = newRelease.HtmlUrl;
7070

7171
_logger.LogInformation(
72-
$"A new version of Damselfly is available: ({newRelease.Name})");
72+
$"A new version of Damselfly is ready to install now: ({newRelease.Name})");
7373
}
7474
}
7575
catch( Exception ex )

Damselfly.Core/Services/SearchQueryService.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ private async Task<SearchResponse> LoadMoreData(SearchQuery query, int first, in
178178
// Filter by month
179179
images = images.Where(x => query.Months.Contains(x.SortDate.Month));
180180

181+
if ( query.OnThisDay != null )
182+
// Filter by month and day
183+
images = images.Where(x => query.OnThisDay.Value.Month == x.SortDate.Month && query.OnThisDay.Value.Day == x.SortDate.Day);
184+
181185
if ( query.MinSizeKB.HasValue )
182186
{
183187
var minSizeBytes = query.MinSizeKB.Value * 1024;

Damselfly.Web.Client/Components/Controls/VersionChecker.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
<div class="new-version">
66
<NavLink href="@newVersionState.ReleaseUrl" target="_blank">
7-
v<text>@newVersionState.NewVersion</text> of Damselfly is available
7+
v<text>@newVersionState.NewVersion</text> of Damselfly is ready to install now
88
</NavLink>
99
</div>
1010
}

Damselfly.Web.Client/Components/ImageBrowser/AdvancedSearchPanel.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
DateRange = range;
142142
}
143143
}
144-
144+
145145
private void DateRangeChanged(DateRange value)
146146
{
147147
if( value != null )

Damselfly.Web.Client/Components/ImageBrowser/GridImage.razor

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ else
151151
}
152152
<RadzenMenuItem Text="View Folder" Value="7"/>
153153
<RadzenMenuItem Text="View Images From This Day" Value="8"/>
154+
<RadzenMenuItem Text="On This Day..." Value="10"/>
154155
<hr class="separator">
155156
@if ( InBasket )
156157
{
@@ -224,6 +225,9 @@ else
224225
case 9:
225226
await DeleteImages(ContextSelection.Select(x => x.ImageId).ToList());
226227
break;
228+
case 10:
229+
FilterByImageDayAndMonth();
230+
break;
227231
}
228232
}
229233

@@ -252,6 +256,12 @@ else
252256
NavigationManager.NavigateTo(url);
253257
}
254258

259+
private void FilterByImageDayAndMonth()
260+
{
261+
var url = $"/?date={CurrentImage.SortDate:dd-MMM}";
262+
NavigationManager.NavigateTo(url);
263+
}
264+
255265
private void FindImageSimilarTo()
256266
{
257267
searchService.SimilarToId = CurrentImage.ImageId;

0 commit comments

Comments
 (0)