diff --git a/src/components/Graph.jsx b/src/components/Graph.jsx index e84c123..aa79a08 100644 --- a/src/components/Graph.jsx +++ b/src/components/Graph.jsx @@ -1,158 +1,162 @@ 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 { - constructor(props){ - super(props) + constructor(props){ + super(props) - this.state = { - sigmaInstance : null, - design: null, - dragged: false - } - } + this.state = { + sigmaInstance : null, + design: null, + dragged: false + } + } - render() { - return ( -
- ); - } + render() { + return ( +
+ ); + } - doQueryNative(params){ - sigma.neo4j.cypher({ - url: appStore.databaseInfo.url, - user: appStore.databaseInfo.user, - password: appStore.databaseInfo.password - }, - params.statement, - this.state.sigmaInstance, - function(sigmaInstance){ - var design = this.state.design; - sigmaInstance = setNodeData(this.state.sigmaInstance); - if (params.allowCollapse){ - sigmaInstance = collapseEdgeNodes(sigmaInstance); - sigmaInstance = collapseSiblingNodes(sigmaInstance); - } - this.state.sigmaInstance = sigmaInstance - design.deprecate(); - design.apply(); - sigmaInstance.refresh(); - this.state.design = design; - sigma.misc.animation.camera(sigmaInstance.camera, { x: 0, y: 0, ratio: 1.075 }); - sigma.layouts.startForceLink() - }.bind(this)) - } + doQueryNative(params){ + sigma.neo4j.cypher({ + url: appStore.databaseInfo.url, + user: appStore.databaseInfo.user, + password: appStore.databaseInfo.password + }, + params.statement, + this.state.sigmaInstance, + function(sigmaInstance){ + var design = this.state.design; + sigmaInstance = setNodeData(this.state.sigmaInstance); + if (params.allowCollapse){ + sigmaInstance = collapseEdgeNodes(sigmaInstance); + sigmaInstance = collapseSiblingNodes(sigmaInstance); + } + this.state.sigmaInstance = sigmaInstance + design.deprecate(); + design.apply(); + sigmaInstance.refresh(); + this.state.design = design; + sigma.misc.animation.camera(sigmaInstance.camera, { x: 0, y: 0, ratio: 1.075 }); + sigma.layouts.startForceLink() + }.bind(this)) + } - doQueryEvent(){ - 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 - }) - } + doQueryEvent(){ + 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 + }) + } - _nodeDragged(){ - this.setState({dragged:true}) - } + _nodeDragged(){ + this.setState({dragged:true}) + } - _nodeClicked(n){ - if (!this.state.dragged){ - if (n.data.node.type_user){ - emitter.emit('userNodeClicked', n.data.node.label) - } - }else{ - this.setState({dragged: false}) - } - } + _nodeClicked(n){ + if (!this.state.dragged){ + if (n.data.node.type_user){ + emitter.emit('userNodeClicked', n.data.node.label) + } + }else{ + this.setState({dragged: false}) + } + } - componentWillMount() { - emitter.on('query', this.doQueryEvent.bind(this)) - } + componentWillMount() { + emitter.on('query', this.doQueryEvent.bind(this)) + } - componentDidMount() { - //Sigma Initialization - var sigmaInstance, design; - sigma.renderers.def = sigma.renderers.canvas; + componentDidMount() { + //Sigma Initialization + var sigmaInstance, design; + sigma.renderers.def = sigma.renderers.canvas; - sigma.classes.graph.addMethod('outboundNodes', function(id) { - return this.outNeighborsIndex.get(id).keyList(); - }); + sigma.classes.graph.addMethod('outboundNodes', function(id) { + return this.outNeighborsIndex.get(id).keyList(); + }); - sigma.classes.graph.addMethod('inboundNodes', function(id) { - return this.inNeighborsIndex.get(id).keyList(); - }); + sigma.classes.graph.addMethod('inboundNodes', function(id) { + return this.inNeighborsIndex.get(id).keyList(); + }); - sigmaInstance = new sigma( - { - container: 'graph' - } - ) + sigmaInstance = new sigma( + { + container: 'graph' + } + ) - sigmaInstance.settings( - { - edgeColor: 'default', - nodeColor: 'default', - minEdgeSize: 1, - maxEdgeSize: 2.5, - iconThreshold: 4, - labelThreshold: 15, - labelAlignment: 'bottom', - labelColor: 'default', - font: 'Roboto', - glyphFillColor: 'black', - glyphTextColor: 'white', - glyphTextThreshold: 1, - zoomingRatio: 1.4 - } - ) + sigmaInstance.settings( + { + edgeColor: 'default', + nodeColor: 'default', + minEdgeSize: 1, + maxEdgeSize: 2.5, + iconThreshold: 4, + labelThreshold: 15, + labelAlignment: 'bottom', + labelColor: 'default', + font: 'Roboto', + glyphFillColor: 'black', + glyphTextColor: 'white', + glyphTextThreshold: 1, + zoomingRatio: 1.4 + } + ) - sigmaInstance.renderers[0].bind('render', function(e) { - sigmaInstance.renderers[0].glyphs(); - }); + sigmaInstance.renderers[0].bind('render', function(e) { + sigmaInstance.renderers[0].glyphs(); + }); - sigmaInstance.camera.bind('coordinatesUpdated', function(e){ - if (e.target.ratio > 1.25){ - sigmaInstance.settings('drawEdgeLabels', false); - }else{ - sigmaInstance.settings('drawEdgeLabels', true); - } - }) + sigmaInstance.camera.bind('coordinatesUpdated', function(e){ + if (e.target.ratio > 1.25){ + sigmaInstance.settings('drawEdgeLabels', false); + }else{ + sigmaInstance.settings('drawEdgeLabels', true); + } + }) - var dragListener = sigma.plugins.dragNodes(sigmaInstance, - sigmaInstance.renderers[0]) + var dragListener = sigma.plugins.dragNodes(sigmaInstance, + 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, { - worker: true, - background: true, - easing: 'cubicInOut', - autoStop: true, - alignNodeSiblings: true, - barnesHutOptimize: true - }); + var fa = sigma.layouts.configForceLink(sigmaInstance, { + worker: true, + background: true, + easing: 'cubicInOut', + autoStop: true, + alignNodeSiblings: true, + barnesHutOptimize: true + }); - var lowgfx = appStore.performance.lowGraphics + fa.bind('stop', function(event) { + sigmaInstance.startNoverlap(); + }) - design = sigma.plugins.design(sigmaInstance); - 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); - } + var lowgfx = appStore.performance.lowGraphics - 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 - }) - } + design = sigma.plugins.design(sigmaInstance); + 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; + 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 + }) + } } \ No newline at end of file diff --git a/src/components/SearchContainer/SearchContainer.jsx b/src/components/SearchContainer/SearchContainer.jsx index 83e5241..78fb8fd 100644 --- a/src/components/SearchContainer/SearchContainer.jsx +++ b/src/components/SearchContainer/SearchContainer.jsx @@ -1,7 +1,7 @@ import React, { Component } from 'react'; import GlyphiconSpan from '../glyphiconspan' import Icon from '../icon' -import { escapeRegExp } from '../../js/utils.js'; +import { escapeRegExp } from 'utils'; import TabContainer from './tabcontainer' export default class SearchContainer extends Component { diff --git a/src/components/SearchContainer/TabContainer.jsx b/src/components/SearchContainer/TabContainer.jsx index 54eace4..6aff99c 100644 --- a/src/components/SearchContainer/TabContainer.jsx +++ b/src/components/SearchContainer/TabContainer.jsx @@ -1,8 +1,8 @@ import React, { Component } from 'react'; -import DatabaseDataDisplay from './databasedatadisplay' -import PrebuiltQueriesDisplay from './prebuiltqueriesdisplay' -import NoNodeData from './nonodedata' -import UserNodeData from './usernodedata' +import DatabaseDataDisplay from './Tabs/databasedatadisplay' +import PrebuiltQueriesDisplay from './Tabs/prebuiltqueriesdisplay' +import NoNodeData from './Tabs/nonodedata' +import UserNodeData from './Tabs/usernodedata' import { Tabs, Tab } from 'react-bootstrap'; export default class TabContainer extends Component { diff --git a/src/components/SearchContainer/DatabaseDataDisplay.jsx b/src/components/SearchContainer/Tabs/DatabaseDataDisplay.jsx similarity index 96% rename from src/components/SearchContainer/DatabaseDataDisplay.jsx rename to src/components/SearchContainer/Tabs/DatabaseDataDisplay.jsx index a4c9b57..81eacc1 100644 --- a/src/components/SearchContainer/DatabaseDataDisplay.jsx +++ b/src/components/SearchContainer/Tabs/DatabaseDataDisplay.jsx @@ -1,6 +1,6 @@ import React, { Component } from 'react'; -import { defaultAjaxSettings } from '../../js/utils.js'; -import LogoutModal from '../Modals/logoutmodal'; +import { defaultAjaxSettings } from 'utils'; +import LogoutModal from 'modals/logoutmodal'; export default class DatabaseDataDisplay extends Component { constructor(){ diff --git a/src/components/SearchContainer/NoNodeData.jsx b/src/components/SearchContainer/Tabs/NoNodeData.jsx similarity index 100% rename from src/components/SearchContainer/NoNodeData.jsx rename to src/components/SearchContainer/Tabs/NoNodeData.jsx diff --git a/src/components/SearchContainer/NodeALink.jsx b/src/components/SearchContainer/Tabs/NodeALink.jsx similarity index 100% rename from src/components/SearchContainer/NodeALink.jsx rename to src/components/SearchContainer/Tabs/NodeALink.jsx diff --git a/src/components/SearchContainer/PrebuiltQueriesDisplay.jsx b/src/components/SearchContainer/Tabs/PrebuiltQueriesDisplay.jsx similarity index 100% rename from src/components/SearchContainer/PrebuiltQueriesDisplay.jsx rename to src/components/SearchContainer/Tabs/PrebuiltQueriesDisplay.jsx diff --git a/src/components/SearchContainer/UserNodeData.jsx b/src/components/SearchContainer/Tabs/UserNodeData.jsx similarity index 99% rename from src/components/SearchContainer/UserNodeData.jsx rename to src/components/SearchContainer/Tabs/UserNodeData.jsx index 6ae2613..7fb9986 100644 --- a/src/components/SearchContainer/UserNodeData.jsx +++ b/src/components/SearchContainer/Tabs/UserNodeData.jsx @@ -1,6 +1,6 @@ import React, { Component } from 'react'; import NodeALink from './nodealink' -import { fullAjax } from '../../js/utils.js' +import { fullAjax } from 'utils' export default class UserNodeData extends Component { propTypes: { diff --git a/webpack.config.development.js b/webpack.config.development.js index e118d44..1799f0a 100644 --- a/webpack.config.development.js +++ b/webpack.config.development.js @@ -1,5 +1,6 @@ var webpack = require('webpack'); var webpackTargetElectronRenderer = require('webpack-target-electron-renderer'); +var path = require('path') var config = { entry: [ @@ -20,6 +21,10 @@ var config = { }, resolve: { extensions: ['', '.js', '.jsx'], + alias: { + utils: path.resolve(__dirname, 'src', 'js', 'utils.js'), + modals: path.resolve(__dirname, 'src', 'components', 'Modals') + } }, plugins: [ new webpack.HotModuleReplacementPlugin(),