2020-03-19 10:52:13 +00:00
|
|
|
import React from "react";
|
2020-03-25 23:15:02 +00:00
|
|
|
import {
|
|
|
|
Dropdown,
|
|
|
|
Icon,
|
|
|
|
Grid,
|
|
|
|
Divider,
|
|
|
|
Button,
|
|
|
|
Label,
|
|
|
|
Responsive,
|
|
|
|
} from "semantic-ui-react";
|
2020-03-23 20:24:17 +00:00
|
|
|
import { Segment, Image } from "semantic-ui-react";
|
2020-03-24 17:17:04 +00:00
|
|
|
import { BrowserView, MobileView } from "react-device-detect";
|
2020-03-25 23:15:02 +00:00
|
|
|
import { call } from "../client_server";
|
2020-03-13 13:43:31 +00:00
|
|
|
|
2020-03-21 15:06:18 +00:00
|
|
|
const AvatarImage = () => (
|
2020-03-24 15:03:08 +00:00
|
|
|
<Image src="avatar3.png" style={{ width: "25px", height: "auto" }} centered />
|
2020-03-23 20:24:17 +00:00
|
|
|
);
|
2020-03-13 13:43:31 +00:00
|
|
|
|
2020-03-23 20:24:17 +00:00
|
|
|
const IconHomeImage = () => (
|
|
|
|
<Image
|
|
|
|
src="smart-home.png"
|
|
|
|
style={{ width: "50px", height: "auto" }}
|
|
|
|
centered
|
|
|
|
as="a"
|
|
|
|
href="/"
|
|
|
|
/>
|
|
|
|
);
|
2020-03-13 13:43:31 +00:00
|
|
|
|
2020-03-25 14:43:03 +00:00
|
|
|
const TitleImage = () => <Image src="sm_logo.png" size="medium" centered />;
|
2020-03-24 09:10:49 +00:00
|
|
|
|
|
|
|
export default class MyHeader extends React.Component {
|
2020-03-25 23:15:02 +00:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
username: "",
|
|
|
|
};
|
|
|
|
|
|
|
|
this.getInfo();
|
|
|
|
}
|
|
|
|
getInfo() {
|
|
|
|
call.getUserInfo(this.state.token).then((res) => {
|
|
|
|
if (res.status === 200) {
|
|
|
|
this.setState({
|
|
|
|
username: res.data.username,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-03-24 09:10:49 +00:00
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<div>
|
2020-03-25 23:15:02 +00:00
|
|
|
<Responsive minWidth={768}>
|
|
|
|
<Grid columns="equal" divided inverted padded>
|
|
|
|
<Grid.Row color="black" textAlign="center">
|
|
|
|
<Grid.Column width={3} height={0.5}>
|
|
|
|
<Segment color="black" inverted>
|
|
|
|
<IconHomeImage />
|
|
|
|
</Segment>
|
|
|
|
</Grid.Column>
|
|
|
|
<Grid.Column>
|
|
|
|
<Segment color="black" inverted>
|
|
|
|
<TitleImage />
|
|
|
|
</Segment>
|
|
|
|
</Grid.Column>
|
|
|
|
<Grid.Column width={2} heigth={1}>
|
|
|
|
<Label as="a" image color="black">
|
|
|
|
<img alt="SmartHut logo" src="smart-home.png" />
|
|
|
|
{this.state.username}
|
|
|
|
</Label>
|
|
|
|
<Divider />
|
|
|
|
<Button onClick={this.props.logout}>Logout</Button>
|
|
|
|
</Grid.Column>
|
|
|
|
</Grid.Row>
|
|
|
|
</Grid>
|
|
|
|
</Responsive>
|
|
|
|
<Responsive maxWidth={768}>
|
|
|
|
<Grid columns="equal" divided inverted padded>
|
|
|
|
<Grid.Row color="black" textAlign="center">
|
|
|
|
<Segment color="black" inverted>
|
|
|
|
<TitleImage />
|
|
|
|
</Segment>
|
|
|
|
</Grid.Row>
|
|
|
|
<Grid.Row color="black" textAlign="center">
|
|
|
|
<Grid.Column>
|
|
|
|
<IconHomeImage />
|
|
|
|
</Grid.Column>
|
|
|
|
<Grid.Column>
|
|
|
|
<Label as="a" image color="black">
|
|
|
|
<img alt="SmartHut logo" src="smart-home.png" />
|
|
|
|
{this.state.username}
|
|
|
|
</Label>
|
|
|
|
<Divider />
|
|
|
|
<Button onClick={this.props.logout}>Logout</Button>
|
|
|
|
</Grid.Column>
|
|
|
|
</Grid.Row>
|
|
|
|
</Grid>
|
|
|
|
</Responsive>
|
2020-03-24 09:10:49 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|