Skip to content

Commit dd70ae0

Browse files
committed
fix: ograf signature to match existing
1 parent 1e752b0 commit dd70ae0

2 files changed

Lines changed: 65 additions & 46 deletions

File tree

‎backend/src/background/api/settings.ts‎

Lines changed: 52 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { mutations as typeManifestMutations } from './typeManifests'
1515
import { Server, Socket } from 'socket.io'
1616
import { ografHandler } from '../ografHandler'
1717
import { getDefaultDataFromSchema } from '../lib/ograf-default-data'
18+
import * as OGraf from 'ograf'
1819

1920
export const mutations = {
2021
async create(
@@ -126,6 +127,8 @@ export function registerSettingsHandlers(socket: Socket, _io: Server) {
126127
{
127128
const ografs = await ografHandler.loadGraphics(payload)
128129

130+
console.log(`Loaded ${ografs.length} graphics from OGraf server`)
131+
129132
const readPieceManifests = await typeManifestMutations.read({
130133
entityType: TypeManifestEntity.Piece
131134
})
@@ -134,47 +137,20 @@ export function registerSettingsHandlers(socket: Socket, _io: Server) {
134137
if (readPieceManifests && Array.isArray(readPieceManifests.result))
135138
pieceManifests = readPieceManifests.result
136139

137-
const OGRAF_GRAPHICS_ID_PREFIX = 'ograf_graphic_'
138140
for (const ograf of ografs) {
139-
const id = `${OGRAF_GRAPHICS_ID_PREFIX}${ograf.id}`
140-
const name = `OGraf: ${ograf.name}`
141-
const shortName = ograf.name
142-
const payload: PayloadManifest[] = [
143-
{
144-
id: 'data',
145-
label: 'Data',
146-
type: ManifestFieldType.OGrafForm,
147-
defaultValue: getDefaultDataFromSchema(ograf.manifest.schema),
148-
includeInName: true,
149-
ografManifest: ograf.manifest
150-
}
151-
]
141+
const typeManifest = getOGrafManifest(ograf.id, ograf.manifest)
152142

153143
const existingPieceManifest = pieceManifests.find(
154-
(pieceManifest) => pieceManifest.id === id
144+
(pieceManifest) => pieceManifest.id === typeManifest.id
155145
)
156146
if (!existingPieceManifest) {
157-
await typeManifestMutations.create({
158-
id,
159-
entityType: TypeManifestEntity.Piece,
160-
name,
161-
shortName,
162-
colour: '#FFCC00',
163-
includeTypeInName: true,
164-
payload
165-
})
147+
console.log(`Creating new piece manifest for OGraf graphic ${typeManifest.id}`)
148+
await typeManifestMutations.create(typeManifest)
166149
} else {
150+
console.log(`Updating existing piece manifest for OGraf graphic ${typeManifest.id}`)
167151
await typeManifestMutations.update({
168-
id,
169-
update: {
170-
id,
171-
// entityType: TypeManifestEntity.Piece,
172-
colour: existingPieceManifest.colour ?? '#FFCC00',
173-
// includeTypeInName: existingPieceManifest.includeTypeInName ?? true,
174-
name,
175-
shortName,
176-
payload
177-
}
152+
id: typeManifest.id,
153+
update: typeManifest
178154
})
179155
}
180156
}
@@ -235,3 +211,45 @@ export async function initializeDefaults(force: boolean = false): Promise<void>
235211
}
236212
}
237213
}
214+
215+
function getOGrafManifest(id: string, manifest: OGraf.GraphicsManifest): TypeManifest {
216+
return {
217+
id: `ograf-${id}`,
218+
colour: '#5555ff',
219+
entityType: TypeManifestEntity.Piece,
220+
name: `${manifest.name}`,
221+
shortName: 'OGraf',
222+
includeTypeInName: true,
223+
224+
payload: [
225+
{
226+
id: 'ograf-id',
227+
label: 'OGraf Id',
228+
type: ManifestFieldType.Const,
229+
defaultValue: id
230+
},
231+
{
232+
id: 'type',
233+
label: 'Type of Graphics',
234+
type: ManifestFieldType.Enum,
235+
enumValues: [
236+
{ label: 'Full Screen', value: 'full-screen' },
237+
{ label: 'Overlay 1', value: 'overlay1' },
238+
{ label: 'Overlay 2', value: 'overlay2' },
239+
{ label: 'Overlay 3', value: 'overlay3' },
240+
{ label: 'Studio Screen 1', value: 'studio1' },
241+
{ label: 'Studio Screen 2', value: 'studio2' },
242+
{ label: 'Studio Screen 3', value: 'studio3' }
243+
],
244+
defaultValue: 'overlay1'
245+
},
246+
{
247+
id: 'ograf-data',
248+
label: 'OGraf Data',
249+
type: ManifestFieldType.OGrafForm,
250+
ografManifest: manifest,
251+
defaultValue: manifest.schema ? getDefaultDataFromSchema(manifest.schema) : undefined
252+
}
253+
]
254+
} satisfies TypeManifest
255+
}

‎frontend/src/components/settings/typeManifestForm/lib/importOGrafManifest.ts‎

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,9 @@ export function isImportOGrafManifest(data: unknown): data is OGraf.GraphicsMani
1818
manifest.$schema === 'https://ograf.ebu.io/v1/specification/json-schemas/graphics/schema.json'
1919
)
2020
}
21-
export async function doImportOGrafManifest(
22-
manifest: OGraf.GraphicsManifest,
23-
typeManifests: TypeManifest[],
24-
dispatch: AppDispatch
25-
) {
26-
const id = `ograf-${manifest.id}`
27-
28-
const existing = typeManifests.find((m) => m.id === id)
29-
30-
const typeManifest: TypeManifest = {
31-
id,
21+
function getOGrafManifest(id: string, manifest: OGraf.GraphicsManifest): TypeManifest {
22+
return {
23+
id: `ograf-${id}`,
3224
colour: '#5555ff',
3325
entityType: 'piece' as TypeManifestEntity,
3426
name: manifest.name,
@@ -62,7 +54,16 @@ export async function doImportOGrafManifest(
6254
defaultValue: getDefaultDataFromSchema(manifest.schema)
6355
}
6456
]
65-
}
57+
} satisfies TypeManifest
58+
}
59+
export async function doImportOGrafManifest(
60+
manifest: OGraf.GraphicsManifest,
61+
typeManifests: TypeManifest[],
62+
dispatch: AppDispatch
63+
) {
64+
const typeManifest = getOGrafManifest(manifest.id, manifest)
65+
66+
const existing = typeManifests.find((m) => m.id === typeManifest.id)
6667

6768
if (existing) {
6869
await dispatch(updateTypeManifest({ originalId: existing.id, typeManifest }))

0 commit comments

Comments
 (0)