Merge pull request #25 in DNS/adguard-dns from feature/331 to master

* commit 'df12038f33b7acf6a3e9329054f1b5ad4cb02cd8':
  Add refresh button to querylog page
This commit is contained in:
Eugene Bujak 2018-09-17 19:03:45 +03:00
commit a2f06aadc0
2 changed files with 28 additions and 12 deletions

View File

@ -13,10 +13,14 @@ import Loading from '../ui/Loading';
class Dashboard extends Component {
componentDidMount() {
this.getAllStats();
}
getAllStats = () => {
this.props.getStats();
this.props.getStatsHistory();
this.props.getTopStats();
}
};
render() {
const { dashboard } = this.props;
@ -26,8 +30,8 @@ class Dashboard extends Component {
dashboard.processingStatsHistory ||
dashboard.processingTopStats;
const refreshFullButton = <button type="button" className="btn btn-outline-primary btn-sm" onClick={() => this.componentDidMount()}>Refresh statistics</button>;
const refreshButton = <button type="button" className="btn btn-outline-primary btn-sm card-refresh" onClick={() => this.componentDidMount()}></button>;
const refreshFullButton = <button type="button" className="btn btn-outline-primary btn-sm" onClick={() => this.getAllStats()}>Refresh statistics</button>;
const refreshButton = <button type="button" className="btn btn-outline-primary btn-sm card-refresh" onClick={() => this.getAllStats()} />;
return (
<Fragment>

View File

@ -12,10 +12,7 @@ const DOWNLOAD_LOG_FILENAME = 'dns-logs.txt';
class Logs extends Component {
componentDidMount() {
// get logs on initialization if queryLogIsEnabled
if (this.props.dashboard.queryLogEnabled) {
this.props.getLogs();
}
this.getLogs();
}
componentDidUpdate(prevProps) {
@ -25,6 +22,13 @@ class Logs extends Component {
}
}
getLogs = () => {
// get logs on initialization if queryLogIsEnabled
if (this.props.dashboard.queryLogEnabled) {
this.props.getLogs();
}
}
renderTooltip(isFiltered, rule) {
if (rule) {
return (isFiltered && <Tooltip text={rule}/>);
@ -145,10 +149,18 @@ class Logs extends Component {
>{queryLogEnabled ? 'Disable log' : 'Enable log'}</button>
{queryLogEnabled &&
<button
className="btn btn-primary btn-standart"
className="btn btn-primary btn-standart mr-2"
type="submit"
onClick={this.handleDownloadButton}
>Download log file</button> }
>Download log file</button>
}
{queryLogEnabled &&
<button
className="btn btn-outline-primary btn-standart"
type="submit"
onClick={this.getLogs}
>Refresh</button>
}
</div>);
}