WellSelector в заголовке теперь связан с маршрутом.

поправлен его стиль.
This commit is contained in:
Фролов 2021-05-31 15:02:35 +05:00
parent 8238bdb523
commit 2045006d6f
6 changed files with 90 additions and 47 deletions

View File

@ -65,11 +65,10 @@ export default function WellTreeSelector(props) {
return ( return (
<> <>
<TreeSelect <TreeSelect
style={{ className='header-tree-select'
width: '25%', bordered={false}
alignItems: 'center' dropdownMatchSelectWidth={false}
}} placeholder='Выберите месторождение'
placeholder="Выберите месторождение"
treeData={wellsTree} treeData={wellsTree}
treeDefaultExpandAll treeDefaultExpandAll
onSelect={onSelect} onSelect={onSelect}

View File

@ -6,7 +6,7 @@ import WellTreeSelector from '../components/WellTreeSelector'
const { Header } = Layout const { Header } = Layout
export default function PageHeader(props){ export default function PageHeader({title='Мониторинг', wellsList}){
const login = localStorage['login'] const login = localStorage['login']
let handleLogout = () => { let handleLogout = () => {
@ -18,9 +18,8 @@ export default function PageHeader(props){
<Layout> <Layout>
<Header className="header"> <Header className="header">
<img src={logo} alt="АСБ" className="logo"/> <img src={logo} alt="АСБ" className="logo"/>
<WellTreeSelector /> <WellTreeSelector wellsList={wellsList}/>
<h1 className="title">Мониторинг</h1> <h1 className="title">{title}</h1>
<Link to="/login" onClick={handleLogout}> <Link to="/login" onClick={handleLogout}>
<Button icon={<UserOutlined/>}> <Button icon={<UserOutlined/>}>
({login}) Выход ({login}) Выход
@ -29,4 +28,4 @@ export default function PageHeader(props){
</Header> </Header>
</Layout> </Layout>
) )
}; };

View File

@ -0,0 +1,39 @@
import {Layout} from 'antd'
import PageHeader from './Header'
// import { useState, useEffect, createContext} from 'react'
// import { useParams } from 'react-router-dom'
const {Content} = Layout
export default function LayoutPortal({title, children}) {
// const [wells, setWells] = useState([])
// let { id } = useParams();
// let updateWellsList = async () => {
// setLoader(true)
// try {
// let newWells = (await WellService.getWells()).map(w => { return { key: w.id, ...w } })
// setWells(newWells)
// }
// catch (e) {
// console.error(`${e.message}`);
// }
// setLoader(false)
// }
// useEffect(() => {
// updateWellsList()
// }, [])
// const WellsContext = createContext({wells});
return (
<Content>
<PageHeader title={title}/>
<Layout>
<Content className="site-layout-background sheet">
{children}
</Content>
</Layout>
</Content>)
}

View File

@ -1,31 +1,25 @@
import {Layout} from 'antd'
import Wells from './Wells' import Wells from './Wells'
import PageHeader from './Header'
import Well from "../components/Well"; import Well from "../components/Well";
import LayoutPortal from './LayoutPortal'
import {Redirect, Route, Switch} from "react-router-dom"; import {Redirect, Route, Switch} from "react-router-dom";
const {Content} = Layout
export default function Main() { export default function Main() {
return ( return (
<Content>
<PageHeader/>
<Layout>
<Content className="site-layout-background sheet">
<Switch> <Switch>
<Route path="/well/:id/"> <Route path="/well/:id/">
<LayoutPortal>
<Well/> <Well/>
</LayoutPortal>
</Route> </Route>
<Route path="/well"> <Route path="/well">
<LayoutPortal>
<Wells/> <Wells/>
</LayoutPortal>
</Route> </Route>
<Route path="/"> <Route path="/">
<Redirect to={{pathname: `/well`}}/> <Redirect to={{pathname: `/well`}}/>
</Route> </Route>
</Switch> </Switch>
</Content>
</Layout>
</Content>
) )
} }

View File

@ -145,3 +145,18 @@ tr.table_row_size {
width: 50%; width: 50%;
margin-right: 5px; margin-right: 5px;
} }
.header-tree-select *{
color: #fff;
font-size: '1.5rem';
}
.header-tree-select{
border: 1px solid rgba(255, 255, 255, 0.2);
background-color: rgba(0, 0, 0, 0.3);
}
.header-tree-select:hover{
border: 1px solid rgba(255, 255, 255, 0.8);
background-color: rgba(0, 0, 0, 0.5);
}

View File

@ -1,3 +0,0 @@
.content-sheet {
display: inline-flex;
}