From 4a980c62540b1803ccd89ed5b9326d7650671221 Mon Sep 17 00:00:00 2001 From: Sandra Larsson Date: Fri, 1 Nov 2024 15:30:55 +0100 Subject: [PATCH 1/4] fix: bug html creation (#71) --- src/app/production/[id]/page.tsx | 9 ++++++++- .../modal/renderingEngineModals/CreateHtmlModal.tsx | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/app/production/[id]/page.tsx b/src/app/production/[id]/page.tsx index 57986804..722329ce 100644 --- a/src/app/production/[id]/page.tsx +++ b/src/app/production/[id]/page.tsx @@ -152,8 +152,15 @@ export default function ProductionConfiguration({ params }: PageProps) { const memoizedProduction = useMemo(() => productionSetup, [productionSetup]); + const pipelinesAreSelected = + productionSetup?.production_settings.pipelines.some( + (pipeline) => pipeline.pipeline_id === undefined + ) === false; + const isAddButtonDisabled = - (selectedValue !== 'HTML' && selectedValue !== 'Media Player') || locked; + (selectedValue !== 'HTML' && selectedValue !== 'Media Player') || + locked || + !pipelinesAreSelected; useEffect(() => { refreshPipelines(); diff --git a/src/components/modal/renderingEngineModals/CreateHtmlModal.tsx b/src/components/modal/renderingEngineModals/CreateHtmlModal.tsx index c856e9af..a186d3fa 100644 --- a/src/components/modal/renderingEngineModals/CreateHtmlModal.tsx +++ b/src/components/modal/renderingEngineModals/CreateHtmlModal.tsx @@ -53,12 +53,12 @@ export function CreateHtmlModal({ const handleCreate = () => { let hasError = false; - if (!height || height < 20) { + if (!height || height < 20 || height > 8192) { setHeightError(true); hasError = true; } - if (!width || width < 20) { + if (!width || width < 20 || width > 8192) { setWidthError(true); hasError = true; } From d49a6e56f5acacfcf2770e64f4101210cb39a96c Mon Sep 17 00:00:00 2001 From: Sandra Larsson Date: Mon, 4 Nov 2024 09:15:35 +0100 Subject: [PATCH 2/4] fix: production page crash, undefined (#72) --- src/app/production/[id]/page.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/app/production/[id]/page.tsx b/src/app/production/[id]/page.tsx index 722329ce..b1ec1e36 100644 --- a/src/app/production/[id]/page.tsx +++ b/src/app/production/[id]/page.tsx @@ -152,10 +152,11 @@ export default function ProductionConfiguration({ params }: PageProps) { const memoizedProduction = useMemo(() => productionSetup, [productionSetup]); - const pipelinesAreSelected = - productionSetup?.production_settings.pipelines.some( - (pipeline) => pipeline.pipeline_id === undefined - ) === false; + const pipelinesAreSelected = productionSetup?.production_settings + ? productionSetup?.production_settings.pipelines.some( + (pipeline) => pipeline.pipeline_id === undefined + ) === false + : false; const isAddButtonDisabled = (selectedValue !== 'HTML' && selectedValue !== 'Media Player') || From 65097e09afd006d97ecd72b76867d10a59d1c0f1 Mon Sep 17 00:00:00 2001 From: Linda Malm <109201562+malmen237@users.noreply.github.com> Date: Mon, 4 Nov 2024 11:17:44 +0100 Subject: [PATCH 3/4] fix: when srt-source is active it updates db with metadata (#74) --- src/api/manager/job/syncInventory.ts | 50 +++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/src/api/manager/job/syncInventory.ts b/src/api/manager/job/syncInventory.ts index f92186bd..2cb8864d 100644 --- a/src/api/manager/job/syncInventory.ts +++ b/src/api/manager/job/syncInventory.ts @@ -4,6 +4,7 @@ import { getIngests, getIngest } from '../../ateliereLive/ingest'; import { upsertSource } from '../sources'; import { getDatabase } from '../../mongoClient/dbClient'; import { WithId } from 'mongodb'; +import { API_SECRET_KEY } from '../../../utils/constants'; type SourceWithoutLastConnected = Omit; @@ -81,6 +82,41 @@ export async function runSyncInventory() { } }; + const updateSrtMetadata = ( + inventorySource: WithId, + apiSource: SourceWithoutLastConnected + ) => { + if ( + apiSource.status === 'new' && + apiSource.ingest_type === 'SRT' && + apiSource.srt && + apiSource.srt.video_format && + inventorySource.srt + ) { + const updatedSrt = { + ...inventorySource.srt, + video_format: apiSource.srt.video_format + }; + fetch('/api/manager/inventory', { + method: 'POST', + body: JSON.stringify({ + source: updatedSrt + }), + headers: [['x-api-key', `Bearer ${API_SECRET_KEY}`]] + }); + + return updatedSrt; + } else if ( + apiSource.ingest_type === 'SRT' && + !inventorySource.srt && + apiSource.srt + ) { + return apiSource.srt; + } else { + return inventorySource.srt; + } + }; + // Update status of all sources in the inventory to the status found in API. // If a source is not found in the API, it is marked as gone. const dbInventoryWithCorrectStatus = dbInventory.map((inventorySource) => { @@ -105,12 +141,16 @@ export async function runSyncInventory() { ...inventorySource, status: statusUpdateCheck(inventorySource, apiSource, lastConnected), lastConnected: lastConnected, + video_stream: + apiSource.ingest_type === 'SRT' && apiSource.status === 'gone' + ? inventorySource.video_stream + : apiSource.video_stream, + audio_stream: + apiSource.ingest_type === 'SRT' && apiSource.status === 'gone' + ? inventorySource.audio_stream + : apiSource.audio_stream, // Add srt metadata if missing from SRT sources - srt: - (apiSource.ingest_type === 'SRT' && - !inventorySource.srt && - apiSource.srt) || - inventorySource.srt + srt: updateSrtMetadata(inventorySource, apiSource) } satisfies WithId; }); From 60bf6fe196dcd1b11203ddf23b78fb15f3a6535c Mon Sep 17 00:00:00 2001 From: Sandra Larsson Date: Mon, 4 Nov 2024 11:18:00 +0100 Subject: [PATCH 4/4] fix: error handling stop production (#73) * fix: error handling stop production * fix: test fails --- .../renderingengine/renderingengine.ts | 26 +++++++++++++++++-- src/api/manager/workflow.ts | 16 +++++++----- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/api/ateliereLive/pipelines/renderingengine/renderingengine.ts b/src/api/ateliereLive/pipelines/renderingengine/renderingengine.ts index 68507b9d..15cb7428 100644 --- a/src/api/ateliereLive/pipelines/renderingengine/renderingengine.ts +++ b/src/api/ateliereLive/pipelines/renderingengine/renderingengine.ts @@ -529,11 +529,33 @@ export async function getPipelineRenderingEngine( method: 'GET', headers: { authorization: getAuthorizationHeader() + }, + next: { + revalidate: 0 } } ); + if (response.ok) { - return await response.json(); + try { + return await response.json(); + } catch (error) { + console.error('Failed to parse successful JSON response:', error); + throw new Error('Parsing error in successful response.'); + } + } + + const contentType = response.headers.get('content-type'); + const responseText = await response.text(); + + if (contentType && contentType.includes('application/json')) { + try { + throw JSON.parse(responseText); + } catch (error) { + console.error('Failed to parse JSON error response:', error); + throw new Error(`Failed to parse JSON error response: ${responseText}`); + } + } else { + throw new Error(`Unexpected non-JSON response: ${responseText}`); } - throw await response.json(); } diff --git a/src/api/manager/workflow.ts b/src/api/manager/workflow.ts index 6520377b..a9d7ca26 100644 --- a/src/api/manager/workflow.ts +++ b/src/api/manager/workflow.ts @@ -378,10 +378,12 @@ export async function stopProduction( } for (const source of production.sources) { - for (const stream_uuid of source.stream_uuids || []) { - await deleteStreamByUuid(stream_uuid).catch((error) => { - Log().error('Failed to delete stream! \nError: ', error); - }); + if (source.type === 'ingest_source') { + for (const stream_uuid of source.stream_uuids || []) { + await deleteStreamByUuid(stream_uuid).catch((error) => { + Log().error('Failed to delete stream! \nError: ', error); + }); + } } } @@ -441,7 +443,7 @@ export async function stopProduction( value: { step: 'remove_pipeline_streams', success: false, - message: 'Unexpected error occured' + message: `Error occurred when removing streams from pipeline: ${e}` } }; } else { @@ -464,7 +466,7 @@ export async function stopProduction( value: { step: 'remove_pipeline_multiviews', success: false, - message: 'Unexpected error occured' + message: `Error occurred when removing multiviews from pipeline: ${e}` } }; } else { @@ -638,7 +640,7 @@ export async function startProduction( return { ok: false, value: [{ step: 'streams', success: false }], - error: 'Could not setup streams: Unexpected error occured' + error: `Could not setup streams: Unexpected error occured: ${e}` }; } return {