Skip to content

Commit

Permalink
Merge pull request #1261 from VirtualFlyBrain/feature/1259
Browse files Browse the repository at this point in the history
Feature/1259 - Circuit Browser filters
  • Loading branch information
ddelpiano authored Nov 25, 2021
2 parents 5a51ed7 + ac3235e commit 4876fb2
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
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

0 comments on commit 4876fb2

Please sign in to comment.