-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bumped version to 0.0.2 macadocious added in players tab with filtering
- Loading branch information
Chris Sprance
committed
Dec 10, 2016
1 parent
82a21a2
commit 04a61cc
Showing
12 changed files
with
394 additions
and
12 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,97 @@ | ||
/** | ||
* Name: PlayersCard | ||
* Author: Chrissprance | ||
* Creation Date: 12/9/2016 | ||
* Description: Component used to display player information from the server as well as from the localStorage | ||
*/ | ||
import React, { | ||
Component, | ||
PropTypes, | ||
} from 'react'; | ||
import styled from 'styled-components'; | ||
import {Card, CardActions, CardHeader, CardTitle, CardText} from 'material-ui/Card'; | ||
import FlatButton from 'material-ui/FlatButton'; | ||
import TextField from 'material-ui/TextField'; | ||
import store from 'store'; | ||
import axios from 'axios'; | ||
|
||
import Spacer from '../common/Spacer'; | ||
import {darkGrey, white} from '../../styles/colors'; | ||
import {log} from '../../utils/loggerUtils'; | ||
import ExternalLink from '../common/ExternalLink' | ||
|
||
|
||
class PlayersCard extends Component { | ||
constructor(props, context) { | ||
super(props, context); | ||
this.state = { | ||
avatar: 'http://placehold.it/42x42', | ||
notes: store.get(this.props.steam) !== undefined ? store.get(this.props.steam).notes : '' | ||
} | ||
} | ||
|
||
componentWillMount() { | ||
this.getAvatar(); | ||
} | ||
|
||
getAvatar = () => { | ||
axios.get('https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2/', { | ||
params: { | ||
key: 'C4E62F89FF5D569A481850BCD3098D52', | ||
steamids: this.props.steam | ||
} | ||
}).then((res) => { | ||
this.setState({ | ||
avatar: res.data.response.players[0].avatar, | ||
}); | ||
}).catch((err) => { | ||
log('error', err); | ||
}); | ||
}; | ||
|
||
updateNotes = (e) => { | ||
this.setState({ | ||
notes: e.target.value, | ||
}); | ||
store.set(this.props.steam, {avatar: this.state.avatar, notes: e.target.value}); | ||
}; | ||
|
||
render() { | ||
const link = String('https://steamrep.com/profiles/' + this.props.steam); | ||
return ( | ||
<PCard key={this.props.steam + this.props.name}> | ||
<Card> | ||
<CardHeader | ||
avatar={this.state.avatar} | ||
style={{background: darkGrey}} | ||
title={this.props.name} | ||
subtitle={<ExternalLink to={link}>{this.props.steam}</ExternalLink>} | ||
/> | ||
<CardText> | ||
<TextField onChange={this.updateNotes} | ||
value={this.state.notes} | ||
style={{width: '100%'}} | ||
floatingLabelStyle={{color: white}} | ||
floatingLabelText="Notes:"/> | ||
</CardText> | ||
<CardActions style={{display: 'flex'}}> | ||
<Spacer /> | ||
<FlatButton label="Kick" onTouchTap={this.kickPlayer}/> | ||
<FlatButton secondary={true} label="Ban" onTouchTap={this.openBanDialog}/> | ||
</CardActions> | ||
</Card> | ||
</PCard> | ||
); | ||
} | ||
} | ||
|
||
PlayersCard.propTypes = {}; | ||
PlayersCard.defaultProps = {}; | ||
|
||
const PCard = styled.div` | ||
flex-basis: 20%; | ||
margin: 5px; | ||
`; | ||
|
||
|
||
export default PlayersCard; |
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,33 @@ | ||
/** | ||
* Name: ExternalLink | ||
* Author: Chrissprance | ||
* Creation Date: 12/9/2016 | ||
* Description: Handles sending a user to an external browser link | ||
*/ | ||
import {log} from '../../utils/loggerUtils'; | ||
import React, { | ||
PropTypes, | ||
} from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
const ExternalLink = (props) => { | ||
const handleClick = () => { | ||
require('electron').shell.openExternal(props.to); | ||
log(`Navigating to External Link: ${props.to}`); | ||
}; | ||
|
||
return ( | ||
<Pointer onClick={handleClick}> | ||
{props.children} | ||
</Pointer> | ||
); | ||
}; | ||
|
||
ExternalLink.propTypes = { | ||
to: PropTypes.string.isRequired | ||
}; | ||
|
||
const Pointer = styled.div` | ||
cursor: pointer; | ||
`; | ||
export default ExternalLink; |
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,28 @@ | ||
/** | ||
* Name: Spacer | ||
* Author: Chrissprance | ||
* Creation Date: 12/9/2016 | ||
* Description: Spacer Component | ||
*/ | ||
import React, { | ||
PropTypes, | ||
} from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
const Spacer = (props) => { | ||
return ( | ||
<SpacerDiv> | ||
|
||
</SpacerDiv> | ||
); | ||
}; | ||
|
||
|
||
Spacer.propTypes = {}; | ||
Spacer.defaultProps = {}; | ||
const SpacerDiv = styled.div` | ||
flex-grow: 1; | ||
`; | ||
|
||
export default Spacer; | ||
|
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
Oops, something went wrong.