Skip to content

Commit

Permalink
Fix cancel upload, add Enabled property to nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
rvazarkar committed Sep 29, 2017
1 parent c5a1a0b commit 16a5059
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 70 deletions.
1 change: 1 addition & 0 deletions src/components/Graph.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ export default class GraphContainer extends Component {
id: id,
type: type,
label: label,
Enabled: data.properties.Enabled,
glyphs: [],
folded: {
nodes: [],
Expand Down
20 changes: 16 additions & 4 deletions src/components/Menu/MenuContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ export default class MenuContainer extends Component {
refreshHover: false,
uploading: false,
progress: 0,
parser: null
cancelled: false
};

emitter.on('cancelUpload', this.cancelUpload.bind(this))
}

cancelUpload(){
this.state.parser.abort()
this.setState({cancelled: true});
setTimeout(function(){
this.setState({uploading: false})
}.bind(this), 1000)
}.bind(this), 1000);
}

_refreshClick(){
Expand Down Expand Up @@ -153,6 +153,11 @@ export default class MenuContainer extends Component {
});
return;
}

if (this.state.cancelled){
parser.abort();
}

dataset = dataset.concat(results.data);
count += results.data.length;
}.bind(this),
Expand All @@ -175,6 +180,10 @@ export default class MenuContainer extends Component {
var session = driver.session();

while (index < chunks.length){
if (this.state.cancelled){
this.setState({cancelled:false});
break;
}
var currentChunk = chunks[index];

if (filetype === 'groupmembership'){
Expand Down Expand Up @@ -229,7 +238,10 @@ export default class MenuContainer extends Component {
this.setState({progress: Math.floor(sent / total * 100)});
index++;
}
this.setState({progress:100});
if (!this.state.cancelled){
this.setState({progress:100});
}

emitter.emit('refreshDBData');
console.timeEnd('IngestTime');
callback();
Expand Down
132 changes: 66 additions & 66 deletions src/components/Menu/ProgressBarMenuButton.jsx
Original file line number Diff line number Diff line change
@@ -1,80 +1,80 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types'
import PropTypes from 'prop-types';

export default class ProgressBarMenuButton extends Component {
constructor(){
super()
constructor(){
super();

this.state = {
expanded: false
}
}
this.state = {
expanded: false
};
}

_leave(e){
this.setState({expanded: false})
var target = $(e.target)
var oldWidth = target.width()
target.html('{}%'.format(this.props.progress))
target.animate({
width: '41px'
}, 100)
}
componentDidMount(){
$(this.refs.btn).html('{}%'.format(this.props.progress));
$(this.refs.btn).css('padding','6px 0px 6px 0px');
$(this.refs.btn).css('width','41px');
}

_enter(e){
this.setState({expanded: true})
var target = $(e.target)
var oldWidth = target.width()
var template = `
<div class="progress" style="margin-bottom:0px">
<div class="progress-bar progress-bar-striped active" role="progressbar" aria-value-now={} aria-value-max="100" style="width:{}%">
</div>
<span>
{}%
</span>
</div>
`.formatAll(this.props.progress)

target.html(template)
target.animate({
width: '150px'
}, 100)
}
componentWillReceiveProps(nextProps){
if (this.state.expanded){
var template = `<div class="progress" style="margin-bottom:0px">
<div class="progress-bar progress-bar-striped active" role="progressbar" aria-value-now={} aria-value-max="100" style="width:{}%">
</div>
<span>
{}%
</span>
</div>`.formatAll(nextProps.progress);
$(this.refs.btn).html(template);
}else{
$(this.refs.btn).html('{}%'.format(nextProps.progress));
}

componentWillReceiveProps(nextProps){
if (this.state.expanded){
var template = `<div class="progress" style="margin-bottom:0px">
<div class="progress-bar progress-bar-striped active" role="progressbar" aria-value-now={} aria-value-max="100" style="width:{}%">
</div>
<span>
{}%
</span>
</div>`.formatAll(nextProps.progress)
$(this.refs.btn).html(template)
}else{
$(this.refs.btn).html('{}%'.format(nextProps.progress))
}
this.forceUpdate();
}

this.forceUpdate()
}
shouldComponentUpdate(nextProps, nextState){
return true;
}

shouldComponentUpdate(nextProps, nextState){
return true
}
_leave(e){
this.setState({expanded: false});
var target = $(e.target);
var oldWidth = target.width();
target.html('{}%'.format(this.props.progress));
target.animate({
width: '41px'
}, 100);
}

componentDidMount(){
$(this.refs.btn).html('{}%'.format(this.props.progress))
$(this.refs.btn).css('padding','6px 0px 6px 0px')
$(this.refs.btn).css('width','41px')
}
_enter(e){
this.setState({expanded: true});
var target = $(e.target);
var oldWidth = target.width();
var template = `
<div class="progress" style="margin-bottom:0px">
<div class="progress-bar progress-bar-striped active" role="progressbar" aria-value-now={} aria-value-max="100" style="width:{}%">
</div>
<span>
{}%
</span>
</div>
`.formatAll(this.props.progress);

target.html(template);
target.animate({
width: '150px'
}, 100);
}

render() {
return (
<button ref="btn" onClick={this.props.click} onMouseLeave={this._leave.bind(this)} onMouseEnter={this._enter.bind(this)} className="btn" />
);
}
render() {
return (
<button ref="btn" onClick={this.props.click} onMouseLeave={this._leave.bind(this)} onMouseEnter={this._enter.bind(this)} className="btn" />
);
}
}

ProgressBarMenuButton.propTypes = {
progress : React.PropTypes.number.isRequired,
click : React.PropTypes.func.isRequired
}
progress : React.PropTypes.number.isRequired,
click : React.PropTypes.func.isRequired
};

0 comments on commit 16a5059

Please sign in to comment.