Implemented random loading message

This commit is contained in:
Marcel Baumgartner 2023-04-15 22:57:29 +02:00
parent ec4e5a9db6
commit 30106c2c45
2 changed files with 22 additions and 1 deletions

View file

@ -0,0 +1,14 @@
using Microsoft.EntityFrameworkCore;
namespace Moonlight.App.Extensions;
public static class DbSetExtensions
{
public static T Random<T>(this DbSet<T> repo) where T : class
{
Random rand = new Random();
int toSkip = rand.Next(0, repo.Count());
return repo.Skip(toSkip).Take(1).First();
}
}

View file

@ -1,9 +1,12 @@
@using Microsoft.AspNetCore.Components.Web
@using Moonlight.App.Extensions
@using Moonlight.App.Repositories
@using Moonlight.App.Services
@namespace Moonlight.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@inject ConfigService ConfigService
@inject LoadingMessageRepository LoadingMessageRepository
@{
var headerConfig = ConfigService
@ -73,9 +76,13 @@
<div class="app-page-loader flex-column">
<img alt="Logo" src="@(moonlightConfig.GetValue<string>("AppUrl"))/api/moonlight/resources/images/logo.svg" class="h-25px"/>
@{
var loadingMessage = LoadingMessageRepository.Get().Random();
}
<div class="d-flex align-items-center mt-5">
<span class="spinner-border text-primary" role="status"></span>
<span class="text-muted fs-6 fw-semibold ms-5">CHANGEME</span>
<span class="text-muted fs-6 fw-semibold ms-5">@(loadingMessage.Message)</span>
</div>
</div>