-
Notifications
You must be signed in to change notification settings - Fork 712
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
Grid Mode #1673
Merged
Grid Mode #1673
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c51e290
Node grid view
foot fa502ae
Removes the combined table-topo-view
foot d0b9996
Grid-mode tuning!
foot 29e6768
New selection model.
foot f83e0f1
Remove a lot of un-used code that I still want to keep
foot df1efff
Force a layout after a toggle to viz-mode
foot a2810af
Fixes grid -> topo transition.
foot 3e4ec1d
Review feedback + fiddling w/ the columns widths a little more.
foot 925905b
Table-mode: fixes processes view if internet is present.
foot 504eb7f
Fixes after rebasing onto master (loading-indicator)
foot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
/* eslint react/jsx-no-bind: "off", no-multi-comp: "off" */ | ||
|
||
import React from 'react'; | ||
import { connect } from 'react-redux'; | ||
import { List as makeList, Map as makeMap } from 'immutable'; | ||
import NodeDetailsTable from '../components/node-details/node-details-table'; | ||
import { clickNode, sortOrderChanged } from '../actions/app-actions'; | ||
|
||
import { getNodeColor } from '../utils/color-utils'; | ||
|
||
|
||
const IGNORED_COLUMNS = ['docker_container_ports', 'docker_container_id', 'docker_image_id', | ||
This comment was marked as abuse.
Sorry, something went wrong. |
||
'docker_container_command', 'docker_container_networks']; | ||
|
||
|
||
function getColumns(nodes) { | ||
const metricColumns = nodes | ||
.toList() | ||
.flatMap(n => { | ||
const metrics = (n.get('metrics') || makeList()) | ||
.map(m => makeMap({ id: m.get('id'), label: m.get('label') })); | ||
return metrics; | ||
}) | ||
.toSet() | ||
.toList() | ||
.sortBy(m => m.get('label')); | ||
|
||
const metadataColumns = nodes | ||
.toList() | ||
.flatMap(n => { | ||
const metadata = (n.get('metadata') || makeList()) | ||
.map(m => makeMap({ id: m.get('id'), label: m.get('label') })); | ||
return metadata; | ||
}) | ||
.toSet() | ||
.filter(n => !IGNORED_COLUMNS.includes(n.get('id'))) | ||
.toList() | ||
.sortBy(m => m.get('label')); | ||
|
||
const relativesColumns = nodes | ||
.toList() | ||
.flatMap(n => { | ||
const metadata = (n.get('parents') || makeList()) | ||
.map(m => makeMap({ id: m.get('topologyId'), label: m.get('topologyId') })); | ||
return metadata; | ||
}) | ||
.toSet() | ||
.toList() | ||
.sortBy(m => m.get('label')); | ||
|
||
return relativesColumns.concat(metadataColumns, metricColumns).toJS(); | ||
} | ||
|
||
|
||
function renderIdCell(props) { | ||
const iconStyle = { | ||
width: 16, | ||
flex: 'none', | ||
color: getNodeColor(props.rank, props.label_major) | ||
}; | ||
const showSubLabel = Boolean(props.pseudo); | ||
|
||
return ( | ||
<div title={props.label} className="nodes-grid-id-column"> | ||
<div style={iconStyle}><i className="fa fa-square" /></div> | ||
<div className="truncate"> | ||
{props.label} {showSubLabel && | ||
<span className="nodes-grid-label-minor">{props.label_minor}</span>} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
|
||
class NodesGrid extends React.Component { | ||
|
||
constructor(props, context) { | ||
super(props, context); | ||
|
||
this.onClickRow = this.onClickRow.bind(this); | ||
this.onSortChange = this.onSortChange.bind(this); | ||
} | ||
|
||
onClickRow(ev, node, el) { | ||
// TODO: do this better | ||
if (ev.target.className === 'node-details-table-node-link') { | ||
return; | ||
} | ||
this.props.clickNode(node.id, node.label, el.getBoundingClientRect()); | ||
} | ||
|
||
onSortChange(sortBy, sortedDesc) { | ||
this.props.sortOrderChanged(sortBy, sortedDesc); | ||
} | ||
|
||
render() { | ||
const { margins, nodes, height, gridSortBy, gridSortedDesc, | ||
searchNodeMatches = makeMap(), searchQuery } = this.props; | ||
const cmpStyle = { | ||
height, | ||
marginTop: margins.top, | ||
paddingLeft: margins.left, | ||
paddingRight: margins.right, | ||
}; | ||
const tbodyHeight = height - 24 - 18; | ||
const className = 'scroll-body'; | ||
const tbodyStyle = { | ||
height: `${tbodyHeight}px`, | ||
}; | ||
|
||
const detailsData = { | ||
label: this.props.currentTopology && this.props.currentTopology.get('fullName'), | ||
id: '', | ||
nodes: nodes | ||
.toList() | ||
.filter(n => !searchQuery || searchNodeMatches.has(n.get('id'))) | ||
.toJS(), | ||
columns: getColumns(nodes) | ||
}; | ||
|
||
return ( | ||
<div className="nodes-grid"> | ||
{nodes.size > 0 && <NodeDetailsTable | ||
style={cmpStyle} | ||
className={className} | ||
renderIdCell={renderIdCell} | ||
tbodyStyle={tbodyStyle} | ||
topologyId={this.props.currentTopologyId} | ||
onSortChange={this.onSortChange} | ||
onClickRow={this.onClickRow} | ||
sortBy={gridSortBy} | ||
sortedDesc={gridSortedDesc} | ||
selectedNodeId={this.props.selectedNodeId} | ||
limit={1000} | ||
{...detailsData} | ||
/>} | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
|
||
function mapStateToProps(state) { | ||
return { | ||
gridSortBy: state.get('gridSortBy'), | ||
gridSortedDesc: state.get('gridSortedDesc'), | ||
currentTopology: state.get('currentTopology'), | ||
currentTopologyId: state.get('currentTopologyId'), | ||
searchNodeMatches: state.getIn(['searchNodeMatches', state.get('currentTopologyId')]), | ||
searchQuery: state.get('searchQuery'), | ||
selectedNodeId: state.get('selectedNodeId') | ||
}; | ||
} | ||
|
||
|
||
export default connect( | ||
mapStateToProps, | ||
{ clickNode, sortOrderChanged } | ||
)(NodesGrid); |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as abuse.
Sorry, something went wrong.