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';
|
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';
|
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();
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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} />
|
|
|
|
<div className="container container--wrap">
|
2019-06-03 12:41:45 +00:00
|
|
|
{!dashboard.processing && !dashboard.isCoreRunning && (
|
2018-08-30 14:25:33 +00:00
|
|
|
<div className="row row-cards">
|
|
|
|
<div className="col-lg-12">
|
|
|
|
<Status handleStatusChange={this.handleStatusChange} />
|
|
|
|
</div>
|
|
|
|
</div>
|
2019-06-03 12:41:45 +00:00
|
|
|
)}
|
|
|
|
{!dashboard.processing && dashboard.isCoreRunning && (
|
2018-08-30 14:25:33 +00:00
|
|
|
<Fragment>
|
|
|
|
<Route path="/" exact component={Dashboard} />
|
|
|
|
<Route path="/settings" component={Settings} />
|
2019-06-03 12:41:45 +00:00
|
|
|
<Route path="/dns" component={Dns} />
|
|
|
|
<Route path="/encryption" component={Encryption} />
|
|
|
|
<Route path="/dhcp" component={Dhcp} />
|
|
|
|
<Route path="/clients" component={Clients} />
|
2018-08-30 14:25:33 +00:00
|
|
|
<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>
|
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}
|
|
|
|
/>
|
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
|
|
|
};
|
|
|
|
|
2019-01-25 12:18:05 +00:00
|
|
|
export default withNamespaces()(App);
|