|
|
|
@ -3,9 +3,10 @@ import { observer } from "mobx-react";
@@ -3,9 +3,10 @@ import { observer } from "mobx-react";
|
|
|
|
|
import * as React from "react"; |
|
|
|
|
import FontAwesome = require("react-fontawesome"); |
|
|
|
|
import { Header, Item } from "semantic-ui-react"; |
|
|
|
|
import { ProgramTable, RunSectionForm, SectionRunnerView, SectionTable } from "."; |
|
|
|
|
|
|
|
|
|
import { injectState, State } from "@app/state"; |
|
|
|
|
import { SprinklersDevice } from "@common/sprinklers"; |
|
|
|
|
import { ProgramTable, RunSectionForm, SectionRunnerView, SectionTable } from "."; |
|
|
|
|
|
|
|
|
|
const ConnectionState = ({ connected }: { connected: boolean }) => { |
|
|
|
|
const classes = classNames({ |
|
|
|
@ -21,12 +22,27 @@ const ConnectionState = ({ connected }: { connected: boolean }) => {
@@ -21,12 +22,27 @@ const ConnectionState = ({ connected }: { connected: boolean }) => {
|
|
|
|
|
); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
class DeviceView extends React.Component<{ device: SprinklersDevice }> { |
|
|
|
|
interface DeviceViewProps { |
|
|
|
|
deviceId: string; |
|
|
|
|
state: State; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class DeviceView extends React.Component<DeviceViewProps> { |
|
|
|
|
device: SprinklersDevice; |
|
|
|
|
|
|
|
|
|
componentWillMount() { |
|
|
|
|
this.updateDevice(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
componentWillUpdate() { |
|
|
|
|
this.updateDevice(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
|
const { id, connected, sections, programs, sectionRunner } = this.props.device; |
|
|
|
|
const { id, connected, sections, programs, sectionRunner } = this.device; |
|
|
|
|
return ( |
|
|
|
|
<Item> |
|
|
|
|
<Item.Image src={require<string>("@app/images/raspberry_pi.png")} /> |
|
|
|
|
<Item.Image src={require("@app/images/raspberry_pi.png")} /> |
|
|
|
|
<Item.Content> |
|
|
|
|
<Header as="h1"> |
|
|
|
|
<span>Device </span><kbd>{id}</kbd> |
|
|
|
@ -43,6 +59,13 @@ class DeviceView extends React.Component<{ device: SprinklersDevice }> {
@@ -43,6 +59,13 @@ class DeviceView extends React.Component<{ device: SprinklersDevice }> {
|
|
|
|
|
</Item> |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private updateDevice() { |
|
|
|
|
const { state, deviceId } = this.props; |
|
|
|
|
if (!this.device || this.device.id !== deviceId) { |
|
|
|
|
this.device = state.sprinklersApi.getDevice(deviceId); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export default observer(DeviceView); |
|
|
|
|
export default injectState(observer(DeviceView)); |
|
|
|
|