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

Tree browser #442

Merged
merged 7 commits into from
Nov 6, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
91 changes: 72 additions & 19 deletions components/interface/TreeWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,20 @@ export default class TreeWidget extends React.Component {
nodesList.push(edges[childrenList[i]].to)
}
var uniqNodes = [...new Set(nodesList)];

for (var j = uniqNodes.length - 1; j >= 0 ; j--) {
var node = nodes[this.findChildren({ id: uniqNodes[j] }, "id", nodes)[0]];
if (node.instanceId.indexOf("VFB_") > -1) {
child.instanceId = node.instanceId;
// child.subtitle = child.subtitle + " " + node.instanceId;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ddelpiano cleanup if this is gone for real

uniqNodes.splice(j, 1);
}
}

for ( var j = 0; j < uniqNodes.length; j++) {
var node = nodes[this.findChildren({ id: uniqNodes[j] }, "id", nodes)[0]];
if (node.instanceId.indexOf("VFB_") > -1) {
console.log("child.instanceId contains " + child.instanceId + "but I am overwriting it with " + node.instanceId);
child.instanceId = node.instanceId;
} else {
child.children.push({
Expand Down Expand Up @@ -420,34 +431,76 @@ export default class TreeWidget extends React.Component {

getButtons (rowInfo) {
var buttons = [];
if (rowInfo.node.title !== "No data available.") {
buttons.push(<i className="fa fa-tint"
aria-hidden="true"
onClick={ () => {
this.setState({ displayColorPicker: true });
}}>
{ (this.state.displayColorPicker
if (Instances[rowInfo.node.instanceId] !== undefined && typeof Instances[rowInfo.node.instanceId].isVisible !== "undefined") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ddelpiano too many nested if else else if else - very hard to read --> switch

// rowInfo.node.subtitle = rowInfo.node.instanceId;
if (Instances[rowInfo.node.instanceId].isVisible()) {
var color = Instances[rowInfo.node.instanceId].getColor();
buttons.push(<i className="fa fa-eye-slash"
aria-hidden="true"
onClick={ () => {
Instances[rowInfo.node.instanceId].hide();
this.setState({ nodeSelected: rowInfo.node });
}} />);
buttons.push(<i className="fa fa-tint"
style={{
paddingLeft: "6px",
color: color
}}
aria-hidden="true"
onClick={ () => {
this.setState({ displayColorPicker: true });
}}>
{ (this.state.displayColorPicker
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ddelpiano ternary operator here makes the code hard to read, it's ok for short one-liners but in cases like this I would avoid it

&& this.state.nodeSelected.subtitle === rowInfo.node.subtitle
&& this.colorPickerNode === undefined)
? <CompactColor
style={{ zIndex: 10 }}/>
: null}
</i>);
? <CompactColor
ref={node => this.colorPickerNode = node}
color={Instances[rowInfo.node.instanceId].getColor()}
onChangeComplete={ color => {
Instances[rowInfo.node.instanceId].setColor(color.hex);
this.setState({ displayColorPicker: true });
}}
style={{ zIndex: 10 }}/>
: null}
</i>);
} else {
if (rowInfo.node.instanceId.indexOf("VFB_") > -1) {
buttons.push(<i className="fa fa-eye"
aria-hidden="true"
onClick={ () => {
Instances[rowInfo.node.instanceId].show();
this.setState({ nodeSelected: rowInfo.node });
}} />);
}
}
} else {
if (rowInfo.node.instanceId.indexOf("VFB_") > -1) {
buttons.push(<i className="fa fa-eye"
aria-hidden="true"
onClick={ () => {
// rowInfo.node.subtitle = rowInfo.node.instanceId;
this.props.selectionHandler(rowInfo.node.instanceId);
this.setState({ nodeSelected: rowInfo.node });
}} />);
}
}
return buttons;
}

getNodes (rowInfo) {
if (rowInfo.node.title !== "No data available.") {
var title = <MuiThemeProvider theme={this.theme}>
<Tooltip
title={<div id="dario">
<div> {rowInfo.node.instanceId} </div>
<div> {rowInfo.node.description} </div>
<div>
<img id="dario"
src={"https://VirtualFlyBrain.org/reports/" + rowInfo.node.instanceId + "/thumbnailT.png"} />
</div></div>}>
<Tooltip placement="right-start"
title={ (rowInfo.node.instanceId.indexOf("VFB_") > -1)
? (<div>
<div> {rowInfo.node.description} </div>
<div>
<img style={{ textAlign: "center" }}
src={"https://VirtualFlyBrain.org/reports/" + rowInfo.node.instanceId + "/thumbnailT.png"} />
</div></div>)
: (<div>
<div> {rowInfo.node.description} </div>
</div>)}>
<div
className={rowInfo.node.subtitle === this.state.nodeSelected.subtitle
? "nodeFound nodeSelected"
Expand Down
8 changes: 5 additions & 3 deletions css/VFBMain.less
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,7 @@
.rst__collapseButton:focus,
.rst__expandButton:focus {
outline: none;
box-shadow: 0 0 0 1px #000, 0 0 1px 3px #83bef9;
box-shadow: none; //0 0 0 1px #000, 0 0 1px 3px #83bef9;
}
.rst__collapseButton:hover:not(:active),
.rst__expandButton:hover:not(:active) {
Expand Down Expand Up @@ -1615,10 +1615,12 @@
}

.nodeFound {
outline: solid 3px #0080ff;
//outline: solid 3px #0080ff;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ddelpiano cleanup

color: #0080ff;

}

.chrome-picker {
position: absolute;
z-index: 1;
}
}