Merge pull request #90 in DNS/adguard-dns from fix/437 to master
* commit 'c39831abbcc3942bc7af9f8fd6c816b96770ee3e': Fix sorting method Move tiny-version-compare module to helpers Fix tooltips over-lapping Fix IP address sorting
This commit is contained in:
commit
f711d6558f
|
@ -6551,7 +6551,7 @@
|
|||
},
|
||||
"html-webpack-plugin": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-3.2.0.tgz",
|
||||
"resolved": "http://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-3.2.0.tgz",
|
||||
"integrity": "sha1-sBq71yOsqqeze2r0SS69oD2d03s=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
|
@ -6601,7 +6601,7 @@
|
|||
},
|
||||
"readable-stream": {
|
||||
"version": "1.0.34",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz",
|
||||
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz",
|
||||
"integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
|
@ -14930,7 +14930,7 @@
|
|||
},
|
||||
"through": {
|
||||
"version": "2.3.8",
|
||||
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
|
||||
"resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz",
|
||||
"integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=",
|
||||
"dev": true
|
||||
},
|
||||
|
@ -14965,11 +14965,6 @@
|
|||
"setimmediate": "^1.0.4"
|
||||
}
|
||||
},
|
||||
"tiny-version-compare": {
|
||||
"version": "0.9.1",
|
||||
"resolved": "https://registry.npmjs.org/tiny-version-compare/-/tiny-version-compare-0.9.1.tgz",
|
||||
"integrity": "sha512-kYim94l7ptSmj9rqxUMkrcMCJ448CS+hwqjA7OFcRi0ISdi0zjgdSUklQ4velVVECCjCo5frU3tNZ3oSgIKzsA=="
|
||||
},
|
||||
"tmp": {
|
||||
"version": "0.0.33",
|
||||
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz",
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
"redux-actions": "^2.4.0",
|
||||
"redux-thunk": "^2.3.0",
|
||||
"svg-url-loader": "^2.3.2",
|
||||
"tiny-version-compare": "^0.9.1",
|
||||
"whatwg-fetch": "2.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -20,8 +20,8 @@ class BlockedDomains extends Component {
|
|||
const trackerData = getTrackerData(value);
|
||||
|
||||
return (
|
||||
<div className="logs__row" title={value}>
|
||||
<div className="logs__text">
|
||||
<div className="logs__row">
|
||||
<div className="logs__text" title={value}>
|
||||
{value}
|
||||
</div>
|
||||
{trackerData && <Popover data={trackerData} />}
|
||||
|
|
|
@ -23,6 +23,7 @@ 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) => parseInt(a.replace(/\./g, ''), 10) - parseInt(b.replace(/\./g, ''), 10),
|
||||
}, {
|
||||
Header: 'Requests count',
|
||||
accessor: 'count',
|
||||
|
|
|
@ -29,8 +29,8 @@ class QueriedDomains extends Component {
|
|||
const trackerData = getTrackerData(value);
|
||||
|
||||
return (
|
||||
<div className="logs__row" title={value}>
|
||||
<div className="logs__text">
|
||||
<div className="logs__row">
|
||||
<div className="logs__text" title={value}>
|
||||
{value}
|
||||
</div>
|
||||
{trackerData && <Popover data={trackerData} />}
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Project: tiny-version-compare https://github.com/bfred-it/tiny-version-compare
|
||||
* License (MIT) https://github.com/bfred-it/tiny-version-compare/blob/master/LICENSE
|
||||
*/
|
||||
const split = v => String(v).replace(/^[vr]/, '') // Drop initial 'v' or 'r'
|
||||
.replace(/([a-z]+)/gi, '.$1.') // Sort each word separately
|
||||
.replace(/[-.]+/g, '.') // Consider dashes as separators (+ trim multiple separators)
|
||||
.split('.');
|
||||
|
||||
// Development versions are considered "negative",
|
||||
// but localeCompare doesn't handle negative numbers.
|
||||
// This offset is applied to reset the lowest development version to 0
|
||||
const offset = (part) => {
|
||||
// Not numeric, return as is
|
||||
if (Number.isNaN(part)) {
|
||||
return part;
|
||||
}
|
||||
return 5 + Number(part);
|
||||
};
|
||||
|
||||
const parsePart = (part) => {
|
||||
// Missing, consider it zero
|
||||
if (typeof part === 'undefined') {
|
||||
return 0;
|
||||
}
|
||||
// Sort development versions
|
||||
switch (part.toLowerCase()) {
|
||||
case 'dev':
|
||||
return -5;
|
||||
case 'alpha':
|
||||
return -4;
|
||||
case 'beta':
|
||||
return -3;
|
||||
case 'rc':
|
||||
return -2;
|
||||
case 'pre':
|
||||
return -1;
|
||||
default:
|
||||
}
|
||||
// Return as is, it’s either a plain number or text that will be sorted alphabetically
|
||||
return part;
|
||||
};
|
||||
|
||||
const versionCompare = (prev, next) => {
|
||||
const a = split(prev);
|
||||
const b = split(next);
|
||||
for (let i = 0; i < a.length || i < b.length; i += 1) {
|
||||
const ai = offset(parsePart(a[i]));
|
||||
const bi = offset(parsePart(b[i]));
|
||||
const sort = String(ai).localeCompare(bi, 'en', {
|
||||
numeric: true,
|
||||
});
|
||||
// Once the difference is found,
|
||||
// stop comparing the rest of the parts
|
||||
if (sort !== 0) {
|
||||
return sort;
|
||||
}
|
||||
}
|
||||
// No difference found
|
||||
return 0;
|
||||
};
|
||||
|
||||
export default versionCompare;
|
|
@ -1,8 +1,8 @@
|
|||
import { combineReducers } from 'redux';
|
||||
import { handleActions } from 'redux-actions';
|
||||
import { loadingBarReducer } from 'react-redux-loading-bar';
|
||||
import versionCompare from 'tiny-version-compare';
|
||||
import nanoid from 'nanoid';
|
||||
import versionCompare from '../helpers/versionCompare';
|
||||
|
||||
import * as actions from '../actions';
|
||||
|
||||
|
|
Loading…
Reference in New Issue