2018-08-30 14:25:33 +00:00
|
|
|
import React, { Component, Fragment } from 'react';
|
|
|
|
import { HashRouter, Route } from 'react-router-dom';
|
|
|
|
import PropTypes from 'prop-types';
|
2020-05-22 14:06:05 +00:00
|
|
|
import { withTranslation } from 'react-i18next';
|
2018-09-19 15:58:55 +00:00
|
|
|
import LoadingBar from 'react-redux-loading-bar';
|
2018-08-30 14:25:33 +00:00
|
|
|
|
|
|
|
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';
|
2020-02-26 16:58:25 +00:00
|
|
|
|
|
|
|
import CustomRules from '../../containers/CustomRules';
|
|
|
|
import DnsBlocklist from '../../containers/DnsBlocklist';
|
|
|
|
import DnsAllowlist from '../../containers/DnsAllowlist';
|
|
|
|
import DnsRewrites from '../../containers/DnsRewrites';
|
2019-06-03 12:41:45 +00:00
|
|
|
|
|
|
|
import Dns from '../../containers/Dns';
|
|
|
|
import Encryption from '../../containers/Encryption';
|
|
|
|
import Dhcp from '../../containers/Dhcp';
|
|
|
|
import Clients from '../../containers/Clients';
|
|
|
|
|
2018-08-30 14:25:33 +00:00
|
|
|
import Logs from '../../containers/Logs';
|
2019-03-19 13:19:53 +00:00
|
|
|
import SetupGuide from '../../containers/SetupGuide';
|
2018-09-14 12:37:35 +00:00
|
|
|
import Toasts from '../Toasts';
|
2019-03-19 13:19:53 +00:00
|
|
|
import Footer from '../ui/Footer';
|
2018-08-30 14:25:33 +00:00
|
|
|
import Status from '../ui/Status';
|
2019-02-20 13:54:14 +00:00
|
|
|
import UpdateTopline from '../ui/UpdateTopline';
|
2019-05-16 14:24:30 +00:00
|
|
|
import UpdateOverlay from '../ui/UpdateOverlay';
|
2019-02-18 13:06:27 +00:00
|
|
|
import EncryptionTopline from '../ui/EncryptionTopline';
|
2019-05-23 09:32:51 +00:00
|
|
|
import Icons from '../ui/Icons';
|
2018-11-22 14:56:57 +00:00
|
|
|
import i18n from '../../i18n';
|
2019-12-06 15:00:01 +00:00
|
|
|
import Loading from '../ui/Loading';
|
2020-06-05 10:03:48 +00:00
|
|
|
import { FILTERS_URLS, MENU_URLS, SETTINGS_URLS } from '../../helpers/constants';
|
|
|
|
import Services from '../Filters/Services';
|
2020-07-03 08:14:54 +00:00
|
|
|
import { setHtmlLangAttr } from '../../helpers/helpers';
|
2018-08-30 14:25:33 +00:00
|
|
|
|
|
|
|
class App extends Component {
|
|
|
|
componentDidMount() {
|
|
|
|
this.props.getDnsStatus();
|
|
|
|
}
|
|
|
|
|
2018-11-22 14:56:57 +00:00
|
|
|
componentDidUpdate(prevProps) {
|
|
|
|
if (this.props.dashboard.language !== prevProps.dashboard.language) {
|
|
|
|
this.setLanguage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-06 15:00:01 +00:00
|
|
|
reloadPage = () => {
|
|
|
|
window.location.reload();
|
2018-08-30 14:25:33 +00:00
|
|
|
};
|
|
|
|
|
2019-05-16 14:24:30 +00:00
|
|
|
handleUpdate = () => {
|
|
|
|
this.props.getUpdate();
|
2019-06-03 12:41:45 +00:00
|
|
|
};
|
2019-05-16 14:24:30 +00:00
|
|
|
|
2018-11-22 14:56:57 +00:00
|
|
|
setLanguage = () => {
|
|
|
|
const { processing, language } = this.props.dashboard;
|
|
|
|
|
|
|
|
if (!processing) {
|
2018-11-26 08:48:06 +00:00
|
|
|
if (language) {
|
2018-11-22 14:56:57 +00:00
|
|
|
i18n.changeLanguage(language);
|
2020-07-03 08:14:54 +00:00
|
|
|
setHtmlLangAttr(language);
|
2018-11-22 14:56:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
i18n.on('languageChanged', (lang) => {
|
|
|
|
this.props.changeLanguage(lang);
|
|
|
|
});
|
2019-06-03 12:41:45 +00:00
|
|
|
};
|
2018-11-22 14:56:57 +00:00
|
|
|
|
2018-08-30 14:25:33 +00:00
|
|
|
render() {
|
2019-09-05 16:07:14 +00:00
|
|
|
const { dashboard, encryption, getVersion } = this.props;
|
2019-06-25 14:56:50 +00:00
|
|
|
const updateAvailable = dashboard.isCoreRunning && dashboard.isUpdateAvailable;
|
2018-09-21 12:20:41 +00:00
|
|
|
|
2018-08-30 14:25:33 +00:00
|
|
|
return (
|
2019-06-03 12:41:45 +00:00
|
|
|
<HashRouter hashType="noslash">
|
2018-08-30 14:25:33 +00:00
|
|
|
<Fragment>
|
2019-06-03 12:41:45 +00:00
|
|
|
{updateAvailable && (
|
2019-05-16 14:24:30 +00:00
|
|
|
<Fragment>
|
|
|
|
<UpdateTopline
|
|
|
|
url={dashboard.announcementUrl}
|
|
|
|
version={dashboard.newVersion}
|
|
|
|
canAutoUpdate={dashboard.canAutoUpdate}
|
|
|
|
getUpdate={this.handleUpdate}
|
|
|
|
processingUpdate={dashboard.processingUpdate}
|
|
|
|
/>
|
|
|
|
<UpdateOverlay processingUpdate={dashboard.processingUpdate} />
|
|
|
|
</Fragment>
|
2019-06-03 12:41:45 +00:00
|
|
|
)}
|
|
|
|
{!encryption.processing && (
|
2019-02-18 13:06:27 +00:00
|
|
|
<EncryptionTopline notAfter={encryption.not_after} />
|
2019-06-03 12:41:45 +00:00
|
|
|
)}
|
2018-09-19 15:58:55 +00:00
|
|
|
<LoadingBar className="loading-bar" updateTime={1000} />
|
2018-08-30 14:25:33 +00:00
|
|
|
<Route component={Header} />
|
2020-06-17 21:36:19 +00:00
|
|
|
<div className="container container--wrap pb-5">
|
2019-12-17 13:14:30 +00:00
|
|
|
{dashboard.processing && <Loading />}
|
|
|
|
{!dashboard.isCoreRunning && (
|
2018-08-30 14:25:33 +00:00
|
|
|
<div className="row row-cards">
|
|
|
|
<div className="col-lg-12">
|
2019-12-06 15:00:01 +00:00
|
|
|
<Status reloadPage={this.reloadPage}
|
|
|
|
message="dns_start"
|
2020-06-05 10:03:48 +00:00
|
|
|
/>
|
2019-12-06 15:00:01 +00:00
|
|
|
<Loading />
|
2018-08-30 14:25:33 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2019-06-03 12:41:45 +00:00
|
|
|
)}
|
|
|
|
{!dashboard.processing && dashboard.isCoreRunning && (
|
2020-06-05 10:03:48 +00:00
|
|
|
<>
|
|
|
|
<Route path={MENU_URLS.root} exact component={Dashboard} />
|
|
|
|
<Route path={MENU_URLS.logs} component={Logs} />
|
|
|
|
<Route path={MENU_URLS.guide} component={SetupGuide} />
|
|
|
|
<Route path={SETTINGS_URLS.settings} component={Settings} />
|
|
|
|
<Route path={SETTINGS_URLS.dns} component={Dns} />
|
|
|
|
<Route path={SETTINGS_URLS.encryption} component={Encryption} />
|
|
|
|
<Route path={SETTINGS_URLS.dhcp} component={Dhcp} />
|
|
|
|
<Route path={SETTINGS_URLS.clients} component={Clients} />
|
|
|
|
<Route path={FILTERS_URLS.dns_blocklists}
|
|
|
|
component={DnsBlocklist} />
|
|
|
|
<Route path={FILTERS_URLS.dns_allowlists}
|
|
|
|
component={DnsAllowlist} />
|
|
|
|
<Route path={FILTERS_URLS.dns_rewrites} component={DnsRewrites} />
|
|
|
|
<Route path={FILTERS_URLS.custom_rules} component={CustomRules} />
|
|
|
|
<Route path={FILTERS_URLS.blocked_services} component={Services} />
|
|
|
|
</>
|
2019-06-03 12:41:45 +00:00
|
|
|
)}
|
2018-08-30 14:25:33 +00:00
|
|
|
</div>
|
2019-09-05 16:07:14 +00:00
|
|
|
<Footer
|
|
|
|
dnsVersion={dashboard.dnsVersion}
|
|
|
|
dnsPort={dashboard.dnsPort}
|
|
|
|
processingVersion={dashboard.processingVersion}
|
|
|
|
getVersion={getVersion}
|
2020-05-27 11:25:27 +00:00
|
|
|
checkUpdateFlag={dashboard.checkUpdateFlag}
|
2019-09-05 16:07:14 +00:00
|
|
|
/>
|
2018-09-14 12:37:35 +00:00
|
|
|
<Toasts />
|
2019-05-23 09:32:51 +00:00
|
|
|
<Icons />
|
2018-08-30 14:25:33 +00:00
|
|
|
</Fragment>
|
|
|
|
</HashRouter>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
App.propTypes = {
|
|
|
|
getDnsStatus: PropTypes.func,
|
2019-05-16 14:24:30 +00:00
|
|
|
getUpdate: PropTypes.func,
|
2018-08-30 14:25:33 +00:00
|
|
|
enableDns: PropTypes.func,
|
|
|
|
dashboard: PropTypes.object,
|
|
|
|
isCoreRunning: PropTypes.bool,
|
2018-09-14 12:37:35 +00:00
|
|
|
error: PropTypes.string,
|
2018-11-22 14:56:57 +00:00
|
|
|
changeLanguage: PropTypes.func,
|
2019-01-25 12:18:05 +00:00
|
|
|
encryption: PropTypes.object,
|
2019-09-05 16:07:14 +00:00
|
|
|
getVersion: PropTypes.func,
|
2018-08-30 14:25:33 +00:00
|
|
|
};
|
|
|
|
|
2020-05-22 14:06:05 +00:00
|
|
|
export default withTranslation()(App);
|