Skip to content

Commit

Permalink
Merge pull request #472 from VirtualFlyBrain/development
Browse files Browse the repository at this point in the history
latest changes to Development
  • Loading branch information
Robbie1977 authored Dec 17, 2019
2 parents aef0a10 + 9e5e974 commit ece8a7e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 9 deletions.
52 changes: 43 additions & 9 deletions components/VFBMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export default class VFBMain extends React.Component {
this.idFromURL = undefined;
this.firstLoad = true;
this.idsFromURL = [];
this.urlQueryLoader = undefined;

this.UIElementsVisibility = {};

Expand Down Expand Up @@ -914,11 +915,15 @@ export default class VFBMain extends React.Component {
// Loading ids passed through the browser's url
if ((this.props.location.search.indexOf("id=VFB") == -1) && (this.props.location.search.indexOf("i=VFB") == -1)) {
this.idFromURL = "VFB_00017894";
var that = this;
var idList = this.props.location.search;
idList = idList.replace("?","").split("&");
for (let list in idList) {
if (idList[list].indexOf("q=") > -1) {
this.urlQueryLoader = idList[list].replace("q=","").replace("%20", " ").split(",");
}
}
console.log("Loading default Adult Brain VFB_00017894 template.");
GEPPETTO.on(GEPPETTO.Events.Model_loaded, function () {
that.addVfbId(that.idFromURL);
});
this.idsFinalList = this.idFromURL;
} else {
var idsList = "";
var idList = this.props.location.search;
Expand All @@ -935,6 +940,8 @@ export default class VFBMain extends React.Component {
idsList = "," + idsList;
}
idsList = idList[list].replace("i=","") + idsList;
} else if (idList[list].indexOf("q=") > -1) {
this.urlQueryLoader = idList[list].replace("q=","").replace("%20", " ").split(",");
}
}
if ((idsList.length > 0) && (this.state.modelLoaded == true) && (this.urlIdsLoaded == false)) {
Expand All @@ -952,14 +959,42 @@ export default class VFBMain extends React.Component {
}
this.idsFromURL.push(this.idFromURL);
this.idsFromURL = [... new Set(this.idsFromURL)];
var that = this;
this.idsFinalList = this.idsFromURL;
console.log("Loading IDS to add to the scene from url");
GEPPETTO.on(GEPPETTO.Events.Model_loaded, function () {
that.addVfbId(that.idsFromURL);
});
}
}

var that = this;
GEPPETTO.on(GEPPETTO.Events.Model_loaded, function () {
that.addVfbId(that.idsFinalList);

var callback = function () {
// check if any results with count flag
if (that.refs.querybuilderRef.props.model.count > 0) {
// runQuery if any results
that.refs.querybuilderRef.runQuery();
} else {
that.refs.querybuilderRef.switchView(false);
}
// show query component
that.refs.querybuilderRef.open();
$("body").css("cursor", "default");
GEPPETTO.trigger('stop_spin_logo');
};

if (that.urlQueryLoader !== undefined) {
if (window[that.urlQueryLoader[0]] == undefined) {
window.fetchVariableThenRun(that.urlQueryLoader[0], function () {
that.refs.querybuilderRef.addQueryItem({ term: "", id: that.urlQueryLoader[0], queryObj: Model[that.urlQueryLoader[1]] }, callback)
});
} else {
setTimeout(function () {
that.refs.querybuilderRef.addQueryItem({ term: "", id: that.urlQueryLoader[0], queryObj: Model[that.urlQueryLoader[1]] }, callback);
}, 100);
}
}
});

// wipe the history state:
window.history.replaceState({ s:4, n:"", b:"", f:"" }, "", window.location.pathname + window.location.search);

Expand Down Expand Up @@ -1093,7 +1128,6 @@ export default class VFBMain extends React.Component {
if (this.treeBrowserReference !== undefined && this.treeBrowserReference !== null) {
this.treeBrowserReference.updateTree(this.instanceOnFocus);
}

}

render () {
Expand Down
4 changes: 4 additions & 0 deletions components/interface/VFBTree/VFBTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,10 @@ export default class VFBTree extends React.Component {
GEPPETTO.on(GEPPETTO.Events.Instances_created, function () {
that.setState({ displayColorPicker: false });
});

GEPPETTO.on(GEPPETTO.Events.Color_set, function (instance) {
that.forceUpdate();
});
}

render () {
Expand Down

0 comments on commit ece8a7e

Please sign in to comment.