Newer
Older
piotr.kupczyk@id.ethz.ch
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import React from 'react'
import Container from '@src/js/components/common/form/Container.jsx'
import openbis from '@src/js/services/openbis.js'
import objectType from '@src/js/common/consts/objectType.js'
import logger from '@src/js/common/logger.js'
class DatabaseComponent extends React.PureComponent {
constructor(props) {
super(props)
this.state = {
json: null
}
}
async componentDidMount() {
const { object } = this.props
let json = null
if (object.type === objectType.SPACE) {
const spaces = await openbis.getSpaces(
[new openbis.SpacePermId(object.id)],
new openbis.SpaceFetchOptions()
)
json = spaces[object.id]
} else if (object.type === objectType.PROJECT) {
const projects = await openbis.getProjects(
[new openbis.ProjectPermId(object.id)],
new openbis.ProjectFetchOptions()
)
json = projects[object.id]
} else if (object.type === objectType.COLLECTION) {
const experiments = await openbis.getExperiments(
[new openbis.ExperimentPermId(object.id)],
new openbis.ExperimentFetchOptions()
)
json = experiments[object.id]
} else if (object.type === objectType.OBJECT) {
const samples = await openbis.getSamples(
[new openbis.SamplePermId(object.id)],
new openbis.SampleFetchOptions()
)
json = samples[object.id]
} else if (object.type === objectType.DATA_SET) {
const dataSets = await openbis.getDataSets(
[new openbis.DataSetPermId(object.id)],
new openbis.DataSetFetchOptions()
)
json = dataSets[object.id]
}
this.setState({
json
})
}
render() {
logger.log(logger.DEBUG, 'DatabaseComponent.render')
return (
<Container>
<pre>{JSON.stringify(this.state.json, null, 2)}</pre>
</Container>
)
}
}
export default DatabaseComponent