diff --git a/app/script/App.tsx b/app/script/App.tsx
index 45325aa..46cc661 100644
--- a/app/script/App.tsx
+++ b/app/script/App.tsx
@@ -2,7 +2,7 @@ import * as React from "react";
import { computed } from "mobx";
import DevTools from "mobx-react-devtools";
import { observer } from "mobx-react";
-import { SprinklersDevice, Section, Program, Duration } from "./sprinklers";
+import { SprinklersDevice, Section, Program, Duration, Schedule } from "./sprinklers";
import { Item, Table, Header, Segment, Form, Input, DropdownItemProps } from "semantic-ui-react";
import FontAwesome = require("react-fontawesome");
import * as classNames from "classnames";
@@ -64,28 +64,55 @@ class DurationInput extends React.Component<{
}, void> {
public render() {
const duration = this.props.duration;
+ const editing = this.props.onDurationChange != null;
return
;
}
+
+ private onMinutesChange = (e, { value }) => {
+ this.props.onDurationChange(new Duration(Number(value), this.props.duration.seconds));
+ }
+
+ private onSecondsChange = (e, { value }) => {
+ let newSeconds = Number(value);
+ let newMinutes = this.props.duration.minutes;
+ if (newSeconds >= 60) {
+ newMinutes++;
+ newSeconds = 0;
+ }
+ if (newSeconds < 0) {
+ newMinutes = Math.max(0, newMinutes - 1);
+ newSeconds = 59;
+ }
+ this.props.onDurationChange(new Duration(newMinutes, newSeconds));
+ }
}
@observer
-class RunSectionForm extends React.Component<{ sections: Section[] }, void> {
+class RunSectionForm extends React.Component<{ sections: Section[] }, { duration: Duration }> {
+ public componentWillMount() {
+ this.setState({
+ duration: new Duration(1, 1),
+ });
+ }
+
public render() {
return
-
+ this.setState({ duration: newDuration })} />
;
@@ -100,20 +127,42 @@ class RunSectionForm extends React.Component<{ sections: Section[] }, void> {
}
}
+@observer
+class ScheduleView extends React.PureComponent<{ schedule: Schedule }, void> {
+ public render() {
+ return (
+ {JSON.stringify(this.props.schedule)}
+ );
+ }
+}
+
@observer
class ProgramTable extends React.PureComponent<{ programs: Program[] }, void> {
private static renderRow(program: Program, i: number) {
if (!program) {
return null;
}
- const { name, running } = program;
- return (
+ const { name, running, enabled, schedule, sequence } = program;
+ return [
{"" + (i + 1)}
{name}
{running ? "Running" : "Not running"}
+ {enabled ? "Enabled" : "Not enabled"}
- );
+ ,
+
+
+
+ {sequence.map((item) =>
+ (- Section {item.section + 1 + ""} for
+ {item.duration.minutes}M {item.duration.seconds}S
))}
+
+
+
+
+ ,
+ ];
}
public render() {
@@ -121,17 +170,18 @@ class ProgramTable extends React.PureComponent<{ programs: Program[] }, void> {
- Programs
+ Programs
#
Name
- Running
+ Running?
+ Enabled?
{
- this.props.programs.map(ProgramTable.renderRow)
+ Array.prototype.concat.apply([], this.props.programs.map(ProgramTable.renderRow))
}
diff --git a/app/style/app.css b/app/style/app.css
index b564f42..9099f26 100644
--- a/app/style/app.css
+++ b/app/style/app.css
@@ -17,8 +17,8 @@
width: 20px
}
-.section--name,
-.program--name {
+.section--name /*,
+.program--name*/ {
width: 150px;
white-space: nowrap;
}
@@ -37,9 +37,5 @@
.durationInput--minutes,
.durationInput--seconds {
- width: 100px;
-}
-
-.durationInput--colon {
- line-height: 38px;
+ width: 80px;
}
\ No newline at end of file