From fb6cd051272e506de6066a7e311ebc676e10ef55 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Mon, 4 Jun 2018 20:32:27 -0400 Subject: [PATCH] Remove forwarded over time and hide query types over time graphs Forwarded over time was removed in FTL and will be removed from the API, and query types was removed from the PHP web interface and will have its fate decided later. Signed-off-by: Mcat12 --- src/components/ForwardDestOverTime.js | 168 -------------------------- src/utils.js | 3 - src/views/Dashboard.js | 4 - 3 files changed, 175 deletions(-) delete mode 100644 src/components/ForwardDestOverTime.js diff --git a/src/components/ForwardDestOverTime.js b/src/components/ForwardDestOverTime.js deleted file mode 100644 index 1f2d792..0000000 --- a/src/components/ForwardDestOverTime.js +++ /dev/null @@ -1,168 +0,0 @@ -/* Pi-hole: A black hole for Internet advertisements -* (c) 2017 Pi-hole, LLC (https://pi-hole.net) -* Network-wide ad blocking via your own hardware. -* -* Web Interface -* Forward Destinations Over Time component -* -* This file is copyright under the latest version of the EUPL. -* Please see LICENSE file for your rights under this license. */ - -import React, { Component } from 'react'; -import { Line } from 'react-chartjs-2'; -import { padNumber, api, makeCancelable, ignoreCancel } from '../utils'; - -export default class ForwardDestOverTime extends Component { - state = { - loading: true, - data: { - labels: [], - datasets: [] - }, - options: { - tooltips: { - enabled: true, - mode: "x-axis", - callbacks: { - title: tooltipItem => { - const label = tooltipItem[0].xLabel; - const time = label.match(/(\d?\d):?(\d?\d?)/); - const h = parseInt(time[1], 10); - const m = parseInt(time[2], 10) || 0; - const from = padNumber(h)+":"+padNumber(m-5)+":00"; - const to = padNumber(h)+":"+padNumber(m+4)+":59"; - return "Forward destinations from "+from+" to "+to; - }, - label: (tooltipItems, data) => { - return data.datasets[tooltipItems.datasetIndex].label + ": " + (100.0*tooltipItems.yLabel).toFixed(1) + "%"; - } - } - }, - legend: { - display: false - }, - scales: { - xAxes: [{ - type: "time", - time: { - unit: "hour", - displayFormats: { - hour: "HH:mm" - }, - tooltipFormat: "HH:mm" - } - }], - yAxes: [{ - ticks: { - mix: 0.0, - max: 1.0, - beginAtZero: true, - callback: (value, index, values) => Math.round(value*100) + "%" - }, - stacked: true - }] - }, - maintainAspectRatio: true - } - }; - - constructor(props) { - super(props); - this.updateGraph = this.updateGraph.bind(this); - } - - updateGraph() { - this.updateHandler = makeCancelable( - api.getForwardDestOverTime(), - { repeat: this.updateGraph, interval: 10 * 60 * 1000 } - ); - this.updateHandler.promise.then(res => { - // Remove last data point as it's not yet finished - res.over_time.splice(-1, 1); - - const labels = []; - const destinations = res.forward_destinations; - const datasets = []; - const colors = [ - "#20a8d8", - "#f86c6b", - "#4dbd74", - "#f8cb00", - "#263238", - "#63c2de", - "#b0bec5" - ]; - - // Fill in destination information - let i = 0; - for(let destination of destinations) { - datasets.push({ - label: destination.split("|")[0], - // If we ran out of colors, make a random one - backgroundColor: i < colors.length - ? colors[i] - : '#' + parseInt("" + Math.random() * 0xffffff, 10).toString(16), - pointRadius: 0, - pointHitRadius: 5, - pointHoverRadius: 5, - data: [] - }); - - i++; - } - - // Fill in data & labels - for(let step of res.over_time) { - const date = new Date(1000 * step.timestamp); - const sum = step.data.reduce((a, b) => a + b); - - if (sum > 0) { - for(let destination in datasets) { - if(datasets.hasOwnProperty(destination)) - datasets[destination].data.push(step.data[destination] / sum); - } - } - - labels.push(date); - } - - const data = this.state.data; - data.labels = labels; - data.datasets = datasets; - - this.setState({ data, loading: false }); - }).catch(ignoreCancel); - } - - componentDidMount() { - this.updateGraph(); - } - - componentWillUnmount() { - this.updateHandler.cancel(); - } - - render() { - return ( -
-
-
- Forward Destinations Over Time -
-
- -
- { - this.state.loading - ? -
- -
- : - null - } -
-
- ); - } -} diff --git a/src/utils.js b/src/utils.js index 1735aba..1942f0d 100644 --- a/src/utils.js +++ b/src/utils.js @@ -75,9 +75,6 @@ export const api = { getQueryTypesOverTime() { return api.get("stats/overTime/query_types"); }, - getForwardDestOverTime() { - return api.get("stats/overTime/forward_destinations"); - }, getTopDomains() { return api.get("stats/top_domains"); }, diff --git a/src/views/Dashboard.js b/src/views/Dashboard.js index 1b2ca6e..8302bb9 100644 --- a/src/views/Dashboard.js +++ b/src/views/Dashboard.js @@ -11,8 +11,6 @@ import React, { Fragment } from 'react'; import SummaryStats from '../components/SummaryStats'; import QueriesGraph from '../components/QueriesGraph'; -import QueryTypesOverTime from '../components/QueryTypesOverTime'; -import ForwardDestOverTime from '../components/ForwardDestOverTime'; import TopDomains from '../components/TopDomains'; import TopBlocked from '../components/TopBlocked'; import TopClients from '../components/TopClients'; @@ -26,8 +24,6 @@ export default () => ( api.loggedIn ?
- -