import React from 'react'; import Path from 'path'; import { Route, Switch, Link, NavLink } from 'react-router-dom'; import ReactCSSTransitionGroup from 'react-addons-css-transition-group'; import './error.scss'; import './adminpage.scss'; import { Icon, LoadingPage } from '../components/'; import { Config, Admin } from '../model'; import { notify } from '../helpers/'; import { HomePage, DashboardPage, ConfigPage, LogPage, PluginPage, SupportPage, SetupPage, LoginPage } from './adminpage/'; function AdminOnly(WrappedComponent){ return class extends React.Component { constructor(props){ super(props); this.state = { isAdmin: null }; this.admin = () => { Admin.isAdmin().then((t) => { this.setState({isAdmin: t}); }).catch((err) => { notify.send("Error: " + (err && err.message) , "error"); }); }; } componentWillMount(){ this.timeout = window.setInterval(this.admin.bind(this), 30 * 1000); this.admin.call(this); } componentWillUnmount(){ window.clearInterval(this.timeout); } render(){ if(this.state.isAdmin === true){ return ( ); } else if(this.state.isAdmin === false) { return ( this.admin()} /> ); } return ( ); } }; } @AdminOnly export class AdminPage extends React.Component { constructor(props){ super(props); this.state = { isAdmin: null }; } render(){ return (
); } } const SideMenu = (props) => { return (

Admin console

  • Dashboard
  • Configure
  • Activity
  • Support
); };