Enhance admin maintenance functionality with new endpoints and response types
CI / Backend (build + test) (push) Successful in 1m17s
CI / Frontend (lint + typecheck + build) (push) Successful in 33s

- Added new DELETE endpoints for managing audit logs and disabled apps in the admin maintenance section.
- Updated existing endpoint for closed tickets to use a unified response type, `MaintenanceCleanupResponseDto`.
- Enhanced API documentation to reflect the new operations and their expected request/response formats.
- Improved frontend integration with new functions for deleting old audit logs and disabled apps, including user confirmation prompts.
- Added localization support for new maintenance actions in both Russian and English.
This commit is contained in:
Leonid Pershin
2026-07-14 18:37:22 +03:00
parent 8dfeb05912
commit 94ba514b8e
15 changed files with 449 additions and 15 deletions
@@ -1,6 +1,7 @@
using PnvPanel.Api.Common;
using PnvPanel.Application.Admin.Maintenance;
using PnvPanel.Application.Common.Messaging;
using PnvPanel.Application.Common.Models;
using PnvPanel.Infrastructure.Identity;
namespace PnvPanel.Api.Endpoints;
@@ -15,7 +16,13 @@ public static class AdminMaintenanceEndpoints
admin
.MapDelete("/tickets/closed", DeleteClosedTickets)
.Produces<DeleteClosedTicketsResponseDto>();
.Produces<MaintenanceCleanupResponseDto>();
admin
.MapDelete("/audit-logs", DeleteOldAuditLogs)
.Produces<MaintenanceCleanupResponseDto>();
admin
.MapDelete("/apps/disabled", DeleteDisabledApps)
.Produces<MaintenanceCleanupResponseDto>();
return app;
}
@@ -26,11 +33,35 @@ public static class AdminMaintenanceEndpoints
)
{
var result = await sender.Send(new DeleteClosedTicketsCommand(), cancellationToken);
if (!result.IsSuccess)
return result.ToHttpResult();
return Results.Ok(new DeleteClosedTicketsResponseDto(result.Value));
return ToResponse(result);
}
private static async Task<IResult> DeleteOldAuditLogs(
int olderThanDays,
ISender sender,
CancellationToken cancellationToken
)
{
var result = await sender.Send(
new DeleteOldAuditLogsCommand(olderThanDays),
cancellationToken
);
return ToResponse(result);
}
private static async Task<IResult> DeleteDisabledApps(
ISender sender,
CancellationToken cancellationToken
)
{
var result = await sender.Send(new DeleteDisabledAppsCommand(), cancellationToken);
return ToResponse(result);
}
private static IResult ToResponse(Result<int> result) =>
result.IsSuccess
? Results.Ok(new MaintenanceCleanupResponseDto(result.Value))
: result.ToHttpResult();
}
public sealed record DeleteClosedTicketsResponseDto(int DeletedCount);
public sealed record MaintenanceCleanupResponseDto(int DeletedCount);