import * as classNames from "classnames";
import { observer } from "mobx-react";
import * as React from "react";
import { Header, Icon, Item } from "semantic-ui-react";
import { injectState, MqttApiState } from "@app/state";
import { SprinklersDevice } from "@common/sprinklers";
import { ProgramTable, RunSectionForm, SectionRunnerView, SectionTable } from ".";
const ConnectionState = ({ connected }: { connected: boolean }) => {
const classes = classNames({
"device--connectionState": true,
"device--connectionState-connected": connected,
"device--connectionState-disconnected": !connected,
});
return (
{connected ? "Connected" : "Disconnected"}
);
};
interface DeviceViewProps {
deviceId: string;
state: MqttApiState;
}
class DeviceView extends React.Component {
device: SprinklersDevice;
componentWillMount() {
this.updateDevice();
}
componentWillUpdate() {
this.updateDevice();
}
render() {
const { id, connected, sections, programs, sectionRunner } = this.device;
return (
-
Raspberry Pi Grinklers Instance
);
}
private updateDevice() {
const { state, deviceId } = this.props;
if (!this.device || this.device.id !== deviceId) {
this.device = state.sprinklersApi.getDevice(deviceId);
}
}
}
export default injectState(observer(DeviceView));