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({
|
|
|
|
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-02-22 15:41:12 -05:00
|
|
|
renderTemplate: function() {
|
|
|
|
this.render({into: 'admin/templates/admin'});
|
|
|
|
},
|
2013-02-25 16:21:52 -05:00
|
|
|
|
2013-03-14 18:26:12 -04: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-02-22 15:41:12 -05:00
|
|
|
c.set('loading', false);
|
|
|
|
});
|
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-03-13 08:04:10 -04:00
|
|
|
if( !c.get('commitsCheckedAt') || Date.create('1 hour ago', 'en') > 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
|
|
|
|