Add grid auto-build functionality with profile management and preview capabilities
Implemented new API endpoints and frontend components for grid auto-building based on predefined profiles. Added functionality to list grid profiles, preview generated grids, and generate grids with specified parameters. Enhanced the TemplateEndpoints and related services to support these features, improving the user experience for channel scheduling. Localization updates were made to accommodate new features in both English and Russian.
This commit is contained in:
@@ -8,6 +8,7 @@ using TeleWave.Application.Programming.Templates.CopyTemplate;
|
||||
using TeleWave.Application.Programming.Templates.CreateSlot;
|
||||
using TeleWave.Application.Programming.Templates.CreateTemplate;
|
||||
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.UpdateSlot;
|
||||
@@ -62,6 +63,18 @@ public static class TemplateEndpoints
|
||||
)
|
||||
.Produces<CopyTemplateResultDto>();
|
||||
|
||||
// Автосборка сетки: каталог профилей, план по выбранному и его создание. План считается
|
||||
// одним и тем же кодом, поэтому предпросмотр показывает ровно то, что создаст кнопка.
|
||||
admin
|
||||
.MapGet("/grid-profiles", ListGridProfiles)
|
||||
.Produces<IReadOnlyList<GridProfileDto>>();
|
||||
admin
|
||||
.MapGet("/channels/{channelId:guid}/template/grid-plan", PreviewGrid)
|
||||
.Produces<GridPlanDto>();
|
||||
admin
|
||||
.MapPost("/channels/{channelId:guid}/template/generate", GenerateGrid)
|
||||
.Produces<GenerateGridResultDto>();
|
||||
|
||||
admin
|
||||
.MapPost("/templates/{templateId:guid}/layers", CreateLayer)
|
||||
.Produces<CreatedIdResponse>(StatusCodes.Status201Created);
|
||||
@@ -158,6 +171,44 @@ public static class TemplateEndpoints
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> ListGridProfiles(
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(new ListGridProfilesQuery(), cancellationToken);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> PreviewGrid(
|
||||
Guid channelId,
|
||||
GridProfileKind profile,
|
||||
GridGenerationMode mode,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new PreviewGeneratedGridQuery(channelId, profile, mode),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> GenerateGrid(
|
||||
Guid channelId,
|
||||
GenerateGridBody body,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new GenerateGridCommand(channelId, body.Profile, body.Mode),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> CopyTemplate(
|
||||
Guid channelId,
|
||||
Guid targetChannelId,
|
||||
@@ -286,6 +337,8 @@ public sealed record UpdateTemplateBody(
|
||||
PlanningRules? Rules
|
||||
);
|
||||
|
||||
public sealed record GenerateGridBody(GridProfileKind Profile, GridGenerationMode Mode);
|
||||
|
||||
public sealed record CreateLayerBody(string Name, int Priority);
|
||||
|
||||
public sealed record UpdateLayerBody(
|
||||
|
||||
Reference in New Issue
Block a user