Skip to content
Snippets Groups Projects
Commit 3d03ac5e authored by esikkala's avatar esikkala
Browse files

Testing export to yasgui button

parent 645919da
No related branches found
No related tags found
No related merge requests found
...@@ -104,12 +104,10 @@ export const updateFacetValues = ({ ...@@ -104,12 +104,10 @@ export const updateFacetValues = ({
id, id,
data, data,
flatValues, flatValues,
min,
max,
sparqlQuery sparqlQuery
}) => ({ }) => ({
type: UPDATE_FACET_VALUES, type: UPDATE_FACET_VALUES,
facetClass, id, data, flatValues, min, max, sparqlQuery facetClass, id, data, flatValues, sparqlQuery
}); });
export const updateFacetOption = ({ facetClass, facetID, option, value }) => ({ export const updateFacetOption = ({ facetClass, facetID, option, value }) => ({
type: UPDATE_FACET_OPTION, type: UPDATE_FACET_OPTION,
......
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);
...@@ -7,6 +7,7 @@ import Tab from '@material-ui/core/Tab'; ...@@ -7,6 +7,7 @@ import Tab from '@material-ui/core/Tab';
import CalendarViewDayIcon from '@material-ui/icons/CalendarViewDay'; import CalendarViewDayIcon from '@material-ui/icons/CalendarViewDay';
import AddLocationIcon from '@material-ui/icons/AddLocation'; import AddLocationIcon from '@material-ui/icons/AddLocation';
import RedoIcon from '@material-ui/icons/Redo'; import RedoIcon from '@material-ui/icons/Redo';
import CloudDownloadIcon from '@material-ui/icons/CloudDownload';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import Paper from '@material-ui/core/Paper'; import Paper from '@material-ui/core/Paper';
...@@ -50,6 +51,9 @@ class PerspectiveTabs extends React.Component { ...@@ -50,6 +51,9 @@ class PerspectiveTabs extends React.Component {
case 'Redo': case 'Redo':
icon = <RedoIcon />; icon = <RedoIcon />;
break; break;
case 'Download':
icon = <CloudDownloadIcon />;
break;
} }
return icon; return icon;
} }
......
...@@ -7,6 +7,7 @@ import LeafletMap from '../facet_results/LeafletMap'; ...@@ -7,6 +7,7 @@ import LeafletMap from '../facet_results/LeafletMap';
import Deck from '../facet_results/Deck'; import Deck from '../facet_results/Deck';
import Pie from '../facet_results/Pie'; import Pie from '../facet_results/Pie';
import Network from '../facet_results/Network'; import Network from '../facet_results/Network';
import Export from '../facet_results/Export';
let Manuscripts = props => { let Manuscripts = props => {
return ( return (
...@@ -34,6 +35,11 @@ let Manuscripts = props => { ...@@ -34,6 +35,11 @@ let Manuscripts = props => {
value: 2, value: 2,
icon: 'Redo', icon: 'Redo',
}, },
'/manuscripts/export': {
label: 'export',
value: 3,
icon: 'Download',
},
// '/manuscripts/network': { // '/manuscripts/network': {
// label: 'network', // label: 'network',
// value: 3, // value: 3,
...@@ -106,6 +112,13 @@ let Manuscripts = props => { ...@@ -106,6 +112,13 @@ let Manuscripts = props => {
showInstanceCountInClusters={true} showInstanceCountInClusters={true}
/>} />}
/> />
<Route
path={'/manuscripts/export'}
render={() =>
<Export
sparqlQuery={props.manuscripts.sparqlQuery}
/>}
/>
<Route <Route
path={'/manuscripts/network'} path={'/manuscripts/network'}
render={() => render={() =>
......
...@@ -234,8 +234,6 @@ const fetchFacetEpic = (action$, state$) => action$.pipe( ...@@ -234,8 +234,6 @@ const fetchFacetEpic = (action$, state$) => action$.pipe(
id: facetID, id: facetID,
data: res.data || [], data: res.data || [],
flatData: res.flatData || [], flatData: res.flatData || [],
min: res.min || null,
max: res.max || null,
sparqlQuery: res.sparqlQuery sparqlQuery: res.sparqlQuery
})), })),
catchError(error => of({ catchError(error => of({
......
...@@ -157,6 +157,7 @@ export const updatePaginatedResults = (state, action) => { ...@@ -157,6 +157,7 @@ export const updatePaginatedResults = (state, action) => {
...state, ...state,
resultsUpdateID: ++state.resultsUpdateID, resultsUpdateID: ++state.resultsUpdateID,
paginatedResults: action.data || [], paginatedResults: action.data || [],
sparqlQuery: action.sparqlQuery,
fetching: false fetching: false
}; };
}; };
...@@ -196,14 +197,13 @@ export const updateFacetValues = (state, action) => { ...@@ -196,14 +197,13 @@ export const updateFacetValues = (state, action) => {
...state.facets, ...state.facets,
[ action.id ]: { [ action.id ]: {
...state.facets[action.id], ...state.facets[action.id],
min: action.min || null, min: action.data.min || null,
max: action.max || null, max: action.data.max || null,
isFetching: false isFetching: false
} }
} }
}; };
} else { } else {
console.log(action)
return { return {
...state, ...state,
facets: { facets: {
......
...@@ -38,6 +38,7 @@ export const INITIAL_STATE = { ...@@ -38,6 +38,7 @@ export const INITIAL_STATE = {
sortDirection: null, sortDirection: null,
fetching: false, fetching: false,
fetchingResultCount: false, fetchingResultCount: false,
sparqlQuery: null,
tableColumns: [ tableColumns: [
{ {
id: 'prefLabel', id: 'prefLabel',
......
...@@ -96,9 +96,6 @@ export const getAllResults = ({ ...@@ -96,9 +96,6 @@ export const getAllResults = ({
facetID: null facetID: null
})); }));
} }
// if (variant == 'actorPlaces') {
// console.log(prefixes + q)
// }
return runSelectQuery(prefixes + q, endpoint, mapper, resultFormat); return runSelectQuery(prefixes + q, endpoint, mapper, resultFormat);
}; };
......
...@@ -102,11 +102,7 @@ export const getFacet = async ({ ...@@ -102,11 +102,7 @@ export const getFacet = async ({
q = q.replace('<START_PROPERTY>', facetConfig.startProperty); q = q.replace('<START_PROPERTY>', facetConfig.startProperty);
q = q.replace('<END_PROPERTY>', facetConfig.endProperty); q = q.replace('<END_PROPERTY>', facetConfig.endProperty);
} }
// if (facetID == 'productionPlace') {
// console.log(prefixes + q)
// }
const response = await runSelectQuery(prefixes + q, endpoint, mapper, resultFormat); const response = await runSelectQuery(prefixes + q, endpoint, mapper, resultFormat);
console.log(response)
return({ return({
facetClass: facetClass, facetClass: facetClass,
id: facetID, id: facetID,
......
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