Backend: extend channel list API for the management table (group, enabled, EPG visibility) #96

Closed
opened 2026-07-02 18:48:48 +02:00 by timothy · 1 comment
Owner

The Channels screen (#84) recreates design-system/templates/chicorytv-admin/Channels.jsx, which per channel renders a group header (c.group), a (D) marker when disabled (!c.enabled), an (H) marker when hidden from EPG (!c.epg), and dims disabled rows. But the list endpoint GET /api/channels returns ChannelResponseModel = id, number, name, ffmpegProfile, language, streamingMode — it is missing group, isEnabled, showInEpg.

These fields already exist on the Channel entity (ErsatzTV.Core/Domain/Channel.cs) and are already writable via UpdateChannelRequest; only the read projection drops them.

Do

  • Add Group, IsEnabled, ShowInEpg to ChannelResponseModel (ErsatzTV.Core/Api/Channels/ChannelResponseModel.cs) and Mapper.ProjectToResponseModel (ErsatzTV.Application/Channels/Mapper.cs).
  • Include SortNumber (already on the entity) so the table can order/group deterministically; consider Categories.
  • Regenerate the SPA OpenAPI types (web/scripts/generate-openapi-types.mjs → web/src/api/generated/v1.d.ts).
  • No DB migration — fields already exist.

Acceptance: GET /api/channels returns group, isEnabled, showInEpg (and sortNumber) so #84 can render grouping, (D)/(H) markers, and disabled-dimming from live data. Streaming-mode + FFmpeg-profile badges are already covered by the existing DTO.

Supports #84. Root cause: the redesign backend epic #62 scoped only the Channel Builder/create flow, so the management-table read fields were never audited. Parent: #59.

The Channels screen (#84) recreates `design-system/templates/chicorytv-admin/Channels.jsx`, which per channel renders a **group header** (`c.group`), a **(D)** marker when disabled (`!c.enabled`), an **(H)** marker when hidden from EPG (`!c.epg`), and dims disabled rows. But the list endpoint `GET /api/channels` returns `ChannelResponseModel` = `id, number, name, ffmpegProfile, language, streamingMode` — it is **missing `group`, `isEnabled`, `showInEpg`**. These fields already exist on the `Channel` entity (`ErsatzTV.Core/Domain/Channel.cs`) and are already writable via `UpdateChannelRequest`; only the read projection drops them. **Do** - Add `Group`, `IsEnabled`, `ShowInEpg` to `ChannelResponseModel` (`ErsatzTV.Core/Api/Channels/ChannelResponseModel.cs`) and `Mapper.ProjectToResponseModel` (`ErsatzTV.Application/Channels/Mapper.cs`). - Include `SortNumber` (already on the entity) so the table can order/group deterministically; consider `Categories`. - Regenerate the SPA OpenAPI types (`web/scripts/generate-openapi-types.mjs` → `web/src/api/generated/v1.d.ts`). - **No DB migration** — fields already exist. **Acceptance:** `GET /api/channels` returns `group`, `isEnabled`, `showInEpg` (and sortNumber) so #84 can render grouping, (D)/(H) markers, and disabled-dimming from live data. Streaming-mode + FFmpeg-profile badges are already covered by the existing DTO. Supports #84. Root cause: the redesign backend epic #62 scoped only the Channel Builder/create flow, so the management-table read fields were never audited. Parent: #59.
timothy added the api label 2026-07-02 18:48:48 +02:00
timothy added a new dependency 2026-07-02 18:48:48 +02:00
Author
Owner

Done

What was done: Extended GET /api/channels ChannelResponseModel with sortNumber, group, categories, isEnabled, and showInEpg; projected those fields from the existing Channel entity; regenerated the static OpenAPI document and SPA TypeScript API types. Added coverage for both the runtime projection and the OpenAPI schema contract.

Root cause: The redesign backend epic #62 covered the Channel Builder/create flow, but the Channels management-table read model was not audited; the fields already existed on the entity and write DTOs, but the list projection dropped them.

Files changed: ErsatzTV.Core/Api/Channels/ChannelResponseModel.cs, ErsatzTV.Application/Channels/Mapper.cs, ErsatzTV.Tests/Application/Channels/GetAllChannelsForApiHandlerTests.cs, ErsatzTV.Tests/Controllers/OpenApiErrorResponseContractTests.cs, ErsatzTV/wwwroot/openapi/v1.json, web/src/api/generated/v1.d.ts.

Verification: Red test first: targeted OpenAPI contract test failed on missing group. Final checks passed: /usr/bin/env TZ=UTC dotnet test ErsatzTV.Tests/ErsatzTV.Tests.csproj --filter "FullyQualifiedName~GetAllChannelsForApiHandlerTests|FullyQualifiedName~OpenApiErrorResponseContractTests.Static_OpenApi_Should_Document_Channel_List_Management_Fields" -v minimal; cd web && npm run check:api; cd web && npm run lint; cd web && npm test -- --run (29 passed); cd web && npm run build.

Deferred: #84 still needs to consume the enriched fields in the SPA Channels screen.

Follow-up issues: none created.

Docs updated: OpenAPI document and generated SPA API types updated; no narrative docs needed.

## Done **What was done**: Extended `GET /api/channels` `ChannelResponseModel` with `sortNumber`, `group`, `categories`, `isEnabled`, and `showInEpg`; projected those fields from the existing `Channel` entity; regenerated the static OpenAPI document and SPA TypeScript API types. Added coverage for both the runtime projection and the OpenAPI schema contract. **Root cause**: The redesign backend epic #62 covered the Channel Builder/create flow, but the Channels management-table read model was not audited; the fields already existed on the entity and write DTOs, but the list projection dropped them. **Files changed**: `ErsatzTV.Core/Api/Channels/ChannelResponseModel.cs`, `ErsatzTV.Application/Channels/Mapper.cs`, `ErsatzTV.Tests/Application/Channels/GetAllChannelsForApiHandlerTests.cs`, `ErsatzTV.Tests/Controllers/OpenApiErrorResponseContractTests.cs`, `ErsatzTV/wwwroot/openapi/v1.json`, `web/src/api/generated/v1.d.ts`. **Verification**: Red test first: targeted OpenAPI contract test failed on missing `group`. Final checks passed: `/usr/bin/env TZ=UTC dotnet test ErsatzTV.Tests/ErsatzTV.Tests.csproj --filter "FullyQualifiedName~GetAllChannelsForApiHandlerTests|FullyQualifiedName~OpenApiErrorResponseContractTests.Static_OpenApi_Should_Document_Channel_List_Management_Fields" -v minimal`; `cd web && npm run check:api`; `cd web && npm run lint`; `cd web && npm test -- --run` (29 passed); `cd web && npm run build`. **Deferred**: #84 still needs to consume the enriched fields in the SPA Channels screen. **Follow-up issues**: none created. **Docs updated**: OpenAPI document and generated SPA API types updated; no narrative docs needed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Blocks
Reference: timothy/ersatztv#96