Skip to content
Snippets Groups Projects
Commit 32552a3c authored by esikkala's avatar esikkala
Browse files

JSON config for Network and result tabs

parent dd7079ac
No related branches found
No related tags found
No related merge requests found
...@@ -8,9 +8,9 @@ const ResultTable = lazy(() => import('./ResultTable')) ...@@ -8,9 +8,9 @@ const ResultTable = lazy(() => import('./ResultTable'))
const LeafletMap = lazy(() => import('./LeafletMap')) const LeafletMap = lazy(() => import('./LeafletMap'))
const Deck = lazy(() => import('./Deck')) const Deck = lazy(() => import('./Deck'))
const ApexCharts = lazy(() => import('./ApexCharts')) const ApexCharts = lazy(() => import('./ApexCharts'))
const Network = lazy(() => import('./Network'))
// const BarChartRace = lazy(() => import('../../facet_results/BarChartRace')) // const BarChartRace = lazy(() => import('../../facet_results/BarChartRace'))
// const Network = lazy(() => import('../../facet_results/Network')) const Export = lazy(() => import('./Export'))
// const Export = lazy(() => import('../../facet_results/Export'))
const FacetResults = props => { const FacetResults = props => {
const { const {
...@@ -53,6 +53,7 @@ const FacetResults = props => { ...@@ -53,6 +53,7 @@ const FacetResults = props => {
render={routeProps => render={routeProps =>
<ResultTable <ResultTable
portalConfig={portalConfig} portalConfig={portalConfig}
perspectiveConfig={perspective}
data={perspectiveState} data={perspectiveState}
facetUpdateID={facetState.facetUpdateID} facetUpdateID={facetState.facetUpdateID}
resultClass={resultClass} resultClass={resultClass}
...@@ -78,6 +79,7 @@ const FacetResults = props => { ...@@ -78,6 +79,7 @@ const FacetResults = props => {
render={() => render={() =>
<LeafletMap <LeafletMap
portalConfig={portalConfig} portalConfig={portalConfig}
perspectiveConfig={perspective}
center={resultClassMap.center} center={resultClassMap.center}
zoom={resultClassMap.zoom} zoom={resultClassMap.zoom}
results={perspectiveState.results} results={perspectiveState.results}
...@@ -120,6 +122,7 @@ const FacetResults = props => { ...@@ -120,6 +122,7 @@ const FacetResults = props => {
const resultClassMap = maps[resultClass] const resultClassMap = maps[resultClass]
let deckProps = { let deckProps = {
portalConfig, portalConfig,
perspectiveConfig: perspective,
center: resultClassMap.center, center: resultClassMap.center,
zoom: resultClassMap.zoom, zoom: resultClassMap.zoom,
results: perspectiveState.results, results: perspectiveState.results,
...@@ -183,6 +186,7 @@ const FacetResults = props => { ...@@ -183,6 +186,7 @@ const FacetResults = props => {
} = resultClassConfig } = resultClassConfig
const apexProps = { const apexProps = {
portalConfig, portalConfig,
perspectiveConfig: perspective,
pageType, pageType,
resultClass, resultClass,
facetClass, facetClass,
...@@ -212,14 +216,65 @@ const FacetResults = props => { ...@@ -212,14 +216,65 @@ const FacetResults = props => {
) )
break break
} }
// case 'Network': case 'Network': {
// routeComponent = ( const { networkConfig } = props
const {
// ) pageType = 'facetResults',
// case 'BarChartRace': limit,
// routeComponent = ( optimize,
style,
// ) layout,
preprocess
} = resultClassConfig
const networkProps = {
portalConfig,
perspectiveConfig: perspective,
pageType,
resultClass,
facetClass,
results: perspectiveState.results,
resultUpdateID: perspectiveState.resultUpdateID,
facetUpdateID: facetState.facetUpdateID,
fetching: perspectiveState.fetching,
fetchResults: props.fetchResults,
layoutConfig: props.layoutConfig,
limit,
optimize,
style: networkConfig[style],
layout: networkConfig[layout],
preprocess: networkConfig[preprocess]
}
routeComponent = (
<Route
path={path}
key={resultClass}
render={() =>
<Network {...networkProps} />}
/>
)
break
}
case 'Export': {
const exportResultClass = resultClassConfig.resultClass
routeComponent = (
<Route
path={path}
key={resultClass}
render={routeProps =>
<Export
portalConfig={portalConfig}
data={perspectiveState}
resultClass={exportResultClass}
facetClass={facetClass}
pageType='facetResults'
fetchPaginatedResults={props.fetchPaginatedResults}
updatePage={props.updatePage}
layoutConfig={props.layoutConfig}
/>}
/>
)
break
}
} }
return routeComponent return routeComponent
} }
...@@ -228,7 +283,7 @@ const FacetResults = props => { ...@@ -228,7 +283,7 @@ const FacetResults = props => {
<> <>
<PerspectiveTabs <PerspectiveTabs
routeProps={props.routeProps} routeProps={props.routeProps}
tabs={props.perspective.tabs} tabs={perspective.tabs}
screenSize={props.screenSize} screenSize={props.screenSize}
layoutConfig={props.layoutConfig} layoutConfig={props.layoutConfig}
/> />
...@@ -260,44 +315,6 @@ const FacetResults = props => { ...@@ -260,44 +315,6 @@ const FacetResults = props => {
layoutConfig={props.layoutConfig} layoutConfig={props.layoutConfig}
/>} />}
/> />
<Route
path={`${rootUrl}/${perspective.id}/faceted-search/event_dates`}
render={() =>
<ApexChart
portalConfig={portalConfig}
pageType='facetResults'
rawData={props.perspectiveState.results}
rawDataUpdateID={props.perspectiveState.resultUpdateID}
facetUpdateID={props.facetState.facetUpdateID}
fetching={props.perspectiveState.fetching}
fetchData={props.fetchResults}
createChartData={props.lineChartConfig.createMultipleLineChartData}
title='Manuscript events by decade'
xaxisTitle='Year'
xaxisType='category'
xaxisTickAmount={30}
yaxisTitle='Count'
seriesTitle='Count'
stroke={{
curve: 'straight',
width: 2
}}
fill={{
type: 'gradient',
gradient: {
shadeIntensity: 1,
inverseColors: false,
opacityFrom: 0.6,
opacityTo: 0.05,
stops: [20, 60, 100, 100]
}
}}
resultClass='eventLineChart'
facetClass='perspective1'
layoutConfig={props.layoutConfig}
/>}
/>
<Route <Route
path={`${rootUrl}/${perspective.id}/faceted-search/bar_chart_race_ms_productions`} path={`${rootUrl}/${perspective.id}/faceted-search/bar_chart_race_ms_productions`}
render={() => render={() =>
...@@ -330,41 +347,7 @@ const FacetResults = props => { ...@@ -330,41 +347,7 @@ const FacetResults = props => {
stepDuration={1000} stepDuration={1000}
/>} />}
/> />
<Route */}
path={`${rootUrl}/${perspective.id}/faceted-search/network`}
render={() =>
<Network
portalConfig={portalConfig}
results={props.perspectiveState.results}
facetUpdateID={props.facetState.facetUpdateID}
resultUpdateID={props.perspectiveState.resultUpdateID}
fetchResults={props.fetchResults}
fetching={props.perspectiveState.fetching}
resultClass='manuscriptFacetResultsNetwork'
facetClass='perspective1'
limit={500}
optimize={1.2}
style={props.networkConfig.cytoscapeStyle}
layout={props.networkConfig.coseLayout}
preprocess={props.networkConfig.preprocess}
pageType='facetResults'
layoutConfig={props.layoutConfig}
/>}
/>
<Route
path={`${rootUrl}/${perspective.id}/faceted-search/export`}
render={() =>
<Export
portalConfig={portalConfig}
data={props.perspectiveState}
resultClass='perspective1'
facetClass='perspective1'
pageType='facetResults'
fetchPaginatedResults={props.fetchPaginatedResults}
updatePage={props.updatePage}
layoutConfig={props.layoutConfig}
/>}
/> */}
</> </>
) )
} }
......
...@@ -125,9 +125,6 @@ ...@@ -125,9 +125,6 @@
} }
}, },
"productionsByDecadeAndCountry": { "productionsByDecadeAndCountry": {
"tabID": 1,
"tabPath": "",
"tabIcon": "AddLocation",
"sparqlQuery": "productionsByDecadeAndCountryQuery", "sparqlQuery": "productionsByDecadeAndCountryQuery",
"facetClass": "perspective1", "facetClass": "perspective1",
"filterTarget": "manuscript", "filterTarget": "manuscript",
...@@ -140,8 +137,9 @@ ...@@ -140,8 +137,9 @@
} }
}, },
"eventLineChart": { "eventLineChart": {
"tabID": 1, "tabID": 4,
"tabPath": "", "component": "ApexCharts",
"tabPath": "event_dates",
"tabIcon": "AddLocation", "tabIcon": "AddLocation",
"sparqlQuery": "eventsByDecadeQuery", "sparqlQuery": "eventsByDecadeQuery",
"facetClass": "perspective1", "facetClass": "perspective1",
...@@ -149,6 +147,32 @@ ...@@ -149,6 +147,32 @@
"resultMapper": "mapMultipleLineChart", "resultMapper": "mapMultipleLineChart",
"resultMapperConfig": { "resultMapperConfig": {
"fillEmptyValues": false "fillEmptyValues": false
},
"createChartData": "createMultipleLineChartData",
"title": "Manuscript events by decade",
"xaxisTitle": "Decade",
"xaxisType": "category",
"xaxisTickAmount": 30,
"yaxisTitle": "Count",
"seriesTitle": "Count",
"stroke": {
"curve": "straight",
"width": 2
},
"fill": {
"type": "gradient",
"gradient": {
"shadeIntensity": 1,
"inverseColors": false,
"opacityFrom": 0.6,
"opacityTo": 0.05,
"stops": [
20,
60,
100,
100
]
}
} }
}, },
"manuscriptInstancePageNetwork": { "manuscriptInstancePageNetwork": {
...@@ -157,14 +181,28 @@ ...@@ -157,14 +181,28 @@
"useNetworkAPI": true "useNetworkAPI": true
}, },
"manuscriptFacetResultsNetwork": { "manuscriptFacetResultsNetwork": {
"tabID": 1, "tabID": 7,
"tabPath": "", "component": "Network",
"tabIcon": "AddLocation", "tabPath": "network",
"tabIcon": "BubbleChart",
"sparqlQuery": "manuscriptFacetResultsNetworkLinksQuery", "sparqlQuery": "manuscriptFacetResultsNetworkLinksQuery",
"facetClass": "perspective1", "facetClass": "perspective1",
"sparqlQueryNodes": "manuscriptNetworkNodesQuery", "sparqlQueryNodes": "manuscriptNetworkNodesQuery",
"filterTarget": "manuscript", "filterTarget": "manuscript",
"useNetworkAPI": true "useNetworkAPI": true,
"limit": 500,
"optimize": 1.2,
"style": "cytoscapeStyle",
"layout": "coseLayout",
"preprocess": "preprocess"
},
"export": {
"tabID": 8,
"component": "Export",
"tabPath": "export",
"tabIcon": "CloudDownload",
"resultClass": "perspective1",
"facetClass": "perspective1"
}, },
"perspective1KnowledgeGraphMetadata": { "perspective1KnowledgeGraphMetadata": {
"sparqlQuery": "knowledgeGraphMetadataQuery", "sparqlQuery": "knowledgeGraphMetadataQuery",
...@@ -211,53 +249,6 @@ ...@@ -211,53 +249,6 @@
"zoom": 4 "zoom": 4
} }
}, },
"tabs": [
{
"id": "table",
"value": 0,
"icon": "CalendarViewDay"
},
{
"id": "production_places",
"value": 1,
"icon": "AddLocation"
},
{
"id": "production_places_heatmap",
"value": 2,
"icon": "AddLocation"
},
{
"id": "production_dates",
"value": 3,
"icon": "ShowChart"
},
{
"id": "event_dates",
"value": 4,
"icon": "ShowChart"
},
{
"id": "last_known_locations",
"value": 5,
"icon": "LocationOn"
},
{
"id": "migrations",
"value": 6,
"icon": "Redo"
},
{
"id": "network",
"value": 7,
"icon": "BubbleChart"
},
{
"id": "export",
"value": 8,
"icon": "CloudDownload"
}
],
"instancePageTabs": [ "instancePageTabs": [
{ {
"id": "table", "id": "table",
......
import React from 'react' import React from 'react'
import querystring from 'querystring' import querystring from 'querystring'
import { has } from 'lodash' import { has, sortBy } from 'lodash'
import intl from 'react-intl-universal' import intl from 'react-intl-universal'
import MuiIcon from '../components/main_layout/MuiIcon' import MuiIcon from '../components/main_layout/MuiIcon'
...@@ -199,10 +199,25 @@ export const createPerspectiveConfig = async ({ portalID, searchPerspectives }) ...@@ -199,10 +199,25 @@ export const createPerspectiveConfig = async ({ portalID, searchPerspectives })
const { default: image } = await import(/* webpackMode: "eager" */ `../img/${perspective.frontPageImage}`) const { default: image } = await import(/* webpackMode: "eager" */ `../img/${perspective.frontPageImage}`)
perspective.frontPageImage = image perspective.frontPageImage = image
} }
if (has(perspective, 'tabs')) { if (has(perspective, 'resultClasses')) {
for (const tab of perspective.tabs) { const tabs = []
tab.icon = <MuiIcon iconName={tab.icon} /> // console.log(perspective)
} Object.keys(perspective.resultClasses).forEach(resultClass => {
let resultClassConfig = perspective.resultClasses[resultClass]
if (has(resultClassConfig, 'paginatedResultsConfig')) {
resultClassConfig = resultClassConfig.paginatedResultsConfig
}
if (has(resultClassConfig, 'tabID') && has(resultClassConfig, 'tabPath')) {
const { tabID, tabPath, tabIcon } = resultClassConfig
tabs.push({
id: tabPath,
value: tabID,
icon: <MuiIcon iconName={tabIcon} />
})
}
sortBy(tabs, 'value')
})
perspective.tabs = tabs
} }
if (has(perspective, 'instancePageTabs')) { if (has(perspective, 'instancePageTabs')) {
for (const tab of perspective.instancePageTabs) { for (const tab of perspective.instancePageTabs) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment