Add a refresh button to problems on dashboard, so you can check for problems again

This commit is contained in:
Neil Lalonde 2013-04-16 12:09:37 -04:00
parent 9a5706241b
commit 2b5a2b5fce
5 changed files with 57 additions and 16 deletions

View File

@ -9,8 +9,37 @@
Discourse.AdminDashboardController = Ember.Controller.extend({
loading: true,
versionCheck: null,
problemsCheckInterval: '1 minute ago',
foundProblems: function() {
return(this.get('problems') && this.get('problems').length > 0);
}.property('problems')
}.property('problems'),
thereWereProblems: function() {
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 minute ago';
} else {
c.problemsCheckInterval = '10 minutes ago';
}
});
},
problemsTimestamp: function() {
return this.get('problemsFetchedAt').long();
}.property('problemsFetchedAt')
});

View File

@ -8,8 +8,6 @@
**/
Discourse.AdminDashboardRoute = Discourse.Route.extend({
problemsCheckInterval: '1 minute ago',
setupController: function(c) {
this.fetchDashboardData(c);
this.fetchGithubCommits(c);
@ -35,18 +33,9 @@ Discourse.AdminDashboardRoute = Discourse.Route.extend({
c.set('problems', d.problems);
c.set('loading', false);
});
} else if( !c.get('problemsFetchedAt') || Date.create(this.problemsCheckInterval, 'en') > c.get('problemsFetchedAt') ) {
} else if( !c.get('problemsFetchedAt') || Date.create(c.problemsCheckInterval, 'en') > c.get('problemsFetchedAt') ) {
c.set('problemsFetchedAt', new Date());
var _this = this;
Discourse.AdminDashboard.fetchProblems().then(function(d) {
c.set('problems', d.problems);
c.set('loading', false);
if( d.problems && d.problems.length > 0 ) {
_this.problemsCheckInterval = '1 minute ago';
} else {
_this.problemsCheckInterval = '10 minutes ago';
}
});
c.loadProblems();
}
},

View File

@ -3,17 +3,34 @@
<div class="dashboard-stats detected-problems">
<div class="look-here"><i class="icon icon-warning-sign"></i></div>
<div class="problem-messages">
<p>
<p {{bindAttr class="loadingProblems:invisible"}}>
{{i18n admin.dashboard.problems_found}}
<ul>
<ul {{bindAttr class="loadingProblems:invisible"}}>
{{#each problem in problems}}
<li>{{{problem}}}</li>
{{/each}}
</ul>
</p>
<p class="actions">
<small>{{i18n admin.dashboard.last_checked}}: {{problemsTimestamp}}</small>
<button {{action loadProblems}} class="btn btn-small"><i class="icon icon-refresh"></i>{{i18n admin.dashboard.refresh_problems}}</button>
</p>
</div>
<div class="clearfix"></div>
</div>
{{else}}
{{#if thereWereProblems}}
<div class="dashboard-stats detected-problems">
<div class="look-here">&nbsp;</div>
<div class="problem-messages">
<p>
{{i18n admin.dashboard.no_problems}}
<button {{action loadProblems}} class="btn btn-small"><i class="icon icon-refresh"></i>{{i18n admin.dashboard.refresh_problems}}</button>
</p>
</div>
<div class="clearfix"></div>
</div>
{{/if}}
{{/if}}
{{#if Discourse.SiteSettings.version_checks}}

View File

@ -407,6 +407,9 @@ table {
a {
text-decoration: underline;
}
.actions {
text-align: right;
}
}
}

View File

@ -818,6 +818,9 @@ en:
latest_version: "Latest"
update_often: 'Please update often!'
problems_found: "Some problems have been found with your installation of Discourse:"
last_checked: "Last checked"
refresh_problems: "Refresh"
no_problems: "No problems were found."
moderators: 'Moderators:'
admins: 'Admins:'