import React, { Component, Fragment } from 'react'; import { HashRouter, Route } from 'react-router-dom'; import PropTypes from 'prop-types'; import { withTranslation } from 'react-i18next'; import LoadingBar from 'react-redux-loading-bar'; import 'react-table/react-table.css'; import '../ui/Tabler.css'; import '../ui/ReactTable.css'; import './index.css'; import Header from '../../containers/Header'; import Dashboard from '../../containers/Dashboard'; import Settings from '../../containers/Settings'; import CustomRules from '../../containers/CustomRules'; import DnsBlocklist from '../../containers/DnsBlocklist'; import DnsAllowlist from '../../containers/DnsAllowlist'; import DnsRewrites from '../../containers/DnsRewrites'; import Dns from '../../containers/Dns'; import Encryption from '../../containers/Encryption'; import Dhcp from '../../containers/Dhcp'; import Clients from '../../containers/Clients'; import Logs from '../../containers/Logs'; import SetupGuide from '../../containers/SetupGuide'; import Toasts from '../Toasts'; import Footer from '../ui/Footer'; import Status from '../ui/Status'; import UpdateTopline from '../ui/UpdateTopline'; import UpdateOverlay from '../ui/UpdateOverlay'; import EncryptionTopline from '../ui/EncryptionTopline'; import Icons from '../ui/Icons'; import i18n from '../../i18n'; import Loading from '../ui/Loading'; class App extends Component { componentDidMount() { this.props.getDnsStatus(); } componentDidUpdate(prevProps) { if (this.props.dashboard.language !== prevProps.dashboard.language) { this.setLanguage(); } } reloadPage = () => { window.location.reload(); }; handleUpdate = () => { this.props.getUpdate(); }; setLanguage = () => { const { processing, language } = this.props.dashboard; if (!processing) { if (language) { i18n.changeLanguage(language); } } i18n.on('languageChanged', (lang) => { this.props.changeLanguage(lang); }); }; render() { const { dashboard, encryption, getVersion } = this.props; const updateAvailable = dashboard.isCoreRunning && dashboard.isUpdateAvailable; return ( {updateAvailable && ( )} {!encryption.processing && ( )}
{dashboard.processing && } {!dashboard.isCoreRunning && (
)} {!dashboard.processing && dashboard.isCoreRunning && ( )}