|
|
@@ -7272,6 +7272,29 @@ function buildPihole(array){
|
|
|
`;
|
|
|
return (array) ? html : '';
|
|
|
}
|
|
|
+function buildAdGuard(array){
|
|
|
+ if(array === false){ return ''; }
|
|
|
+ var html = `
|
|
|
+ <div id="allPihole">
|
|
|
+ <div class="el-element-overlay row">`;
|
|
|
+ if(array['options']['title']) {
|
|
|
+ html += `
|
|
|
+ <div class="col-md-12">
|
|
|
+ <h4 class="pull-left homepage-element-title"><span lang="en">AdGuard Home</span> : </h4><h4 class="pull-left"> </h4>
|
|
|
+ <hr class="hidden-xs ml-2">
|
|
|
+ </div>
|
|
|
+ <div class="clearfix"></div>
|
|
|
+ `;
|
|
|
+ }
|
|
|
+ html += `
|
|
|
+ <div class="piholeCards col-sm-12 my-3">
|
|
|
+ `+buildAdGuardItem(array)+`
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ `;
|
|
|
+ return (array) ? html : '';
|
|
|
+}
|
|
|
function buildUnifi(array){
|
|
|
if(array === false){ return ''; }
|
|
|
var items = (typeof array.content.unifi.data !== 'undefined') ? array.content.unifi.data.length : false;
|
|
|
@@ -7555,6 +7578,243 @@ function arrayRemove(arr, value) {
|
|
|
return ele != value;
|
|
|
});
|
|
|
}
|
|
|
+function buildAdGuardItem(array){
|
|
|
+ var stats = `
|
|
|
+ <style>
|
|
|
+ .bg-green {
|
|
|
+ background-color: #00a65a !important;
|
|
|
+ }
|
|
|
+
|
|
|
+ .bg-aqua {
|
|
|
+ background-color: #00c0ef!important;
|
|
|
+ }
|
|
|
+
|
|
|
+ .bg-yellow {
|
|
|
+ background-color: #f39c12!important;
|
|
|
+ }
|
|
|
+
|
|
|
+ .bg-red {
|
|
|
+ background-color: #dd4b39!important;
|
|
|
+ }
|
|
|
+
|
|
|
+ .pihole-stat {
|
|
|
+ color: #fff !important;
|
|
|
+ }
|
|
|
+
|
|
|
+ .pihole-stat .card-body h3 {
|
|
|
+ font-size: 38px;
|
|
|
+ font-weight: 700;
|
|
|
+ }
|
|
|
+
|
|
|
+ .pihole-stat .card-body i {
|
|
|
+ font-size: 5em;
|
|
|
+ float: right;
|
|
|
+ color: #ffffff6b;
|
|
|
+ }
|
|
|
+
|
|
|
+ .inline-block {
|
|
|
+ display: inline-block;
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+ `;
|
|
|
+ var length = Object.keys(array['data']).length;
|
|
|
+ var combine = array['options']['combine'];
|
|
|
+ var totalQueries = function(data) {
|
|
|
+ var card = `
|
|
|
+ <div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
|
|
|
+ <div class="card text-white mb-3 pihole-stat bg-green">
|
|
|
+ <div class="card-body">
|
|
|
+ <div class="inline-block">
|
|
|
+ <p class="d-inline mr-1">Total Queries</p>`;
|
|
|
+ for(var key in data) {
|
|
|
+ var e = data[key];
|
|
|
+ if(length > 1 && !combine) {
|
|
|
+ card += `<p class="d-inline text-muted">(`+key+`)</p>`;
|
|
|
+ }
|
|
|
+ card += `<h3 data-toggle="tooltip" data-placement="right" title="`+key+`">`+e['num_dns_queries'].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")+`</h3>`;
|
|
|
+ };
|
|
|
+ card += `
|
|
|
+ </div>
|
|
|
+ <i class="fa fa-globe inline-block" aria-hidden="true"></i>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ `
|
|
|
+ return card;
|
|
|
+ };
|
|
|
+ var totalBlocked = function(data) {
|
|
|
+ var card = `
|
|
|
+ <div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
|
|
|
+ <div class="card bg-inverse text-white mb-3 pihole-stat bg-aqua">
|
|
|
+ <div class="card-body">
|
|
|
+ <div class="inline-block">
|
|
|
+ <p class="d-inline mr-1">Queries Blocked</p>`;
|
|
|
+ for(var key in data) {
|
|
|
+ var e = data[key];
|
|
|
+ if (length > 1 && !combine) {
|
|
|
+ card += `<p class="d-inline text-muted">(${key})</p>`;
|
|
|
+ }
|
|
|
+ card += `<h3 data-toggle="tooltip" data-placement="right" title="${key}">${e['num_blocked_filtering'].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}</h3>`;
|
|
|
+ };
|
|
|
+ card += `
|
|
|
+ </div>
|
|
|
+ <i class="fa fa-hand-paper-o inline-block" aria-hidden="true"></i>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ `
|
|
|
+ return card;
|
|
|
+ };
|
|
|
+ var avgProcessingTime = function(data) {
|
|
|
+ var card = `
|
|
|
+ <div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
|
|
|
+ <div class="card bg-inverse text-white mb-3 pihole-stat bg-purple">
|
|
|
+ <div class="card-body">
|
|
|
+ <div class="inline-block">
|
|
|
+ <p class="d-inline mr-1">Avg Processing Time</p>`;
|
|
|
+ for(var key in data) {
|
|
|
+ var e = data[key];
|
|
|
+ if (length > 1 && !combine) {
|
|
|
+ card += `<p class="d-inline text-muted">(${key})</p>`;
|
|
|
+ }
|
|
|
+ ms_time = parseFloat(e['avg_processing_time'])*1000
|
|
|
+ card += `<h3 data-toggle="tooltip" data-placement="right" title="${key}">${ms_time.toFixed(2)} ms</h3>`;
|
|
|
+ };
|
|
|
+ card += `
|
|
|
+ </div>
|
|
|
+ <i class="fa fa-group inline-block" aria-hidden="true"></i>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ `
|
|
|
+ return card;
|
|
|
+ };
|
|
|
+ var domainsBlocked = function(data) {
|
|
|
+ var card = `
|
|
|
+ <div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
|
|
|
+ <div class="card bg-inverse text-white mb-3 pihole-stat bg-red">
|
|
|
+ <div class="card-body">
|
|
|
+ <div class="inline-block">
|
|
|
+ <p class="d-inline mr-1">Domains on Blocklist</p>`;
|
|
|
+ for(var key in data) {
|
|
|
+ var e = data[key];
|
|
|
+ if (length > 1 && !combine) {
|
|
|
+ card += `<p class="d-inline text-muted">(${key})</p>`;
|
|
|
+ }
|
|
|
+ var total_domains_blocked = 0
|
|
|
+ for(var key in e['filters']){
|
|
|
+ total_domains_blocked += parseFloat(e['filters'][key]['rules_count'])
|
|
|
+ }
|
|
|
+ card += `<h3 data-toggle="tooltip" data-placement="right" title="${key}">${total_domains_blocked.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}</h3>`;
|
|
|
+ };
|
|
|
+ card += `
|
|
|
+ </div>
|
|
|
+ <i class="fa fa-list inline-block" aria-hidden="true"></i>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ `
|
|
|
+ return card;
|
|
|
+ };
|
|
|
+ var domainsBlocked = function(data) {
|
|
|
+ var card = `
|
|
|
+ <div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
|
|
|
+ <div class="card bg-inverse text-white mb-3 pihole-stat bg-red">
|
|
|
+ <div class="card-body">
|
|
|
+ <div class="inline-block">
|
|
|
+ <p class="d-inline mr-1">Domains on Blocklist</p>`;
|
|
|
+ for(var key in data) {
|
|
|
+ var e = data[key];
|
|
|
+ if (length > 1 && !combine) {
|
|
|
+ card += `<p class="d-inline text-muted">(${key})</p>`;
|
|
|
+ }
|
|
|
+ var total_domains_blocked = 0
|
|
|
+ for(var key in e['filters']){
|
|
|
+ total_domains_blocked += parseFloat(e['filters'][key]['rules_count'])
|
|
|
+ }
|
|
|
+ total_domains_blocked += Object.keys(e['user_rules']).length
|
|
|
+ card += `<h3 data-toggle="tooltip" data-placement="right" title="${key}">${total_domains_blocked.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}</h3>`;
|
|
|
+ };
|
|
|
+ card += `
|
|
|
+ </div>
|
|
|
+ <i class="fa fa-list inline-block" aria-hidden="true"></i>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ `
|
|
|
+ return card;
|
|
|
+ };
|
|
|
+ var percentBlocked = function(data) {
|
|
|
+ var card = `
|
|
|
+ <div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
|
|
|
+ <div class="card bg-inverse text-white mb-3 pihole-stat bg-yellow">
|
|
|
+ <div class="card-body">
|
|
|
+ <div class="inline-block">
|
|
|
+ <p class="d-inline mr-1">Percent Blocked</p>`;
|
|
|
+ for(var key in data) {
|
|
|
+ var e = data[key];
|
|
|
+ if(typeof e['FTLnotrunning'] == 'undefined') {
|
|
|
+ if (length > 1 && !combine) {
|
|
|
+ card += `<p class="d-inline text-muted">(${key})</p>`;
|
|
|
+ }
|
|
|
+ var percent = 100*(parseFloat(e['num_blocked_filtering'])/parseFloat(e['num_dns_queries']))
|
|
|
+ card += `<h3 data-toggle="tooltip" data-placement="right" title="${key}">${percent.toFixed(2)}%</h3>`
|
|
|
+ }
|
|
|
+ };
|
|
|
+ card += `
|
|
|
+ </div>
|
|
|
+ <i class="fa fa-pie-chart inline-block" aria-hidden="true"></i>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ `
|
|
|
+ return card;
|
|
|
+ };
|
|
|
+ if(combine) {
|
|
|
+ stats += '<div class="row">'
|
|
|
+ if(array['options']['queries']){
|
|
|
+ stats += totalQueries(array['data']);
|
|
|
+ }
|
|
|
+ if(array['options']['blocked_count']){
|
|
|
+ stats += totalBlocked(array['data']);
|
|
|
+ }
|
|
|
+ if(array['options']['blocked_percent']){
|
|
|
+ stats += percentBlocked(array['data']);
|
|
|
+ }
|
|
|
+ if(array['options']['processing_time']){
|
|
|
+ stats += avgProcessingTime(array['data']);
|
|
|
+ }
|
|
|
+ if(array['options']['domain_count']){
|
|
|
+ stats += domainsBlocked(array['filters']);
|
|
|
+ }
|
|
|
+ stats += '</div>';
|
|
|
+ } else {
|
|
|
+ for(var key in array['data']) {
|
|
|
+ var data = array['data'][key];
|
|
|
+ obj = {};
|
|
|
+ obj[key] = data;
|
|
|
+ stats += '<div class="row">'
|
|
|
+ if(array['options']['queries']){
|
|
|
+ stats += totalQueries(array['data']);
|
|
|
+ }
|
|
|
+ if(array['options']['blocked_count']){
|
|
|
+ stats += totalBlocked(array['data']);
|
|
|
+ }
|
|
|
+ if(array['options']['blocked_percent']){
|
|
|
+ stats += percentBlocked(array['data']);
|
|
|
+ }
|
|
|
+ if(array['options']['processing_time']){
|
|
|
+ stats += avgProcessingTime(array['data']);
|
|
|
+ }
|
|
|
+ if(array['options']['domain_count']){
|
|
|
+ stats += domainsBlocked(array['filters']);
|
|
|
+ }
|
|
|
+ stats += '</div>';
|
|
|
+ };
|
|
|
+ };
|
|
|
+ return stats
|
|
|
+}
|
|
|
+
|
|
|
function buildPiholeItem(array){
|
|
|
var stats = `
|
|
|
<style>
|
|
|
@@ -7740,6 +8000,27 @@ function homepagePihole(timeout){
|
|
|
timeouts[timeoutTitle] = setTimeout(function(){ homepagePihole(timeout); }, timeout);
|
|
|
delete timeout;
|
|
|
}
|
|
|
+function homepageAdGuard(timeout){
|
|
|
+ var timeout = (typeof timeout !== 'undefined') ? timeout : activeInfo.settings.homepage.refresh.homepagePiholeRefresh;
|
|
|
+ organizrAPI2('GET','api/v2/homepage/adguard/stats').success(function(data) {
|
|
|
+ try {
|
|
|
+ let response = data.response;
|
|
|
+ document.getElementById('homepageOrderAdGuard').innerHTML = '';
|
|
|
+ if(response.data !== null){
|
|
|
+ buildAdGuard(response.data)
|
|
|
+ $('#homepageOrderAdGuard').html(buildAdGuard(response.data));
|
|
|
+ }
|
|
|
+ }catch(e) {
|
|
|
+ organizrCatchError(e,data);
|
|
|
+ }
|
|
|
+ }).fail(function(xhr) {
|
|
|
+ OrganizrApiError(xhr);
|
|
|
+ });
|
|
|
+ let timeoutTitle = 'AdGuard-Homepage';
|
|
|
+ if(typeof timeouts[timeoutTitle] !== 'undefined'){ clearTimeout(timeouts[timeoutTitle]); }
|
|
|
+ timeouts[timeoutTitle] = setTimeout(function(){ homepageAdGuard(timeout); }, timeout);
|
|
|
+ delete timeout;
|
|
|
+}
|
|
|
function homepageHealthChecks(tags, timeout){
|
|
|
tags = (typeof tags !== 'undefined') ? tags : activeInfo.settings.homepage.options.healthChecksTags;
|
|
|
if(tags == ''){
|