2013-02-23 04:41:12 +08:00
|
|
|
/**
|
|
|
|
Handles the default admin route
|
2013-02-21 02:15:50 +08:00
|
|
|
|
2013-02-23 04:41:12 +08:00
|
|
|
@class AdminDashboardRoute
|
|
|
|
@extends Discourse.Route
|
|
|
|
@namespace Discourse
|
|
|
|
@module Discourse
|
|
|
|
**/
|
|
|
|
Discourse.AdminDashboardRoute = Discourse.Route.extend({
|
|
|
|
setupController: function(c) {
|
|
|
|
if( !c.get('versionCheckedAt') || Date.create('12 hours ago') > c.get('versionCheckedAt') ) {
|
|
|
|
this.checkVersion(c);
|
|
|
|
}
|
2013-03-08 00:07:59 +08:00
|
|
|
if( !c.get('reportsCheckedAt') || Date.create('1 hour ago') > c.get('reportsCheckedAt') ) {
|
|
|
|
this.fetchReports(c);
|
|
|
|
}
|
2013-02-23 04:41:12 +08:00
|
|
|
},
|
2013-02-26 05:21:52 +08:00
|
|
|
|
2013-02-23 04:41:12 +08:00
|
|
|
renderTemplate: function() {
|
|
|
|
this.render({into: 'admin/templates/admin'});
|
|
|
|
},
|
2013-02-26 05:21:52 +08:00
|
|
|
|
2013-02-23 04:41:12 +08:00
|
|
|
checkVersion: function(c) {
|
|
|
|
if( Discourse.SiteSettings.version_checks ) {
|
2013-03-08 00:07:59 +08:00
|
|
|
c.set('versionCheckedAt', new Date());
|
2013-02-23 04:41:12 +08:00
|
|
|
Discourse.VersionCheck.find().then(function(vc) {
|
|
|
|
c.set('versionCheck', vc);
|
|
|
|
c.set('loading', false);
|
|
|
|
});
|
2013-02-21 02:15:50 +08:00
|
|
|
}
|
2013-03-08 00:07:59 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
fetchReports: function(c) {
|
|
|
|
// TODO: use one request to get all reports, or maybe one request for all dashboard data including version check.
|
|
|
|
c.set('reportsCheckedAt', new Date());
|
|
|
|
['visits', 'signups', 'topics', 'posts'].each(function(reportType){
|
|
|
|
c.set(reportType, Discourse.Report.find(reportType));
|
|
|
|
});
|
2013-02-23 04:41:12 +08:00
|
|
|
}
|
|
|
|
});
|
2013-02-21 02:15:50 +08:00
|
|
|
|