diff --git a/src/client/components/facet_results/Deck.js b/src/client/components/facet_results/Deck.js index c9809992be4d347907522bd130ae0e2c4f0fc7a9..36707a2e03d42434a9780078f0e196fa5c6e9435 100644 --- a/src/client/components/facet_results/Deck.js +++ b/src/client/components/facet_results/Deck.js @@ -205,7 +205,8 @@ class Deck extends React.Component { }) render () { - const { classes, mapBoxAccessToken, mapBoxStyle, layerType, fetching, results, showTooltips } = this.props + const { classes, layerType, fetching, results, showTooltips, portalConfig } = this.props + const { mapboxAccessToken, mapboxStyle } = portalConfig.mapboxConfig const { hoverInfo } = this.state const showTooltip = showTooltips && hoverInfo && hoverInfo.object const hasData = !fetching && results && results.length > 0 && @@ -246,9 +247,9 @@ class Deck extends React.Component { width='100%' height='100%' reuseMaps - mapStyle={`mapbox://styles/mapbox/${mapBoxStyle}`} + mapStyle={`mapbox://styles/mapbox/${mapboxStyle}`} preventStyleDiffing - mapboxApiAccessToken={mapBoxAccessToken} + mapboxApiAccessToken={mapboxAccessToken} onViewportChange={this.handleOnViewportChange} > <div className={classes.navigationContainer}> @@ -321,8 +322,6 @@ Deck.propTypes = { results: PropTypes.array, layerType: PropTypes.oneOf(['arcLayer', 'heatmapLayer', 'hexagonLayer', 'polygonLayer']), tooltips: PropTypes.bool, - mapBoxAccessToken: PropTypes.string.isRequired, - mapBoxStyle: PropTypes.string.isRequired, facetUpdateID: PropTypes.number, fetchResults: PropTypes.func, resultClass: PropTypes.string, diff --git a/src/client/components/facet_results/Export.js b/src/client/components/facet_results/Export.js index 14fc6ce4b4f16bd9545bbeb9ee6f80066d6237de..50b2767ad9d369d32196925f80fc5d85e8b07553 100644 --- a/src/client/components/facet_results/Export.js +++ b/src/client/components/facet_results/Export.js @@ -41,11 +41,12 @@ class Export extends React.Component { } render = () => { - const { classes, data, pageType, yasguiBaseUrl, yasguiParams } = this.props + const { classes, data, pageType, portalConfig } = this.props + const { yasguiBaseURL, yasguiParams } = portalConfig.yasguiConfig let yasguiUrl = '' - const sparqlQuery = pageType === 'facetResults' ? data.paginatedResultsSparqlQuery : this.props.sparqlQuery + const sparqlQuery = pageType === 'facetResults' ? data.paginatedResultsSparqlQuery : data.instanceSparqlQuery if (sparqlQuery !== null) { - yasguiUrl = `${yasguiBaseUrl}/#query=${encodeURIComponent(sparqlQuery)}&${querystring.stringify(yasguiParams)}` + yasguiUrl = `${yasguiBaseURL}/#query=${encodeURIComponent(sparqlQuery)}&${querystring.stringify(yasguiParams)}` } return ( <div className={classes.root}> diff --git a/src/client/components/facet_results/LeafletMap.js b/src/client/components/facet_results/LeafletMap.js index ef69908d72435d3ed1f7ba8be0965c0298af9a5f..5a29ac0d41b59d56a88c42123554438cc59d656d 100644 --- a/src/client/components/facet_results/LeafletMap.js +++ b/src/client/components/facet_results/LeafletMap.js @@ -293,8 +293,11 @@ class LeafletMap extends React.Component { } initMap = () => { + const { mapboxConfig } = this.props.portalConfig + const { mapboxAccessToken, mapboxStyle } = mapboxConfig + // Base layer(s) - const mapboxBaseLayer = L.tileLayer(`https://api.mapbox.com/styles/v1/mapbox/${this.props.mapBoxStyle}/tiles/{z}/{x}/{y}?access_token=${this.props.mapBoxAccessToken}`, { + const mapboxBaseLayer = L.tileLayer(`https://api.mapbox.com/styles/v1/mapbox/${mapboxStyle}/tiles/{z}/{x}/{y}?access_token=${mapboxAccessToken}`, { attribution: '© <a href="https://www.mapbox.com/map-feedback/" target="_blank" rel="noopener">Mapbox</a> © <a href="http://osm.org/copyright" target="_blank" rel="noopener">OpenStreetMap</a> contributors', tileSize: 512, zoomOffset: -1 @@ -368,7 +371,7 @@ class LeafletMap extends React.Component { // initialize layers from external sources if (this.props.showExternalLayers) { const basemaps = { - [intl.get(`leafletMap.basemaps.mapbox.${this.props.mapBoxStyle}`)]: mapboxBaseLayer + [intl.get(`leafletMap.basemaps.mapbox.${mapboxStyle}`)]: mapboxBaseLayer // [intl.get('leafletMap.basemaps.backgroundMapNLS')]: nlsVectortilesBackgroundmap, // [intl.get('leafletMap.basemaps.topographicalMapNLS')]: topographicalMapNLS, // [intl.get('leafletMap.basemaps.airMapNLS')]: airMapNLS @@ -1047,9 +1050,7 @@ LeafletMap.propTypes = { facetedSearchMode: PropTypes.string, container: PropTypes.string, showError: PropTypes.func, - uri: PropTypes.string, - mapBoxStyle: PropTypes.string, - mapBoxAccessToken: PropTypes.string + uri: PropTypes.string } export const LeafletMapComponent = LeafletMap diff --git a/src/client/components/main_layout/MuiIcon.js b/src/client/components/main_layout/MuiIcon.js index 1b4501c15f88b7fa7b3adf9b3ce74d6c64bd100e..0dc5307b8ec5f2efd97d24f27810c47a6a4d60be 100644 --- a/src/client/components/main_layout/MuiIcon.js +++ b/src/client/components/main_layout/MuiIcon.js @@ -11,11 +11,12 @@ import { BubbleChart, ShowChart } from '@material-ui/icons' +import has from 'lodash' const MuiIcon = props => { const MuiIcons = { CalendarViewDay: CalendarViewDay, - TripOriginIcon: TripOrigin, + TripOrigin: TripOrigin, LocationOn: LocationOn, AddLocation: AddLocation, Star: Star, @@ -25,8 +26,12 @@ const MuiIcon = props => { BubbleChart: BubbleChart, ShowChart: ShowChart } - const MuiIconComponent = MuiIcons[props.iconName] - return <MuiIconComponent /> + if (has(MuiIcons, props.iconName)) { + const MuiIconComponent = MuiIcons[props.iconName] + return <MuiIconComponent /> + } else { + return <div /> + } } export default MuiIcon diff --git a/src/client/components/perspectives/sampo/InstanceHomePage.js b/src/client/components/perspectives/sampo/InstanceHomePage.js index 99288ab90d366014fcddf7531abe46c9e9ca5849..0817e7978b6ae82413da2b4bb546ffc4c7dabf96 100644 --- a/src/client/components/perspectives/sampo/InstanceHomePage.js +++ b/src/client/components/perspectives/sampo/InstanceHomePage.js @@ -101,7 +101,7 @@ class InstanceHomePage extends React.Component { } render = () => { - const { classes, perspectiveState, perspectiveConfig, rootUrl, screenSize, layoutConfig } = this.props + const { classes, perspectiveState, perspectiveConfig, rootUrl, screenSize, layoutConfig, portalConfig } = this.props const { instanceTableData, fetching } = perspectiveState const resultClass = perspectiveConfig.id const defaultInstancePageTab = perspectiveConfig.defaultInstancePageTab @@ -144,6 +144,7 @@ class InstanceHomePage extends React.Component { path={[`${rootUrl}/${resultClass}/page/${this.state.localID}/table`, '/iframe.html']} // support also rendering in Storybook render={() => <InstanceHomePageTable + portalConfig={portalConfig} resultClass={resultClass} data={instanceTableData} properties={this.getVisibleRows(perspectiveState.properties)} @@ -155,6 +156,7 @@ class InstanceHomePage extends React.Component { path={`${rootUrl}/${resultClass}/page/${this.state.localID}/network`} render={() => <Network + portalConfig={portalConfig} pageType='instancePage' results={perspectiveState.results} resultUpdateID={perspectiveState.resultUpdateID} @@ -173,7 +175,8 @@ class InstanceHomePage extends React.Component { path={`${rootUrl}/${resultClass}/page/${this.state.localID}/export`} render={() => <Export - sparqlQuery={this.props.sparqlQuery} + portalConfig={portalConfig} + data={perspectiveState} pageType='instancePage' id={instanceTableData.id} layoutConfig={layoutConfig} diff --git a/src/client/components/perspectives/sampo/Perspective1.js b/src/client/components/perspectives/sampo/Perspective1.js index 0735397faef368b5ce52b50f6670d6cec632fd37..ae781e5b7d276adad63b749bbf425f48ca6c4937 100644 --- a/src/client/components/perspectives/sampo/Perspective1.js +++ b/src/client/components/perspectives/sampo/Perspective1.js @@ -12,7 +12,7 @@ const Network = lazy(() => import('../../facet_results/Network')) const Export = lazy(() => import('../../facet_results/Export')) const Perspective1 = props => { - const { rootUrl, perspective, screenSize } = props + const { rootUrl, perspective, screenSize, portalConfig } = props const layerControlExpanded = screenSize === 'md' || screenSize === 'lg' || screenSize === 'xl' @@ -40,6 +40,7 @@ const Perspective1 = props => { path={[`${props.rootUrl}/${perspective.id}/faceted-search/table`, '/iframe.html']} render={routeProps => <ResultTable + portalConfig={portalConfig} data={props.perspectiveState} facetUpdateID={props.facetState.facetUpdateID} resultClass='perspective1' @@ -57,8 +58,7 @@ const Perspective1 = props => { path={`${rootUrl}/${perspective.id}/faceted-search/production_places`} render={() => <LeafletMap - mapBoxAccessToken={props.mapBoxAccessToken} - mapBoxStyle={props.mapBoxStyle} + portalConfig={portalConfig} center={props.perspectiveState.maps.placesMsProduced.center} zoom={props.perspectiveState.maps.placesMsProduced.zoom} // center={[60.187, 24.821]} @@ -99,6 +99,7 @@ const Perspective1 = props => { path={`${rootUrl}/${perspective.id}/faceted-search/production_places_heatmap`} render={() => <Deck + portalConfig={portalConfig} center={props.perspectiveState.maps.placesMsProducedHeatmap.center} zoom={props.perspectiveState.maps.placesMsProducedHeatmap.zoom} results={props.perspectiveState.results} @@ -108,8 +109,6 @@ const Perspective1 = props => { fetchResults={props.fetchResults} fetching={props.perspectiveState.fetching} layerType='heatmapLayer' - mapBoxAccessToken={props.mapBoxAccessToken} - mapBoxStyle={props.mapBoxStyle} updateMapBounds={props.updateMapBounds} layoutConfig={props.layoutConfig} />} @@ -118,8 +117,7 @@ const Perspective1 = props => { path={`${rootUrl}/${perspective.id}/faceted-search/last_known_locations`} render={() => <LeafletMap - mapBoxAccessToken={props.mapBoxAccessToken} - mapBoxStyle={props.mapBoxStyle} + portalConfig={portalConfig} center={props.perspectiveState.maps.lastKnownLocations.center} zoom={props.perspectiveState.maps.lastKnownLocations.zoom} results={props.perspectiveState.results} @@ -157,6 +155,7 @@ const Perspective1 = props => { path={`${rootUrl}/${perspective.id}/faceted-search/migrations`} render={() => <Deck + portalConfig={portalConfig} center={props.perspectiveState.maps.placesMsMigrations.center} zoom={props.perspectiveState.maps.placesMsMigrations.zoom} results={props.perspectiveState.results} @@ -182,8 +181,6 @@ const Perspective1 = props => { listHeadingMultipleInstances={intl.get('deckGlMap.manuscriptMigrations.listHeadingMultipleInstances')} instanceVariable='manuscript' showTooltips - mapBoxAccessToken={props.mapBoxAccessToken} - mapBoxStyle={props.mapBoxStyle} layoutConfig={props.layoutConfig} />} /> @@ -191,6 +188,7 @@ const Perspective1 = props => { path={`${rootUrl}/${perspective.id}/faceted-search/choropleth_map`} render={() => <Deck + portalConfig={portalConfig} center={props.perspectiveState.maps.casualtiesByMunicipality.center} zoom={props.perspectiveState.maps.casualtiesByMunicipality.zoom} results={props.perspectiveState.results} @@ -205,7 +203,6 @@ const Perspective1 = props => { fetchingInstanceAnalysisData={props.perspectiveState.fetchingInstanceAnalysisData} layerType='polygonLayer' mapBoxAccessToken={props.mapBoxAccessToken} - mapBoxStyle={props.mapBoxStyle} layoutConfig={props.layoutConfig} />} /> @@ -213,6 +210,7 @@ const Perspective1 = props => { path={`${rootUrl}/${perspective.id}/faceted-search/production_dates`} render={() => <ApexChart + portalConfig={portalConfig} pageType='facetResults' rawData={props.perspectiveState.results} rawDataUpdateID={props.perspectiveState.resultUpdateID} @@ -236,6 +234,7 @@ const Perspective1 = props => { path={`${rootUrl}/${perspective.id}/faceted-search/event_dates`} render={() => <ApexChart + portalConfig={portalConfig} pageType='facetResults' rawData={props.perspectiveState.results} rawDataUpdateID={props.perspectiveState.resultUpdateID} @@ -272,6 +271,7 @@ const Perspective1 = props => { path={`${rootUrl}/${perspective.id}/faceted-search/bar_chart_race_ms_productions`} render={() => <BarChartRace + portalConfig={portalConfig} fetchData={props.fetchResults} resultClass='productionsByDecadeAndCountry' facetClass='perspective1' @@ -287,6 +287,7 @@ const Perspective1 = props => { path={`${rootUrl}/${perspective.id}/faceted-search/bar_chart_race_speeches`} render={() => <BarChartRace + portalConfig={portalConfig} fetchData={props.fetchResults} resultClass='speechesByYearAndParty' facetClass='perspective1' @@ -302,6 +303,7 @@ const Perspective1 = props => { path={`${rootUrl}/${perspective.id}/faceted-search/network`} render={() => <Network + portalConfig={portalConfig} results={props.perspectiveState.results} facetUpdateID={props.facetState.facetUpdateID} resultUpdateID={props.perspectiveState.resultUpdateID} @@ -322,6 +324,7 @@ const Perspective1 = props => { path={`${rootUrl}/${perspective.id}/faceted-search/export`} render={() => <Export + portalConfig={portalConfig} data={props.perspectiveState} resultClass='perspective1' facetClass='perspective1' @@ -329,8 +332,6 @@ const Perspective1 = props => { fetchPaginatedResults={props.fetchPaginatedResults} updatePage={props.updatePage} layoutConfig={props.layoutConfig} - yasguiBaseUrl={props.yasguiBaseUrl} - yasguiParams={props.yasguiParams} />} /> </> diff --git a/src/client/components/perspectives/sampo/Perspective2.js b/src/client/components/perspectives/sampo/Perspective2.js index e611098abdc43e005096aa64fc0c07df30aae5c9..dd9b9d984a8ab7df7d1c9def6f13f6b99844a46a 100644 --- a/src/client/components/perspectives/sampo/Perspective2.js +++ b/src/client/components/perspectives/sampo/Perspective2.js @@ -6,7 +6,7 @@ const ResultTable = lazy(() => import('../../facet_results/ResultTable')) const Export = lazy(() => import('../../facet_results/Export')) const Perspective2 = props => { - const { rootUrl, perspective } = props + const { rootUrl, perspective, portalConfig } = props return ( <> <PerspectiveTabs @@ -23,6 +23,7 @@ const Perspective2 = props => { path={`${props.rootUrl}/${perspective.id}/faceted-search/table`} render={routeProps => <ResultTable + portalConfig={portalConfig} data={props.perspectiveState} facetUpdateID={props.facetState.facetUpdateID} resultClass='perspective2' @@ -40,6 +41,7 @@ const Perspective2 = props => { path={`${rootUrl}/${perspective.id}/faceted-search/export`} render={() => <Export + portalConfig={portalConfig} data={props.perspectiveState} resultClass='perspective2' facetClass='perspective2' diff --git a/src/client/components/perspectives/sampo/Perspective3.js b/src/client/components/perspectives/sampo/Perspective3.js index 04b40b62ffd3695c5e1d486a4217849c917381b9..8c80c4dd03e830dfe5ac689dbf5509114d88e317 100644 --- a/src/client/components/perspectives/sampo/Perspective3.js +++ b/src/client/components/perspectives/sampo/Perspective3.js @@ -7,7 +7,7 @@ const LeafletMap = lazy(() => import('../../facet_results/LeafletMap')) const Export = lazy(() => import('../../facet_results/Export')) const Perspective3 = props => { - const { rootUrl, perspective, screenSize } = props + const { rootUrl, perspective, screenSize, portalConfig } = props const layerControlExpanded = screenSize === 'md' || screenSize === 'lg' || screenSize === 'xl' @@ -27,6 +27,7 @@ const Perspective3 = props => { path={`${props.rootUrl}/${perspective.id}/faceted-search/table`} render={routeProps => <ResultTable + portalConfig={portalConfig} data={props.perspectiveState} facetUpdateID={props.facetState.facetUpdateID} resultClass='perspective3' @@ -44,8 +45,7 @@ const Perspective3 = props => { path={`${rootUrl}/${perspective.id}/faceted-search/map`} render={() => <LeafletMap - mapBoxAccessToken={props.mapBoxAccessToken} - mapBoxStyle={props.mapBoxStyle} + portalConfig={portalConfig} center={props.perspectiveState.maps.placesEvents.center} zoom={props.perspectiveState.maps.placesEvents.zoom} results={props.perspectiveState.results} @@ -81,6 +81,7 @@ const Perspective3 = props => { path={`${rootUrl}/${perspective.id}/faceted-search/export`} render={() => <Export + portalConfig={portalConfig} data={props.perspectiveState} resultClass='perspective3' facetClass='perspective3' @@ -88,8 +89,6 @@ const Perspective3 = props => { fetchPaginatedResults={props.fetchPaginatedResults} updatePage={props.updatePage} layoutConfig={props.layoutConfig} - yasguiBaseUrl={props.yasguiBaseUrl} - yasguiParams={props.yasguiParams} />} /> </> @@ -98,92 +97,92 @@ const Perspective3 = props => { Perspective3.propTypes = { /** - * Faceted search configs and results of this perspective. - */ + * Faceted search configs and results of this perspective. + */ perspectiveState: PropTypes.object.isRequired, /** - * Faceted search configs and results of places related to this perspective. - */ + * Faceted search configs and results of places related to this perspective. + */ facetState: PropTypes.object.isRequired, /** - * Facet values where facets constrain themselves, used for statistics. - */ - facetConstrainSelfState: PropTypes.object.isRequired, + * Facet values where facets constrain themselves, used for statistics. + */ + facetConstrainSelfState: PropTypes.object, /** - * Leaflet map config and external layers. - */ - leafletMapState: PropTypes.object.isRequired, + * Leaflet map config and external layers. + */ + leafletMapState: PropTypes.object, /** - * Redux action for fetching paginated results. - */ + * Redux action for fetching paginated results. + */ fetchPaginatedResults: PropTypes.func.isRequired, /** - * Redux action for fetching all results. - */ + * Redux action for fetching all results. + */ fetchResults: PropTypes.func.isRequired, /** - * Redux action for fetching facet values for statistics. - */ - fetchFacetConstrainSelf: PropTypes.func.isRequired, + * Redux action for fetching facet values for statistics. + */ + fetchFacetConstrainSelf: PropTypes.func, /** - * Redux action for loading external GeoJSON layers. - */ - fetchGeoJSONLayers: PropTypes.func.isRequired, + * Redux action for loading external GeoJSON layers. + */ + fetchGeoJSONLayers: PropTypes.func, /** - * Redux action for loading external GeoJSON layers via backend. - */ - fetchGeoJSONLayersBackend: PropTypes.func.isRequired, + * Redux action for loading external GeoJSON layers via backend. + */ + fetchGeoJSONLayersBackend: PropTypes.func, /** - * Redux action for clearing external GeoJSON layers. - */ - clearGeoJSONLayers: PropTypes.func.isRequired, + * Redux action for clearing external GeoJSON layers. + */ + clearGeoJSONLayers: PropTypes.func, /** - * Redux action for fetching information about a single entity. - */ + * Redux action for fetching information about a single entity. + */ fetchByURI: PropTypes.func.isRequired, /** - * Redux action for updating the page of paginated results. - */ + * Redux action for updating the page of paginated results. + */ updatePage: PropTypes.func.isRequired, /** - * Redux action for updating the rows per page of paginated results. - */ + * Redux action for updating the rows per page of paginated results. + */ updateRowsPerPage: PropTypes.func.isRequired, /** - * Redux action for sorting the paginated results. - */ + * Redux action for sorting the paginated results. + */ sortResults: PropTypes.func.isRequired, /** - * Redux action for updating the active selection or config of a facet. - */ + * Redux action for updating the active selection or config of a facet. + */ showError: PropTypes.func.isRequired, /** - * Redux action for showing an error - */ + * Redux action for showing an error + */ updateFacetOption: PropTypes.func.isRequired, /** - * Routing information from React Router. - */ + * Routing information from React Router. + */ routeProps: PropTypes.object.isRequired, /** - * Perspective config. - */ + * Perspective config. + */ perspective: PropTypes.object.isRequired, /** - * State of the animation, used by TemporalMap. - */ - animationValue: PropTypes.array.isRequired, + * State of the animation, used by TemporalMap. + */ + animationValue: PropTypes.array, /** - * Redux action for animating TemporalMap. - */ - animateMap: PropTypes.func.isRequired, + * Redux action for animating TemporalMap. + */ + animateMap: PropTypes.func, /** - * Current screen size. - */ + * Current screen size. + */ screenSize: PropTypes.string.isRequired, /** - * Root url of the application. - */ + * Root url of the application. + */ rootUrl: PropTypes.string.isRequired, layoutConfig: PropTypes.object.isRequired } diff --git a/src/client/components/perspectives/sampo/client_fs/ClientFSPerspective.js b/src/client/components/perspectives/sampo/client_fs/ClientFSPerspective.js index 8d25c469234322ee512828134bd9b53356c3622d..cf802f10cc5b2dcd11d398427ea772878bc4b050 100644 --- a/src/client/components/perspectives/sampo/client_fs/ClientFSPerspective.js +++ b/src/client/components/perspectives/sampo/client_fs/ClientFSPerspective.js @@ -11,7 +11,7 @@ import Pie from '../../../facet_results/Pie.js' import CSVButton from '../../../facet_results/CSVButton' const ClientFSPerspective = props => { - const { rootUrl, perspective, screenSize, clientFSState, layoutConfig } = props + const { rootUrl, perspective, screenSize, clientFSState, layoutConfig, portalConfig } = props const { maps } = clientFSState const { clientFSMapClusters, clientFSMapMarkers } = maps // console.log(clientFSMapClusters) @@ -34,6 +34,7 @@ const ClientFSPerspective = props => { path={`${rootUrl}/${perspective.id}/federated-search/table`} render={() => <VirtualizedTable + portalConfig={portalConfig} list={Immutable.List(props.clientFSResults)} clientFSState={props.clientFSState} clientFSSortResults={props.clientFSSortResults} @@ -45,8 +46,7 @@ const ClientFSPerspective = props => { path={`${rootUrl}/${perspective.id}/federated-search/map_clusters`} render={() => <LeafletMap - mapBoxAccessToken={props.mapBoxAccessToken} - mapBoxStyle={props.mapBoxStyle} + portalConfig={portalConfig} center={clientFSMapClusters.center} zoom={clientFSMapClusters.zoom} results={props.clientFSResults} @@ -78,8 +78,7 @@ const ClientFSPerspective = props => { } else { return ( <LeafletMap - mapBoxAccessToken={props.mapBoxAccessToken} - mapBoxStyle={props.mapBoxStyle} + portalConfig={portalConfig} center={clientFSMapMarkers.center} zoom={clientFSMapMarkers.zoom} results={props.clientFSResults} @@ -110,6 +109,7 @@ const ClientFSPerspective = props => { path={`${rootUrl}/${perspective.id}/federated-search/statistics`} render={() => <Pie + portalConfig={portalConfig} data={props.clientFSResults} groupBy={props.clientFSState.groupBy} groupByLabel={props.clientFSState.groupByLabel} @@ -120,7 +120,11 @@ const ClientFSPerspective = props => { <Route path={`${rootUrl}/${perspective.id}/federated-search/download`} render={() => - <CSVButton results={props.clientFSResults} layoutConfig={layoutConfig} />} + <CSVButton + results={props.clientFSResults} + layoutConfig={layoutConfig} + portalConfig={portalConfig} + />} /> </> ) diff --git a/src/client/configs/PortalConfig.json b/src/client/configs/PortalConfig.json index f9636eccad7f5602eae81013563c73d9fc7930b4..91ff1b1344ed1707bd74b642cdefcb342482bb95 100644 --- a/src/client/configs/PortalConfig.json +++ b/src/client/configs/PortalConfig.json @@ -1,15 +1,82 @@ { "portalID": "sampo", - "localeConfig": [ - { - "id": "en", - "label": "English", - "filename": "localeEN.json" + "rootUrl": "", + "localeConfig": { + "defaultLocale": "en", + "readTranslationsFromGoogleSheets": "false", + "availableLocales": [ + { + "id": "en", + "label": "English", + "filename": "localeEN.json" + }, + { + "id": "fi", + "label": "English", + "filename": "localeFI.json" + } + ] + }, + "layoutConfig": { + "hundredPercentHeightBreakPoint": "md", + "reducedHeightBreakpoint": "xl", + "tabHeight": 58, + "paginationToolbarHeight": 37, + "topBar": { + "showLanguageButton": true, + "feedbackLink": "https://link.webropolsurveys.com/...", + "reducedHeight": 48, + "defaultHeight": 64, + "mobileMenuBreakpoint": 1360 }, - { - "id": "fi", - "label": "English", - "filename": "localeFI.json" + "mainPage": { + "bannerImage": "main_page/mmm-banner.jpg", + "bannerBackround": "linear-gradient( rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.45) ), url(<BANNER_IMAGE_URL)", + "bannerMobileHeight": 150, + "bannerReducedHeight": 220, + "bannerDefaultHeight": 300 + }, + "infoHeader": { + "default": { + "height": 49, + "expandedContentHeight": 160, + "headingVariant": "h4", + "infoIconFontSize": 40 + }, + "reducedHeight": { + "height": 40, + "expandedContentHeight": 100, + "headingVariant": "h6", + "infoIconFontSize": 32 + } + }, + "footer": { + "reducedHeight": 44, + "defaultHeight": 64 + } + }, + "mapboxConfig": { + "mapboxAccessToken": "pk.eyJ1IjoiZWtrb25lbiIsImEiOiJja2FkbGxiY2owMDZkMnFxcGVqNTZ0dmk2In0.6keLTN8VveJkM5y4_OFmUw", + "mapboxStyle": "light-v10" + }, + "yasguiConfig": { + "yasguiBaseURL": "https://yasgui.triply.cc", + "yasguiParams": { + "contentTypeConstruct": "text/turtle", + "contentTypeSelect": "application/sparql-results+json", + "endpoint": "http://ldf.fi/mmm/sparql", + "requestMethod": "POST", + "tabTitle": "Exported query" + } + }, + "documentFinderConfig": { + "apiURL": "https://data.finlex.fi/document-finder-backend" + }, + "temporalMapConfig": { + "sliderDuration": { + "halfSpeed": 1200, + "normalSpeed": 600, + "doubleSpeed": 300 } - ] + } } \ No newline at end of file diff --git a/src/client/configs/sampo/GeneralConfig.js b/src/client/configs/sampo/GeneralConfig.js deleted file mode 100644 index 4fdb723af1528b4e47848adbf41d0120ee931603..0000000000000000000000000000000000000000 --- a/src/client/configs/sampo/GeneralConfig.js +++ /dev/null @@ -1,69 +0,0 @@ -import bannerImage from '../../img/main_page/mmm-banner.jpg' - -export const rootUrl = '' - -export const defaultLocale = 'en' - -export const readTranslationsFromGoogleSheets = false - -export const MAPBOX_ACCESS_TOKEN = 'pk.eyJ1IjoiZWtrb25lbiIsImEiOiJja2FkbGxiY2owMDZkMnFxcGVqNTZ0dmk2In0.6keLTN8VveJkM5y4_OFmUw' // https://docs.mapbox.com/accounts/overview/tokens/ - -export const MAPBOX_STYLE = 'light-v10' // https://docs.mapbox.com/api/maps/#styles - -export const documentFinderAPIUrl = 'https://data.finlex.fi/document-finder-backend' - -export const yasguiBaseUrl = 'https://yasgui.triply.cc' - -export const yasguiParams = { - contentTypeConstruct: 'text/turtle', - contentTypeSelect: 'application/sparql-results+json', - endpoint: 'http://ldf.fi/mmm/sparql', - requestMethod: 'POST', - tabTitle: 'Exported query' -} - -export const SLIDER_DURATION = { - halfSpeed: 1200, - normalSpeed: 600, - doubleSpeed: 300 -} - -export const layoutConfig = { - hundredPercentHeightBreakPoint: 'md', - reducedHeightBreakpoint: 'xl', - tabHeight: 58, - paginationToolbarHeight: 37, - tableFontSize: '0.8rem', - topBar: { - showLanguageButton: true, - feedbackLink: 'https://link.webropolsurveys.com/', - // 48 px is minimun for tab targets: https://web.dev/tap-targets/?utm_source=lighthouse&utm_medium=devtools#how-to-fix-your-tap-targets - reducedHeight: 48, - defaultHeight: 64, - mobileMenuBreakpoint: 1360 - }, - mainPage: { - bannerBackround: `linear-gradient( rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.45) ), url(${bannerImage})`, - bannerMobileHeight: 150, - bannerReducedHeight: 220, - bannerDefaultHeight: 300 - }, - infoHeader: { - default: { - height: 49, - expandedContentHeight: 160, - headingVariant: 'h4', - infoIconFontSize: 40 - }, - reducedHeight: { - height: 40, - expandedContentHeight: 100, - headingVariant: 'h6', - infoIconFontSize: 32 - } - }, - footer: { - reducedHeight: 44, - defaultHeight: 64 - } -} diff --git a/src/client/containers/SemanticPortal.js b/src/client/containers/SemanticPortal.js index 7ff8fbb2f583653203ab792b137b92a041b9f22d..a0920ddca7c6ab90c98e28858a0096150f94600a 100644 --- a/src/client/containers/SemanticPortal.js +++ b/src/client/containers/SemanticPortal.js @@ -51,18 +51,16 @@ import { filterResults } from '../selectors' // ** Portal configuration ** import portalConfig from '../configs/PortalConfig.json' -const { portalID } = portalConfig -const { default: perspectiveConfig } = await import(`../configs/${portalID}/PerspectiveConfig.json`) -const { default: perspectiveConfigOnlyInfoPages } = await import(`../configs/${portalID}/PerspectiveConfigOnlyInfoPages.json`) const { + portalID, rootUrl, - layoutConfig, - MAPBOX_ACCESS_TOKEN, - MAPBOX_STYLE, - SLIDER_DURATION, - yasguiBaseUrl, - yasguiParams -} = await import(`../configs/${portalID}/GeneralConfig`) + layoutConfig +} = portalConfig +const { bannerImage, bannerBackround } = layoutConfig.mainPage +const { default: bannerImageURL } = await import(/* webpackMode: "eager" */ `../img/${bannerImage}`) +layoutConfig.mainPage.bannerBackround = bannerBackround.replace('<BANNER_IMAGE_URL', bannerImageURL) +const { default: perspectiveConfig } = await import(`../configs/${portalID}/PerspectiveConfig.json`) +const { default: perspectiveConfigOnlyInfoPages } = await import(`../configs/${portalID}/PerspectiveConfigOnlyInfoPages.json`) // ** Portal configuration end ** // ** General components ** @@ -165,20 +163,18 @@ const useStyles = makeStyles(theme => ({ margin: theme.spacing(0.5), width: `calc(100% - ${theme.spacing(1)}px)`, [theme.breakpoints.up(layoutConfig.hundredPercentHeightBreakPoint)]: { - height: `calc(100% - ${ - layoutConfig.topBar.reducedHeight + + height: `calc(100% - ${layoutConfig.topBar.reducedHeight + layoutConfig.infoHeader.reducedHeight.height + layoutConfig.infoHeader.reducedHeight.expandedContentHeight + theme.spacing(3.5) - }px)` + }px)` }, [theme.breakpoints.up(layoutConfig.reducedHeightBreakpoint)]: { - height: `calc(100% - ${ - layoutConfig.topBar.defaultHeight + + height: `calc(100% - ${layoutConfig.topBar.defaultHeight + layoutConfig.infoHeader.default.height + layoutConfig.infoHeader.default.expandedContentHeight + theme.spacing(3.5) - }px)` + }px)` } }, // perspective container is divided into two columns: @@ -242,20 +238,18 @@ const useStyles = makeStyles(theme => ({ margin: theme.spacing(0.5), width: `calc(100% - ${theme.spacing(1)}px)`, [theme.breakpoints.up(layoutConfig.hundredPercentHeightBreakPoint)]: { - height: `calc(100% - ${ - layoutConfig.topBar.reducedHeight + + height: `calc(100% - ${layoutConfig.topBar.reducedHeight + 2 * layoutConfig.infoHeader.reducedHeight.height + layoutConfig.infoHeader.reducedHeight.expandedContentHeight + theme.spacing(3.5) - }px)` + }px)` }, [theme.breakpoints.up(layoutConfig.reducedHeightBreakpoint)]: { - height: `calc(100% - ${ - layoutConfig.topBar.defaultHeight + + height: `calc(100% - ${layoutConfig.topBar.defaultHeight + 89 + layoutConfig.infoHeader.default.expandedContentHeight + theme.spacing(3.5) - }px)` + }px)` } }, instancePageContent: { @@ -326,7 +320,10 @@ const SemanticPortal = props => { rootUrl={rootUrlWithLang} layoutConfig={layoutConfig} /> - <Footer layoutConfig={layoutConfig} /> + <Footer + portalConfig={portalConfig} + layoutConfig={layoutConfig} + /> </>} /> {/* https://stackoverflow.com/a/41024944 */} @@ -364,12 +361,13 @@ const SemanticPortal = props => { return ( <> <InfoHeader + portalConfig={portalConfig} + layoutConfig={layoutConfig} resultClass={perspective.id} pageType='facetResults' expanded={props[perspective.id].facetedSearchHeaderExpanded} updateExpanded={props.updatePerspectiveHeaderExpanded} screenSize={screenSize} - layoutConfig={layoutConfig} /> <Grid container spacing={1} className={props[perspective.id].facetedSearchHeaderExpanded @@ -378,6 +376,8 @@ const SemanticPortal = props => { > <Grid item xs={12} md={3} className={classes.facetBarContainer}> <FacetBar + portalConfig={portalConfig} + layoutConfig={layoutConfig} facetedSearchMode='serverFS' facetData={props[`${perspective.id}Facets`]} facetDataConstrainSelf={props[`${perspective.id}FacetsConstrainSelf`]} @@ -397,9 +397,6 @@ const SemanticPortal = props => { defaultActiveFacets={perspective.defaultActiveFacets} rootUrl={rootUrlWithLang} screenSize={screenSize} - layoutConfig={layoutConfig} - mapBoxAccessToken={MAPBOX_ACCESS_TOKEN} - mapBoxStyle={MAPBOX_STYLE} barChartConfig={barChartConfig} lineChartConfig={lineChartConfig} pieChartConfig={pieChartConfig} @@ -409,8 +406,9 @@ const SemanticPortal = props => { </Grid> <Grid item xs={12} md={9} className={classes.resultsContainer}> <PerspectiveComponent - portalID={portalID} - perspectiveConfig={perspectiveConfig} + portalConfig={portalConfig} + layoutConfig={layoutConfig} + perspectiveConfig={perspective} perspectiveState={props[`${perspective.id}`]} facetState={props[`${perspective.id}Facets`]} facetConstrainSelfState={props[`${perspective.id}FacetsConstrainSelf`]} @@ -435,17 +433,11 @@ const SemanticPortal = props => { animateMap={props.animateMap} screenSize={screenSize} rootUrl={rootUrlWithLang} - layoutConfig={layoutConfig} - mapBoxAccessToken={MAPBOX_ACCESS_TOKEN} - mapBoxStyle={MAPBOX_STYLE} barChartConfig={barChartConfig} lineChartConfig={lineChartConfig} pieChartConfig={pieChartConfig} leafletConfig={leafletConfig} networkConfig={networkConfig} - yasguiBaseUrl={yasguiBaseUrl} - yasguiParams={yasguiParams} - sliderDuration={SLIDER_DURATION} /> </Grid> </Grid> @@ -467,13 +459,14 @@ const SemanticPortal = props => { return ( <> <InfoHeader + portalConfig={portalConfig} + layoutConfig={layoutConfig} resultClass={perspective.id} pageType='instancePage' instanceData={props[perspective.id].instanceTableData} expanded={props[perspective.id].instancePageHeaderExpanded} updateExpanded={props.updatePerspectiveHeaderExpanded} screenSize={screenSize} - layoutConfig={layoutConfig} /> <Grid container spacing={1} className={props[perspective.id].instancePageHeaderExpanded @@ -482,8 +475,10 @@ const SemanticPortal = props => { > <Grid item xs={12} className={classes.instancePageContent}> <InstanceHomePage - perspectiveState={props[`${perspective.id}`]} + portalConfig={portalConfig} + layoutConfig={layoutConfig} perspectiveConfig={perspective} + perspectiveState={props[`${perspective.id}`]} leafletMapState={props.leafletMap} fetchPaginatedResults={props.fetchPaginatedResults} fetchResults={props.fetchResults} @@ -505,15 +500,11 @@ const SemanticPortal = props => { animateMap={props.animateMap} screenSize={screenSize} rootUrl={rootUrlWithLang} - layoutConfig={layoutConfig} - mapBoxAccessToken={MAPBOX_ACCESS_TOKEN} - mapBoxStyle={MAPBOX_STYLE} barChartConfig={barChartConfig} lineChartConfig={lineChartConfig} pieChartConfig={pieChartConfig} leafletConfig={leafletConfig} networkConfig={networkConfig} - portalConfig={portalConfig} /> </Grid> </Grid> @@ -540,13 +531,14 @@ const SemanticPortal = props => { return ( <> <InfoHeader + portalConfig={portalConfig} + layoutConfig={layoutConfig} resultClass={perspective.id} pageType='instancePage' instanceData={props[perspective.id].instanceTableData} expanded={props[perspective.id].instancePageHeaderExpanded} updateExpanded={props.updatePerspectiveHeaderExpanded} screenSize={screenSize} - layoutConfig={layoutConfig} /> <Grid container spacing={1} className={props[perspective.id].instancePageHeaderExpanded @@ -555,8 +547,10 @@ const SemanticPortal = props => { > <Grid item xs={12} className={classes.instancePageContent}> <InstanceHomePage - perspectiveState={props[`${perspective.id}`]} + portalConfig={portalConfig} + layoutConfig={layoutConfig} perspectiveConfig={perspective} + perspectiveState={props[`${perspective.id}`]} leafletMapState={props.leafletMap} fetchPaginatedResults={props.fetchPaginatedResults} fetchResults={props.fetchResults} @@ -578,15 +572,11 @@ const SemanticPortal = props => { animateMap={props.animateMap} screenSize={screenSize} rootUrl={rootUrlWithLang} - layoutConfig={layoutConfig} - mapBoxAccessToken={MAPBOX_ACCESS_TOKEN} - mapBoxStyle={MAPBOX_STYLE} barChartConfig={barChartConfig} lineChartConfig={lineChartConfig} pieChartConfig={pieChartConfig} leafletConfig={leafletConfig} networkConfig={networkConfig} - portalConfig={portalConfig} /> </Grid> </Grid> @@ -603,6 +593,8 @@ const SemanticPortal = props => { <Grid container className={classes.mainContainerClientFS}> <Grid item sm={12} md={4} lg={3} className={classes.facetBarContainerClientFS}> <FacetBar + portalConfig={portalConfig} + layoutConfig={layoutConfig} facetedSearchMode='clientFS' facetClass='clientFSPlaces' resultClass='clientFSPlaces' @@ -622,9 +614,6 @@ const SemanticPortal = props => { screenSize={screenSize} showError={props.showError} rootUrl={rootUrlWithLang} - layoutConfig={layoutConfig} - mapBoxAccessToken={MAPBOX_ACCESS_TOKEN} - mapBoxStyle={MAPBOX_STYLE} barChartConfig={barChartConfig} lineChartConfig={lineChartConfig} pieChartConfig={pieChartConfig} @@ -636,8 +625,10 @@ const SemanticPortal = props => { {noClientFSResults && <ClientFSMain />} {!noClientFSResults && <ClientFSPerspective - routeProps={routeProps} + portalConfig={portalConfig} + layoutConfig={layoutConfig} perspective={perspectiveConfig.find(p => p.id === 'clientFSPlaces')} + routeProps={routeProps} screenSize={screenSize} clientFSState={props.clientFSState} clientFSResults={props.clientFSResults} @@ -649,9 +640,6 @@ const SemanticPortal = props => { clearGeoJSONLayers={props.clearGeoJSONLayers} showError={props.showError} rootUrl={rootUrlWithLang} - layoutConfig={layoutConfig} - mapBoxAccessToken={MAPBOX_ACCESS_TOKEN} - mapBoxStyle={MAPBOX_STYLE} barChartConfig={barChartConfig} lineChartConfig={lineChartConfig} pieChartConfig={pieChartConfig} @@ -660,7 +648,10 @@ const SemanticPortal = props => { />} </Grid> </Grid> - <Footer layoutConfig={layoutConfig} /> + <Footer + portalConfig={portalConfig} + layoutConfig={layoutConfig} + /> </>} /> @@ -672,6 +663,8 @@ const SemanticPortal = props => { <TextPage> {intl.getHTML('aboutThePortalPartOne')} <KnowledgeGraphMetadataTable + portalConfig={portalConfig} + layoutConfig={layoutConfig} resultClass='perspective1KnowledgeGraphMetadata' fetchKnowledgeGraphMetadata={props.fetchKnowledgeGraphMetadata} knowledgeGraphMetadata={props.perspective1.knowledgeGraphMetadata} diff --git a/src/client/epics/index.js b/src/client/epics/index.js index f789c2027bb850da979ec3110163fa6b300b8b92..2c9db01e5d95d4a061097a20264b91fbfff3efe0 100644 --- a/src/client/epics/index.js +++ b/src/client/epics/index.js @@ -52,10 +52,10 @@ import { fetchGeoJSONLayersFailed } from '../actions' import portalConfig from '../configs/PortalConfig.json' -const { portalID, localeConfig } = portalConfig -const { documentFinderAPIUrl } = await import(`../configs/${portalID}/GeneralConfig`) +const { portalID, localeConfig, documentFinderConfig } = portalConfig +const { documentFinderAPIUrl } = documentFinderConfig export const availableLocales = {} -for (const locale of localeConfig) { +for (const locale of localeConfig.availableLocales) { availableLocales[locale.id] = await import(`../translations/${portalID}/${locale.filename}`) } diff --git a/src/client/index.js b/src/client/index.js index 660e39aabba33c92a4ee754c5f1e7b893a30be16..62030c855946665f551d2fefc0b3151144c87dec 100644 --- a/src/client/index.js +++ b/src/client/index.js @@ -19,8 +19,7 @@ import 'react-redux-toastr/lib/css/react-redux-toastr.min.css' import 'mapbox-gl/dist/mapbox-gl.css' import portalConfig from './configs/PortalConfig.json' -const { portalID } = portalConfig -const { defaultLocale } = await import(`./configs/${portalID}/GeneralConfig`) +const { defaultLocale } = portalConfig const store = configureStore() diff --git a/src/server/translations_generator/index.js b/src/server/translations_generator/index.js index df49fca20e9c67c0fcb40dc65541de46042e31da..c8c0d4fd6598c64f3cf69f335cd388b7e9da6ad4 100644 --- a/src/server/translations_generator/index.js +++ b/src/server/translations_generator/index.js @@ -1,12 +1,14 @@ import { google } from 'googleapis' import { /* flatten, */ unflatten } from 'flat' import fs from 'fs-extra' -import { readTranslationsFromGoogleSheets } from '../../../src/client/configs/sampo/GeneralConfig' +import { portalConfig } from '../../../src/client/configs/PortalConfig.json' // import localeEN from '../../client/translations/sampo/localeEN' import dotenv from 'dotenv' dotenv.config() +const { readTranslationsFromGoogleSheets } = portalConfig + // console.log(`spreadsheetId: ${process.env.SHEETS_API_SHEET_ID}`) // console.log(`credentials: ${process.env.GOOGLE_APPLICATION_CREDENTIALS}`)