Skip to content

Commit 4e36f68

Browse files
fix(#246): fetch temporary datatypes
WIP
1 parent 892d2ad commit 4e36f68

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/renderer/utils/temp-datatype.ts

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { datatypeXmlToJson } from 'shared/parser/pipelineXmlConverter'
2+
3+
const { App } = window
4+
// import { baseurl } from 'shared/types'
5+
// import { useWindowStore } from 'renderer/store'
6+
7+
async function fetchTemporaryDatatype(id) {
8+
try {
9+
// let href = `${baseurl(
10+
// useWindowStore().pipeline.webservice
11+
// )}/datatypes/${id}`
12+
// TODO construct URL dynamically; the above was causing react to throw lifecycle error
13+
let href = `http://localhost:49152/ws/datatypes/${id}`
14+
// can't use IPC fetch due to async problems matching event send and receive
15+
// when multiple controls could be sending the same type of event
16+
// however this browser-based fetch is at risk of CORS issues depending on how the pipeline engine
17+
// was started
18+
// the reason we have to do this differently than with standard datatypes is that these temp
19+
// datatypes aren't at the global /datatypes endpoint
20+
let data = await fetch(href)
21+
let txt = await data.text()
22+
console.log(`data for ${id}: \n`, txt)
23+
let datatypeAsJson = datatypeXmlToJson(href, id, txt)
24+
return datatypeAsJson ?? null
25+
} catch (err) {
26+
return null
27+
}
28+
}
29+
export { fetchTemporaryDatatype }

0 commit comments

Comments
 (0)