Fix resolves

master
Rohan Vazarkar 2016-07-26 20:34:53 -04:00
parent d693573a6b
commit 501f43979e
9 changed files with 150 additions and 141 deletions

View File

@ -1,158 +1,162 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { collapseEdgeNodes, setNodeData, collapseSiblingNodes } from '../js/utils.js'; import { collapseEdgeNodes, setNodeData, collapseSiblingNodes } from 'utils';
export default class GraphContainer extends Component { export default class GraphContainer extends Component {
constructor(props){ constructor(props){
super(props) super(props)
this.state = { this.state = {
sigmaInstance : null, sigmaInstance : null,
design: null, design: null,
dragged: false dragged: false
} }
} }
render() { render() {
return ( return (
<div id="graph" className="graph"></div> <div id="graph" className="graph"></div>
); );
} }
doQueryNative(params){ doQueryNative(params){
sigma.neo4j.cypher({ sigma.neo4j.cypher({
url: appStore.databaseInfo.url, url: appStore.databaseInfo.url,
user: appStore.databaseInfo.user, user: appStore.databaseInfo.user,
password: appStore.databaseInfo.password password: appStore.databaseInfo.password
}, },
params.statement, params.statement,
this.state.sigmaInstance, this.state.sigmaInstance,
function(sigmaInstance){ function(sigmaInstance){
var design = this.state.design; var design = this.state.design;
sigmaInstance = setNodeData(this.state.sigmaInstance); sigmaInstance = setNodeData(this.state.sigmaInstance);
if (params.allowCollapse){ if (params.allowCollapse){
sigmaInstance = collapseEdgeNodes(sigmaInstance); sigmaInstance = collapseEdgeNodes(sigmaInstance);
sigmaInstance = collapseSiblingNodes(sigmaInstance); sigmaInstance = collapseSiblingNodes(sigmaInstance);
} }
this.state.sigmaInstance = sigmaInstance this.state.sigmaInstance = sigmaInstance
design.deprecate(); design.deprecate();
design.apply(); design.apply();
sigmaInstance.refresh(); sigmaInstance.refresh();
this.state.design = design; this.state.design = design;
sigma.misc.animation.camera(sigmaInstance.camera, { x: 0, y: 0, ratio: 1.075 }); sigma.misc.animation.camera(sigmaInstance.camera, { x: 0, y: 0, ratio: 1.075 });
sigma.layouts.startForceLink() sigma.layouts.startForceLink()
}.bind(this)) }.bind(this))
} }
doQueryEvent(){ doQueryEvent(){
this.doQueryNative({ this.doQueryNative({
statement: 'MATCH (n:Group) WHERE n.name =~ "(?i).*DOMAIN ADMINS.*" WITH n MATCH (n)<-[r:MemberOf]-(m) RETURN n,r,m', statement: 'MATCH (n:Group) WHERE n.name =~ "(?i).*DOMAIN ADMINS.*" WITH n MATCH (n)<-[r:MemberOf]-(m) RETURN n,r,m',
allowCollapse: false allowCollapse: false
}) })
} }
_nodeDragged(){ _nodeDragged(){
this.setState({dragged:true}) this.setState({dragged:true})
} }
_nodeClicked(n){ _nodeClicked(n){
if (!this.state.dragged){ if (!this.state.dragged){
if (n.data.node.type_user){ if (n.data.node.type_user){
emitter.emit('userNodeClicked', n.data.node.label) emitter.emit('userNodeClicked', n.data.node.label)
} }
}else{ }else{
this.setState({dragged: false}) this.setState({dragged: false})
} }
} }
componentWillMount() { componentWillMount() {
emitter.on('query', this.doQueryEvent.bind(this)) emitter.on('query', this.doQueryEvent.bind(this))
} }
componentDidMount() { componentDidMount() {
//Sigma Initialization //Sigma Initialization
var sigmaInstance, design; var sigmaInstance, design;
sigma.renderers.def = sigma.renderers.canvas; sigma.renderers.def = sigma.renderers.canvas;
sigma.classes.graph.addMethod('outboundNodes', function(id) { sigma.classes.graph.addMethod('outboundNodes', function(id) {
return this.outNeighborsIndex.get(id).keyList(); return this.outNeighborsIndex.get(id).keyList();
}); });
sigma.classes.graph.addMethod('inboundNodes', function(id) { sigma.classes.graph.addMethod('inboundNodes', function(id) {
return this.inNeighborsIndex.get(id).keyList(); return this.inNeighborsIndex.get(id).keyList();
}); });
sigmaInstance = new sigma( sigmaInstance = new sigma(
{ {
container: 'graph' container: 'graph'
} }
) )
sigmaInstance.settings( sigmaInstance.settings(
{ {
edgeColor: 'default', edgeColor: 'default',
nodeColor: 'default', nodeColor: 'default',
minEdgeSize: 1, minEdgeSize: 1,
maxEdgeSize: 2.5, maxEdgeSize: 2.5,
iconThreshold: 4, iconThreshold: 4,
labelThreshold: 15, labelThreshold: 15,
labelAlignment: 'bottom', labelAlignment: 'bottom',
labelColor: 'default', labelColor: 'default',
font: 'Roboto', font: 'Roboto',
glyphFillColor: 'black', glyphFillColor: 'black',
glyphTextColor: 'white', glyphTextColor: 'white',
glyphTextThreshold: 1, glyphTextThreshold: 1,
zoomingRatio: 1.4 zoomingRatio: 1.4
} }
) )
sigmaInstance.renderers[0].bind('render', function(e) { sigmaInstance.renderers[0].bind('render', function(e) {
sigmaInstance.renderers[0].glyphs(); sigmaInstance.renderers[0].glyphs();
}); });
sigmaInstance.camera.bind('coordinatesUpdated', function(e){ sigmaInstance.camera.bind('coordinatesUpdated', function(e){
if (e.target.ratio > 1.25){ if (e.target.ratio > 1.25){
sigmaInstance.settings('drawEdgeLabels', false); sigmaInstance.settings('drawEdgeLabels', false);
}else{ }else{
sigmaInstance.settings('drawEdgeLabels', true); sigmaInstance.settings('drawEdgeLabels', true);
} }
}) })
var dragListener = sigma.plugins.dragNodes(sigmaInstance, var dragListener = sigma.plugins.dragNodes(sigmaInstance,
sigmaInstance.renderers[0]) sigmaInstance.renderers[0])
dragListener.bind('drag', this._nodeDragged.bind(this)) dragListener.bind('drag', this._nodeDragged.bind(this))
sigmaInstance.bind('clickNode', this._nodeClicked.bind(this)) sigmaInstance.bind('clickNode', this._nodeClicked.bind(this))
var fa = sigma.layouts.configForceLink(sigmaInstance, { var fa = sigma.layouts.configForceLink(sigmaInstance, {
worker: true, worker: true,
background: true, background: true,
easing: 'cubicInOut', easing: 'cubicInOut',
autoStop: true, autoStop: true,
alignNodeSiblings: true, alignNodeSiblings: true,
barnesHutOptimize: true barnesHutOptimize: true
}); });
var lowgfx = appStore.performance.lowGraphics fa.bind('stop', function(event) {
sigmaInstance.startNoverlap();
})
design = sigma.plugins.design(sigmaInstance); var lowgfx = appStore.performance.lowGraphics
if (lowgfx){
sigmaInstance.settings('defaultEdgeType', 'line');
sigmaInstance.settings('defaultEdgeColor', 'black');
design.setPalette(appStore.lowResPalette);
design.setStyles(appStore.lowResStyle);
}else{
sigmaInstance.settings('defaultEdgeType', 'tapered');
sigmaInstance.settings('defaultEdgeColor', '#356');
design.setPalette(appStore.highResPalette);
design.setStyles(appStore.highResStyle);
}
this.state.sigmaInstance = sigmaInstance; design = sigma.plugins.design(sigmaInstance);
this.state.design = design; if (lowgfx){
this.doQueryNative({ sigmaInstance.settings('defaultEdgeType', 'line');
statement: 'MATCH (n:Group) WHERE n.name =~ "(?i).*DOMAIN ADMINS.*" WITH n MATCH (n)<-[r:MemberOf]-(m) RETURN n,r,m', sigmaInstance.settings('defaultEdgeColor', 'black');
allowCollapse: false design.setPalette(appStore.lowResPalette);
}) design.setStyles(appStore.lowResStyle);
} }else{
sigmaInstance.settings('defaultEdgeType', 'tapered');
sigmaInstance.settings('defaultEdgeColor', '#356');
design.setPalette(appStore.highResPalette);
design.setStyles(appStore.highResStyle);
}
this.state.sigmaInstance = sigmaInstance;
this.state.design = design;
this.doQueryNative({
statement: 'MATCH (n:Group) WHERE n.name =~ "(?i).*DOMAIN ADMINS.*" WITH n MATCH (n)<-[r:MemberOf]-(m) RETURN n,r,m',
allowCollapse: false
})
}
} }

