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.
48 lines
1.8 KiB
48 lines
1.8 KiB
8 years ago
|
import * as classNames from "classnames";
|
||
8 years ago
|
import { observer } from "mobx-react";
|
||
8 years ago
|
import * as React from "react";
|
||
8 years ago
|
import FontAwesome = require("react-fontawesome");
|
||
8 years ago
|
import { Header, Item } from "semantic-ui-react";
|
||
|
import { ProgramTable, RunSectionForm, SectionRunnerView, SectionTable } from ".";
|
||
8 years ago
|
|
||
8 years ago
|
import { SprinklersDevice } from "@common/sprinklers";
|
||
8 years ago
|
|
||
8 years ago
|
const ConnectionState = ({ connected }: { connected: boolean }) => {
|
||
|
const classes = classNames({
|
||
8 years ago
|
"device--connectionState": true,
|
||
|
"device--connectionState-connected": connected,
|
||
|
"device--connectionState-disconnected": !connected,
|
||
8 years ago
|
});
|
||
|
return (
|
||
|
<span className={classes}>
|
||
|
<FontAwesome name={connected ? "plug" : "chain-broken"} />
|
||
|
{connected ? "Connected" : "Disconnected"}
|
||
|
</span>
|
||
|
);
|
||
|
};
|
||
8 years ago
|
|
||
|
@observer
|
||
8 years ago
|
export default class DeviceView extends React.Component<{ device: SprinklersDevice }> {
|
||
8 years ago
|
render() {
|
||
8 years ago
|
const { id, connected, sections, programs, sectionRunner } = this.props.device;
|
||
8 years ago
|
return (
|
||
|
<Item>
|
||
8 years ago
|
<Item.Image src={require<string>("@app/images/raspberry_pi.png")} />
|
||
8 years ago
|
<Item.Content>
|
||
|
<Header as="h1">
|
||
|
<span>Device </span><kbd>{id}</kbd>
|
||
8 years ago
|
<ConnectionState connected={connected} />
|
||
8 years ago
|
</Header>
|
||
|
<Item.Meta>
|
||
8 years ago
|
Raspberry Pi Grinklers Instance
|
||
8 years ago
|
</Item.Meta>
|
||
8 years ago
|
<SectionRunnerView sectionRunner={sectionRunner} />
|
||
|
<SectionTable sections={sections} />
|
||
|
<RunSectionForm sections={sections} />
|
||
|
<ProgramTable programs={programs} />
|
||
8 years ago
|
</Item.Content>
|
||
|
</Item>
|
||
|
);
|
||
|
}
|
||
8 years ago
|
}
|