mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-02 23:48:47 +00:00
119 lines
3.6 KiB
JavaScript
119 lines
3.6 KiB
JavaScript
import React from 'react';
|
|
import ReactDOM from 'react-dom';
|
|
import { Router } from '@reach/router';
|
|
import { siteRoot } from '../../utils/constants';
|
|
import SidePanel from './side-panel';
|
|
import MainPanel from './main-panel';
|
|
import FileScanRecords from './file-scan-records';
|
|
import WorkWeixinDepartments from './work-weixin-departments';
|
|
import Info from './info';
|
|
|
|
import DesktopDevices from './devices/desktop-devices';
|
|
import MobileDevices from './devices/mobile-devices';
|
|
import DeviceErrors from './devices/devices-errors';
|
|
|
|
import AllRepos from './repos/all-repos';
|
|
import SystemRepo from './repos/system-repo';
|
|
import TrashRepos from './repos/trash-repos';
|
|
import DirView from './repos/dir-view';
|
|
|
|
import '../../assets/css/fa-solid.css';
|
|
import '../../assets/css/fa-regular.css';
|
|
import '../../assets/css/fontawesome.css';
|
|
import '../../css/layout.css';
|
|
import '../../css/toolbar.css';
|
|
|
|
class SysAdmin extends React.Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = {
|
|
isSidePanelClosed: false,
|
|
currentTab: 'file-scan',
|
|
};
|
|
}
|
|
|
|
componentDidMount() {
|
|
let href = window.location.href.split('/');
|
|
let currentTab = href[href.length - 2];
|
|
|
|
const pageList = [
|
|
{
|
|
tab: 'devices',
|
|
urlPartList: ['desktop-devices', 'mobile-devices', 'device-errors']
|
|
},
|
|
{
|
|
tab: 'libraries',
|
|
urlPartList: ['all-libraries', 'system-library', 'trash-libraries', 'libraries/']
|
|
},
|
|
];
|
|
const tmpTab = this.getCurrentTabForPageList(pageList);
|
|
currentTab = tmpTab ? tmpTab : currentTab;
|
|
|
|
this.setState({currentTab: currentTab});
|
|
}
|
|
|
|
getCurrentTabForPageList = (pageList) => {
|
|
let urlPartList, tab;
|
|
const urlBase = `${siteRoot}sys/`;
|
|
for (let i = 0, len = pageList.length; i < len; i++) {
|
|
urlPartList = pageList[i].urlPartList;
|
|
tab = pageList[i].tab;
|
|
for (let j = 0, jlen = urlPartList.length; j < jlen; j++) {
|
|
if (location.href.indexOf(`${urlBase}${urlPartList[j]}`) != -1) {
|
|
return tab;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
onCloseSidePanel = () => {
|
|
this.setState({isSidePanelClosed: !this.state.isSidePanelClosed});
|
|
}
|
|
|
|
tabItemClick = (param) => {
|
|
this.setState({currentTab: param});
|
|
}
|
|
|
|
render() {
|
|
let { currentTab, isSidePanelClosed } = this.state;
|
|
|
|
return (
|
|
<div id="main">
|
|
<SidePanel
|
|
isSidePanelClosed={isSidePanelClosed}
|
|
onCloseSidePanel={this.onCloseSidePanel}
|
|
currentTab={currentTab}
|
|
tabItemClick={this.tabItemClick}
|
|
/>
|
|
<MainPanel>
|
|
<Router className="reach-router">
|
|
<Info path={siteRoot + 'sys/info'} />
|
|
<DesktopDevices path={siteRoot + 'sys/desktop-devices'} />
|
|
<MobileDevices path={siteRoot + 'sys/mobile-devices'} />
|
|
<DeviceErrors path={siteRoot + 'sys/device-errors'} />
|
|
<AllRepos path={siteRoot + 'sys/all-libraries'} />
|
|
<SystemRepo path={siteRoot + 'sys/system-library'} />
|
|
<TrashRepos path={siteRoot + 'sys/trash-libraries'} />
|
|
<DirView path={siteRoot + 'sys/libraries/:repoID/*'} />
|
|
<FileScanRecords
|
|
path={siteRoot + 'sys/file-scan-records'}
|
|
currentTab={currentTab}
|
|
tabItemClick={this.tabItemClick}
|
|
/>
|
|
<WorkWeixinDepartments
|
|
path={siteRoot + 'sys/work-weixin/departments'}
|
|
currentTab={currentTab}
|
|
tabItemClick={this.tabItemClick}
|
|
/>
|
|
</Router>
|
|
</MainPanel>
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
ReactDOM.render(
|
|
<SysAdmin />,
|
|
document.getElementById('wrapper')
|
|
);
|