Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/1259 - Circuit Browser filters #1261

Merged
merged 2 commits into from
Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ var locationCypherQuery = ( instances, paths, weight ) => ({
}
]
});

var Neo4jLabels = {
FAFB : "FAFB",
L1EM : "L1EM",
FlyEM_HB : "FlyEM_HB"
}

// See query explanation on https://github.com/VirtualFlyBrain/graph_queries/blob/main/weighted_path.md

var configuration = {
Expand Down Expand Up @@ -120,5 +127,6 @@ module.exports = {
configuration,
styling,
restPostConfig,
locationCypherQuery
locationCypherQuery,
Neo4jLabels
};
32 changes: 30 additions & 2 deletions components/interface/VFBCircuitBrowser/Controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,11 @@ const configuration = require('../../configuration/VFBCircuitBrowser/circuitBrow
const restPostConfig = require('../../configuration/VFBCircuitBrowser/circuitBrowserConfiguration').restPostConfig;
const cypherQuery = require('../../configuration/VFBCircuitBrowser/circuitBrowserConfiguration').locationCypherQuery;
const stylingConfiguration = require('../../configuration/VFBCircuitBrowser/circuitBrowserConfiguration').styling;
const Neo4jLabels = require('../../configuration/VFBCircuitBrowser/circuitBrowserConfiguration').Neo4jLabels;

const searchConfiguration = require('./../../configuration/VFBCircuitBrowser/datasources/SOLRclient').searchConfiguration;
const datasourceConfiguration = require('./../../configuration/VFBCircuitBrowser/datasources/SOLRclient').datasourceConfiguration;
const defaultDatasourceConfiguration = require('./../../configuration/VFBCircuitBrowser/datasources/SOLRclient').datasourceConfiguration;
const datasourceConfiguration = JSON.parse(JSON.stringify(defaultDatasourceConfiguration));

/**
* Create custom marks for Paths slider.
Expand Down Expand Up @@ -161,6 +163,10 @@ class AutocompleteResults extends Component {
this.setState({ filteredResults : results });
}

clearResults () {
this.setState({ filteredResults : {} });
}

getFilteredResults (){
return this.state.filteredResults;
}
Expand All @@ -179,8 +185,10 @@ class AutocompleteResults extends Component {
fullWidth
freeSolo
disableClearable
clearOnEscape
disablePortal
autoHighlight
clearOnBlur
value={this.fieldLabel}
id={this.props.index.toString()}
ListboxProps={{ style: { maxHeight: "10rem" } }}
Expand Down Expand Up @@ -267,6 +275,12 @@ class Controls extends Component {
this.props.vfbCircuitBrowser(UPDATE_CIRCUIT_QUERY, neurons);
delete this.autocompleteRef[id.toString()];
this.neuronFields = neurons;

if ( !this.state.neurons.find( neuron => neuron.id != "") ) {
// reset configuration of fq to default
datasourceConfiguration.query_settings.fq = defaultDatasourceConfiguration.query_settings.fq;
}

this.forceUpdate();
}

Expand Down Expand Up @@ -360,6 +374,12 @@ class Controls extends Component {
getResultsSOLR( event.target.value, this.autocompleteRef[this.setInputValue].current.handleResults,searchConfiguration.sorter,datasourceConfiguration );
}
this.neuronFields = neurons;

if ( !this.neuronFields.find( neuron => neuron.id != "") ) {
// reset configuration of fq to default
this.autocompleteRef[this.setInputValue].current.clearResults();
datasourceConfiguration.query_settings.fq = defaultDatasourceConfiguration.query_settings.fq;
}
}

/**
Expand All @@ -369,9 +389,17 @@ class Controls extends Component {
// Copy neurons and add selection to correct array index
let neurons = this.neuronFields;
let textFieldId = event.target.id.toString().split("-")[0];
let shortForm = this.autocompleteRef[textFieldId].current.getFilteredResults()[value] && this.autocompleteRef[textFieldId].current.getFilteredResults()[value].short_form;
let result = this.autocompleteRef[textFieldId].current.getFilteredResults()[value];
let shortForm = result && result.short_form;
neurons[index] = { id : shortForm, label : value };

result.facets_annotation.forEach( annotation => {
let facet = "facets_annotation:" + annotation;
if ( Object.values(Neo4jLabels).includes(annotation) && !datasourceConfiguration.query_settings.fq.includes(facet) ) {
datasourceConfiguration.query_settings.fq.push(facet);
}
});

// Keep track of query selected, and send an event to redux store that circuit has been updated
this.circuitQuerySelected = neurons;
this.props.vfbCircuitBrowser(UPDATE_CIRCUIT_QUERY, neurons);
Expand Down