c0d04fa855
Closes the theme→render gap: the studio theme picker now actually drives a
FlexStory render's colours. GetFlexStoryProps reads saved_shared_colors by
element_key (accentColor/secondaryColor/backgroundColor/textColor), but the studio
only wrote the theme into scene_data — so the picker never reached the MP4.
- studio-svc: UpdateSharedColorsAsync upserts saved_shared_colors by (project,
element_key) + PATCH /v1/saved-projects/{id}/shared-colors endpoint +
UpdateColorsRequest/UpdateColorItem. Mirrors UpdateSceneContentsAsync. (dotnet
build: 0 errors.)
- gateway already wildcard-routes /v1/saved-projects/*path → studio-svc (no change).
- Next: /api/projects/[id]/colors route → gateway; project-api patchProjectColors
+ themeColorsFromSceneData (maps scene_data sceneAccentColor… → the colorSchema
keys); performSave best-effort pushes the 4 colours alongside contents.
Chain: theme picker → store → scene_data → performSave → patchProjectColors →
gateway → studio-svc upsert → saved_shared_colors → GetFlexStoryProps → render.
Verified: Next build + dotnet build both clean; theme presets render cohesively
across all 6 (incl. dark Midnight). End-to-end studio→render needs the live stack.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
75 lines
3.2 KiB
C#
75 lines
3.2 KiB
C#
using System.Security.Claims;
|
|
using FlatRender.StudioSvc.Application.Services;
|
|
using FlatRender.StudioSvc.Models.Requests;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace FlatRender.StudioSvc.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("v1/saved-projects")]
|
|
[Authorize]
|
|
public class StudioController(StudioService svc) : ControllerBase
|
|
{
|
|
private Guid UserId => Guid.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)!);
|
|
private Guid TenantId => Guid.Parse(
|
|
User.FindFirstValue("tenant_id") ?? "00000000-0000-0000-0000-000000000001");
|
|
|
|
[HttpGet]
|
|
public async Task<IActionResult> List([FromQuery] SavedProjectListRequest req) =>
|
|
Ok(await svc.ListProjectsAsync(UserId, req));
|
|
|
|
// Admin: view any user's saved projects ("user videos" viewer).
|
|
[HttpGet("by-user/{userId:guid}")]
|
|
[Authorize(Roles = "Admin")]
|
|
public async Task<IActionResult> ListByUser(Guid userId, [FromQuery] SavedProjectListRequest req) =>
|
|
Ok(await svc.ListProjectsAsync(userId, req));
|
|
|
|
[HttpGet("{id:guid}")]
|
|
public async Task<IActionResult> Get(Guid id) =>
|
|
Ok(await svc.GetProjectAsync(id, UserId));
|
|
|
|
[HttpPost]
|
|
public async Task<IActionResult> Create([FromBody] CreateSavedProjectRequest req)
|
|
{
|
|
var result = await svc.CreateProjectAsync(UserId, TenantId, req);
|
|
return CreatedAtAction(nameof(Get), new { id = result.Id }, result);
|
|
}
|
|
|
|
[HttpPatch("{id:guid}")]
|
|
public async Task<IActionResult> Update(Guid id, [FromBody] UpdateSavedProjectRequest req) =>
|
|
Ok(await svc.UpdateProjectAsync(id, UserId, req));
|
|
|
|
[HttpDelete("{id:guid}")]
|
|
public async Task<IActionResult> Delete(Guid id)
|
|
{
|
|
await svc.DeleteProjectAsync(id, UserId);
|
|
return NoContent();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Save all scenes for a project (full atomic replace).
|
|
/// Called by the studio editor on every save.
|
|
/// </summary>
|
|
[HttpPut("{id:guid}/scenes")]
|
|
public async Task<IActionResult> SaveScenes(Guid id, [FromBody] List<SaveSceneRequest> scenes) =>
|
|
Ok(await svc.SaveScenesAsync(id, UserId, scenes));
|
|
|
|
/// <summary>Update individual scene-input values by content key (live studio edits).</summary>
|
|
[HttpPatch("{id:guid}/contents")]
|
|
public async Task<IActionResult> UpdateContents(Guid id, [FromBody] UpdateContentsRequest req) =>
|
|
Ok(new { updated = await svc.UpdateSceneContentsAsync(id, UserId, req.Items ?? new List<UpdateContentItem>()) });
|
|
|
|
/// <summary>Update the project's theme colours (accentColor/secondaryColor/
|
|
/// backgroundColor/textColor) so the FlexStory render reads the theme picker.</summary>
|
|
[HttpPatch("{id:guid}/shared-colors")]
|
|
public async Task<IActionResult> UpdateColors(Guid id, [FromBody] UpdateColorsRequest req) =>
|
|
Ok(new { updated = await svc.UpdateSharedColorsAsync(id, UserId, req.Items ?? new List<UpdateColorItem>()) });
|
|
|
|
/// <summary>Internal endpoint: get project for render service (no user-ownership check).</summary>
|
|
[HttpGet("{id:guid}/render-payload")]
|
|
[Authorize(Roles = "Service")]
|
|
public async Task<IActionResult> GetRenderPayload(Guid id) =>
|
|
Ok(await svc.GetProjectForRenderAsync(id));
|
|
}
|