1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-04 16:31:13 +00:00
Files
seahub/frontend/src/pages/sys-admin/index.js

97 lines
2.9 KiB
JavaScript
Raw Normal View History

import React from 'react';
import ReactDOM from 'react-dom';
import { Router } from '@reach/router';
2019-06-04 17:59:54 +08:00
import { siteRoot } from '../../utils/constants';
import SidePanel from './side-panel';
import MainPanel from './main-panel';
import FileScanRecords from './file-scan-records';
2019-06-04 17:59:54 +08:00
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 '../../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];
let tmpTab;
const devicesUrlParts = ['desktop-devices', 'mobile-devices', 'device-errors'];
const devicesTab = 'devices';
tmpTab = this.getCurrentTabForPageList(devicesUrlParts, devicesTab);
currentTab = tmpTab ? tmpTab : currentTab;
this.setState({currentTab: currentTab});
}
getCurrentTabForPageList = (pageUrlPartList, curTab) => {
const urlBase = `${siteRoot}sys/`;
for (let i = 0, len = pageUrlPartList.length; i < len; i++) {
if (location.href.indexOf(`${urlBase}${pageUrlPartList[i]}`) != -1) {
return curTab;
}
}
}
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'} />
<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')
);