1
0
Fork 0
empact/app/jsx/app/dashboard.jsx

51 lines
1.8 KiB
JavaScript

var Dashboard = React.createClass({
mixins: [ReactRouter.State],
render: function(){
var p = this.getParams(),
infoImage, infoImageClass, infoTitle,
bcApi, bcItems,
sacApi, sacItems;
if (p.team) {
infoTitle = p.team +' Team';
infoImageClass = 'team';
bcApi = '/api/stat/teams/top';
bcItems = ['repo', 'user'],
sacApi = '/api/stat/teams/activity';
sacItems = ['user', 'repo'];
} else if (p.user) {
var info = Storage.get('user', p.user);
infoImage = info ? info.avatar_url : null;
infoTitle = info && info.name ? info.name : p.user;
bcApi = '/api/stat/users/top';
bcItems = ['repo'],
sacApi = '/api/stat/users/activity';
sacItems = ['repo'];
} else if (p.repo) {
infoTitle = p.repo;
infoImageClass = 'repo';
bcApi = '/api/stat/repos/top';
bcItems = ['user', 'team'],
sacApi = '/api/stat/repos/activity';
sacItems = ['user', 'team'];
} else {
var info = Storage.get('org', p.org);
infoImage = info.avatar_url;
infoTitle = info.login;
bcApi = '/api/stat/orgs/top';
bcItems = ['repo', 'team', 'user'],
sacApi = '/api/stat/orgs/activity';
sacItems = ['team', 'user', 'repo'];
}
return (
<div className="content">
<InfoBlock image={infoImage} className={infoImageClass} title={infoTitle} />
<BarChart api={bcApi} params={this.getParams()} items={bcItems} />
<StackedAreaChart api={sacApi} params={this.getParams()} items={sacItems} />
</div>
);
}
});