Merge pull request #169 from Moonlight-Panel/NotificationDebuggingUi

added simple debugging page
This commit is contained in:
Daniel Balk
2023-06-16 20:25:39 +02:00
committed by GitHub
2 changed files with 38 additions and 0 deletions

View File

@@ -36,6 +36,11 @@ public class NotificationServerService
private List<NotificationClientService> connectedClients = new();
public List<NotificationClientService> GetConnectedClients()
{
return connectedClients.ToList();
}
public List<NotificationClientService> GetConnectedClients(User user)
{
return connectedClients.Where(x => x.User == user).ToList();

View File

@@ -0,0 +1,33 @@
@page "/admin/notifications/debugging"
@using Moonlight.App.Services.Notifications
@inject NotificationServerService NotificationServerService
<OnlyAdmin>
<LazyLoader Load="Load">
<h1>Notification Debugging</h1>
@foreach (var client in Clients)
{
<hr/>
<div>
<p>Id: @client.NotificationClient.Id User: @client.User.Email</p>
<button @onclick="async () => await SendSampleNotification(client)"></button>
</div>
}
</LazyLoader>
</OnlyAdmin>
@code {
private List<NotificationClientService> Clients;
private async Task Load(LazyLoader loader)
{
Clients = NotificationServerService.GetConnectedClients();
}
private async Task SendSampleNotification(NotificationClientService client)
{
await client.SendAction(@"{""action"": ""notify"",""notification"":{""id"":999,""channel"":""Sample Channel"",""content"":""This is a sample Notification"",""title"":""Sample Notification""}}");
}
}