Skip to content
Snippets Groups Projects
Commit 04c351c2 authored by esikkala's avatar esikkala
Browse files

Test manuscript -> author network

parent 3179ecef
No related branches found
Tags release_2021-10-01
No related merge requests found
...@@ -16,6 +16,25 @@ const styles = theme => ({ ...@@ -16,6 +16,25 @@ const styles = theme => ({
} }
}); });
const layout = {
name: 'cose',
idealEdgeLength: 100,
nodeOverlap: 20,
refresh: 20,
fit: true,
padding: 30,
randomize: false,
componentSpacing: 100,
nodeRepulsion: 400000,
edgeElasticity: 100,
nestingFactor: 5,
gravity: 80,
numIter: 1000,
initialTemp: 200,
coolingFactor: 0.95,
minTemp: 1.0
};
class Network extends React.Component { class Network extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
...@@ -23,20 +42,39 @@ class Network extends React.Component { ...@@ -23,20 +42,39 @@ class Network extends React.Component {
} }
componentDidMount = () => { componentDidMount = () => {
this.props.fetchResults({ this.props.fetchResults({
resultClass: this.props.resultClass, resultClass: this.props.resultClass,
facetClass: this.props.facetClass, facetClass: this.props.facetClass,
}); });
this.cy = cytoscape({ this.cy = cytoscape({
container: this.cyRef.current container: this.cyRef.current,
layout: { name: 'circle'},
style: [ // the stylesheet for the graph
{
selector: 'node',
style: {
'background-color': '#666',
'label': 'data(prefLabel)'
}
},
{
selector: 'edge',
style: {
'width': 3,
'line-color': '#ccc',
'target-arrow-color': '#ccc',
'target-arrow-shape': 'triangle'
}
}
]
}); });
this.cy.add([ }
{ group: 'nodes', data: { id: 'n0' }, position: { x: 100, y: 100 } },
{ group: 'nodes', data: { id: 'n1' }, position: { x: 200, y: 200 } }, componentDidUpdate = () => {
{ group: 'edges', data: { id: 'e0', source: 'n0', target: 'n1' } } if (this.props.results !== null) {
]); this.cy.add(this.props.results.elements);
this.cy.layout(layout).run();
}
} }
render = () => { render = () => {
......
...@@ -281,8 +281,13 @@ export const INITIAL_STATE = { ...@@ -281,8 +281,13 @@ export const INITIAL_STATE = {
], ],
}; };
const resultClasses = new Set([
'manuscripts',
'manuscriptsNetwork'
]);
const manuscripts = (state = INITIAL_STATE, action) => { const manuscripts = (state = INITIAL_STATE, action) => {
if (action.resultClass === 'manuscripts') { if (resultClasses.has(action.resultClass)) {
switch (action.type) { switch (action.type) {
case FETCH_RESULTS: case FETCH_RESULTS:
case FETCH_PAGINATED_RESULTS: case FETCH_PAGINATED_RESULTS:
......
...@@ -6,23 +6,24 @@ export const runNetworkQuery = async({ ...@@ -6,23 +6,24 @@ export const runNetworkQuery = async({
links, links,
nodes nodes
}) => { }) => {
const headers = { const payload = {
'Content-Type': 'application/x-www-form-urlencoded',
};
const params = JSON.stringify({
endpoint, endpoint,
prefixes, prefixes,
links,
nodes, nodes,
links limit: 500
}); };
const url = 'http://127.0.0.1:5000/query';
const config = {
headers: {
'Content-Type': 'application/json'
}
};
try { try {
const response = await axios({ const response = await axios.post(url, payload, config);
method: 'post', return {
headers: headers, data: response.data
url: 'http://127.0.0.1:5000/query', };
data: params,
});
return response.data;
} catch(error) { } catch(error) {
if (error.response) { if (error.response) {
// The request was made and the server responded with a status code // The request was made and the server responded with a status code
......
...@@ -428,9 +428,8 @@ export const networkLinksQuery = ` ...@@ -428,9 +428,8 @@ export const networkLinksQuery = `
SELECT DISTINCT ?source ?target SELECT DISTINCT ?source ?target
WHERE { WHERE {
<FILTER> <FILTER>
?source mmm-schema:manuscript_author ?target . ?target mmm-schema:manuscript_author ?source .
} }
LIMIT 100
`; `;
export const networkNodesQuery = ` export const networkNodesQuery = `
......
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