import { observer } from "mobx-react"; import * as React from "react"; import { Table } from "semantic-ui-react"; import { Duration } from "@common/Duration"; import { Program, Schedule } from "@common/sprinklers"; @observer export class ScheduleView extends React.Component<{ schedule: Schedule }> { render() { return (
{JSON.stringify(this.props.schedule)}
); } } @observer export default class ProgramTable extends React.Component<{ programs: Program[] }> { private static renderRows(program: Program, i: number): JSX.Element[] | null { if (!program) { return null; } const { name, running, enabled, schedule, sequence } = program; const sequenceItems = sequence.map((item, index) => { const duration = Duration.fromSeconds(item.duration); return (
  • Section {item.section + 1 + ""} for {duration.toString()}
  • ); }); return [( {"" + (i + 1)} {name} {running ? "Running" : "Not running"} {enabled ? "Enabled" : "Not enabled"} ), ( )]; } render() { const programRows = Array.prototype.concat.apply([], this.props.programs.map(ProgramTable.renderRows)); return ( Programs # Name Running? Enabled? {programRows}
    ); } }