2017-06-20 08:45:25 -06:00
|
|
|
import * as classNames from "classnames";
|
2017-08-29 22:42:56 -06:00
|
|
|
import { observer } from "mobx-react";
|
2017-06-30 01:08:51 -06:00
|
|
|
import * as React from "react";
|
2017-08-29 22:42:56 -06:00
|
|
|
import { Header, Item } from "semantic-ui-react";
|
|
|
|
import { ProgramTable, RunSectionForm, SectionRunnerView, SectionTable } from ".";
|
2017-06-20 08:45:25 -06:00
|
|
|
|
2017-08-29 22:42:56 -06:00
|
|
|
import { SprinklersDevice } from "../sprinklers";
|
2017-06-30 01:08:51 -06:00
|
|
|
import FontAwesome = require("react-fontawesome");
|
2017-06-20 08:45:25 -06:00
|
|
|
|
2017-08-29 22:42:56 -06:00
|
|
|
const ConnectionState = ({ connected }: { connected: boolean }) =>
|
2017-06-20 08:45:25 -06:00
|
|
|
<span className={classNames({
|
|
|
|
"device--connectionState": true,
|
|
|
|
"device--connectionState-connected": connected,
|
|
|
|
"device--connectionState-disconnected": !connected,
|
|
|
|
})}>
|
2017-08-29 22:42:56 -06:00
|
|
|
<FontAwesome name={connected ? "plug" : "chain-broken"} />
|
2017-06-20 08:45:25 -06:00
|
|
|
|
|
|
|
{connected ? "Connected" : "Disconnected"}
|
|
|
|
</span>;
|
|
|
|
|
|
|
|
@observer
|
2017-06-30 00:30:41 -06:00
|
|
|
export default class DeviceView extends React.PureComponent<{ device: SprinklersDevice }, {}> {
|
2017-06-20 08:45:25 -06:00
|
|
|
render() {
|
2017-08-29 22:42:56 -06:00
|
|
|
const { id, connected, sections, programs, sectionRunner } = this.props.device;
|
2017-06-20 08:45:25 -06:00
|
|
|
return (
|
|
|
|
<Item>
|
2017-08-29 22:42:56 -06:00
|
|
|
<Item.Image src={require<string>("app/images/raspberry_pi.png")} />
|
2017-06-20 08:45:25 -06:00
|
|
|
<Item.Content>
|
|
|
|
<Header as="h1">
|
|
|
|
<span>Device </span><kbd>{id}</kbd>
|
2017-08-29 22:42:56 -06:00
|
|
|
<ConnectionState connected={connected} />
|
2017-06-20 08:45:25 -06:00
|
|
|
</Header>
|
|
|
|
<Item.Meta>
|
|
|
|
|
|
|
|
</Item.Meta>
|
2017-08-29 22:42:56 -06:00
|
|
|
<SectionRunnerView sectionRunner={sectionRunner} />
|
|
|
|
<SectionTable sections={sections} />
|
|
|
|
<RunSectionForm sections={sections} />
|
|
|
|
<ProgramTable programs={programs} />
|
2017-06-20 08:45:25 -06:00
|
|
|
</Item.Content>
|
|
|
|
</Item>
|
|
|
|
);
|
|
|
|
}
|
2017-06-20 08:53:50 -06:00
|
|
|
}
|