Merge in DNS/adguard-home from new-client-dashboard to master Squashed commit of the following: commit 7bbd67c1e3d2af62b96bf41bb356cd6b784e473e Merge: 113743a69cd9054cAuthor: Vlad <v.abdulmyanov@adguard.com> Date: Wed Feb 3 16:01:17 2021 +0300 Merge branch 'master' into new-client-dashboard commit 113743a60665e40383d367dc17fa709dc54e4e2e Author: Vlad <v.abdulmyanov@adguard.com> Date: Wed Feb 3 15:45:16 2021 +0300 Remove unneded modal styles commit 04f9d93a9ac17ee046f0d5bedfb2bf5a5e6c0a48 Author: Vlad <v.abdulmyanov@adguard.com> Date: Wed Feb 3 14:19:56 2021 +0300 Consider comments commit 78a96cd8fed8b3e03547e7e45724c23db295f67b Author: Vlad <v.abdulmyanov@adguard.com> Date: Mon Feb 1 18:46:52 2021 +0300 Remove old params for MiniCssExtractPlugin commit 40e5a9b2b1e04036deb70af17f2719eadd0c9c02 Author: Vlad <v.abdulmyanov@adguard.com> Date: Mon Feb 1 18:27:46 2021 +0300 Fix mobile version commit 509cefc308f945b03cafa62bf48257490a0a4be1 Author: Vlad <v.abdulmyanov@adguard.com> Date: Mon Feb 1 18:20:56 2021 +0300 Remove unneeded imports commit d192f39cd2503b8ec942f00ba78fca02cac9fa60 Author: Vlad <v.abdulmyanov@adguard.com> Date: Mon Feb 1 18:20:13 2021 +0300 Finish first version of dashboard commit f82429e53d334874ff7dd0641092ec83c66ab61c Merge: fd91a0a33e0238aaAuthor: Vlad <v.abdulmyanov@adguard.com> Date: Mon Feb 1 17:12:59 2021 +0300 Merge branch 'master' into new-client-dashboard commit fd91a0a3d76c2a052a6548232b75d151d6065b88 Author: Vlad <v.abdulmyanov@adguard.com> Date: Mon Feb 1 17:12:27 2021 +0300 wip commit 237679965052d38acfcd6a72d24b2444cc5b3896 Author: Vlad <v.abdulmyanov@adguard.com> Date: Fri Jan 29 11:18:10 2021 +0300 Finish general settings commit 397a7e10efd34a8d31bb175a5a5a7158338388d4 Author: Vlad <v.abdulmyanov@adguard.com> Date: Thu Jan 28 19:24:03 2021 +0300 Add General settings page commit 486aaa6f3f9ad66f3a0dcfcccad9a32659767e90 Author: Vlad <v.abdulmyanov@adguard.com> Date: Thu Jan 28 14:05:16 2021 +0300 Remove husky commit b895306c0655019ca56ce161e050d83b4e7f5ff1 Merge: a195f1f4154c9c1cAuthor: Vlad <v.abdulmyanov@adguard.com> Date: Thu Jan 28 14:03:37 2021 +0300 Merge branch 'master' into new-client-dashboard commit a195f1f4d46043d9c53dea08734733f9817b95a0 Merge: c45c5fe9 362f390f Author: Vlad <v.abdulmyanov@adguard.com> Date: Wed Jan 27 15:46:18 2021 +0300 Merge branch 'new-client-dashboard' of ssh://bit.adguard.com:7999/dns/adguard-home into new-client-dashboard commit c45c5fe92e6c5c852bec8f512dc46b4cd513156c Author: Vlad <v.abdulmyanov@adguard.com> Date: Wed Jan 27 15:46:01 2021 +0300 wip commit 362f390fd3dcfca75633a8d30a2e54c3c30b4f3d Author: Vladislav Abdulmyanov <v.abdulmyanov@adguard.com> Date: Wed Jan 27 15:45:12 2021 +0300 Pull request #949: + client: add setup guide page Merge in DNS/adguard-home from 2554-setup-guide to new-client-dashboard Squashed commit of the following: commit c240d52e9e5d90429f2018fde808f4d04ccec138 Merge: 256f1056 137b88e4 Author: Ildar Kamalov <ik@adguard.com> Date: Wed Jan 27 14:13:52 2021 +0300 Merge branch 'new-client-dashboard' into 2554-setup-guide commit 256f1056770c67339e93275ab6dc7aaf2c10da0b Author: Ildar Kamalov <ik@adguard.com> Date: Wed Jan 27 14:10:45 2021 +0300 + client: add DNS addresses to the setup guide commit 0ecf91275a16ecc0dca23cae2ae209836fc622d2 Author: Ildar Kamalov <ik@adguard.com> Date: Wed Jan 27 14:00:12 2021 +0300 + client: add setup guide tabs commit 137b88e4253af5be32d542adbe74575ef74805c8 Author: Vlad <v.abdulmyanov@adguard.com> Date: Thu Jan 21 19:17:58 2021 +0300 Add clients top commit c3318e6932d87fdff5f22d76bee12b49f099129a Merge: 2776276b 021eb22f Author: Vlad <v.abdulmyanov@adguard.com> Date: Thu Jan 21 19:15:57 2021 +0300 Merge branch 'new-client-dashboard' of ssh://bit.adguard.com:7999/dns/adguard-home into new-client-dashboard commit 2776276b2e6dc026e1326b02c388fcf7d48d47ff Author: Vlad <v.abdulmyanov@adguard.com> Date: Thu Jan 21 19:15:53 2021 +0300 Add top client info commit 021eb22ff877aec12eb7fab60147a2cc2ddd08b7 Author: Ildar Kamalov <ik@adguard.com> Date: Thu Jan 21 14:13:54 2021 +0300 Merge: client: add sidebar Squashed commit of the following: commit 6885ba953971e68602889fbb3219221f90265421 Author: Ildar Kamalov <ik@adguard.com> Date: Thu Jan 21 13:56:55 2021 +0300 add sidebar mask commit f069bfe8cba2b31355e19a51ca00bf774ee9e560 Author: Ildar Kamalov <ik@adguard.com> Date: Thu Jan 21 13:03:47 2021 +0300 fix store commit 77c8791002887ae022da07dc264d9010576e7bab Merge: d0a6eff6 ea6d54d4 Author: Ildar Kamalov <ik@adguard.com> Date: Thu Jan 21 13:01:04 2021 +0300 Merge branch 'new-client-dashboard' into 2254-sidebar commit d0a6eff67fd74533d63f5d56382085e98ddbb702 Author: Ildar Kamalov <ik@adguard.com> Date: Thu Jan 21 12:47:32 2021 +0300 client: remove unused file commit 9d2424477de85503fe41fa00cc1294cb0c0e7dfa Author: Ildar Kamalov <ik@adguard.com> Date: Thu Jan 21 12:39:13 2021 +0300 client: header commit 9ddea19c136f15b184caa72d7e82738f7d4f3f1f Merge: 797f1248 b694bb05 Author: Ildar Kamalov <ik@adguard.com> Date: Thu Jan 21 10:57:24 2021 +0300 Merge branch 'new-client-dashboard' into 2254-sidebar commit 797f1248df5c1ef8e59c2a9999138f9e05a7adaa Author: Ildar Kamalov <ik@adguard.com> Date: Thu Jan 21 10:51:57 2021 +0300 client: sidebar ... and 14 more commits
258 lines
9.6 KiB
TypeScript
258 lines
9.6 KiB
TypeScript
import TopArrayEntry, { ITopArrayEntry } from './TopArrayEntry';
|
|
|
|
// This file was autogenerated. Please do not change.
|
|
// All changes will be overwrited on commit.
|
|
export interface IStats {
|
|
avg_processing_time?: number;
|
|
blocked_filtering?: number[];
|
|
dns_queries?: number[];
|
|
num_blocked_filtering?: number;
|
|
num_dns_queries?: number;
|
|
num_replaced_parental?: number;
|
|
num_replaced_safebrowsing?: number;
|
|
num_replaced_safesearch?: number;
|
|
replaced_parental?: number[];
|
|
replaced_safebrowsing?: number[];
|
|
time_units?: string;
|
|
top_blocked_domains?: ITopArrayEntry[];
|
|
top_clients?: ITopArrayEntry[];
|
|
top_queried_domains?: ITopArrayEntry[];
|
|
}
|
|
|
|
export default class Stats {
|
|
readonly _avg_processing_time: number | undefined;
|
|
|
|
/**
|
|
* Description: Average time in milliseconds on processing a DNS
|
|
* Example: 0.34
|
|
*/
|
|
get avgProcessingTime(): number | undefined {
|
|
return this._avg_processing_time;
|
|
}
|
|
|
|
readonly _blocked_filtering: number[] | undefined;
|
|
|
|
get blockedFiltering(): number[] | undefined {
|
|
return this._blocked_filtering;
|
|
}
|
|
|
|
readonly _dns_queries: number[] | undefined;
|
|
|
|
get dnsQueries(): number[] | undefined {
|
|
return this._dns_queries;
|
|
}
|
|
|
|
readonly _num_blocked_filtering: number | undefined;
|
|
|
|
/**
|
|
* Description: Number of requests blocked by filtering rules
|
|
* Example: 50
|
|
*/
|
|
get numBlockedFiltering(): number | undefined {
|
|
return this._num_blocked_filtering;
|
|
}
|
|
|
|
readonly _num_dns_queries: number | undefined;
|
|
|
|
/**
|
|
* Description: Total number of DNS queries
|
|
* Example: 123
|
|
*/
|
|
get numDnsQueries(): number | undefined {
|
|
return this._num_dns_queries;
|
|
}
|
|
|
|
readonly _num_replaced_parental: number | undefined;
|
|
|
|
/**
|
|
* Description: Number of blocked adult websites
|
|
* Example: 15
|
|
*/
|
|
get numReplacedParental(): number | undefined {
|
|
return this._num_replaced_parental;
|
|
}
|
|
|
|
readonly _num_replaced_safebrowsing: number | undefined;
|
|
|
|
/**
|
|
* Description: Number of requests blocked by safebrowsing module
|
|
* Example: 5
|
|
*/
|
|
get numReplacedSafebrowsing(): number | undefined {
|
|
return this._num_replaced_safebrowsing;
|
|
}
|
|
|
|
readonly _num_replaced_safesearch: number | undefined;
|
|
|
|
/**
|
|
* Description: Number of requests blocked by safesearch module
|
|
* Example: 5
|
|
*/
|
|
get numReplacedSafesearch(): number | undefined {
|
|
return this._num_replaced_safesearch;
|
|
}
|
|
|
|
readonly _replaced_parental: number[] | undefined;
|
|
|
|
get replacedParental(): number[] | undefined {
|
|
return this._replaced_parental;
|
|
}
|
|
|
|
readonly _replaced_safebrowsing: number[] | undefined;
|
|
|
|
get replacedSafebrowsing(): number[] | undefined {
|
|
return this._replaced_safebrowsing;
|
|
}
|
|
|
|
readonly _time_units: string | undefined;
|
|
|
|
/**
|
|
* Description: Time units
|
|
* Example: hours
|
|
*/
|
|
get timeUnits(): string | undefined {
|
|
return this._time_units;
|
|
}
|
|
|
|
readonly _top_blocked_domains: TopArrayEntry[] | undefined;
|
|
|
|
get topBlockedDomains(): TopArrayEntry[] | undefined {
|
|
return this._top_blocked_domains;
|
|
}
|
|
|
|
readonly _top_clients: TopArrayEntry[] | undefined;
|
|
|
|
get topClients(): TopArrayEntry[] | undefined {
|
|
return this._top_clients;
|
|
}
|
|
|
|
readonly _top_queried_domains: TopArrayEntry[] | undefined;
|
|
|
|
get topQueriedDomains(): TopArrayEntry[] | undefined {
|
|
return this._top_queried_domains;
|
|
}
|
|
|
|
constructor(props: IStats) {
|
|
if (typeof props.avg_processing_time === 'number') {
|
|
this._avg_processing_time = props.avg_processing_time;
|
|
}
|
|
if (props.blocked_filtering) {
|
|
this._blocked_filtering = props.blocked_filtering;
|
|
}
|
|
if (props.dns_queries) {
|
|
this._dns_queries = props.dns_queries;
|
|
}
|
|
if (typeof props.num_blocked_filtering === 'number') {
|
|
this._num_blocked_filtering = props.num_blocked_filtering;
|
|
}
|
|
if (typeof props.num_dns_queries === 'number') {
|
|
this._num_dns_queries = props.num_dns_queries;
|
|
}
|
|
if (typeof props.num_replaced_parental === 'number') {
|
|
this._num_replaced_parental = props.num_replaced_parental;
|
|
}
|
|
if (typeof props.num_replaced_safebrowsing === 'number') {
|
|
this._num_replaced_safebrowsing = props.num_replaced_safebrowsing;
|
|
}
|
|
if (typeof props.num_replaced_safesearch === 'number') {
|
|
this._num_replaced_safesearch = props.num_replaced_safesearch;
|
|
}
|
|
if (props.replaced_parental) {
|
|
this._replaced_parental = props.replaced_parental;
|
|
}
|
|
if (props.replaced_safebrowsing) {
|
|
this._replaced_safebrowsing = props.replaced_safebrowsing;
|
|
}
|
|
if (typeof props.time_units === 'string') {
|
|
this._time_units = props.time_units.trim();
|
|
}
|
|
if (props.top_blocked_domains) {
|
|
this._top_blocked_domains = props.top_blocked_domains.map((p) => new TopArrayEntry(p));
|
|
}
|
|
if (props.top_clients) {
|
|
this._top_clients = props.top_clients.map((p) => new TopArrayEntry(p));
|
|
}
|
|
if (props.top_queried_domains) {
|
|
this._top_queried_domains = props.top_queried_domains.map((p) => new TopArrayEntry(p));
|
|
}
|
|
}
|
|
|
|
serialize(): IStats {
|
|
const data: IStats = {
|
|
};
|
|
if (typeof this._avg_processing_time !== 'undefined') {
|
|
data.avg_processing_time = this._avg_processing_time;
|
|
}
|
|
if (typeof this._blocked_filtering !== 'undefined') {
|
|
data.blocked_filtering = this._blocked_filtering;
|
|
}
|
|
if (typeof this._dns_queries !== 'undefined') {
|
|
data.dns_queries = this._dns_queries;
|
|
}
|
|
if (typeof this._num_blocked_filtering !== 'undefined') {
|
|
data.num_blocked_filtering = this._num_blocked_filtering;
|
|
}
|
|
if (typeof this._num_dns_queries !== 'undefined') {
|
|
data.num_dns_queries = this._num_dns_queries;
|
|
}
|
|
if (typeof this._num_replaced_parental !== 'undefined') {
|
|
data.num_replaced_parental = this._num_replaced_parental;
|
|
}
|
|
if (typeof this._num_replaced_safebrowsing !== 'undefined') {
|
|
data.num_replaced_safebrowsing = this._num_replaced_safebrowsing;
|
|
}
|
|
if (typeof this._num_replaced_safesearch !== 'undefined') {
|
|
data.num_replaced_safesearch = this._num_replaced_safesearch;
|
|
}
|
|
if (typeof this._replaced_parental !== 'undefined') {
|
|
data.replaced_parental = this._replaced_parental;
|
|
}
|
|
if (typeof this._replaced_safebrowsing !== 'undefined') {
|
|
data.replaced_safebrowsing = this._replaced_safebrowsing;
|
|
}
|
|
if (typeof this._time_units !== 'undefined') {
|
|
data.time_units = this._time_units;
|
|
}
|
|
if (typeof this._top_blocked_domains !== 'undefined') {
|
|
data.top_blocked_domains = this._top_blocked_domains.map((p) => p.serialize());
|
|
}
|
|
if (typeof this._top_clients !== 'undefined') {
|
|
data.top_clients = this._top_clients.map((p) => p.serialize());
|
|
}
|
|
if (typeof this._top_queried_domains !== 'undefined') {
|
|
data.top_queried_domains = this._top_queried_domains.map((p) => p.serialize());
|
|
}
|
|
return data;
|
|
}
|
|
|
|
validate(): string[] {
|
|
const validate = {
|
|
time_units: !this._time_units ? true : typeof this._time_units === 'string' && !this._time_units ? true : this._time_units,
|
|
num_dns_queries: !this._num_dns_queries ? true : typeof this._num_dns_queries === 'number',
|
|
num_blocked_filtering: !this._num_blocked_filtering ? true : typeof this._num_blocked_filtering === 'number',
|
|
num_replaced_safebrowsing: !this._num_replaced_safebrowsing ? true : typeof this._num_replaced_safebrowsing === 'number',
|
|
num_replaced_safesearch: !this._num_replaced_safesearch ? true : typeof this._num_replaced_safesearch === 'number',
|
|
num_replaced_parental: !this._num_replaced_parental ? true : typeof this._num_replaced_parental === 'number',
|
|
avg_processing_time: !this._avg_processing_time ? true : typeof this._avg_processing_time === 'number',
|
|
top_queried_domains: !this._top_queried_domains ? true : this._top_queried_domains.reduce((result, p) => result && p.validate().length === 0, true),
|
|
top_clients: !this._top_clients ? true : this._top_clients.reduce((result, p) => result && p.validate().length === 0, true),
|
|
top_blocked_domains: !this._top_blocked_domains ? true : this._top_blocked_domains.reduce((result, p) => result && p.validate().length === 0, true),
|
|
dns_queries: !this._dns_queries ? true : this._dns_queries.reduce((result, p) => result && typeof p === 'number', true),
|
|
blocked_filtering: !this._blocked_filtering ? true : this._blocked_filtering.reduce((result, p) => result && typeof p === 'number', true),
|
|
replaced_safebrowsing: !this._replaced_safebrowsing ? true : this._replaced_safebrowsing.reduce((result, p) => result && typeof p === 'number', true),
|
|
replaced_parental: !this._replaced_parental ? true : this._replaced_parental.reduce((result, p) => result && typeof p === 'number', true),
|
|
};
|
|
const isError: string[] = [];
|
|
Object.keys(validate).forEach((key) => {
|
|
if (!(validate as any)[key]) {
|
|
isError.push(key);
|
|
}
|
|
});
|
|
return isError;
|
|
}
|
|
|
|
update(props: Partial<IStats>): Stats {
|
|
return new Stats({ ...this.serialize(), ...props });
|
|
}
|
|
}
|