2013-02-23 04:41:12 +08:00
|
|
|
/**
|
|
|
|
This controller supports the default interface when you enter the admin section.
|
2013-02-21 02:15:50 +08:00
|
|
|
|
2013-02-23 04:41:12 +08:00
|
|
|
@class AdminDashboardController
|
|
|
|
@extends Ember.Controller
|
|
|
|
@namespace Discourse
|
2013-05-28 23:08:32 +08:00
|
|
|
@module Discourse
|
2013-02-23 04:41:12 +08:00
|
|
|
**/
|
|
|
|
Discourse.AdminDashboardController = Ember.Controller.extend({
|
|
|
|
loading: true,
|
2013-03-20 11:18:00 +08:00
|
|
|
versionCheck: null,
|
2013-06-11 04:48:50 +08:00
|
|
|
problemsCheckMinutes: 1,
|
2013-03-20 11:18:00 +08:00
|
|
|
|
|
|
|
foundProblems: function() {
|
2013-08-09 00:42:08 +08:00
|
|
|
return(Discourse.User.currentProp('admin') && this.get('problems') && this.get('problems').length > 0);
|
2013-04-17 00:09:37 +08:00
|
|
|
}.property('problems'),
|
|
|
|
|
|
|
|
thereWereProblems: function() {
|
2013-08-09 00:42:08 +08:00
|
|
|
if(!Discourse.User.currentProp('admin')) { return false }
|
2013-04-17 00:09:37 +08:00
|
|
|
if( this.get('foundProblems') ) {
|
|
|
|
this.set('hadProblems', true);
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return this.get('hadProblems') || false;
|
|
|
|
}
|
|
|
|
}.property('foundProblems'),
|
|
|
|
|
|
|
|
loadProblems: function() {
|
|
|
|
this.set('loadingProblems', true);
|
|
|
|
this.set('problemsFetchedAt', new Date());
|
|
|
|
var c = this;
|
|
|
|
Discourse.AdminDashboard.fetchProblems().then(function(d) {
|
|
|
|
c.set('problems', d.problems);
|
|
|
|
c.set('loadingProblems', false);
|
|
|
|
if( d.problems && d.problems.length > 0 ) {
|
2013-06-11 04:48:50 +08:00
|
|
|
c.problemsCheckInterval = 1;
|
2013-04-17 00:09:37 +08:00
|
|
|
} else {
|
2013-06-11 04:48:50 +08:00
|
|
|
c.problemsCheckInterval = 10;
|
2013-04-17 00:09:37 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
problemsTimestamp: function() {
|
2013-06-11 13:19:19 +08:00
|
|
|
return moment(this.get('problemsFetchedAt')).format('LLL');
|
2013-08-03 06:31:25 +08:00
|
|
|
}.property('problemsFetchedAt'),
|
|
|
|
|
|
|
|
updatedTimestamp: function() {
|
|
|
|
return moment(this.get('updated_at')).format('LLL');
|
|
|
|
}.property('updated_at')
|
2013-02-23 04:41:12 +08:00
|
|
|
});
|