-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from copios-jp/master
Add Training Reporting
- Loading branch information
Showing
44 changed files
with
1,114 additions
and
226 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
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,31 @@ | ||
import events from 'events' | ||
|
||
import Ant from './' | ||
import Receiver from './Receiver' | ||
|
||
class Scanner extends events.EventEmitter { | ||
activate = () => { | ||
const stick = new Ant.GarminStick2(1) | ||
stick.once('startup', this.onStartup.bind(this, stick)) | ||
stick.open() | ||
} | ||
|
||
deactivate = () => { | ||
if (this.receiver) { | ||
this.receiver.deactivate() | ||
this.emit('receiver-removed', this.receiver, []) | ||
delete this.receiver | ||
} | ||
|
||
this.emit('scanner-deactivated', this) | ||
} | ||
|
||
onStartup = (stick) => { | ||
this.emit('scanner-activated', this) | ||
this.receiver = new Receiver(stick) | ||
this.emit('receiver-added', this.receiver, [this.receiver]) | ||
this.receiver.activate() | ||
} | ||
} | ||
|
||
export default new Scanner() |
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
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 |
---|---|---|
@@ -1,17 +1,32 @@ | ||
import React from 'react' | ||
import { Component } from 'react' | ||
|
||
import { withStyles } from '@material-ui/core/styles' | ||
import styles from '../../../styles/' | ||
import { getZone, getPercentageOfMax } from '../../../../services/analytics/' | ||
|
||
export const Body = (props) => { | ||
const { classes, sensor } = props | ||
return ( | ||
<svg style={{ flexGrow: 1 }} className={classes[`rate_${getZone(sensor)}`]}> | ||
<text x="50%" y="50%" dominantBaseline="central" textAnchor="middle" fill="lightgrey"> | ||
{`${getPercentageOfMax(sensor)}%`} | ||
</text> | ||
</svg> | ||
) | ||
export class Body extends Component { | ||
shouldComponentUpdate(nextProps) { | ||
const nextSensor = nextProps.sensor | ||
const { sensor } = this.props | ||
|
||
return ( | ||
nextSensor.rate !== sensor.rate || | ||
nextSensor.method !== sensor.method || | ||
nextSensor.max !== sensor.max | ||
) | ||
} | ||
|
||
render() { | ||
const { classes, sensor } = this.props | ||
return ( | ||
<svg style={{ flexGrow: 1 }} className={classes[`zone_${getZone(sensor)}`]}> | ||
<text x="50%" y="50%" dominantBaseline="central" textAnchor="middle" fill="lightgrey"> | ||
{`${getPercentageOfMax(sensor)}%`} | ||
</text> | ||
</svg> | ||
) | ||
} | ||
} | ||
|
||
export default withStyles(styles)(Body) |
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 |
---|---|---|
@@ -1,17 +1,25 @@ | ||
import React from 'react' | ||
import { Component } from 'react' | ||
|
||
import { Favorite } from '@material-ui/icons' | ||
import { withStyles } from '@material-ui/core/styles' | ||
import styles from '../../../styles/' | ||
import Rate from './rate' | ||
|
||
export const Footer = (props) => { | ||
const { classes, sensor } = props | ||
return ( | ||
<div className={classes.cardFooter}> | ||
<Favorite fontSize="small" /> | ||
<span className={classes.cardRate}>{sensor.rate}</span> | ||
</div> | ||
) | ||
export class Footer extends Component { | ||
shouldComponentUpdate(nextProps) { | ||
const nextSensor = nextProps.sensor | ||
const { sensor } = this.props | ||
return nextSensor.rate !== sensor.rate || nextSensor.recording | ||
} | ||
|
||
render() { | ||
const { classes, sensor } = this.props | ||
return ( | ||
<div className={classes.cardFooter}> | ||
<Rate rate={sensor.rate} /> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
export default withStyles(styles)(Footer) |
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,24 @@ | ||
import React from 'react' | ||
import { Component } from 'react' | ||
import { Favorite } from '@material-ui/icons' | ||
|
||
import { withStyles } from '@material-ui/core/styles' | ||
import styles from '../../../styles/' | ||
|
||
export class Rate extends Component { | ||
shouldComponentUpdate(nextProps) { | ||
return nextProps.rate !== this.props.rate | ||
} | ||
|
||
render() { | ||
const { classes, rate } = this.props | ||
return ( | ||
<span className={classes.cardRate}> | ||
<Favorite fontSize="small" /> | ||
{rate} | ||
</span> | ||
) | ||
} | ||
} | ||
|
||
export default withStyles(styles)(Rate) |
26 changes: 26 additions & 0 deletions
26
app/renderer/components/sensor/header/history_button/index.jsx
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,26 @@ | ||
import React from 'react' | ||
import { Component } from 'react' | ||
import { Button } from '@material-ui/core' | ||
import { History } from '@material-ui/icons' | ||
|
||
export class HistoryButton extends Component { | ||
onClick = (e) => { | ||
e.stopPropagation() | ||
this.props.handleChange({ showReport: true }) | ||
} | ||
|
||
render = () => { | ||
const { classes, sensor } = this.props | ||
return ( | ||
<Button | ||
className={classes.recordButton} | ||
onClick={this.onClick} | ||
color="inherit" | ||
disabled={!sensor.history.length || sensor.recording}> | ||
<History /> | ||
</Button> | ||
) | ||
} | ||
} | ||
|
||
export default HistoryButton |
Oops, something went wrong.