2013-02-22 14:41:12 -06:00
|
|
|
/**
|
|
|
|
Handles the default admin route
|
2013-02-20 12:15:50 -06:00
|
|
|
|
2013-02-22 14:41:12 -06:00
|
|
|
@class AdminDashboardRoute
|
|
|
|
@extends Discourse.Route
|
|
|
|
@namespace Discourse
|
|
|
|
@module Discourse
|
|
|
|
**/
|
|
|
|
Discourse.AdminDashboardRoute = Discourse.Route.extend({
|
2013-03-29 15:05:29 -05:00
|
|
|
|
2013-02-22 14:41:12 -06:00
|
|
|
setupController: function(c) {
|
2013-03-14 17:26:12 -05:00
|
|
|
this.fetchDashboardData(c);
|
2013-03-11 14:26:14 -05:00
|
|
|
this.fetchGithubCommits(c);
|
2013-02-22 14:41:12 -06:00
|
|
|
},
|
2013-02-25 15:21:52 -06:00
|
|
|
|
2013-03-14 17:26:12 -05:00
|
|
|
fetchDashboardData: function(c) {
|
2013-06-10 15:48:50 -05:00
|
|
|
if( !c.get('dashboardFetchedAt') || moment().subtract('hour', 1).toDate() > c.get('dashboardFetchedAt') ) {
|
2013-03-14 17:26:12 -05:00
|
|
|
c.set('dashboardFetchedAt', new Date());
|
|
|
|
Discourse.AdminDashboard.find().then(function(d) {
|
|
|
|
if( Discourse.SiteSettings.version_checks ){
|
|
|
|
c.set('versionCheck', Discourse.VersionCheck.create(d.version_check));
|
|
|
|
}
|
2013-06-10 15:48:50 -05:00
|
|
|
_.each(d.reports,function(report){
|
2013-03-14 17:26:12 -05:00
|
|
|
c.set(report.type, Discourse.Report.create(report));
|
|
|
|
});
|
2013-07-23 12:35:32 -05:00
|
|
|
|
|
|
|
var topReferrers = d.top_referrers;
|
|
|
|
if (topReferrers && topReferrers.data) {
|
|
|
|
d.top_referrers.data = topReferrers.data.map(function (user) {
|
|
|
|
return Discourse.AdminUser.create(user);
|
|
|
|
});
|
|
|
|
c.set('top_referrers', topReferrers);
|
|
|
|
}
|
|
|
|
|
|
|
|
['admins', 'moderators', 'blocked', 'banned', 'top_traffic_sources', 'top_referred_topics'].forEach(function(x) {
|
2013-07-08 11:21:08 -05:00
|
|
|
c.set(x, d[x]);
|
|
|
|
});
|
2013-07-23 12:35:32 -05:00
|
|
|
|
2013-02-22 14:41:12 -06:00
|
|
|
c.set('loading', false);
|
|
|
|
});
|
2013-05-15 10:09:12 -05:00
|
|
|
}
|
|
|
|
|
2013-06-11 10:46:14 -05:00
|
|
|
if( !c.get('problemsFetchedAt') || moment().subtract('minute',c.problemsCheckMinutes).toDate() > c.get('problemsFetchedAt') ) {
|
2013-03-29 14:48:26 -05:00
|
|
|
c.set('problemsFetchedAt', new Date());
|
2013-04-16 11:09:37 -05:00
|
|
|
c.loadProblems();
|
2013-02-20 12:15:50 -06:00
|
|
|
}
|
2013-03-07 10:07:59 -06:00
|
|
|
},
|
|
|
|
|
2013-03-11 14:26:14 -05:00
|
|
|
fetchGithubCommits: function(c) {
|
2013-06-10 15:48:50 -05:00
|
|
|
if( !c.get('commitsCheckedAt') || moment().subtract('hour',1).toDate() > c.get('commitsCheckedAt') ) {
|
2013-03-11 14:26:14 -05:00
|
|
|
c.set('commitsCheckedAt', new Date());
|
|
|
|
c.set('githubCommits', Discourse.GithubCommit.findAll());
|
|
|
|
}
|
2013-02-22 14:41:12 -06:00
|
|
|
}
|
|
|
|
});
|
2013-02-20 12:15:50 -06:00
|
|
|
|