2015-03-07 14:13:47 +00:00
|
|
|
var Router = ReactRouter,
|
2015-03-08 08:42:40 +00:00
|
|
|
Link = Router.Link;
|
2015-03-07 14:13:47 +00:00
|
|
|
|
|
|
|
var App = React.createClass({
|
|
|
|
mixins: [Router.Navigation],
|
|
|
|
render: function(){
|
|
|
|
return (
|
|
|
|
<section className="app">
|
|
|
|
<Menu/>
|
2015-03-08 08:42:40 +00:00
|
|
|
<Router.RouteHandler/>
|
2015-03-07 14:13:47 +00:00
|
|
|
</section>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-03-07 08:34:35 +00:00
|
|
|
var Menu = React.createClass({
|
2015-03-07 14:13:47 +00:00
|
|
|
mixins: [Router.Navigation, Router.State],
|
|
|
|
api_url: "/api/teams?org=",
|
|
|
|
|
2015-03-07 08:34:35 +00:00
|
|
|
getInitialState: function() {
|
|
|
|
return {teams: []};
|
|
|
|
},
|
|
|
|
|
|
|
|
componentDidMount: function() {
|
|
|
|
this.loadTeams();
|
|
|
|
},
|
|
|
|
|
|
|
|
loadTeams: function() {
|
2015-03-07 14:13:47 +00:00
|
|
|
$.get(this.api_url + this.getParams().org, function(res){
|
2015-03-07 08:34:35 +00:00
|
|
|
this.setState({teams: res})
|
|
|
|
}.bind(this));
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
|
|
|
var renderTeam = function(team) {
|
|
|
|
return (
|
2015-03-08 10:02:14 +00:00
|
|
|
<li key={team.name} className="nav team">
|
|
|
|
<Link to="team" params={{org: team.owner, team: team.name}}>{team.name}</Link>
|
2015-03-07 14:13:47 +00:00
|
|
|
</li>
|
2015-03-07 08:34:35 +00:00
|
|
|
)
|
|
|
|
};
|
|
|
|
return (
|
2015-03-07 14:13:47 +00:00
|
|
|
<section className="menu">
|
|
|
|
<ul>
|
|
|
|
<li key="empact" className="nav empact">
|
|
|
|
<Link to="dashboard" params={{org: this.getParams().org}}>Empact</Link>
|
|
|
|
</li>
|
|
|
|
<li key="dash" className="nav dash">
|
|
|
|
<Link to="dashboard" params={{org: this.getParams().org}}>Dashboard</Link>
|
|
|
|
</li>
|
|
|
|
<li key="teams-header" className="nav header">Teams:</li>
|
|
|
|
{this.state.teams.map(renderTeam)}
|
|
|
|
</ul>
|
|
|
|
</section>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var Dashboard = React.createClass({
|
|
|
|
render: function(){
|
|
|
|
return (
|
2015-03-08 08:42:40 +00:00
|
|
|
<Router.RouteHandler/>
|
2015-03-07 14:13:47 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var OrgStats = React.createClass({
|
|
|
|
mixins: [Router.Navigation, Router.State],
|
|
|
|
render: function(){
|
2015-03-08 11:17:56 +00:00
|
|
|
var topRepos = "/api/stat/orgs/top?org="+ this.getParams().org +"&item=repo",
|
|
|
|
repoURL = "/app/"+ this.getParams().org +"/repos/";
|
2015-03-07 14:13:47 +00:00
|
|
|
return (
|
2015-03-08 08:42:40 +00:00
|
|
|
<section className="content">
|
2015-03-08 11:17:56 +00:00
|
|
|
<BarChart api={topRepos} link={repoURL}/>
|
2015-03-08 08:42:40 +00:00
|
|
|
</section>
|
2015-03-07 14:13:47 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var TeamStats = React.createClass({
|
|
|
|
mixins: [Router.Navigation, Router.State],
|
|
|
|
render: function(){
|
2015-03-08 14:35:25 +00:00
|
|
|
var topRepos = "/api/stat/teams/top"+
|
|
|
|
"?org="+ this.getParams().org +
|
|
|
|
"&team="+ this.getParams().team +
|
|
|
|
"&item=repo",
|
2015-03-08 11:17:56 +00:00
|
|
|
repoURL = "/app/"+ this.getParams().org +"/repos/";
|
2015-03-07 14:13:47 +00:00
|
|
|
return (
|
2015-03-08 11:17:56 +00:00
|
|
|
<section className="content">
|
|
|
|
<BarChart api={topRepos} link={repoURL}/>
|
|
|
|
</section>
|
2015-03-07 14:13:47 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var UserStats = React.createClass({
|
2015-03-08 15:16:27 +00:00
|
|
|
mixins: [Router.Navigation, Router.State],
|
2015-03-07 14:13:47 +00:00
|
|
|
render: function(){
|
2015-03-08 15:16:27 +00:00
|
|
|
var topRepos = "/api/stat/users/top"+
|
|
|
|
"?org="+ this.getParams().org +
|
|
|
|
"&author="+ this.getParams().user +
|
|
|
|
"&item=repo",
|
|
|
|
repoURL = "/app/"+ this.getParams().org +"/repos/";
|
2015-03-07 14:13:47 +00:00
|
|
|
return (
|
2015-03-08 15:16:27 +00:00
|
|
|
<section className="content">
|
|
|
|
<BarChart api={topRepos} link={repoURL}/>
|
|
|
|
</section>
|
2015-03-07 14:13:47 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var RepoStats = React.createClass({
|
2015-03-08 15:16:27 +00:00
|
|
|
mixins: [Router.Navigation, Router.State],
|
2015-03-07 14:13:47 +00:00
|
|
|
render: function(){
|
2015-03-08 15:16:27 +00:00
|
|
|
var topAuthors = "/api/stat/repos/top"+
|
|
|
|
"?org="+ this.getParams().org +
|
|
|
|
"&repo="+ this.getParams().repo +
|
|
|
|
"&item=author",
|
|
|
|
userURL = "/app/"+ this.getParams().org +"/users/";
|
2015-03-07 14:13:47 +00:00
|
|
|
return (
|
2015-03-08 15:16:27 +00:00
|
|
|
<section className="content">
|
|
|
|
<BarChart api={topAuthors} link={userURL}/>
|
|
|
|
</section>
|
2015-03-07 14:13:47 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var NotFound = React.createClass({
|
|
|
|
render: function(){
|
|
|
|
return (
|
|
|
|
<section className="content">NOT FOUND :(</section>
|
2015-03-07 08:34:35 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
2015-03-07 14:13:47 +00:00
|
|
|
|
|
|
|
var routes = [
|
2015-03-08 08:42:40 +00:00
|
|
|
<Router.Route name="root" path="/app/" handler={App}>
|
|
|
|
<Router.Route name="dashboard" path=":org" handler={Dashboard}>
|
|
|
|
<Router.DefaultRoute handler={OrgStats} />
|
|
|
|
<Router.Route name="team" path="teams/:team" handler={TeamStats} />
|
|
|
|
<Router.Route name="user" path="users/:user" handler={UserStats} />
|
|
|
|
<Router.Route name="repo" path="repos/:repo" handler={RepoStats} />
|
|
|
|
</Router.Route>
|
|
|
|
<Router.NotFoundRoute handler={NotFound}/>
|
|
|
|
</Router.Route>
|
2015-03-07 14:13:47 +00:00
|
|
|
];
|
|
|
|
Router.run(routes, Router.HistoryLocation, function(Handler) {
|
|
|
|
React.render(<Handler/>, document.body);
|
|
|
|
});
|