discourse/app/assets/javascripts/admin/routes/admin_dashboard_route.js

47 lines
1.5 KiB
JavaScript
Raw Normal View History

/**
Handles the default admin route
@class AdminDashboardRoute
@extends Discourse.Route
@namespace Discourse
@module Discourse
**/
Discourse.AdminDashboardRoute = Discourse.Route.extend({
setupController: function(c) {
this.fetchDashboardData(c);
2013-03-12 03:26:14 +08:00
this.fetchGithubCommits(c);
},
fetchDashboardData: function(c) {
if( !c.get('dashboardFetchedAt') || moment().subtract('hour', 1).toDate() > 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));
}
_.each(d.reports,function(report){
c.set(report.type, Discourse.Report.create(report));
});
2013-07-09 00:21:08 +08:00
_.each(['admins', 'moderators', 'blocked', 'banned', 'top_referrers', 'top_traffic_sources', 'top_referred_topics'], function(x) {
c.set(x, d[x]);
});
c.set('loading', false);
});
}
2013-06-11 23:46:14 +08:00
if( !c.get('problemsFetchedAt') || moment().subtract('minute',c.problemsCheckMinutes).toDate() > c.get('problemsFetchedAt') ) {
c.set('problemsFetchedAt', new Date());
c.loadProblems();
}
2013-03-08 00:07:59 +08:00
},
2013-03-12 03:26:14 +08:00
fetchGithubCommits: function(c) {
if( !c.get('commitsCheckedAt') || moment().subtract('hour',1).toDate() > c.get('commitsCheckedAt') ) {
2013-03-12 03:26:14 +08:00
c.set('commitsCheckedAt', new Date());
c.set('githubCommits', Discourse.GithubCommit.findAll());
}
}
});