Skip to content

Commit

Permalink
api,www: Create deleted state for recordings (#2309)
Browse files Browse the repository at this point in the history
* api: Add deleted recordingStatus to streams

* www: Display deleted recording status
  • Loading branch information
victorges authored Sep 11, 2024
1 parent 7d18e36 commit cbcbfb4
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion packages/api/src/controllers/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ export async function withPlaybackUrls(
asset: WithID<Asset>,
os?: ObjectStore,
): Promise<WithID<Asset>> {
if (asset.files?.length < 1) {
if (asset.files?.length < 1 || asset.deleted) {
// files is only set when playback is available
return asset;
}
Expand Down
11 changes: 6 additions & 5 deletions packages/api/src/controllers/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/schema/api-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,7 @@ components:
- waiting
- ready
- failed
- deleted
- none
recordingUrl:
type: string
Expand Down
12 changes: 8 additions & 4 deletions packages/www/components/Admin/Table-v2/cells/duration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ export type DurationCellProps = {
const DurationCell = <D extends TableData>({
cell,
}: CellComponentProps<D, DurationCellProps>) => {
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),
Expand Down
12 changes: 8 additions & 4 deletions packages/www/components/Table/cells/duration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@ export type DurationCellProps = {
const DurationCell = <D extends TableData>({
cell,
}: CellComponentProps<D, DurationCellProps>) => {
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 ||
cell.value.status !== "ready"
) {
return "n/a";
}

try {
const durationMins = Math.round(cell.value.sourceSegmentsDuration / 60);
if (!durationMins) {
Expand Down

0 comments on commit cbcbfb4

Please sign in to comment.