Files
weave-scope/client/app/scripts/utils/node-details-utils.js
Filip Barl 6888108b83 Made the searching of generic tables work on the UI
Extracted table headers common code on the frontend

Fixed the search matching and extracted further common code in the UI
2017-01-16 12:22:10 +01:00

37 lines
1.0 KiB
JavaScript

import { NODE_DETAILS_TABLE_COLUMN_WIDTHS } from '../constants/styles';
export function isGenericTable(table) {
return (table.type || (table.get && table.get('type'))) === 'multicolumn-table';
}
export function isPropertyList(table) {
return (table.type || (table.get && table.get('type'))) === 'property-list';
}
export function isNumber(data) {
return data.dataType && data.dataType === 'number';
}
export function isIP(data) {
return data.dataType && data.dataType === 'ip';
}
export function genericTableEntryKey(row, column) {
const columnId = column.id || column.get('id');
const rowId = row.id || row.get('id');
return `${rowId}_${columnId}`;
}
export function defaultSortDesc(header) {
return header && isNumber(header);
}
export function getTableColumnsStyles(headers) {
return headers.map(header => ({
// More beauty hacking, ports and counts can only get
// so big, free up WS for other longer fields like IPs!
width: NODE_DETAILS_TABLE_COLUMN_WIDTHS[header.id],
textAlign: isNumber(header) ? 'right' : 'left'
}));
}