Skip to content

Commit f4a1c6b

Browse files
committed
fix: update to match latest ograf (wip) definition
1 parent b06a820 commit f4a1c6b

File tree

17 files changed

+269
-500
lines changed

17 files changed

+269
-500
lines changed

packages/controller/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"jsonschema": "^1.4.1",
3232
"mobx": "^6.15.0",
3333
"mobx-react": "^9.2.1",
34-
"ograf": "1.0.1-nightly-feat-server-api-wip-20251112-165910-35360d9.0",
34+
"ograf": "1.0.1-nightly-feat-server-api-20251119-200040-a6d74dc.0",
3535
"ograf-form": "^0.1.3",
3636
"react": "^19.2.0",
3737
"react-dom": "^19.2.0",

packages/controller/src/components/GraphicsList.tsx

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export const QueuedGraphicItem = observer((props: { graphicKey: string }) => {
8080
const descriptions: string[] = []
8181

8282
if (graphic.graphic.description) descriptions.push(graphic.graphic.description)
83-
if (graphic.graphic.createdBy) descriptions.push(`by ${graphic.graphic.createdBy.name}`)
83+
if (graphic.metadata.createdBy) descriptions.push(`by ${graphic.metadata.createdBy.name}`)
8484

8585
return (
8686
<Card elevation={1} sx={{ m: 1, p: 1 }}>
@@ -121,12 +121,12 @@ export const QueuedGraphicItem = observer((props: { graphicKey: string }) => {
121121
/>
122122
</Box>
123123
<Box>{!queuedGraphic.renderTarget && <Typography color="error">No render target specified!</Typography>}</Box>
124-
{graphic.manifest.schema && (
124+
{graphic.graphic.schema && (
125125
<Box>
126126
<Typography>Graphics Data</Typography>
127127

128128
<OGrafForm
129-
schema={graphic.manifest.schema}
129+
schema={graphic.graphic.schema}
130130
value={clone(queuedGraphic.graphicData)}
131131
onDataChangeCallback={(newData: unknown) => {
132132
const q = appSettingsStore.queuedGraphics.get(props.graphicKey)
@@ -151,8 +151,8 @@ export const QueuedGraphicItem = observer((props: { graphicKey: string }) => {
151151
ografApi
152152
.renderTargetGraphicLoad(
153153
{ rendererId: renderer.id },
154-
{ renderTarget: queuedGraphic.renderTarget },
155154
{
155+
renderTarget: queuedGraphic.renderTarget,
156156
graphicId: queuedGraphic.graphicId,
157157
params: {
158158
data: toJS(queuedGraphic.graphicData),
@@ -195,8 +195,6 @@ export const QueuedGraphicItem = observer((props: { graphicKey: string }) => {
195195
{
196196
renderTarget: queuedGraphic.renderTarget,
197197
graphicInstanceId: gi.graphicInstanceId,
198-
},
199-
{
200198
params: {
201199
// delta
202200
// goto
@@ -220,8 +218,6 @@ export const QueuedGraphicItem = observer((props: { graphicKey: string }) => {
220218
{
221219
renderTarget: queuedGraphic.renderTarget,
222220
graphicInstanceId: gi.graphicInstanceId,
223-
},
224-
{
225221
params: {
226222
data: toJS(queuedGraphic.graphicData),
227223
// skipAnimation
@@ -244,8 +240,6 @@ export const QueuedGraphicItem = observer((props: { graphicKey: string }) => {
244240
{
245241
renderTarget: queuedGraphic.renderTarget,
246242
graphicInstanceId: gi.graphicInstanceId,
247-
},
248-
{
249243
params: {
250244
// skipAnimation
251245
},
@@ -265,10 +259,12 @@ export const QueuedGraphicItem = observer((props: { graphicKey: string }) => {
265259
.renderTargetGraphicClear(
266260
{ rendererId: renderer.id },
267261
{
268-
filters: {
269-
renderTarget: queuedGraphic.renderTarget,
270-
graphicInstanceId: gi.graphicInstanceId,
271-
},
262+
filters: [
263+
{
264+
renderTarget: queuedGraphic.renderTarget,
265+
graphicInstanceId: gi.graphicInstanceId,
266+
},
267+
],
272268
}
273269
)
274270
.then((r) => {
@@ -289,10 +285,10 @@ export const QueuedGraphicItem = observer((props: { graphicKey: string }) => {
289285
Clear
290286
</Button>
291287
</Box>
292-
{graphic.manifest.customActions && (
288+
{graphic.graphic.customActions && (
293289
<Box>
294290
<Typography>Custom Actions</Typography>
295-
{graphic.manifest.customActions?.map((action) => (
291+
{graphic.graphic.customActions?.map((action) => (
296292
<GraphicCustomAction
297293
key={action.id}
298294
rendererId={renderer.id}
@@ -318,7 +314,7 @@ const GraphicCustomAction = (props: {
318314
rendererId: string
319315
renderTarget: unknown
320316
graphicInstanceId: string
321-
graphic: OGraf.ServerApi.components['schemas']['GraphicInfo']
317+
graphic: OGraf.ServerApi.components['schemas']['GraphicManifest']
322318
graphicKey: string
323319
queuedGraphic: QueuedGraphic
324320
action: OGraf.ServerApi.components['schemas']['action']
@@ -359,8 +355,6 @@ const GraphicCustomAction = (props: {
359355
{
360356
renderTarget: renderTarget,
361357
graphicInstanceId: graphicInstanceId,
362-
},
363-
{
364358
actionName: action.name,
365359
params: {
366360
id: action.id,

packages/controller/src/lib/ografApi.ts

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,6 @@ export class OgrafApi {
366366
}
367367
async renderTargetGraphicLoad(
368368
params: ServerApi.paths['/renderers/{rendererId}/target/graphic/load']['put']['parameters']['path'],
369-
query: ServerApi.paths['/renderers/{rendererId}/target/graphic/load']['put']['parameters']['query'],
370369
body: ServerApi.paths['/renderers/{rendererId}/target/graphic/load']['put']['requestBody']['content']['application/json']
371370
): Promise<
372371
| {
@@ -386,7 +385,6 @@ export class OgrafApi {
386385
type Method = ServerApi.paths[typeof url]['put']
387386

388387
const url0 = new URL(url.replace('{rendererId}', params.rendererId), this.BASE_URL_TEMPLATE)
389-
url0.searchParams.set('renderTarget', JSON.stringify(query.renderTarget))
390388

391389
const response = await this.fetch<Method>(url0, false, {
392390
method: 'put',
@@ -402,7 +400,6 @@ export class OgrafApi {
402400
}
403401
async renderTargetGraphicUpdate(
404402
params: ServerApi.paths['/renderers/{rendererId}/target/graphic/updateAction']['post']['parameters']['path'],
405-
query: ServerApi.paths['/renderers/{rendererId}/target/graphic/updateAction']['post']['parameters']['query'],
406403
body: ServerApi.paths['/renderers/{rendererId}/target/graphic/updateAction']['post']['requestBody']['content']['application/json']
407404
): Promise<
408405
| {
@@ -423,8 +420,6 @@ export class OgrafApi {
423420
type Method = ServerApi.paths[typeof url][typeof method]
424421

425422
const url0 = new URL(url.replace('{rendererId}', params.rendererId), this.BASE_URL_TEMPLATE)
426-
url0.searchParams.set('renderTarget', JSON.stringify(query.renderTarget))
427-
url0.searchParams.set('graphicInstanceId', query.graphicInstanceId)
428423

429424
const response = await this.fetch<Method>(url0, false, {
430425
method,
@@ -440,7 +435,6 @@ export class OgrafApi {
440435
}
441436
async renderTargetGraphicPlay(
442437
params: ServerApi.paths['/renderers/{rendererId}/target/graphic/playAction']['post']['parameters']['path'],
443-
query: ServerApi.paths['/renderers/{rendererId}/target/graphic/playAction']['post']['parameters']['query'],
444438
body: ServerApi.paths['/renderers/{rendererId}/target/graphic/playAction']['post']['requestBody']['content']['application/json']
445439
): Promise<
446440
| {
@@ -461,8 +455,6 @@ export class OgrafApi {
461455
type Method = ServerApi.paths[typeof url][typeof method]
462456

463457
const url0 = new URL(url.replace('{rendererId}', params.rendererId), this.BASE_URL_TEMPLATE)
464-
url0.searchParams.set('renderTarget', JSON.stringify(query.renderTarget))
465-
url0.searchParams.set('graphicInstanceId', query.graphicInstanceId)
466458

467459
const response = await this.fetch<Method>(url0, false, {
468460
method,
@@ -478,7 +470,7 @@ export class OgrafApi {
478470
}
479471
async renderTargetGraphicStop(
480472
params: ServerApi.paths['/renderers/{rendererId}/target/graphic/stopAction']['post']['parameters']['path'],
481-
query: ServerApi.paths['/renderers/{rendererId}/target/graphic/stopAction']['post']['parameters']['query'],
473+
482474
body: ServerApi.paths['/renderers/{rendererId}/target/graphic/stopAction']['post']['requestBody']['content']['application/json']
483475
): Promise<
484476
| {
@@ -499,8 +491,6 @@ export class OgrafApi {
499491
type Method = ServerApi.paths[typeof url][typeof method]
500492

501493
const url0 = new URL(url.replace('{rendererId}', params.rendererId), this.BASE_URL_TEMPLATE)
502-
url0.searchParams.set('renderTarget', JSON.stringify(query.renderTarget))
503-
url0.searchParams.set('graphicInstanceId', query.graphicInstanceId)
504494

505495
const response = await this.fetch<Method>(url0, false, {
506496
method,
@@ -516,7 +506,6 @@ export class OgrafApi {
516506
}
517507
async renderTargetGraphicInvokeCustomAction(
518508
params: ServerApi.paths['/renderers/{rendererId}/target/graphic/customAction']['post']['parameters']['path'],
519-
query: ServerApi.paths['/renderers/{rendererId}/target/graphic/customAction']['post']['parameters']['query'],
520509
body: ServerApi.paths['/renderers/{rendererId}/target/graphic/customAction']['post']['requestBody']['content']['application/json']
521510
): Promise<
522511
| {
@@ -537,8 +526,6 @@ export class OgrafApi {
537526
type Method = ServerApi.paths[typeof url][typeof method]
538527

539528
const url0 = new URL(url.replace('{rendererId}', params.rendererId), this.BASE_URL_TEMPLATE)
540-
url0.searchParams.set('renderTarget', JSON.stringify(query.renderTarget))
541-
url0.searchParams.set('graphicInstanceId', query.graphicInstanceId)
542529

543530
const response = await this.fetch<Method>(url0, false, {
544531
method,
@@ -554,7 +541,6 @@ export class OgrafApi {
554541
}
555542
async renderTargetGraphicGoToTime(
556543
params: ServerApi.paths['/renderers/{rendererId}/target/graphic/goToTime']['put']['parameters']['path'],
557-
query: ServerApi.paths['/renderers/{rendererId}/target/graphic/goToTime']['put']['parameters']['query'],
558544
body: ServerApi.paths['/renderers/{rendererId}/target/graphic/goToTime']['put']['requestBody']['content']['application/json']
559545
): Promise<
560546
| {
@@ -575,8 +561,6 @@ export class OgrafApi {
575561
type Method = ServerApi.paths[typeof url][typeof method]
576562

577563
const url0 = new URL(url.replace('{rendererId}', params.rendererId), this.BASE_URL_TEMPLATE)
578-
url0.searchParams.set('renderTarget', JSON.stringify(query.renderTarget))
579-
url0.searchParams.set('graphicInstanceId', query.graphicInstanceId)
580564

581565
const response = await this.fetch<Method>(url0, false, {
582566
method,
@@ -592,7 +576,6 @@ export class OgrafApi {
592576
}
593577
async renderTargetGraphicSetActionsSchedule(
594578
params: ServerApi.paths['/renderers/{rendererId}/target/graphic/setActionsSchedule']['put']['parameters']['path'],
595-
query: ServerApi.paths['/renderers/{rendererId}/target/graphic/setActionsSchedule']['put']['parameters']['query'],
596579
body: ServerApi.paths['/renderers/{rendererId}/target/graphic/setActionsSchedule']['put']['requestBody']['content']['application/json']
597580
): Promise<
598581
| {
@@ -613,8 +596,6 @@ export class OgrafApi {
613596
type Method = ServerApi.paths[typeof url][typeof method]
614597

615598
const url0 = new URL(url.replace('{rendererId}', params.rendererId), this.BASE_URL_TEMPLATE)
616-
url0.searchParams.set('renderTarget', JSON.stringify(query.renderTarget))
617-
url0.searchParams.set('graphicInstanceId', query.graphicInstanceId)
618599

619600
const response = await this.fetch<Method>(url0, false, {
620601
method,

packages/controller/src/stores/serverData.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class ServerData {
1111
public connectedStatus: string = 'Initializing'
1212
public isConnected: boolean = false
1313
public lastError: string | null = null
14-
public graphicsList: OGraf.ServerApi.components['schemas']['GraphicInfo'][] = []
14+
public graphicsList: OGraf.ServerApi.components['schemas']['GraphicListInfo'][] = []
1515
public renderersList: OGraf.ServerApi.paths['/renderers']['get']['responses'][200]['content']['application/json']['renderers'] =
1616
[]
1717
public serverInfo: OGraf.ServerApi.paths['/']['get']['responses'][200]['content']['application/json'] | undefined
@@ -20,8 +20,8 @@ class ServerData {
2020
public graphicsInfo = new ObservableMap<
2121
string,
2222
{
23-
graphic: OGraf.ServerApi.components['schemas']['GraphicInfo']
24-
manifest: OGraf.ServerApi.components['schemas']['GraphicManifest']
23+
graphic: OGraf.ServerApi.components['schemas']['GraphicManifest']
24+
metadata: OGraf.ServerApi.components['schemas']['GraphicMetadata']
2525
}
2626
>()
2727
public graphicsInstanceMap = new ObservableMap<string, GraphicsInstanceMapEntry>()

packages/renderer-layer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"@ograf-server/shared": "*",
2828
"mobx": "^6.15.0",
2929
"mobx-react": "^9.2.1",
30-
"ograf": "1.0.1-nightly-feat-server-api-wip-20251112-165910-35360d9.0",
30+
"ograf": "1.0.1-nightly-feat-server-api-20251119-200040-a6d74dc.0",
3131
"react": "^19.2.0",
3232
"react-dom": "^19.2.0",
3333
"url": "^0.11.4"

packages/renderer-layer/src/lib/GraphicsCache.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class GraphicCache {
2525

2626
// Load the Graphic:
2727
console.log(`Loading Graphic...`, graphicInfo)
28-
const webComponent = await this.fetchModule(graphicId, graphicInfo.manifest)
28+
const webComponent = await this.fetchModule(graphicId, graphicInfo.graphic)
2929

3030
// register the web component
3131
customElements.define(graphicId, webComponent)
@@ -36,20 +36,18 @@ export class GraphicCache {
3636
}
3737
}
3838
private async fetchGraphicInfo(graphicId: string): Promise<GraphicInfo> {
39-
const manifestUrl = `${this.serverApiUrl}/ograf/v1/graphics/${graphicId}`
39+
const url = `${this.serverApiUrl}/ograf/v1/graphics/${graphicId}`
4040

41-
const response = await fetch(manifestUrl)
41+
const response = await fetch(url)
4242
if (response.status === 200) {
4343
const responseData = await response.json()
4444

4545
if (!responseData.graphic) throw new Error('No "graphic" property found in response')
46-
if (!responseData.manifest) throw new Error('No "manifest" property found in response')
46+
if (!responseData.metadata) throw new Error('No "metadata" property found in response')
4747

4848
return responseData
4949
} else {
50-
throw new Error(
51-
`Failed to load manifest from ${manifestUrl}: [${response.status}] ${JSON.stringify(response.body)}`
52-
)
50+
throw new Error(`Failed to load manifest from ${url}: [${response.status}] ${JSON.stringify(response.body)}`)
5351
}
5452
}
5553
async fetchModule(

packages/renderer-layer/src/lib/RendererApiHandler.ts

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -318,53 +318,69 @@ export class RendererApiHandler implements MethodsOnRenderer {
318318
return layer.loadGraphic(params.graphicId, params.params)
319319
}
320320
/** Clear/unloads a GraphicInstance on a RenderTarget */
321-
async clearGraphic(params: {
321+
async clearGraphics(params: {
322322
filters?: {
323323
renderTarget?: unknown
324324
graphicId?: string
325325
graphicInstanceId?: string
326-
}
327-
}): Promise<{ graphicInstance: GraphicInstanceOnTarget[] }> {
326+
}[]
327+
}): Promise<{ graphicInstances: GraphicInstanceOnTarget[] }> {
328328
// JSON RPC Method
329329
// console.log('params', params)
330330

331-
const renderTarget = params.filters?.renderTarget as RenderTarget | undefined
331+
const clearedGraphicInstanceIds = new Set<string>()
332+
const clearedGraphicInstances: GraphicInstanceOnTarget[] = []
332333

333-
let layers = []
334-
if (renderTarget) {
335-
const layer = this.layersManager.getLayer(renderTarget)
336-
if (!layer) throw new Error(`Layer not found: ${JSON.stringify(renderTarget)}`)
337-
layers = [layer]
338-
} else {
339-
layers = this.layersManager.getAllLayers()
334+
const ps: Promise<unknown>[] = []
335+
if (params.filters == undefined || params.filters.length === 0) {
336+
// From definition: "If no filters are defined, All graphics are cleared."
337+
338+
params.filters = [{}]
340339
}
340+
for (const filter of params.filters) {
341+
let layers = []
342+
if (filter.renderTarget) {
343+
const layer = this.layersManager.getLayer(filter.renderTarget as RenderTarget)
344+
if (!layer) throw new Error(`Layer not found: ${JSON.stringify(filter.renderTarget)}`)
345+
layers = [layer]
346+
} else {
347+
layers = this.layersManager.getAllLayers()
348+
}
341349

342-
const clearedGraphicInstancesOnLayer: GraphicInstanceOnTarget[] = []
343-
for (const layer of layers) {
344-
const graphicInstance = layer.getGraphicInstance()
350+
for (const layer of layers) {
351+
const graphicInstance = layer.getGraphicInstance()
345352

346-
if (graphicInstance) {
347-
// Should it be cleared?
348-
let clear = true
349-
if (params.filters?.graphicId && graphicInstance.graphicId !== params.filters?.graphicId) clear = false
350-
if (params.filters?.graphicInstanceId && graphicInstance.id !== params.filters?.graphicInstanceId) clear = false
353+
if (graphicInstance) {
354+
// Should it be cleared?
355+
let clear = true
356+
if (filter.graphicId && graphicInstance.graphicId !== filter.graphicId) clear = false
357+
if (filter.graphicInstanceId && graphicInstance.id !== filter.graphicInstanceId) clear = false
351358

352-
if (clear) {
353-
await layer.clearGraphic()
359+
if (clear) {
360+
if (!clearedGraphicInstanceIds.has(graphicInstance.id)) {
361+
// Has not already been cleared
354362

355-
clearedGraphicInstancesOnLayer.push({
356-
renderTarget: layer.renderTarget,
357-
graphicInstanceId: graphicInstance.id,
358-
graphicId: graphicInstance.graphicId,
359-
})
363+
clearedGraphicInstanceIds.add(graphicInstance.id)
364+
365+
clearedGraphicInstances.push({
366+
renderTarget: layer.renderTarget,
367+
graphicInstanceId: graphicInstance.id,
368+
graphicId: graphicInstance.graphicId,
369+
})
370+
371+
ps.push(layer.clearGraphic())
372+
}
373+
}
360374
}
361375
}
362376
}
377+
await Promise.all(ps)
363378

364379
return {
365-
graphicInstance: clearedGraphicInstancesOnLayer,
380+
graphicInstances: clearedGraphicInstances,
366381
}
367382
}
383+
368384
/** Invokes an action on a graphicInstance. Actions are defined by the Graphic's manifest */
369385
async invokeGraphicUpdateAction(params: {
370386
renderTarget: unknown

0 commit comments

Comments
 (0)