Merge: - client: sort clients table by requests count by default

fix #1253

* commit 'ca79fc98f5d43a5ca1955e8b0056edc3a6ee9b61':
  change code style in reduce
  - client: sort clients table by requests count by default
This commit is contained in:
Andrey Meshkov
2019-12-23 12:35:07 +03:00
5 changed files with 40 additions and 35 deletions

View File

@@ -261,6 +261,13 @@ export const redirectToCurrentProtocol = (values, httpPort = 80) => {
export const normalizeTextarea = text => text && text.replace(/[;, ]/g, '\n').split('\n').filter(n => n);
export const normalizeTopClients = clients => clients.reduce((accumulator, clientObj) => {
const { name, count } = clientObj;
// eslint-disable-next-line no-param-reassign
accumulator[name] = count;
return accumulator;
}, {});
export const getClientInfo = (clients, ip) => {
const client = clients
.find(item => item.ip_addrs && item.ip_addrs.find(clientIp => clientIp === ip));