View File

@ -1,7 +1,7 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import GlyphiconSpan from '../glyphiconspan' import GlyphiconSpan from '../glyphiconspan'
import Icon from '../icon' import Icon from '../icon'
import { escapeRegExp } from '../../js/utils.js'; import { escapeRegExp } from 'utils';
import TabContainer from './tabcontainer' import TabContainer from './tabcontainer'
export default class SearchContainer extends Component { export default class SearchContainer extends Component {

View File

@ -1,8 +1,8 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import DatabaseDataDisplay from './databasedatadisplay' import DatabaseDataDisplay from './Tabs/databasedatadisplay'
import PrebuiltQueriesDisplay from './prebuiltqueriesdisplay' import PrebuiltQueriesDisplay from './Tabs/prebuiltqueriesdisplay'
import NoNodeData from './nonodedata' import NoNodeData from './Tabs/nonodedata'
import UserNodeData from './usernodedata' import UserNodeData from './Tabs/usernodedata'
import { Tabs, Tab } from 'react-bootstrap'; import { Tabs, Tab } from 'react-bootstrap';
export default class TabContainer extends Component { export default class TabContainer extends Component {

View File

@ -1,6 +1,6 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { defaultAjaxSettings } from '../../js/utils.js'; import { defaultAjaxSettings } from 'utils';
import LogoutModal from '../Modals/logoutmodal'; import LogoutModal from 'modals/logoutmodal';
export default class DatabaseDataDisplay extends Component { export default class DatabaseDataDisplay extends Component {
constructor(){ constructor(){

View File

@ -1,6 +1,6 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import NodeALink from './nodealink' import NodeALink from './nodealink'
import { fullAjax } from '../../js/utils.js' import { fullAjax } from 'utils'
export default class UserNodeData extends Component { export default class UserNodeData extends Component {
propTypes: { propTypes: {

View File

@ -1,5 +1,6 @@
var webpack = require('webpack'); var webpack = require('webpack');
var webpackTargetElectronRenderer = require('webpack-target-electron-renderer'); var webpackTargetElectronRenderer = require('webpack-target-electron-renderer');
var path = require('path')
var config = { var config = {
entry: [ entry: [
@ -20,6 +21,10 @@ var config = {
}, },
resolve: { resolve: {
extensions: ['', '.js', '.jsx'], extensions: ['', '.js', '.jsx'],
alias: {
utils: path.resolve(__dirname, 'src', 'js', 'utils.js'),
modals: path.resolve(__dirname, 'src', 'components', 'Modals')
}
}, },
plugins: [ plugins: [
new webpack.HotModuleReplacementPlugin(), new webpack.HotModuleReplacementPlugin(),