You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
2.6 KiB
70 lines
2.6 KiB
7 years ago
|
import { observer } from "mobx-react";
|
||
8 years ago
|
import * as React from "react";
|
||
7 years ago
|
import { Table } from "semantic-ui-react";
|
||
7 years ago
|
|
||
7 years ago
|
import { Program, Schedule } from "@common/sprinklers";
|
||
8 years ago
|
|
||
|
@observer
|
||
7 years ago
|
export class ScheduleView extends React.Component<{ schedule: Schedule }> {
|
||
8 years ago
|
render() {
|
||
|
return (
|
||
|
<div>{JSON.stringify(this.props.schedule)}</div>
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@observer
|
||
7 years ago
|
export default class ProgramTable extends React.Component<{ programs: Program[] }> {
|
||
7 years ago
|
private static renderRows(program: Program, i: number): JSX.Element[] | null {
|
||
8 years ago
|
if (!program) {
|
||
|
return null;
|
||
|
}
|
||
7 years ago
|
const { name, running, enabled, schedule, sequence } = program;
|
||
|
const sequenceItems = sequence.map((item, index) => (
|
||
|
<li key={index}>Section {item.section + 1 + ""} for
|
||
|
{item.duration.minutes}M {item.duration.seconds}S</li>
|
||
|
));
|
||
|
return [(
|
||
8 years ago
|
<Table.Row key={i}>
|
||
|
<Table.Cell className="program--number">{"" + (i + 1)}</Table.Cell>
|
||
|
<Table.Cell className="program--name">{name}</Table.Cell>
|
||
|
<Table.Cell className="program--running">{running ? "Running" : "Not running"}</Table.Cell>
|
||
|
<Table.Cell className="program--enabled">{enabled ? "Enabled" : "Not enabled"}</Table.Cell>
|
||
|
</Table.Row>
|
||
7 years ago
|
), (
|
||
8 years ago
|
<Table.Row key={i + .5}>
|
||
|
<Table.Cell className="program--sequence" colSpan="4">
|
||
|
<ul>
|
||
7 years ago
|
{sequenceItems}
|
||
8 years ago
|
</ul>
|
||
7 years ago
|
<ScheduleView schedule={schedule} />
|
||
8 years ago
|
</Table.Cell>
|
||
|
</Table.Row>
|
||
7 years ago
|
)];
|
||
8 years ago
|
}
|
||
|
|
||
|
render() {
|
||
7 years ago
|
const programRows = Array.prototype.concat.apply([],
|
||
|
this.props.programs.map(ProgramTable.renderRows));
|
||
|
|
||
8 years ago
|
return (
|
||
|
<Table celled>
|
||
|
<Table.Header>
|
||
|
<Table.Row>
|
||
|
<Table.HeaderCell colSpan="7">Programs</Table.HeaderCell>
|
||
|
</Table.Row>
|
||
|
<Table.Row>
|
||
|
<Table.HeaderCell className="program--number">#</Table.HeaderCell>
|
||
|
<Table.HeaderCell className="program--name">Name</Table.HeaderCell>
|
||
|
<Table.HeaderCell className="program--running">Running?</Table.HeaderCell>
|
||
|
<Table.HeaderCell className="program--enabled">Enabled?</Table.HeaderCell>
|
||
|
</Table.Row>
|
||
|
</Table.Header>
|
||
|
<Table.Body>
|
||
7 years ago
|
{programRows}
|
||
8 years ago
|
</Table.Body>
|
||
|
</Table>
|
||
|
);
|
||
|
}
|
||
8 years ago
|
}
|