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) {
|
|
|
|
if( !c.get('dashboardFetchedAt') || Date.create('1 hour ago', 'en') > c.get('dashboardFetchedAt') ) {
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
d.reports.each(function(report){
|
|
|
|
c.set(report.type, Discourse.Report.create(report));
|
|
|
|
});
|
2013-03-22 16:50:22 -05:00
|
|
|
c.set('admins', d.admins);
|
|
|
|
c.set('moderators', d.moderators);
|
2013-06-04 10:53:19 -05:00
|
|
|
c.set('blocked', d.blocked);
|
2013-05-01 17:12:02 -05: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 14:41:12 -06:00
|
|
|
c.set('loading', false);
|
|
|
|
});
|
2013-05-15 10:09:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if( !c.get('problemsFetchedAt') || Date.create(c.problemsCheckInterval, 'en') > 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-03-13 07:04:10 -05:00
|
|
|
if( !c.get('commitsCheckedAt') || Date.create('1 hour ago', 'en') > 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
|
|
|
|