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';
|
2019-02-18 13:06:27 +00:00
|
|
|
import { withNamespaces } 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';
|
|
|
|
import Filters from '../../containers/Filters';
|
|
|
|
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';
|
2018-11-22 14:56:57 +00:00
|
|
|
import i18n from '../../i18n';
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-30 14:25:33 +00:00
|
|
|
handleStatusChange = () => {
|
|
|
|
this.props.enableDns();
|
|
|
|
};
|
|
|
|
|
2019-05-16 14:24:30 +00:00
|
|
|
handleUpdate = () => {
|
|
|
|
this.props.getUpdate();
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
i18n.on('languageChanged', (lang) => {
|
|
|
|
this.props.changeLanguage(lang);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-08-30 14:25:33 +00:00
|
|
|
render() {
|
2019-01-30 13:24:17 +00:00
|
|
|
const { dashboard, encryption } = this.props;
|
2018-09-21 12:20:41 +00:00
|
|
|
const updateAvailable =
|
|
|
|
!dashboard.processingVersions &&
|
|
|
|
dashboard.isCoreRunning &&
|
|
|
|
dashboard.isUpdateAvailable;
|
|
|
|
|
2018-08-30 14:25:33 +00:00
|
|
|
return (
|
|
|
|
<HashRouter hashType='noslash'>
|
|
|
|
<Fragment>
|
2018-09-21 12:20:41 +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-01-25 12:18:05 +00:00
|
|
|
}
|
2019-02-18 13:06:27 +00:00
|
|
|
{!encryption.processing &&
|
|
|
|
<EncryptionTopline notAfter={encryption.not_after} />
|
2018-09-21 12:20:41 +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} />
|
|
|
|
<div className="container container--wrap">
|
|
|
|
{!dashboard.processing && !dashboard.isCoreRunning &&
|
|
|
|
<div className="row row-cards">
|
|
|
|
<div className="col-lg-12">
|
|
|
|
<Status handleStatusChange={this.handleStatusChange} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
{!dashboard.processing && dashboard.isCoreRunning &&
|
|
|
|
<Fragment>
|
|
|
|
<Route path="/" exact component={Dashboard} />
|
|
|
|
<Route path="/settings" component={Settings} />
|
|
|
|
<Route path="/filters" component={Filters} />
|
|
|
|
<Route path="/logs" component={Logs} />
|
2019-03-19 13:19:53 +00:00
|
|
|
<Route path="/guide" component={SetupGuide} />
|
2018-08-30 14:25:33 +00:00
|
|
|
</Fragment>
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
<Footer />
|
2018-09-14 12:37:35 +00:00
|
|
|
<Toasts />
|
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,
|
2018-08-30 14:25:33 +00:00
|
|
|
};
|
|
|
|
|
2019-01-25 12:18:05 +00:00
|
|
|
export default withNamespaces()(App);
|