import { observer } from "mobx-react"; import * as React from "react"; import { Button, Menu, Segment} from "semantic-ui-react"; import { ProgramSequenceView, ScheduleView } from "@app/components"; import { AppState, injectState } from "@app/state"; import { Program, SprinklersDevice } from "@common/sprinklersRpc"; import { RouteComponentProps } from "react-router"; import { Link } from "react-router-dom"; @observer class ProgramDetailView extends React.Component { } @observer class ProgramPage extends React.Component<{ appState: AppState, } & RouteComponentProps<{ deviceId: string, programId: number }>> { device!: SprinklersDevice; render() { const { deviceId, programId } = this.props.match.params; const device = this.device = this.props.appState.sprinklersRpc.getDevice(deviceId); // TODO: check programId if (device.programs.length <= programId || !device.programs[programId]) { return null; } const program = device.programs[programId]; const programRows = this.renderRows(program, programId); return (
Program {program.name} ({program.id}) {programRows}
); } private renderRows = (program: Program, i: number): JSX.Element | null => { const { name, running, enabled, schedule, sequence } = program; const cancelOrRun = () => running ? program.cancel() : program.run(); return ( Enabled: {enabled ? "Enabled" : "Not enabled"}
Running: {running ? "Running" : "Not running"}

Sequence:

Schedule:

); } } const DecoratedProgramPage = injectState(observer(ProgramPage)); export default DecoratedProgramPage;