From cbcbfb41dbba7019fc7a523161902a953522f146 Mon Sep 17 00:00:00 2001 From: Victor Elias Date: Wed, 11 Sep 2024 22:43:37 +0100 Subject: [PATCH] api,www: Create `deleted` state for recordings (#2309) * api: Add deleted recordingStatus to streams * www: Display deleted recording status --- packages/api/src/controllers/asset.ts | 2 +- packages/api/src/controllers/stream.ts | 11 ++++++----- packages/api/src/schema/api-schema.yaml | 1 + .../www/components/Admin/Table-v2/cells/duration.tsx | 12 ++++++++---- packages/www/components/Table/cells/duration.tsx | 12 ++++++++---- 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/packages/api/src/controllers/asset.ts b/packages/api/src/controllers/asset.ts index 57acb6b8f4..1f1ea3741c 100644 --- a/packages/api/src/controllers/asset.ts +++ b/packages/api/src/controllers/asset.ts @@ -429,7 +429,7 @@ export async function withPlaybackUrls( asset: WithID, os?: ObjectStore, ): Promise> { - if (asset.files?.length < 1) { + if (asset.files?.length < 1 || asset.deleted) { // files is only set when playback is available return asset; } diff --git a/packages/api/src/controllers/stream.ts b/packages/api/src/controllers/stream.ts index 500b719b71..66a7c13acb 100644 --- a/packages/api/src/controllers/stream.ts +++ b/packages/api/src/controllers/stream.ts @@ -619,11 +619,12 @@ export async function getRecordingFields( const assetPhase = assetWithPlayback.status?.phase; return { recordingStatus: - assetPhase == "ready" - ? "ready" - : assetPhase == "failed" - ? "failed" - : "waiting", + { + ready: "ready", + failed: "failed", + deleting: "deleted", + deleted: "deleted", + }[assetPhase] ?? "waiting", recordingUrl: assetWithPlayback.playbackUrl, mp4Url: assetWithPlayback.downloadUrl, }; diff --git a/packages/api/src/schema/api-schema.yaml b/packages/api/src/schema/api-schema.yaml index 0fef17f167..ab4e8f8fe0 100644 --- a/packages/api/src/schema/api-schema.yaml +++ b/packages/api/src/schema/api-schema.yaml @@ -941,6 +941,7 @@ components: - waiting - ready - failed + - deleted - none recordingUrl: type: string diff --git a/packages/www/components/Admin/Table-v2/cells/duration.tsx b/packages/www/components/Admin/Table-v2/cells/duration.tsx index f6e2361151..5e39a34565 100644 --- a/packages/www/components/Admin/Table-v2/cells/duration.tsx +++ b/packages/www/components/Admin/Table-v2/cells/duration.tsx @@ -11,14 +11,18 @@ export type DurationCellProps = { const DurationCell = ({ cell, }: CellComponentProps) => { - if (cell.value.status === "waiting") { - return "In progress"; - } else if (cell.value.status === "failed") { - return "Failed"; + switch (cell.value.status) { + case "waiting": + return "In progress"; + case "failed": + return "Failed"; + case "deleted": + return "Deleted"; } if (cell.value.duration === 0 || cell.value.status !== "ready") { return "n/a"; } + try { const dur = intervalToDuration({ start: new Date(0), diff --git a/packages/www/components/Table/cells/duration.tsx b/packages/www/components/Table/cells/duration.tsx index bc81ebc5c7..27fc9f575c 100644 --- a/packages/www/components/Table/cells/duration.tsx +++ b/packages/www/components/Table/cells/duration.tsx @@ -10,10 +10,13 @@ export type DurationCellProps = { const DurationCell = ({ cell, }: CellComponentProps) => { - if (cell.value.status === "waiting") { - return "In progress"; - } else if (cell.value.status === "failed") { - return "Failed"; + switch (cell.value.status) { + case "waiting": + return "In progress"; + case "failed": + return "Failed"; + case "deleted": + return "Deleted"; } if ( cell.value.sourceSegmentsDuration === 0 || @@ -21,6 +24,7 @@ const DurationCell = ({ ) { return "n/a"; } + try { const durationMins = Math.round(cell.value.sourceSegmentsDuration / 60); if (!durationMins) {