Skip to content

Commit 95f2612

Browse files
committed
Update configs
1 parent 054d61c commit 95f2612

File tree

7 files changed

+227
-17
lines changed

7 files changed

+227
-17
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 Semantic Computing Research Group (SeCo)
3+
Copyright (c) 2021 Semantic Computing Research Group (SeCo)
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

src/client/components/App.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import React from 'react'
22
import { MuiThemeProvider, createTheme } from '@material-ui/core/styles'
33
import SemanticPortal from '../containers/SemanticPortal'
4+
import portalConfig from '../../configs/portalConfig.json'
5+
const { colorPalette } = portalConfig.layoutConfig
46

57
const theme = createTheme({
68
palette: {
79
primary: {
8-
main: '#212121'
10+
main: colorPalette.primary.main
911
},
1012
secondary: {
11-
main: '#EB1806'
13+
main: colorPalette.secondary.main
1214
}
1315
},
1416
overrides: {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
import React, { useEffect } from 'react'
2+
import { List, AutoSizer } from 'react-virtualized'
3+
import { makeStyles } from '@material-ui/core/styles'
4+
import Card from '@material-ui/core/Card'
5+
import CardActionArea from '@material-ui/core/CardActionArea'
6+
import CardContent from '@material-ui/core/CardContent'
7+
import CardMedia from '@material-ui/core/CardMedia'
8+
import Typography from '@material-ui/core/Typography'
9+
import intl from 'react-intl-universal'
10+
import { Link } from 'react-router-dom'
11+
import CircularProgress from '@material-ui/core/CircularProgress'
12+
import purple from '@material-ui/core/colors/purple'
13+
14+
const useStyles = makeStyles(theme => ({
15+
root: props => {
16+
return {
17+
marginTop: theme.spacing(1),
18+
maxWidth: 350,
19+
height: window.innerHeight - props.layoutConfig.topBar.reducedHeight - props.layoutConfig.tabHeight - 139,
20+
[theme.breakpoints.up(600)]: {
21+
height: window.innerHeight - props.layoutConfig.topBar.reducedHeight - props.layoutConfig.tabHeight - 256
22+
},
23+
[theme.breakpoints.up(props.layoutConfig.hundredPercentHeightBreakPoint)]: {
24+
height: window.innerHeight - props.layoutConfig.topBar.reducedHeight - props.layoutConfig.tabHeight - 178
25+
},
26+
[theme.breakpoints.up(1100)]: {
27+
height: window.innerHeight - props.layoutConfig.topBar.reducedHeight - props.layoutConfig.tabHeight - 196
28+
},
29+
[theme.breakpoints.up(props.layoutConfig.reducedHeightBreakpoint)]: {
30+
height: window.innerHeight - props.layoutConfig.topBar.reducedHeight - props.layoutConfig.tabHeight - 265
31+
},
32+
fontFamily: 'Roboto'
33+
}
34+
},
35+
list: {
36+
[theme.breakpoints.up('md')]: {
37+
paddingRight: 4
38+
}
39+
},
40+
link: {
41+
textDecoration: 'none'
42+
},
43+
progressContainer: {
44+
width: '100%',
45+
height: 600,
46+
[theme.breakpoints.up('md')]: {
47+
height: 'calc(100% - 80px)'
48+
},
49+
display: 'flex',
50+
alignItems: 'center',
51+
justifyContent: 'center'
52+
}
53+
}))
54+
55+
const ReactVirtualizedList = props => {
56+
const classes = useStyles(props)
57+
const { results } = props.perspectiveState
58+
59+
useEffect(() => {
60+
props.fetchResults({
61+
resultClass: props.resultClass,
62+
facetClass: props.facetClass
63+
})
64+
}, [])
65+
66+
useEffect(() => {
67+
const { facetUpdateID } = props
68+
if (facetUpdateID > 0) {
69+
props.fetchResults({
70+
resultClass: props.resultClass,
71+
facetClass: props.facetClass
72+
})
73+
}
74+
}, [props.facetUpdateID])
75+
76+
const rowRenderer = ({
77+
key, // Unique key within array of rows
78+
index, // Index of row within collection
79+
isScrolling, // The List is currently being scrolled
80+
isVisible, // This row is visible within the List (eg it is not an overscanned row)
81+
style // Style object to be applied to row (to position it)
82+
}) => {
83+
const data = props.perspectiveState.results[index]
84+
let image = null
85+
if (data.imageURL) {
86+
const { imageURL } = data
87+
image = imageURL.includes(', ') ? imageURL.split(', ')[0] : imageURL
88+
}
89+
return (
90+
<div className={classes.rowRoot} key={key} style={style}>
91+
<Link className={classes.link} to={data.dataProviderUrl}>
92+
<Card>
93+
<CardActionArea>
94+
{image &&
95+
<CardMedia
96+
component='img'
97+
alt='Kuva löydöstä'
98+
height='140'
99+
image={image}
100+
title='Kuva löydöstä'
101+
/>}
102+
<CardContent>
103+
<Typography gutterBottom variant='h5' component='h2'>
104+
{data.findName}
105+
</Typography>
106+
<Typography variant='body2' color='textSecondary' component='p'>
107+
<strong>{intl.get('perspectives.finds.properties.objectType.label')}: </strong>
108+
{data.objectType}
109+
</Typography>
110+
<Typography variant='body2' color='textSecondary' component='p'>
111+
<strong>{intl.get('perspectives.finds.properties.material.label')}: </strong>
112+
{data.material}
113+
</Typography>
114+
<Typography variant='body2' color='textSecondary' component='p'>
115+
<strong>{intl.get('perspectives.finds.properties.period.label')}: </strong>
116+
{data.period}
117+
</Typography>
118+
<Typography variant='body2' color='textSecondary' component='p'>
119+
<strong>{intl.get('perspectives.finds.properties.municipality.label')}: </strong>
120+
{data.municipality}
121+
</Typography>
122+
</CardContent>
123+
</CardActionArea>
124+
</Card>
125+
</Link>
126+
127+
</div>
128+
)
129+
}
130+
131+
const getRowHeight = ({ index }) => {
132+
const data = props.perspectiveState.results[index]
133+
let height = 300
134+
if (!data.imageURL) {
135+
height -= 140
136+
}
137+
if (data.findName.length > 26) {
138+
height += 32
139+
}
140+
if (data.findName.length > 40) {
141+
height += 54
142+
}
143+
if (data.period) {
144+
const limit = window.innerWidth < 328 ? 25 : 34
145+
if (data.period.length > limit) {
146+
height += 20
147+
}
148+
}
149+
return height
150+
}
151+
152+
const validResults = () => {
153+
const { results, resultClass } = props.perspectiveState
154+
if (resultClass !== props.resultClass) { return false }
155+
if (results == null) { return false }
156+
if (results.length < 1) { return false }
157+
return true
158+
}
159+
160+
// if (props.perspectiveState.results) {
161+
// props.perspectiveState.results.map(r => {
162+
// if (r.period && r.period.length > 33) {
163+
// console.log(r)
164+
// }
165+
// })
166+
// }
167+
168+
return (
169+
<div className={classes.root}>
170+
{(!validResults() || props.perspectiveState.results.fetching)
171+
? (
172+
<div className={classes.progressContainer}>
173+
<CircularProgress style={{ color: purple[500] }} thickness={5} />
174+
</div>
175+
)
176+
: (
177+
<AutoSizer>
178+
{({ height, width }) => (
179+
<List
180+
className={classes.list}
181+
height={height}
182+
width={width}
183+
rowCount={results.length}
184+
rowHeight={getRowHeight}
185+
rowRenderer={rowRenderer}
186+
/>
187+
)}
188+
</AutoSizer>
189+
)}
190+
</div>
191+
)
192+
}
193+
194+
export default ReactVirtualizedList

src/configs/portalConfig.json

+8
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@
4444
"sitemapInstancePageQuery": "sitemapInstancePageQuery"
4545
},
4646
"layoutConfig": {
47+
"colorPalette": {
48+
"primary": {
49+
"main": "#212121"
50+
},
51+
"secondary": {
52+
"main": "##EB1806"
53+
}
54+
},
4755
"hundredPercentHeightBreakPoint": "md",
4856
"reducedHeightBreakpoint": "xl",
4957
"tabHeight": 58,

src/configs/sampo/search_perspectives/perspective1.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
"component": "Export",
5353
"tabPath": "export",
5454
"tabIcon": "CloudDownload",
55-
"resultClass": "perspective2",
56-
"facetClass": "perspective2"
55+
"resultClass": "perspective1",
56+
"facetClass": "perspective1"
5757
}
5858
},
5959
"properties": [

src/configs/sampo/search_perspectives/perspective2.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"tabPath": "production_places",
6969
"tabIcon": "AddLocation",
7070
"sparqlQuery": "productionPlacesQuery",
71-
"facetClass": "perspective1",
71+
"facetClass": "perspective2",
7272
"filterTarget": "manuscripts",
7373
"resultMapper": "mapPlaces",
7474
"facetID": "productionPlace",
@@ -85,7 +85,7 @@
8585
"tabPath": "production_places_heatmap",
8686
"tabIcon": "AddLocation",
8787
"sparqlQuery": "productionPlacesQuery",
88-
"facetClass": "perspective1",
88+
"facetClass": "perspective2",
8989
"filterTarget": "manuscripts",
9090
"resultMapper": "mapPlaces",
9191
"layerType": "heatmapLayer"
@@ -96,7 +96,7 @@
9696
"tabPath": "last_known_locations",
9797
"tabIcon": "LocationOn",
9898
"sparqlQuery": "lastKnownLocationsQuery",
99-
"facetClass": "perspective1",
99+
"facetClass": "perspective2",
100100
"filterTarget": "manuscripts",
101101
"resultMapper": "mapPlaces",
102102
"facetID": "lastKnownLocation",
@@ -111,7 +111,7 @@
111111
"tabPath": "migrations",
112112
"tabIcon": "Redo",
113113
"sparqlQuery": "migrationsQuery",
114-
"facetClass": "perspective1",
114+
"facetClass": "perspective2",
115115
"filterTarget": "manuscript",
116116
"resultMapper": "makeObjectList",
117117
"layerType": "arcLayer",
@@ -138,7 +138,7 @@
138138
"tabPath": "production_dates",
139139
"tabIcon": "ShowChart",
140140
"sparqlQuery": "productionsByDecadeQuery",
141-
"facetClass": "perspective1",
141+
"facetClass": "perspective2",
142142
"filterTarget": "instance",
143143
"resultMapper": "mapLineChart",
144144
"resultMapperConfig": {
@@ -157,7 +157,7 @@
157157
},
158158
"productionsByDecadeAndCountry": {
159159
"sparqlQuery": "productionsByDecadeAndCountryQuery",
160-
"facetClass": "perspective1",
160+
"facetClass": "perspective2",
161161
"filterTarget": "manuscript",
162162
"resultMapper": "makeObjectList",
163163
"postprocess": {
@@ -173,7 +173,7 @@
173173
"tabPath": "event_dates",
174174
"tabIcon": "AddLocation",
175175
"sparqlQuery": "eventsByDecadeQuery",
176-
"facetClass": "perspective1",
176+
"facetClass": "perspective2",
177177
"filterTarget": "manuscript",
178178
"resultMapper": "mapMultipleLineChart",
179179
"resultMapperConfig": {
@@ -212,7 +212,7 @@
212212
"tabPath": "network",
213213
"tabIcon": "BubbleChart",
214214
"sparqlQuery": "manuscriptFacetResultsNetworkLinksQuery",
215-
"facetClass": "perspective1",
215+
"facetClass": "perspective2",
216216
"sparqlQueryNodes": "manuscriptNetworkNodesQuery",
217217
"filterTarget": "manuscript",
218218
"useNetworkAPI": true,
@@ -227,10 +227,10 @@
227227
"component": "Export",
228228
"tabPath": "export",
229229
"tabIcon": "CloudDownload",
230-
"resultClass": "perspective1",
231-
"facetClass": "perspective1"
230+
"resultClass": "perspective2",
231+
"facetClass": "perspective2"
232232
},
233-
"perspective1KnowledgeGraphMetadata": {
233+
"perspective2KnowledgeGraphMetadata": {
234234
"sparqlQuery": "knowledgeGraphMetadataQuery",
235235
"resultMapper": "makeObjectList"
236236
},

src/server/openapi.yaml

+7-1
Original file line numberDiff line numberDiff line change
@@ -556,10 +556,16 @@ paths:
556556
application/json:
557557
schema:
558558
type: object
559-
/void/{resultClass}:
559+
/void/{perspectiveID}/{resultClass}:
560560
get:
561561
summary: Retrieve a VoID description
562562
parameters:
563+
- in: path
564+
name: perspectiveID
565+
schema:
566+
type: string
567+
example: perspective1
568+
required: true
563569
- in: path
564570
name: resultClass
565571
schema:

0 commit comments

Comments
 (0)