2019-01-11 03:43:21 +07:00
|
|
|
import React, { Component } from "react";
|
|
|
|
|
|
|
|
import { Route, Switch, Redirect, RouterProps, RouteProps } from "react-router";
|
|
|
|
|
|
|
|
import { routes } from '../../routes/routes';
|
|
|
|
import { AUTHELIA_GITHUB_URL } from "../../constants";
|
|
|
|
|
2019-01-26 21:29:12 +07:00
|
|
|
import styles from '../../assets/scss/layouts/PortalLayout/PortalLayout.module.scss';
|
2019-01-11 03:43:21 +07:00
|
|
|
|
2019-01-26 21:29:12 +07:00
|
|
|
interface Props extends RouterProps, RouteProps {}
|
2019-01-11 03:43:21 +07:00
|
|
|
|
2019-01-14 03:35:46 +07:00
|
|
|
class PortalLayout extends Component<Props> {
|
2019-01-11 03:43:21 +07:00
|
|
|
private renderTitle() {
|
|
|
|
if (!this.props.location) return;
|
|
|
|
|
|
|
|
for (let i in routes) {
|
|
|
|
const route = routes[i];
|
|
|
|
if (route.path && route.path.indexOf(this.props.location.pathname) > -1) {
|
|
|
|
return route.title.toUpperCase();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
2019-01-26 21:29:12 +07:00
|
|
|
<div className={styles.main}>
|
|
|
|
<div className={styles.mainContent}>
|
|
|
|
<div className={styles.title}>
|
|
|
|
{this.renderTitle()}
|
|
|
|
</div>
|
|
|
|
<div className={styles.frame}>
|
|
|
|
<div className={styles.innerFrame}>
|
2019-01-11 03:43:21 +07:00
|
|
|
<Switch>
|
|
|
|
{routes.map((r, key) => {
|
|
|
|
return <Route path={r.path} component={r.component} exact={true} key={key} />
|
|
|
|
})}
|
|
|
|
<Redirect to='/' />
|
|
|
|
</Switch>
|
|
|
|
</div>
|
|
|
|
</div>
|
2019-01-26 21:29:12 +07:00
|
|
|
<div className={styles.footer}>
|
|
|
|
<div><a href={AUTHELIA_GITHUB_URL}>Powered by Authelia</a></div>
|
|
|
|
</div>
|
2019-01-11 03:43:21 +07:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
2019-01-14 03:35:46 +07:00
|
|
|
}
|
|
|
|
|
2019-01-26 21:29:12 +07:00
|
|
|
export default PortalLayout;
|