import React, { useState, useEffect } from "react"; import { Route, Switch, NavLink, useRouteMatch } from "react-router-dom"; import "./error.scss"; import "./adminpage.scss"; import { Icon, LoadingPage, CSSTransition, ErrorPage } from "../components/"; import { Admin } from "../model"; import { notify } from "../helpers/"; import { t } from "../locales/"; import { HomePage, BackendPage, SettingsPage, AboutPage, LogPage, SetupPage, LoginPage, } from "./adminpage/"; function AdminOnly(WrappedComponent) { let initIsAdmin = null; return function AdminOnlyComponent(props) { const [isAdmin, setIsAdmin] = useState(initIsAdmin); const refresh = () => { Admin.isAdmin().then((r) => { initIsAdmin = r; setIsAdmin(r); }).catch((err) => { if (err.code === "INTERNAL_SERVER_ERROR") { props.error({message: t("Cannot establish a connection")}) return; } notify.send("Error: " + (err && err.message), "error"); setIsAdmin(false); }); }; useEffect(() => { refresh(); const timeout = window.setInterval(refresh, 5 * 1000); return () => clearInterval(timeout); }, []); if (isAdmin === true || /\/admin\/setup$/.test(location.pathname)) { return ( ); } else if (isAdmin === false) { return ( ); } return ( ); }; } export default ErrorPage(AdminOnly((props) => { const match = useRouteMatch(); const [isSaving, setIsSaving] = useState(false); return (
} /> } /> } /> } />
); })); function SideMenu(props) { const [version, setVersion] = useState(null); useEffect(() => { const controller = new AbortController(); fetch("/about", { signal: controller.signal }).then((r) => { setVersion(r.headers.get("X-Powered-By").replace(/^Filestash\/([v\.0-9]*).*$/, "$1")) }) return () => controller.abort(); }, []); return (
{ props.isLoading ? (
) : ( ) }

Admin console

  • Backend
  • Settings
  • Logs
  • { version }
); };