-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
149 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,84 @@ | ||
import React, { Component } from 'react'; | ||
import GlyphiconSpan from '../GlyphiconSpan'; | ||
import Icon from '../Icon'; | ||
import SpotlightRow from './SpotlightRow' | ||
import SpotlightRow from './SpotlightRow'; | ||
|
||
export default class SpotlightContainer extends Component { | ||
constructor(props){ | ||
super(props); | ||
this.state = { | ||
data: appStore.spotlightData, | ||
searchVal: "", | ||
rex: new RegExp("", 'i') | ||
} | ||
constructor(props){ | ||
super(props); | ||
this.state = { | ||
data: appStore.spotlightData, | ||
searchVal: "", | ||
rex: new RegExp("", 'i') | ||
}; | ||
|
||
emitter.on('spotlightUpdate', function(){ | ||
this.setState({data: appStore.spotlightData}) | ||
}.bind(this)) | ||
emitter.on('spotlightUpdate', function(){ | ||
this.setState({data: appStore.spotlightData}); | ||
}.bind(this)); | ||
|
||
emitter.on('spotlightClick', function(){ | ||
$(this.refs.spotlight).fadeToggle(false) | ||
}.bind(this)) | ||
emitter.on('spotlightClick', function(){ | ||
$(this.refs.spotlight).fadeToggle(false); | ||
}.bind(this)); | ||
|
||
emitter.on('resetSpotlight', function(){ | ||
this.setState({ | ||
searchVal: "", | ||
rex: new RegExp("", 'i') | ||
}) | ||
emitter.on('resetSpotlight', function(){ | ||
this.setState({ | ||
searchVal: "", | ||
rex: new RegExp("", 'i') | ||
}); | ||
|
||
}.bind(this)) | ||
} | ||
}.bind(this)); | ||
} | ||
|
||
_searchChanged(event){ | ||
this.setState({ | ||
searchVal: event.target.value, | ||
rex: new RegExp(event.target.value, 'i') | ||
}) | ||
} | ||
_searchChanged(event){ | ||
this.setState({ | ||
searchVal: event.target.value, | ||
rex: new RegExp(event.target.value, 'i') | ||
}); | ||
} | ||
|
||
render() { | ||
render() { | ||
|
||
return ( | ||
<div ref="spotlight" className="spotlight"> | ||
<div className="input-group input-group-unstyled no-border-radius"> | ||
<GlyphiconSpan tooltip={false} classes="input-group-addon spanfix"> | ||
<Icon glyph="search" /> | ||
</GlyphiconSpan> | ||
<input onChange={this._searchChanged.bind(this)} value={this.state.searchVal} type="search" className="form-control searchbox" autoComplete="off" placeholder="Explore Nodes" data-type="search" /> | ||
</div> | ||
return ( | ||
<div ref="spotlight" className="spotlight"> | ||
<div className="input-group input-group-unstyled no-border-radius"> | ||
<GlyphiconSpan tooltip={false} classes="input-group-addon spanfix"> | ||
<Icon glyph="search" /> | ||
</GlyphiconSpan> | ||
<input onChange={this._searchChanged.bind(this)} value={this.state.searchVal} type="search" className="form-control searchbox" autoComplete="off" placeholder="Explore Nodes" data-type="search" /> | ||
</div> | ||
|
||
<div className="spotlight-nodelist"> | ||
<table data-role="table" className="table table-striped"> | ||
<thead> | ||
<tr> | ||
<td>Node Label</td> | ||
<td>Collapsed Into</td> | ||
</tr> | ||
</thead> | ||
<tbody ref="spotlight-tbody" className="searchable"> | ||
{Object.keys(this.state.data).map(function(key){ | ||
var d = this.state.data[key] | ||
var nid = parseInt(key) | ||
var x = this.state.rex.test(d[0]) ? <SpotlightRow key={key} nodeId={nid} parentNodeId={d[1]} nodeLabel={d[0]} parentNodeLabel={d[2]} nodeType={d[3]} parentNodeType={d[4]} /> : null | ||
return x | ||
}.bind(this))} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
); | ||
} | ||
<div className="spotlight-nodelist"> | ||
<table data-role="table" className="table table-striped"> | ||
<thead> | ||
<tr> | ||
<td>Node Label</td> | ||
<td>Collapsed Into</td> | ||
</tr> | ||
</thead> | ||
<tbody ref="spotlight-tbody" className="searchable"> | ||
{Object.keys(this.state.data).map(function(key){ | ||
var d = this.state.data[key]; | ||
var nid = parseInt(key); | ||
var x = this.state.rex.test(d[0]) ? <SpotlightRow key={key} nodeId={nid} parentNodeId={d[1]} nodeLabel={d[0]} parentNodeLabel={d[2]} nodeType={d[3]} parentNodeType={d[4]} /> : null; | ||
return x; | ||
}.bind(this))} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
componentDidMount() { | ||
jQuery(this.refs.spotlight).fadeToggle(0) | ||
componentDidMount() { | ||
jQuery(this.refs.spotlight).fadeToggle(0); | ||
|
||
$(window).on('keyup', function(e){ | ||
var key = e.keyCode ? e.keyCode : e.which | ||
$(window).on('keyup', function(e){ | ||
var key = e.keyCode ? e.keyCode : e.which; | ||
|
||
if (document.activeElement === document.body && key === 32){ | ||
$(this.refs.spotlight).fadeToggle(); | ||
} | ||
}.bind(this)) | ||
} | ||
}.bind(this)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,75 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types' | ||
import PropTypes from 'prop-types'; | ||
|
||
export default class SpotlightRow extends Component { | ||
_handleClick(){ | ||
emitter.emit('spotlightClick', this.props.nodeId, this.props.parentNodeId) | ||
} | ||
_handleClick(){ | ||
emitter.emit('spotlightClick', this.props.nodeId, this.props.parentNodeId); | ||
} | ||
|
||
render() { | ||
var nodeIcon = ""; | ||
var parentIcon = ""; | ||
switch (this.props.nodeType){ | ||
case "Group": | ||
nodeIcon = "fa fa-users" | ||
break; | ||
case "User": | ||
nodeIcon = "fa fa-user" | ||
break; | ||
case "Computer": | ||
nodeIcon = "fa fa-desktop" | ||
break; | ||
case "Domain": | ||
nodeIcon = "fa fa-globe" | ||
break | ||
default: | ||
nodeIcon = "" | ||
break; | ||
} | ||
render() { | ||
var nodeIcon = ""; | ||
var parentIcon = ""; | ||
switch (this.props.nodeType){ | ||
case "Group": | ||
nodeIcon = "fa fa-users"; | ||
break; | ||
case "User": | ||
nodeIcon = "fa fa-user"; | ||
break; | ||
case "Computer": | ||
nodeIcon = "fa fa-desktop"; | ||
break; | ||
case "Domain": | ||
nodeIcon = "fa fa-globe"; | ||
break; | ||
case "Ou": | ||
nodeIcon = "fa fa-sitemap"; | ||
break; | ||
case "Gpo": | ||
nodeIcon = "fa fa-list"; | ||
break; | ||
default: | ||
nodeIcon = ""; | ||
break; | ||
} | ||
|
||
switch (this.props.parentNodeType){ | ||
case "Group": | ||
parentIcon = "fa fa-users" | ||
break; | ||
case "User": | ||
parentIcon = "fa fa-user" | ||
break; | ||
case "Computer": | ||
parentIcon = "fa fa-desktop" | ||
break; | ||
case "Domain": | ||
parentIcon = "fa fa-globe" | ||
break | ||
default: | ||
parentIcon = "" | ||
break; | ||
} | ||
return ( | ||
<tr style={{cursor: 'pointer'}} onClick={this._handleClick.bind(this)} data-id={this.props.nodeId} data-parent-id={this.props.parentNodeId}> | ||
<td>{this.props.nodeLabel} <i className={nodeIcon}></i></td> | ||
<td>{this.props.parentNodeLabel} <i className={parentIcon}></i></td> | ||
</tr> | ||
); | ||
} | ||
switch (this.props.parentNodeType){ | ||
case "Group": | ||
parentIcon = "fa fa-users"; | ||
break; | ||
case "User": | ||
parentIcon = "fa fa-user"; | ||
break; | ||
case "Computer": | ||
parentIcon = "fa fa-desktop"; | ||
break; | ||
case "Domain": | ||
parentIcon = "fa fa-globe"; | ||
break; | ||
case "Ou": | ||
nodeIcon = "fa fa-sitemap"; | ||
break; | ||
case "Gpo": | ||
nodeIcon = "fa fa-list"; | ||
break; | ||
default: | ||
parentIcon = ""; | ||
break; | ||
} | ||
return ( | ||
<tr style={{cursor: 'pointer'}} onClick={this._handleClick.bind(this)} data-id={this.props.nodeId} data-parent-id={this.props.parentNodeId}> | ||
<td>{this.props.nodeLabel} <i className={nodeIcon}></i></td> | ||
<td>{this.props.parentNodeLabel} <i className={parentIcon}></i></td> | ||
</tr> | ||
); | ||
} | ||
} | ||
|
||
SpotlightRow.propTypes = { | ||
nodeId : PropTypes.number.isRequired, | ||
parentNodeId : PropTypes.number.isRequired, | ||
nodeLabel : PropTypes.string.isRequired, | ||
parentNodeLabel : PropTypes.string.isRequired, | ||
nodeType: PropTypes.string.isRequired, | ||
parentNodeType: PropTypes.string.isRequired | ||
} | ||
nodeId : PropTypes.number.isRequired, | ||
parentNodeId : PropTypes.number.isRequired, | ||
nodeLabel : PropTypes.string.isRequired, | ||
parentNodeLabel : PropTypes.string.isRequired, | ||
nodeType: PropTypes.string.isRequired, | ||
parentNodeType: PropTypes.string.isRequired | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters