mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2025-04-30 13:11:37 +03:00
+ client: handle clients find
This commit is contained in:
parent
a6d6e9ec9e
commit
f8202a74bd
8 changed files with 67 additions and 39 deletions
client/src/helpers
|
@ -8,6 +8,7 @@ import subDays from 'date-fns/sub_days';
|
|||
import round from 'lodash/round';
|
||||
import axios from 'axios';
|
||||
import i18n from 'i18next';
|
||||
import uniqBy from 'lodash/uniqBy';
|
||||
import versionCompare from './versionCompare';
|
||||
|
||||
import {
|
||||
|
@ -92,6 +93,17 @@ export const normalizeTopStats = stats => (
|
|||
}))
|
||||
);
|
||||
|
||||
export const addClientInfo = (data, clients, param) => (
|
||||
data.map((row) => {
|
||||
const clientIp = row[param];
|
||||
const info = clients.find(item => item[clientIp]) || '';
|
||||
return {
|
||||
...row,
|
||||
info: (info && info[clientIp]) || '',
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
export const normalizeFilteringStatus = (filteringStatus) => {
|
||||
const {
|
||||
enabled, filters, user_rules: userRules, interval,
|
||||
|
@ -342,3 +354,13 @@ export const getPathWithQueryString = (path, params) => {
|
|||
|
||||
return `${path}?${searchParams.toString()}`;
|
||||
};
|
||||
|
||||
export const getParamsForClientsSearch = (data, param) => {
|
||||
const uniqueClients = uniqBy(data, param);
|
||||
return uniqueClients
|
||||
.reduce((acc, item, idx) => {
|
||||
const key = `ip${idx}`;
|
||||
acc[key] = item[param];
|
||||
return acc;
|
||||
}, {});
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue