Smart Filters & Dashboard Customization (#2282)
Co-authored-by: Robbie Davis <robbie@therobbiedavis.com>
This commit is contained in:
parent
3d501c9532
commit
84f85b4f24
92 changed files with 7149 additions and 555 deletions
|
@ -6,6 +6,7 @@ using System.Linq;
|
|||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using API.Constants;
|
||||
using API.Data.Repositories;
|
||||
using API.Entities;
|
||||
using API.Entities.Enums;
|
||||
using API.Entities.Enums.Theme;
|
||||
|
@ -38,6 +39,43 @@ public static class Seed
|
|||
}
|
||||
}.ToArray());
|
||||
|
||||
public static readonly ImmutableArray<AppUserDashboardStream> DefaultStreams = ImmutableArray.Create(
|
||||
new List<AppUserDashboardStream>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Name = "On Deck",
|
||||
StreamType = DashboardStreamType.OnDeck,
|
||||
Order = 0,
|
||||
IsProvided = true,
|
||||
Visible = true
|
||||
},
|
||||
new()
|
||||
{
|
||||
Name = "Recently Updated",
|
||||
StreamType = DashboardStreamType.RecentlyUpdated,
|
||||
Order = 1,
|
||||
IsProvided = true,
|
||||
Visible = true
|
||||
},
|
||||
new()
|
||||
{
|
||||
Name = "Newly Added",
|
||||
StreamType = DashboardStreamType.NewlyAdded,
|
||||
Order = 2,
|
||||
IsProvided = true,
|
||||
Visible = true
|
||||
},
|
||||
new()
|
||||
{
|
||||
Name = "More In",
|
||||
StreamType = DashboardStreamType.MoreInGenre,
|
||||
Order = 3,
|
||||
IsProvided = true,
|
||||
Visible = false
|
||||
},
|
||||
}.ToArray());
|
||||
|
||||
public static async Task SeedRoles(RoleManager<AppRole> roleManager)
|
||||
{
|
||||
var roles = typeof(PolicyConstants)
|
||||
|
@ -74,6 +112,31 @@ public static class Seed
|
|||
await context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public static async Task SeedDefaultStreams(IUnitOfWork unitOfWork)
|
||||
{
|
||||
var allUsers = await unitOfWork.UserRepository.GetAllUsersAsync(AppUserIncludes.DashboardStreams);
|
||||
foreach (var user in allUsers)
|
||||
{
|
||||
if (user.DashboardStreams.Count != 0) continue;
|
||||
user.DashboardStreams ??= new List<AppUserDashboardStream>();
|
||||
foreach (var defaultStream in DefaultStreams)
|
||||
{
|
||||
var newStream = new AppUserDashboardStream
|
||||
{
|
||||
Name = defaultStream.Name,
|
||||
IsProvided = defaultStream.IsProvided,
|
||||
Order = defaultStream.Order,
|
||||
StreamType = defaultStream.StreamType,
|
||||
Visible = defaultStream.Visible,
|
||||
};
|
||||
|
||||
user.DashboardStreams.Add(newStream);
|
||||
}
|
||||
unitOfWork.UserRepository.Update(user);
|
||||
await unitOfWork.CommitAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task SeedSettings(DataContext context, IDirectoryService directoryService)
|
||||
{
|
||||
await context.Database.EnsureCreatedAsync();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue