Add restore functionality for template management and enhance related components
Implemented a new endpoint for restoring templates to their last applied state, allowing users to revert changes made since the last application. Updated the ScheduleTemplate class to include a snapshot of the last applied state, enabling rollback capabilities. Enhanced the frontend with a restore button in the ChannelDetail component, providing users with a confirmation prompt before executing the restore action. Localization updates were made to support new UI strings in both English and Russian, improving the overall user experience in template management.
This commit is contained in:
@@ -11,6 +11,7 @@ using TeleWave.Application.Programming.Templates.DeleteSlot;
|
||||
using TeleWave.Application.Programming.Templates.Generate;
|
||||
using TeleWave.Application.Programming.Templates.GetTemplate;
|
||||
using TeleWave.Application.Programming.Templates.Layers;
|
||||
using TeleWave.Application.Programming.Templates.Restore;
|
||||
using TeleWave.Application.Programming.Templates.UpdateSlot;
|
||||
using TeleWave.Application.Programming.Templates.Validate;
|
||||
using TeleWave.Infrastructure.Identity;
|
||||
@@ -44,6 +45,10 @@ public static class TemplateEndpoints
|
||||
admin
|
||||
.MapPost("/channels/{channelId:guid}/template/apply", ApplyTemplate)
|
||||
.Produces<ApplyResultDto>();
|
||||
// Откат правок к состоянию, по которому идёт эфир. Ленту не трогает — она и так по нему.
|
||||
admin
|
||||
.MapPost("/channels/{channelId:guid}/template/restore", RestoreTemplate)
|
||||
.Produces<RestoreTemplateResultDto>();
|
||||
// Предпросмотр — тот же генератор, но без записи и без продвижения курсоров.
|
||||
admin
|
||||
.MapGet("/channels/{channelId:guid}/template/preview", PreviewTemplate)
|
||||
@@ -137,6 +142,16 @@ public static class TemplateEndpoints
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> RestoreTemplate(
|
||||
Guid channelId,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(new RestoreTemplateCommand(channelId), cancellationToken);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> PreviewTemplate(
|
||||
Guid channelId,
|
||||
ISender sender,
|
||||
|
||||
Reference in New Issue
Block a user