asb_cloud_front/src/pages/Main.jsx

74 lines
2.2 KiB
React
Raw Normal View History

2021-04-02 17:22:34 +05:00
import { Layout, Menu, Button, } from 'antd'
import { UserOutlined, MenuOutlined, FundViewOutlined, FolderOutlined } from '@ant-design/icons'
import logo from '../images/logo_32.png'
import { useState } from 'react'
import { Switch, Route, Redirect, Link} from "react-router-dom"
import Wells from './Wells'
2021-04-08 12:29:19 +05:00
import Well from './Well'
2021-04-02 17:22:34 +05:00
import Files from './Files'
const { Header, Content, Sider } = Layout
export default function Main(){
const [sidebarVisible, setSidebarVisible] = useState(true)
const login = localStorage['login']
2021-04-08 12:29:19 +05:00
let handleLogout = () => {
2021-04-02 17:22:34 +05:00
localStorage.removeItem('login')
localStorage.removeItem('token')
}
return(
<Layout>
<Header className="header">
<Button icon={<MenuOutlined />} onClick={()=>setSidebarVisible(!sidebarVisible)}/>
<img src={logo} alt="АСБ" className="logo"/>
<h1 className="title">Мониторинг</h1>
2021-04-08 12:29:19 +05:00
<Link to="/login" onClick={handleLogout}>
2021-04-02 17:22:34 +05:00
<Button icon={<UserOutlined/>}>
({login}) Выход
</Button>
</Link>
</Header>
<Layout>
{sidebarVisible &&
<Sider width={200} className="site-layout-background">
<Menu
mode="inline"
defaultSelectedKeys={['1']}
defaultOpenKeys={['sub1']}
style={{ height: '100%', borderRight: 0 }}
>
<Menu.Item key="1" icon= {<FundViewOutlined />}>
<Link to="/well">Мониторинг</Link>
</Menu.Item>
<Menu.Item key="2" icon= {<FolderOutlined />}>
<Link to="/file">файлы</Link>
</Menu.Item>
</Menu>
</Sider>
}
<Layout>
<Content className="site-layout-background sheet">
<Switch>
<Route path="/file">
<Files />
</Route>
<Route path="/well/:id">
2021-04-08 12:29:19 +05:00
<Well/>
2021-04-02 17:22:34 +05:00
</Route>
<Route path="/well">
<Wells />
</Route>
<Route path="/">
<Redirect to={{pathname: "/well"}}/>
</Route>
</Switch>
</Content>
</Layout>
</Layout>
</Layout>
);
}