2013-02-22 15:41:12 -05:00
|
|
|
/**
|
|
|
|
This controller supports the default interface when you enter the admin section.
|
2013-02-20 13:15:50 -05:00
|
|
|
|
2013-02-22 15:41:12 -05:00
|
|
|
@class AdminDashboardController
|
|
|
|
@extends Ember.Controller
|
|
|
|
@namespace Discourse
|
2013-05-28 11:08:32 -04:00
|
|
|
@module Discourse
|
2013-02-22 15:41:12 -05:00
|
|
|
**/
|
|
|
|
Discourse.AdminDashboardController = Ember.Controller.extend({
|
|
|
|
loading: true,
|
2013-03-19 23:18:00 -04:00
|
|
|
versionCheck: null,
|
2013-06-10 16:48:50 -04:00
|
|
|
problemsCheckMinutes: 1,
|
2013-03-19 23:18:00 -04:00
|
|
|
|
|
|
|
foundProblems: function() {
|
2013-08-08 12:42:08 -04:00
|
|
|
return(Discourse.User.currentProp('admin') && this.get('problems') && this.get('problems').length > 0);
|
2013-04-16 12:09:37 -04:00
|
|
|
}.property('problems'),
|
|
|
|
|
|
|
|
thereWereProblems: function() {
|
2013-08-08 12:42:08 -04:00
|
|
|
if(!Discourse.User.currentProp('admin')) { return false }
|
2013-04-16 12:09:37 -04: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-10 16:48:50 -04:00
|
|
|
c.problemsCheckInterval = 1;
|
2013-04-16 12:09:37 -04:00
|
|
|
} else {
|
2013-06-10 16:48:50 -04:00
|
|
|
c.problemsCheckInterval = 10;
|
2013-04-16 12:09:37 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
problemsTimestamp: function() {
|
2013-06-11 01:19:19 -04:00
|
|
|
return moment(this.get('problemsFetchedAt')).format('LLL');
|
2013-08-02 18:31:25 -04:00
|
|
|
}.property('problemsFetchedAt'),
|
|
|
|
|
|
|
|
updatedTimestamp: function() {
|
|
|
|
return moment(this.get('updated_at')).format('LLL');
|
2013-09-16 14:08:55 -04:00
|
|
|
}.property('updated_at'),
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
refreshProblems: function() {
|
|
|
|
this.loadProblems();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-22 15:41:12 -05:00
|
|
|
});
|