feat(web+api): playout create for all kinds + detail updates (#144 S5, #162) #170

Merged
timothy merged 5 commits from feat/144-s5-playout-create into main 2026-07-07 18:09:57 +02:00
Owner

Slice S5 of the #162 scheduling REST plan (parity issue #144): fixes the disabled Add Playout button.

API

  • POST /api/playouts now creates playouts of all 5 schedule kinds via a scheduleKind discriminator on CreatePlayoutRequest (programScheduleId now nullable; new scheduleFile). Per-kind validation → 422: Classic requires programScheduleId, Sequential/Scripted/ExternalJson require scheduleFile, Block requires neither.
  • New PUT /api/playouts/{id}: updates dailyRebuildTime (null clears — mirrors Blazor's "Do not automatically reset") and scheduleFile (Sequential/Scripted/ExternalJson only, else 422). 404 via pre-check (UpdatePlayoutHandler's own not-found is a plain BaseError → would be 422; follow-up candidate).
  • ApiErrorResponseMetadataTests + PlayoutControllerTests extended; OpenAPI spec regenerated.

SPA

  • createPlayout() / updatePlayoutDetails() in web/src/api/playouts.ts + URL-assert tests.
  • Add Playout dialog (kind select, channel select annotating channels that already have a playout, classic schedule picker, schedule-file input with Blazor helper texts).
  • "Edit details" dialog on the playout card (half-hour daily-reset picker; schedule-file field gated to file kinds).
  • App.test.tsx coverage: create success + 422 error surface + update success.

Verification

  • ErsatzTV.Tests 621 green; Core.Tests 493 green (+1 skip); web 218 green; tsc + vite build clean.
  • Live E2E (scratch config, real browser): all create/update/validation paths (201/422/404) + both dialogs exercised; screenshots taken. Sequential create only checks file existence (parity with Blazor) — bogus YAML fails later at build time, as upstream.

Part of #144 / #162 (slice S5 — do not auto-close).

🤖 Generated with Claude Code

Slice S5 of the #162 scheduling REST plan (parity issue #144): fixes the disabled Add Playout button. **API** - `POST /api/playouts` now creates playouts of **all 5 schedule kinds** via a `scheduleKind` discriminator on `CreatePlayoutRequest` (`programScheduleId` now nullable; new `scheduleFile`). Per-kind validation → 422: Classic requires `programScheduleId`, Sequential/Scripted/ExternalJson require `scheduleFile`, Block requires neither. - New `PUT /api/playouts/{id}`: updates `dailyRebuildTime` (null clears — mirrors Blazor's "Do not automatically reset") and `scheduleFile` (Sequential/Scripted/ExternalJson only, else 422). 404 via pre-check (`UpdatePlayoutHandler`'s own not-found is a plain BaseError → would be 422; follow-up candidate). - `ApiErrorResponseMetadataTests` + `PlayoutControllerTests` extended; OpenAPI spec regenerated. **SPA** - `createPlayout()` / `updatePlayoutDetails()` in `web/src/api/playouts.ts` + URL-assert tests. - Add Playout dialog (kind select, channel select annotating channels that already have a playout, classic schedule picker, schedule-file input with Blazor helper texts). - "Edit details" dialog on the playout card (half-hour daily-reset picker; schedule-file field gated to file kinds). - App.test.tsx coverage: create success + 422 error surface + update success. **Verification** - ErsatzTV.Tests 621 green; Core.Tests 493 green (+1 skip); web 218 green; tsc + vite build clean. - Live E2E (scratch config, real browser): all create/update/validation paths (201/422/404) + both dialogs exercised; screenshots taken. Sequential create only checks file existence (parity with Blazor) — bogus YAML fails later at build time, as upstream. Part of #144 / #162 (slice S5 — do not auto-close). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
timothy added 3 commits 2026-07-07 17:25:04 +02:00
- CreatePlayoutRequest now carries a PlayoutScheduleKind discriminator, a
  nullable ProgramScheduleId, and a ScheduleFile so POST /api/playouts can
  create Classic, Block, Sequential, Scripted, or ExternalJson playouts (not
  just Classic). ToCommand() validates per-kind requirements and returns
  Either<BaseError, CreatePlayout>, surfacing 422 on mismatched fields via the
  existing ToErrorResult() mapping.
- Add PUT /api/playouts/{id} (UpdatePlayoutDetailsRequest): DailyRebuildTime is
  always applied (null clears the daily reset, matching the Blazor
  SchedulePlayoutReset "Do not automatically reset" semantics); ScheduleFile is
  only valid for Sequential/Scripted/ExternalJson playouts (422 otherwise) and
  dispatches the matching Update*Playout command.
- Playout existence is checked via GetPlayoutById (real 404) before dispatching
  UpdatePlayout, since the command's own "Playout does not exist." validation
  produces a plain BaseError (422), not NotFoundError -- an existing quirk in
  UpdatePlayoutHandler left as-is (out of scope for this slice).
- Extend ApiErrorResponseMetadataTests + PlayoutControllerTests for the new
  Update action and the widened Create action (block/sequential/file-kind
  validation paths).
- Regenerate ErsatzTV/wwwroot/openapi/v1.json via update-openapi.sh.
Regenerate v1.d.ts from the updated OpenAPI spec and add createPlayout()/
updatePlayoutDetails() to the playouts API client, with URL/body-assert tests
following the ffmpegProfiles.test.ts pattern.
feat(web): wire up Add Playout dialog and playout-details editing (#144 S5 (#162))
Build ErsatzTV Image / Build & test (.NET) (pull_request) Failing after 42s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 3m36s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
605b325370
- Enable the previously-disabled "Add Playout" button on the Playouts screen:
  a new dialog picks kind (Classic/Block/Sequential/Scripted/ExternalJson),
  channel (annotating channels that already appear in the loaded playouts list
  as "already has a playout" -- the channel list DTO has no playout-count
  field, so this is a best-effort annotation; a real conflict still surfaces
  via the server's 422 in the dialog's error banner), a schedule picker for
  Classic, and a schedule-file input with the same helper text as the Blazor
  PlayoutEditor for the file-backed kinds. On success the new playout is
  selected and the list refreshes.
- Add an "Edit details" affordance on the Playout detail card: a dialog to set
  the daily reset time (half-hour options mirroring SchedulePlayoutReset.razor,
  plus "Do not automatically reset") and, for Sequential/Scripted/ExternalJson
  playouts, the schedule file.
- Add App.test.tsx coverage: classic-playout creation (asserts the POST body
  and dialog close), inline 422 error surfacing, daily-rebuild-time edit
  (asserts the PUT body), and schedule-file-field visibility gated by kind.
  Extends mockDashboardApi with method-aware POST /api/playouts and
  PUT /api/playouts/{id} handling.
timothy added 1 commit 2026-07-07 17:28:16 +02:00
fix(web): derive schedules-loading state instead of sync setState in effect (lint)
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 4m25s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 4m43s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
15f2beb7f9
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
timothy added 1 commit 2026-07-07 17:30:41 +02:00
fix(api): apply schedule-file update before daily rebuild time in PUT /api/playouts/{id} (#170 review)
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 4m24s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 4m38s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
f06bc064a0
A rejected scripted schedule file no longer leaves DailyRebuildTime
half-applied; the file update is the only fallible step post-pre-check.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Author
Owner

Adversarial review complete — no must-fix findings. Disposition:

Applied:

  • 15f2beb7 — CI lint failure + review should-fix 2 in one: the AddPlayoutDialog schedules effect called setState synchronously (lint error) and had no .catch on getSchedules(). Now: loading is derived (kind === 'Classic' && schedules === null), fetch happens lazily once, rejection falls back to an empty list (submit stays blocked by canSubmit).
  • f06bc064 — review should-fix 1: PUT /api/playouts/{id} now applies the fallible schedule-file update before UpdatePlayout, so a rejected scripted file path no longer persists a half-applied dailyRebuildTime.

Noted, not changed (by design): PUT-replace semantics for dailyRebuildTime (documented in the endpoint description; SPA always sends both fields); Classic+scheduleFile extra fields silently ignored (lenient, matches documented per-kind requirements); scheduleKind: "None" correctly 422s.

Folded into existing backlog nits: new PUT route lacks Name= (same as Create/Delete); GetPlayoutById (3 Includes) reused as existence pre-check; AddPlayoutDialog fetches channels/schedules even when never opened; edit dialog's half-hour picker can't display API-set odd values like 06:15:00 (preserved on save, cosmetic).

**Adversarial review complete** — no must-fix findings. Disposition: **Applied:** - `15f2beb7` — CI lint failure + review should-fix 2 in one: the AddPlayoutDialog schedules effect called `setState` synchronously (lint error) and had no `.catch` on `getSchedules()`. Now: loading is *derived* (`kind === 'Classic' && schedules === null`), fetch happens lazily once, rejection falls back to an empty list (submit stays blocked by `canSubmit`). - `f06bc064` — review should-fix 1: `PUT /api/playouts/{id}` now applies the fallible schedule-file update **before** `UpdatePlayout`, so a rejected scripted file path no longer persists a half-applied `dailyRebuildTime`. **Noted, not changed (by design):** PUT-replace semantics for `dailyRebuildTime` (documented in the endpoint description; SPA always sends both fields); Classic+`scheduleFile` extra fields silently ignored (lenient, matches documented per-kind requirements); `scheduleKind: "None"` correctly 422s. **Folded into existing backlog nits:** new PUT route lacks `Name=` (same as Create/Delete); `GetPlayoutById` (3 Includes) reused as existence pre-check; AddPlayoutDialog fetches channels/schedules even when never opened; edit dialog's half-hour picker can't display API-set odd values like `06:15:00` (preserved on save, cosmetic).
timothy merged commit a228927b4f into main 2026-07-07 18:09:57 +02:00
timothy deleted branch feat/144-s5-playout-create 2026-07-07 18:09:57 +02:00
Sign in to join this conversation.