2013-02-22 15:41:12 -05:00
|
|
|
/**
|
|
|
|
Handles the default admin route
|
2013-02-20 13:15:50 -05:00
|
|
|
|
2013-02-22 15:41:12 -05:00
|
|
|
@class AdminDashboardRoute
|
|
|
|
@extends Discourse.Route
|
|
|
|
@namespace Discourse
|
|
|
|
@module Discourse
|
|
|
|
**/
|
|
|
|
Discourse.AdminDashboardRoute = Discourse.Route.extend({
|
2013-03-29 16:05:29 -04:00
|
|
|
|
2013-02-22 15:41:12 -05:00
|
|
|
setupController: function(c) {
|
2013-03-14 18:26:12 -04:00
|
|
|
this.fetchDashboardData(c);
|
2013-03-11 15:26:14 -04:00
|
|
|
this.fetchGithubCommits(c);
|
2013-02-22 15:41:12 -05:00
|
|
|
},
|
2013-02-25 16:21:52 -05:00
|
|
|
|
2013-03-14 18:26:12 -04:00
|
|
|
fetchDashboardData: function(c) {
|
2013-06-10 16:48:50 -04:00
|
|
|
if( !c.get('dashboardFetchedAt') || moment().subtract('hour', 1).toDate() > c.get('dashboardFetchedAt') ) {
|
2013-03-14 18:26:12 -04: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 16:48:50 -04:00
|
|
|
_.each(d.reports,function(report){
|
2013-03-14 18:26:12 -04:00
|
|
|
c.set(report.type, Discourse.Report.create(report));
|
|
|
|
});
|
2013-03-22 17:50:22 -04:00
|
|
|
c.set('admins', d.admins);
|
|
|
|
c.set('moderators', d.moderators);
|
2013-06-04 11:53:19 -04:00
|
|
|
c.set('blocked', d.blocked);
|
2013-05-01 18:12:02 -04:00
|
|
|
c.set('top_referrers', d.top_referrers);
|
|
|
|
c.set('top_traffic_sources', d.top_traffic_sources);
|
|
|
|
c.set('top_referred_topics', d.top_referred_topics);
|
2013-02-22 15:41:12 -05:00
|
|
|
c.set('loading', false);
|
|
|
|
});
|
2013-05-15 11:09:12 -04:00
|
|
|
}
|
|
|
|
|
2013-06-11 11:46:14 -04:00
|
|
|
if( !c.get('problemsFetchedAt') || moment().subtract('minute',c.problemsCheckMinutes).toDate() > c.get('problemsFetchedAt') ) {
|
2013-03-29 15:48:26 -04:00
|
|
|
c.set('problemsFetchedAt', new Date());
|
2013-04-16 12:09:37 -04:00
|
|
|
c.loadProblems();
|
2013-02-20 13:15:50 -05:00
|
|
|
}
|
2013-03-07 11:07:59 -05:00
|
|
|
},
|
|
|
|
|
2013-03-11 15:26:14 -04:00
|
|
|
fetchGithubCommits: function(c) {
|
2013-06-10 16:48:50 -04:00
|
|
|
if( !c.get('commitsCheckedAt') || moment().subtract('hour',1).toDate() > c.get('commitsCheckedAt') ) {
|
2013-03-11 15:26:14 -04:00
|
|
|
c.set('commitsCheckedAt', new Date());
|
|
|
|
c.set('githubCommits', Discourse.GithubCommit.findAll());
|
|
|
|
}
|
2013-02-22 15:41:12 -05:00
|
|
|
}
|
|
|
|
});
|
2013-02-20 13:15:50 -05:00
|
|
|
|