import * as React from "react";
import {observer} from "mobx-react";
import {Program, Schedule} from "../sprinklers";
import {Table} from "semantic-ui-react";
@observer
export class ScheduleView extends React.PureComponent<{ schedule: Schedule }, void> {
render() {
return (
{JSON.stringify(this.props.schedule)}
);
}
}
@observer
export default class ProgramTable extends React.PureComponent<{ programs: Program[] }, void> {
private static renderRow(program: Program, i: number): JSX.Element[] {
if (!program) {
return null;
}
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
))}
,
];
}
render() {
return (
Programs
#
Name
Running?
Enabled?
{
Array.prototype.concat.apply([], this.props.programs.map(ProgramTable.renderRow))
}
);
}
}