Fix IP address sorting

Closes #437
This commit is contained in:
Ildar Kamalov 2018-10-29 13:12:04 +03:00
parent 41c9a89516
commit 3cd3b93511

View File

@ -23,6 +23,22 @@ class Clients extends Component {
Header: 'IP',
accessor: 'ip',
Cell: ({ value }) => (<div className="logs__row logs__row--overflow"><span className="logs__text" title={value}>{value}</span></div>),
sortMethod: (a, b) => {
const nextValue = a.split('.');
const prevValue = b.split('.');
for (let i = 0; i < nextValue.length; i += 1) {
const nextNumber = parseInt(nextValue[i], 10);
const prevNumber = parseInt(prevValue[i], 10);
if (nextNumber < prevNumber) {
return -1;
} else if (nextNumber > prevNumber) {
return 1;
}
}
return 0;
},
}, {
Header: 'Requests count',
accessor: 'count',