-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3171bbd
commit 835ffd4
Showing
3 changed files
with
66 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from 'react'; | ||
import { Card } from 'react-bootstrap'; | ||
|
||
// TODO: Update time since last update every second, | ||
// currently it only updates when the status changes | ||
function _systemStatus(status) { | ||
if (null === status) { | ||
return (<b>Not connected</b>); | ||
} | ||
|
||
const pump = status.pump; | ||
// TODO: check is this is a valid way to get the time since last update | ||
const now = new Date(); | ||
const diff = now - status.updated; | ||
const diffString = new Date(diff).toISOString().substr(11, 8); | ||
return ( | ||
<> | ||
<strong>Time since last update:</strong> {diffString}<br /> | ||
<strong>Pump Running:</strong> {pump.running ? "Yes" : "No"}<br /> | ||
<strong>Time Left:</strong> {pump.timeLeft} ms | ||
</> | ||
); | ||
} | ||
|
||
function SystemStatusArea({ status }) { | ||
return ( | ||
<Card> | ||
<Card.Body> | ||
<Card.Title>System Status</Card.Title> | ||
<Card.Text> | ||
{_systemStatus(status)} | ||
</Card.Text> | ||
</Card.Body> | ||
</Card> | ||
); | ||
} | ||
|
||
export default SystemStatusArea; |