mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 02:00:43 +00:00
Render connection table as nodes table
Also: - Make metadata fields sortable as numbers - Sort by selected metadata column
This commit is contained in:
committed by
Tom Wilkie
parent
1f59795d6c
commit
7b77210108
@@ -174,6 +174,14 @@ export default class NodeDetails extends React.Component {
|
||||
<NodeDetailsInfo rows={details.metadata} />
|
||||
</div>}
|
||||
|
||||
{details.connections && details.connections.map(connections => {
|
||||
return (
|
||||
<div className="node-details-content-section" key={connections.id}>
|
||||
<NodeDetailsTable {...connections} />
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
|
||||
{details.children && details.children.map(children => {
|
||||
return (
|
||||
<div className="node-details-content-section" key={children.topologyId}>
|
||||
|
||||
@@ -5,6 +5,10 @@ import ShowMore from '../show-more';
|
||||
import NodeDetailsTableNodeLink from './node-details-table-node-link';
|
||||
import NodeDetailsTableNodeMetric from './node-details-table-node-metric';
|
||||
|
||||
function isNumberField(field) {
|
||||
return field.dataType && field.dataType === 'number';
|
||||
}
|
||||
|
||||
export default class NodeDetailsTable extends React.Component {
|
||||
|
||||
constructor(props, context) {
|
||||
@@ -39,7 +43,16 @@ export default class NodeDetailsTable extends React.Component {
|
||||
getMetaDataSorters() {
|
||||
// returns an array of sorters that will take a node
|
||||
return _.get(this.props.nodes, [0, 'metadata'], []).map((field, index) => {
|
||||
return node => node.metadata[index] ? node.metadata[index].value : null;
|
||||
return node => {
|
||||
const nodeMetadataField = node.metadata[index];
|
||||
if (nodeMetadataField) {
|
||||
if (isNumberField(nodeMetadataField)) {
|
||||
return parseFloat(nodeMetadataField.value);
|
||||
}
|
||||
return nodeMetadataField.value;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@@ -49,6 +62,9 @@ export default class NodeDetailsTable extends React.Component {
|
||||
if (sortBy !== null) {
|
||||
const field = _.union(node.metrics, node.metadata).find(f => f.id === sortBy);
|
||||
if (field) {
|
||||
if (isNumberField(field)) {
|
||||
return parseFloat(field.value);
|
||||
}
|
||||
return field.value;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user