Skip to content

Commit

Permalink
Merge pull request #895 from weaveworks/891-fix-details-columns
Browse files Browse the repository at this point in the history
Details panel table header looks up label in all rows
  • Loading branch information
davkal committed Feb 1, 2016
2 parents 6f70e70 + 9c4b4e2 commit 02a4493
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions client/app/scripts/components/node-details/node-details-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default class NodeDetailsTable extends React.Component {
return field.value;
}
}
return 0;
return -1e-10; // just under 0 to treat missing values differently from 0
}

getValuesForNode(node) {
Expand All @@ -71,8 +71,16 @@ export default class NodeDetailsTable extends React.Component {
if (this.props.nodes && this.props.nodes.length > 0) {
let headers = [{id: 'label', label: this.props.label}];
// gather header labels from metrics and metadata
const firstValues = this.getValuesForNode(this.props.nodes[0]);
headers = headers.concat(this.props.columns.map(column => ({id: column, label: firstValues[column].label})));
const nodeValues = this.props.nodes.map(this.getValuesForNode);
headers = headers.concat(this.props.columns.map(column => {
// look for a node that has the column label
const valuesWithField = nodeValues.find(values => values[column] !== undefined);
if (valuesWithField) {
return {id: column, label: valuesWithField[column].label};
}
// fall back on column id as label
return {id: column, label: column};
}));
const defaultSortBy = this.getDefaultSortBy();

return (
Expand Down

0 comments on commit 02a4493

Please sign in to comment.