import * as React from "react";
import { computed } from "mobx";
import DevTools from "mobx-react-devtools";
import { observer } from "mobx-react";
import { SprinklersDevice, Section, Program } from "./sprinklers";
import { Item, Table, Header, Segment, Form, Input, DropdownItemProps } from "semantic-ui-react";
import FontAwesome = require("react-fontawesome");
import * as classNames from "classnames";
import "semantic-ui-css/semantic.css";
import "font-awesome/css/font-awesome.css";
import "app/style/app.css";
/* tslint:disable:object-literal-sort-keys */
@observer
class SectionTable extends React.PureComponent<{ sections: Section[] }, void> {
private static renderRow(section: Section, index: number) {
const { name, state } = section;
return (
{"" + (index + 1)}
{name}
{state ?
( Irrigating)
: "Not irrigating"}
);
}
public render() {
return (
Sections
#
Name
State
{
this.props.sections.map(SectionTable.renderRow)
}
);
}
}
@observer
class RunSectionForm extends React.Component<{ sections: Section[] }, void> {
public render() {
return
;
}
@computed
private get sectionOptions(): DropdownItemProps[] {
// return this.props.sections.map((s, i) => ({
// text: s.name,
// value: i,
// }));
return [];
}
}
@observer
class ProgramTable extends React.PureComponent<{ programs: Program[] }, void> {
private static renderRow(program: Program, i: number) {
const { name, running } = program;
return (
{"" + (i + 1)}
{name}
{running ? "Running" : "Not running"}
);
}
public render() {
return (
Programs
#
Name
Running
{
this.props.programs.map(ProgramTable.renderRow)
}
);
}
}
const ConnectionState = ({ connected }: { connected: boolean }) =>
{connected ? "Connected" : "Disconnected"}
;
@observer
class DeviceView extends React.PureComponent<{ device: SprinklersDevice }, void> {
public render() {
const { id, connected, sections, programs } = this.props.device;
return (
-
("app/images/raspberry_pi.png")} />
);
}
}
@observer
export default class App extends React.PureComponent<{ device: SprinklersDevice }, any> {
public render() {
return
;
}
}