Allow the deletion of all Notifications
Added button to delete all the notifications for the selected filter.
This commit is contained in:
parent
dd32b33621
commit
a602a942c4
|
@ -205,6 +205,8 @@ else
|
|||
</Detail>
|
||||
</Pager>
|
||||
}
|
||||
<br />
|
||||
<ActionDialog Header="Clear Notifications" Message="Are You Sure You Wish To Permanently Delete All Notifications ?" Action="Delete All Notifications" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteAllNotifications())" ResourceKey="DeleteAllNotifications" />
|
||||
<br /><hr />
|
||||
<select class="form-select" @onchange="(e => FilterChanged(e))">
|
||||
<option value="to">@Localizer["Inbox"]</option>
|
||||
|
@ -413,4 +415,33 @@ else
|
|||
StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task DeleteAllNotifications()
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach(var Notification in notifications)
|
||||
{
|
||||
if (!Notification.IsDeleted)
|
||||
{
|
||||
Notification.IsDeleted = true;
|
||||
await NotificationService.UpdateNotificationAsync(Notification);
|
||||
}
|
||||
else
|
||||
{
|
||||
await NotificationService.DeleteNotificationAsync(Notification.NotificationId);
|
||||
}
|
||||
await logger.LogInformation("Notification Deleted {Notification}", Notification);
|
||||
}
|
||||
await logger.LogInformation("Notifications Permanently Deleted");
|
||||
await LoadNotificationsAsync();
|
||||
StateHasChanged();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Deleting Notifications {Error}", ex.Message);
|
||||
AddModuleMessage(ex.Message, MessageType.Error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -210,4 +210,13 @@
|
|||
<data name="TwoFactor.Text" xml:space="preserve">
|
||||
<value>Two Factor?</value>
|
||||
</data>
|
||||
<data name="DeleteAllNotifications.Header" xml:space="preserve">
|
||||
<value>Clear Notifications</value>
|
||||
</data>
|
||||
<data name="DeleteAllNotifications.Message" xml:space="preserve">
|
||||
<value>Are You Sure You Wish To Permanently Delete All Notifications?</value>
|
||||
</data>
|
||||
<data name="DeleteAllNotifications.Text" xml:space="preserve">
|
||||
<value>Delete ALL Notifications</value>
|
||||
</data>
|
||||
</root>
|
Loading…
Reference in New Issue
Block a user