|
| 1 | +import { useSubscription, useTracker } from '../../lib/ReactMeteorData/react-meteor-data' |
| 2 | +import { unprotectString } from '../../lib/tempLib' |
| 3 | +import { makeTableOfObject } from '../../lib/utilComponents' |
| 4 | +import { PeripheralDeviceId } from '@sofie-automation/corelib/dist/dataModel/Ids' |
| 5 | +import { PeripheralDevicePubSub } from '@sofie-automation/shared-lib/dist/pubsub/peripheralDevice' |
| 6 | +import { useTranslation } from 'react-i18next' |
| 7 | +import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub' |
| 8 | +import { PeripheralDevices } from '../../collections' |
| 9 | +import { Link } from 'react-router-dom' |
| 10 | +import { PeripheralDeviceCategory } from '@sofie-automation/shared-lib/dist/peripheralDevice/peripheralDeviceAPI' |
| 11 | +import { IngestRundownStatuses } from './collections' |
| 12 | +import { IngestPartStatus, IngestRundownStatus } from '@sofie-automation/shared-lib/dist/ingest/rundownStatus' |
| 13 | + |
| 14 | +interface IMappingsViewProps { |
| 15 | + match?: { |
| 16 | + params?: { |
| 17 | + peripheralDeviceId: PeripheralDeviceId |
| 18 | + } |
| 19 | + } |
| 20 | +} |
| 21 | +function IngestRundownStatusView(props: Readonly<IMappingsViewProps>): JSX.Element { |
| 22 | + const { t } = useTranslation() |
| 23 | + |
| 24 | + return ( |
| 25 | + <div className="mtl gutter"> |
| 26 | + <header className="mvs"> |
| 27 | + <h1>{t('Ingest Rundown Status')}</h1> |
| 28 | + </header> |
| 29 | + <div className="mod mvl"> |
| 30 | + {props.match && props.match.params && ( |
| 31 | + <ComponentMappingsTable peripheralDeviceId={props.match.params.peripheralDeviceId} /> |
| 32 | + )} |
| 33 | + </div> |
| 34 | + </div> |
| 35 | + ) |
| 36 | +} |
| 37 | + |
| 38 | +interface ComponentMappingsTableProps { |
| 39 | + peripheralDeviceId: PeripheralDeviceId |
| 40 | +} |
| 41 | +function ComponentMappingsTable({ peripheralDeviceId }: Readonly<ComponentMappingsTableProps>): JSX.Element { |
| 42 | + useSubscription(PeripheralDevicePubSub.ingestDeviceRundownStatus, peripheralDeviceId) |
| 43 | + |
| 44 | + const rundowns = useTracker(() => IngestRundownStatuses.find({}).fetch(), [], []) |
| 45 | + |
| 46 | + return ( |
| 47 | + <> |
| 48 | + {rundowns.map((rundown) => ( |
| 49 | + <StatusesForRundown key={rundown.externalId} rundown={rundown} /> |
| 50 | + ))} |
| 51 | + </> |
| 52 | + ) |
| 53 | +} |
| 54 | + |
| 55 | +function StatusesForRundown({ rundown }: { rundown: IngestRundownStatus }): JSX.Element { |
| 56 | + return ( |
| 57 | + <div className="mbl"> |
| 58 | + <h3> |
| 59 | + {rundown.externalId} ({unprotectString(rundown._id)}) |
| 60 | + </h3> |
| 61 | + |
| 62 | + <p>Status: {rundown.active}</p> |
| 63 | + |
| 64 | + <table className="testtools-timelinetable mll"> |
| 65 | + <tbody> |
| 66 | + <tr> |
| 67 | + <th>Segment Id</th> |
| 68 | + <th>Part Id</th> |
| 69 | + <th>Ready</th> |
| 70 | + <th>Status</th> |
| 71 | + <th>Items</th> |
| 72 | + </tr> |
| 73 | + {rundown.segments.flatMap((segment) => |
| 74 | + segment.parts.map((part) => ( |
| 75 | + <StatusesForSegmentRow key={segment.externalId} part={part} segmentId={segment.externalId} /> |
| 76 | + )) |
| 77 | + )} |
| 78 | + </tbody> |
| 79 | + </table> |
| 80 | + |
| 81 | + <p></p> |
| 82 | + </div> |
| 83 | + ) |
| 84 | +} |
| 85 | + |
| 86 | +interface StatusesForSegmentRowProps { |
| 87 | + segmentId: string |
| 88 | + part: IngestPartStatus |
| 89 | +} |
| 90 | +function StatusesForSegmentRow({ segmentId, part }: Readonly<StatusesForSegmentRowProps>) { |
| 91 | + return ( |
| 92 | + <tr> |
| 93 | + <td>{segmentId}</td> |
| 94 | + <td>{part.externalId}</td> |
| 95 | + <td>{JSON.stringify(part.isReady)}</td> |
| 96 | + <td>{part.playbackStatus}</td> |
| 97 | + <td>{makeTableOfObject(part.itemsReady)}</td> |
| 98 | + </tr> |
| 99 | + ) |
| 100 | +} |
| 101 | + |
| 102 | +function IngestRundownStatusSelect(): JSX.Element | null { |
| 103 | + const { t } = useTranslation() |
| 104 | + |
| 105 | + useSubscription(CorelibPubSub.peripheralDevices, null) |
| 106 | + const devices = useTracker(() => PeripheralDevices.find({ category: PeripheralDeviceCategory.INGEST }).fetch(), []) |
| 107 | + |
| 108 | + return ( |
| 109 | + <div className="mhl gutter recordings-studio-select"> |
| 110 | + <header className="mbs"> |
| 111 | + <h1>{t('Ingest Rundown Statuses')}</h1> |
| 112 | + </header> |
| 113 | + <div className="mod mvl"> |
| 114 | + <strong>Peripheral Device</strong> |
| 115 | + <ul> |
| 116 | + {devices?.map((device) => ( |
| 117 | + <li key={unprotectString(device._id)}> |
| 118 | + <Link to={`ingestRundownStatus/${device._id}`}>{device.name}</Link> |
| 119 | + </li> |
| 120 | + ))} |
| 121 | + </ul> |
| 122 | + </div> |
| 123 | + </div> |
| 124 | + ) |
| 125 | +} |
| 126 | + |
| 127 | +export { IngestRundownStatusView, IngestRundownStatusSelect } |
0 commit comments