2015-08-08 03:08:27 +08:00
|
|
|
import { setting } from 'discourse/lib/computed';
|
2013-02-21 02:15:50 +08:00
|
|
|
|
2015-08-08 03:08:27 +08:00
|
|
|
// This controller supports the default interface when you enter the admin section.
|
2014-07-23 11:20:45 +08:00
|
|
|
export default Ember.Controller.extend({
|
2013-02-23 04:41:12 +08:00
|
|
|
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
|
|
|
|
2015-08-08 03:08:27 +08:00
|
|
|
showVersionChecks: setting('version_checks'),
|
2014-09-12 04:30:47 +08:00
|
|
|
|
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() {
|
2015-09-16 05:08:50 +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;
|
2015-11-20 23:00:12 +08:00
|
|
|
Discourse.AdminDashboard.fetchProblems().then(function(d) {
|
2013-04-17 00:09:37 +08:00
|
|
|
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');
|
2013-09-17 02:08:55 +08:00
|
|
|
}.property('updated_at'),
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
refreshProblems: function() {
|
|
|
|
this.loadProblems();
|
2015-02-06 11:39:04 +08:00
|
|
|
},
|
|
|
|
showTrafficReport: function() {
|
|
|
|
this.set("showTrafficReport", true);
|
2013-09-17 02:08:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-23 04:41:12 +08:00
|
|
|
});
|