You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.5 KiB
43 lines
1.5 KiB
import * as React from "react"; |
|
import {observer} from "mobx-react"; |
|
import {Item, Header} from "semantic-ui-react"; |
|
import FontAwesome = require("react-fontawesome"); |
|
import * as classNames from "classnames"; |
|
|
|
import {SprinklersDevice} from "../sprinklers"; |
|
import {SectionTable, RunSectionForm, ProgramTable} from "."; |
|
|
|
const ConnectionState = ({connected}: { connected: boolean }) => |
|
<span className={classNames({ |
|
"device--connectionState": true, |
|
"device--connectionState-connected": connected, |
|
"device--connectionState-disconnected": !connected, |
|
})}> |
|
<FontAwesome name={connected ? "plug" : "chain-broken"}/> |
|
|
|
{connected ? "Connected" : "Disconnected"} |
|
</span>; |
|
|
|
@observer |
|
export default class DeviceView extends React.PureComponent<{ device: SprinklersDevice }, {}> { |
|
render() { |
|
const {id, connected, sections, programs} = this.props.device; |
|
return ( |
|
<Item> |
|
<Item.Image src={require<string>("app/images/raspberry_pi.png")}/> |
|
<Item.Content> |
|
<Header as="h1"> |
|
<span>Device </span><kbd>{id}</kbd> |
|
<ConnectionState connected={connected}/> |
|
</Header> |
|
<Item.Meta> |
|
|
|
</Item.Meta> |
|
<SectionTable sections={sections}/> |
|
<RunSectionForm sections={sections}/> |
|
<ProgramTable programs={programs}/> |
|
</Item.Content> |
|
</Item> |
|
); |
|
} |
|
}
|
|
|