diff --git a/src/client/actions/index.js b/src/client/actions/index.js index d25cdfb4c8f34694a70ec0fc05e11319e3713a85..e3094c45652ee42acb2d06fe0f1823946df5e3c7 100644 --- a/src/client/actions/index.js +++ b/src/client/actions/index.js @@ -104,12 +104,10 @@ export const updateFacetValues = ({ id, data, flatValues, - min, - max, sparqlQuery }) => ({ type: UPDATE_FACET_VALUES, - facetClass, id, data, flatValues, min, max, sparqlQuery + facetClass, id, data, flatValues, sparqlQuery }); export const updateFacetOption = ({ facetClass, facetID, option, value }) => ({ type: UPDATE_FACET_OPTION, diff --git a/src/client/components/facet_results/Export.js b/src/client/components/facet_results/Export.js new file mode 100644 index 0000000000000000000000000000000000000000..c49c78b73c93fc6455f2da2aa3b11796a190083f --- /dev/null +++ b/src/client/components/facet_results/Export.js @@ -0,0 +1,62 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { withStyles } from '@material-ui/core/styles'; +// import CloudDownloadIcon from '@material-ui/icons/CloudDownload'; +import Button from '@material-ui/core/Button'; + +const styles = theme => ({ + root: { + height: '100%', + width: '100%', + display: 'flex', + alignItems: 'center', + justifyContent: 'center' + }, + link: { + textDecoration: 'none' + }, + button: { + margin: theme.spacing(3), + }, + rightIcon: { + marginLeft: theme.spacing(1), + }, +}); + +class Export extends React.Component { + + render = () => { + const { classes, sparqlQuery } = this.props; + let yasguiUrl = ''; + if (this.props.sparqlQuery !== null) { + yasguiUrl = 'http://yasgui.org/#query=' + + encodeURIComponent(sparqlQuery) + + '&contentTypeConstruct=text%2Fturtle&contentTypeSelect=application%2Fsparql-results' + + '%2Bjson&endpoint=http%3A%2F%2Fldf.fi%2Fmmm-cidoc%2Fsparql&requestMethod=POST&tabTitle=' + + 'Query+11&headers=%7B%7D&outputFormat=table'; + } + + return ( + <div className={classes.root}> + <a + className={classes.link} + href={yasguiUrl} + target='_blank' + rel='noopener noreferrer' + > + <Button variant="contained" color="primary" className={classes.button}> + Open result table SPARQL query in yasgui.org + </Button> + </a> + </div> + ); + } + +} + +Export.propTypes = { + classes: PropTypes.object.isRequired, + sparqlQuery: PropTypes.string +}; + +export default withStyles(styles)(Export); diff --git a/src/client/components/main_layout/PerspectiveTabs.js b/src/client/components/main_layout/PerspectiveTabs.js index 917048b5f8bea5b5c01a4a9ba470eb405bfdb769..e8d3c092a7945a4a7efc0522cac40303bfa2e63f 100644 --- a/src/client/components/main_layout/PerspectiveTabs.js +++ b/src/client/components/main_layout/PerspectiveTabs.js @@ -7,6 +7,7 @@ import Tab from '@material-ui/core/Tab'; import CalendarViewDayIcon from '@material-ui/icons/CalendarViewDay'; import AddLocationIcon from '@material-ui/icons/AddLocation'; import RedoIcon from '@material-ui/icons/Redo'; +import CloudDownloadIcon from '@material-ui/icons/CloudDownload'; import { Link } from 'react-router-dom'; import Paper from '@material-ui/core/Paper'; @@ -50,6 +51,9 @@ class PerspectiveTabs extends React.Component { case 'Redo': icon = <RedoIcon />; break; + case 'Download': + icon = <CloudDownloadIcon />; + break; } return icon; } diff --git a/src/client/components/perspectives/Manuscripts.js b/src/client/components/perspectives/Manuscripts.js index 71acc5902118bb8241c9a511bac95289a1498c40..93dfe559529c7476f4b4885387642efa31b18cee 100644 --- a/src/client/components/perspectives/Manuscripts.js +++ b/src/client/components/perspectives/Manuscripts.js @@ -7,6 +7,7 @@ import LeafletMap from '../facet_results/LeafletMap'; import Deck from '../facet_results/Deck'; import Pie from '../facet_results/Pie'; import Network from '../facet_results/Network'; +import Export from '../facet_results/Export'; let Manuscripts = props => { return ( @@ -34,6 +35,11 @@ let Manuscripts = props => { value: 2, icon: 'Redo', }, + '/manuscripts/export': { + label: 'export', + value: 3, + icon: 'Download', + }, // '/manuscripts/network': { // label: 'network', // value: 3, @@ -106,6 +112,13 @@ let Manuscripts = props => { showInstanceCountInClusters={true} />} /> + <Route + path={'/manuscripts/export'} + render={() => + <Export + sparqlQuery={props.manuscripts.sparqlQuery} + />} + /> <Route path={'/manuscripts/network'} render={() => diff --git a/src/client/epics/index.js b/src/client/epics/index.js index 707220f4ca2d6adbf011573fcefe2ca29aa9136c..08031c00db00d2267cf53254a5535ad235213ff5 100644 --- a/src/client/epics/index.js +++ b/src/client/epics/index.js @@ -234,8 +234,6 @@ const fetchFacetEpic = (action$, state$) => action$.pipe( id: facetID, data: res.data || [], flatData: res.flatData || [], - min: res.min || null, - max: res.max || null, sparqlQuery: res.sparqlQuery })), catchError(error => of({ diff --git a/src/client/reducers/helpers.js b/src/client/reducers/helpers.js index 7b243250820204b1a01f6f27a3762db1bfb50cb9..ef0923a8f2be697ac99b854ced029bbe61902f96 100644 --- a/src/client/reducers/helpers.js +++ b/src/client/reducers/helpers.js @@ -157,6 +157,7 @@ export const updatePaginatedResults = (state, action) => { ...state, resultsUpdateID: ++state.resultsUpdateID, paginatedResults: action.data || [], + sparqlQuery: action.sparqlQuery, fetching: false }; }; @@ -196,14 +197,13 @@ export const updateFacetValues = (state, action) => { ...state.facets, [ action.id ]: { ...state.facets[action.id], - min: action.min || null, - max: action.max || null, + min: action.data.min || null, + max: action.data.max || null, isFetching: false } } }; } else { - console.log(action) return { ...state, facets: { diff --git a/src/client/reducers/manuscripts.js b/src/client/reducers/manuscripts.js index 28cf0c4611ed214d4908ecd0fc8e83c65531241a..2ae92c7aff8303837898549e40bdef45711f5663 100644 --- a/src/client/reducers/manuscripts.js +++ b/src/client/reducers/manuscripts.js @@ -38,6 +38,7 @@ export const INITIAL_STATE = { sortDirection: null, fetching: false, fetchingResultCount: false, + sparqlQuery: null, tableColumns: [ { id: 'prefLabel', diff --git a/src/server/sparql/FacetResults.js b/src/server/sparql/FacetResults.js index d0655a05c229023cc94449d870238b40ccab4215..21872e917ef9798bee1d0fb31f81bc663de2c52f 100644 --- a/src/server/sparql/FacetResults.js +++ b/src/server/sparql/FacetResults.js @@ -96,9 +96,6 @@ export const getAllResults = ({ facetID: null })); } - // if (variant == 'actorPlaces') { - // console.log(prefixes + q) - // } return runSelectQuery(prefixes + q, endpoint, mapper, resultFormat); }; diff --git a/src/server/sparql/FacetValues.js b/src/server/sparql/FacetValues.js index 55f6b50cf9fa99caf8ead5a8a20677029d126f88..649fcf5cce4ec90a443118a18ef2691cf7a66c06 100644 --- a/src/server/sparql/FacetValues.js +++ b/src/server/sparql/FacetValues.js @@ -102,11 +102,7 @@ export const getFacet = async ({ q = q.replace('<START_PROPERTY>', facetConfig.startProperty); q = q.replace('<END_PROPERTY>', facetConfig.endProperty); } - // if (facetID == 'productionPlace') { - // console.log(prefixes + q) - // } const response = await runSelectQuery(prefixes + q, endpoint, mapper, resultFormat); - console.log(response) return({ facetClass: facetClass, id: facetID,