add smart collections (#355)
* start to add smart collections * add smart collection table; delete smart collection * overwrite smart collections * support scheduling smart collections * update changelog
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
@using ErsatzTV.Application.Search
|
||||
@using ErsatzTV.Application.Search.Queries
|
||||
@using ErsatzTV.Extensions
|
||||
@using Microsoft.AspNetCore.WebUtilities
|
||||
@using Unit = LanguageExt.Unit
|
||||
@inherits MultiSelectBase<Search>
|
||||
@inject NavigationManager _navigationManager
|
||||
@@ -60,12 +59,22 @@
|
||||
<MudLink Class="ml-4" Href="@(_navigationManager.Uri.Split("#").Head() + "#music_videos")" Style="margin-bottom: auto; margin-top: auto">@_musicVideos.Count Music Videos</MudLink>
|
||||
}
|
||||
<div style="margin-left: auto">
|
||||
<MudButton Variant="Variant.Filled"
|
||||
Color="Color.Primary"
|
||||
StartIcon="@Icons.Material.Filled.Add"
|
||||
OnClick="@AddAllToCollection">
|
||||
Add All To Collection
|
||||
</MudButton>
|
||||
<MudTooltip Text="Add All To Collection">
|
||||
<MudButton Variant="Variant.Filled"
|
||||
Color="Color.Primary"
|
||||
StartIcon="@Icons.Material.Filled.Add"
|
||||
OnClick="@AddAllToCollection">
|
||||
Add All
|
||||
</MudButton>
|
||||
</MudTooltip>
|
||||
<MudTooltip Text="Save As Smart Collection">
|
||||
<MudButton Class="ml-3" Variant="Variant.Filled"
|
||||
Color="Color.Secondary"
|
||||
StartIcon="@Icons.Material.Filled.Save"
|
||||
OnClick="@SaveAsSmartCollection">
|
||||
Save As
|
||||
</MudButton>
|
||||
</MudTooltip>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@@ -415,4 +424,33 @@
|
||||
await AddItemsToCollection(results.MovieIds, results.ShowIds, results.EpisodeIds, results.ArtistIds, results.MusicVideoIds, "search results");
|
||||
}
|
||||
|
||||
private async Task SaveAsSmartCollection(MouseEventArgs _)
|
||||
{
|
||||
var options = new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall };
|
||||
|
||||
IDialogReference dialog = Dialog.Show<SaveAsSmartCollectionDialog>("Save As Smart Collection", options);
|
||||
DialogResult result = await dialog.Result;
|
||||
if (!result.Cancelled && result.Data is SmartCollectionViewModel collection)
|
||||
{
|
||||
var request = new UpdateSmartCollection(
|
||||
collection.Id,
|
||||
_query);
|
||||
|
||||
Either<BaseError, Unit> updateResult = await Mediator.Send(request);
|
||||
updateResult.Match(
|
||||
Left: error =>
|
||||
{
|
||||
Snackbar.Add($"Unexpected error saving smart collection: {error.Value}");
|
||||
Logger.LogError("Unexpected error saving smart collection: {Error}", error.Value);
|
||||
},
|
||||
Right: _ =>
|
||||
{
|
||||
Snackbar.Add(
|
||||
$"Saved smart collection {collection.Name}",
|
||||
Severity.Success);
|
||||
ClearSelection();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user