discourse/app/assets/javascripts/admin/controllers/admin_dashboard_controller.js

47 lines
1.3 KiB
JavaScript
Raw Normal View History

/**
This controller supports the default interface when you enter the admin section.
@class AdminDashboardController
@extends Ember.Controller
@namespace Discourse
@module Discourse
**/
Discourse.AdminDashboardController = Ember.Controller.extend({
loading: true,
versionCheck: null,
problemsCheckMinutes: 1,
foundProblems: function() {
return(Discourse.User.current('admin') && this.get('problems') && this.get('problems').length > 0);
}.property('problems'),
thereWereProblems: function() {
if(!Discourse.User.current('admin')) { return false }
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 ) {
c.problemsCheckInterval = 1;
} else {
c.problemsCheckInterval = 10;
}
});
},
problemsTimestamp: function() {
2013-06-11 01:19:19 -04:00
return moment(this.get('problemsFetchedAt')).format('LLL');
}.property('problemsFetchedAt')
});