discourse/app/assets/javascripts/admin/controllers/admin-dashboard.js.es6

59 lines
1.6 KiB
Plaintext
Raw Normal View History

2015-08-08 03:08:27 +08:00
import { setting } from 'discourse/lib/computed';
2016-04-01 05:33:25 +08:00
import AdminDashboard from 'admin/models/admin-dashboard';
2015-08-08 03:08:27 +08:00
// This controller supports the default interface when you enter the admin section.
export default Ember.Controller.extend({
loading: true,
versionCheck: null,
problemsCheckMinutes: 1,
2015-08-08 03:08:27 +08:00
showVersionChecks: setting('version_checks'),
foundProblems: function() {
return(Discourse.User.currentProp('admin') && this.get('problems') && this.get('problems').length > 0);
}.property('problems'),
thereWereProblems: function() {
2015-09-16 05:08:50 +08:00
if(!Discourse.User.currentProp('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;
2016-04-01 05:33:25 +08:00
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 13:19:19 +08:00
return moment(this.get('problemsFetchedAt')).format('LLL');
}.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();
},
showTrafficReport: function() {
this.set("showTrafficReport", true);
2013-09-17 02:08:55 +08:00
}
}
});