diff --git a/app/assets/javascripts/admin/controllers/admin_dashboard_controller.js b/app/assets/javascripts/admin/controllers/admin_dashboard_controller.js
index 8ec0442a3ba..a62912807e0 100644
--- a/app/assets/javascripts/admin/controllers/admin_dashboard_controller.js
+++ b/app/assets/javascripts/admin/controllers/admin_dashboard_controller.js
@@ -8,5 +8,9 @@
**/
Discourse.AdminDashboardController = Ember.Controller.extend({
loading: true,
- versionCheck: null
+ versionCheck: null,
+
+ foundProblems: function() {
+ return(this.get('problems') && this.get('problems').length > 0);
+ }.property('problems')
});
diff --git a/app/assets/javascripts/admin/routes/admin_dashboard_route.js b/app/assets/javascripts/admin/routes/admin_dashboard_route.js
index 769d19870ae..8f3176acb28 100644
--- a/app/assets/javascripts/admin/routes/admin_dashboard_route.js
+++ b/app/assets/javascripts/admin/routes/admin_dashboard_route.js
@@ -27,6 +27,7 @@ Discourse.AdminDashboardRoute = Discourse.Route.extend({
c.set(report.type, Discourse.Report.create(report));
});
c.set('totalUsers', d.total_users);
+ c.set('problems', d.problems);
c.set('loading', false);
});
}
diff --git a/app/assets/javascripts/admin/templates/dashboard.js.handlebars b/app/assets/javascripts/admin/templates/dashboard.js.handlebars
index 63e02055b32..04858ad3d26 100644
--- a/app/assets/javascripts/admin/templates/dashboard.js.handlebars
+++ b/app/assets/javascripts/admin/templates/dashboard.js.handlebars
@@ -1,4 +1,21 @@
+ {{#if foundProblems}}
+
+
+
+
+ {{i18n admin.dashboard.problems_found}}
+
+ {{#each problem in problems}}
+ - {{problem}}
+ {{/each}}
+
+
+
+
+
+ {{/if}}
+
{{#if Discourse.SiteSettings.version_checks}}
diff --git a/app/assets/stylesheets/admin/admin_base.scss b/app/assets/stylesheets/admin/admin_base.scss
index 981cef860b5..636600def27 100644
--- a/app/assets/stylesheets/admin/admin_base.scss
+++ b/app/assets/stylesheets/admin/admin_base.scss
@@ -367,6 +367,31 @@ table {
}
}
+ &.detected-problems {
+ @include border-radius-all(5px);
+ background-color: #eee;
+ border: 1px solid #ccc;
+ margin-bottom: 20px;
+ margin-top: 10px;
+ box-shadow: inset 0 0 10px #bbb;
+
+ .look-here {
+ float: left;
+ margin: 20px 20px 0 20px;
+
+ .icon {
+ font-size: 32px;
+ vertical-align: middle;
+ color: $darkish_gray;
+ }
+ }
+
+ .problem-messages {
+ float: left;
+ width: 355px;
+ }
+ }
+
&.totals {
width: 160px;
diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb
index ce9b2691345..032d7255235 100644
--- a/app/controllers/admin/dashboard_controller.rb
+++ b/app/controllers/admin/dashboard_controller.rb
@@ -2,12 +2,7 @@
class Admin::DashboardController < Admin::AdminController
def index
- render_json_dump({
- reports: ['visits', 'signups', 'topics', 'posts', 'flags', 'users_by_trust_level', 'likes', 'emails'].map { |type| Report.find(type) },
- total_users: User.count
- }.merge(
- SiteSetting.version_checks? ? {version_check: DiscourseUpdates.check_version} : {}
- ))
+ render_json_dump(AdminDashboardData.fetch)
end
end
\ No newline at end of file
diff --git a/app/models/admin_dashboard_data.rb b/app/models/admin_dashboard_data.rb
new file mode 100644
index 00000000000..f08aed0fdd7
--- /dev/null
+++ b/app/models/admin_dashboard_data.rb
@@ -0,0 +1,22 @@
+class AdminDashboardData
+
+ REPORTS = ['visits', 'signups', 'topics', 'posts', 'flags', 'users_by_trust_level', 'likes', 'emails']
+
+ def self.fetch
+ AdminDashboardData.new
+ end
+
+ def as_json
+ @json ||= {
+ reports: REPORTS.map { |type| Report.find(type) },
+ total_users: User.count,
+ problems: [rails_env_check].compact
+ }.merge(
+ SiteSetting.version_checks? ? {version_check: DiscourseUpdates.check_version} : {}
+ )
+ end
+
+ def rails_env_check
+ I18n.t("dashboard.rails_env_warning", env: Rails.env) unless Rails.env == 'production'
+ end
+end
\ No newline at end of file
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 5a6fa50c724..aef417a34b0 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -698,6 +698,7 @@ en:
update_often: 'Please update often!'
total_users: "Total Users"
moderator_short: "mod"
+ problems_found: "Some problems have been found with your installation of Discourse:"
reports:
today: "Today"
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 07b3de15716..0c76bc7a70e 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -283,6 +283,9 @@ en:
xaxis: "Day"
yaxis: "Number of Emails"
+ dashboard:
+ rails_env_warning: "Your server is running in %{env} mode."
+
site_settings:
default_locale: "The default language of this Discourse instance (ISO 639-1 Code)"
min_post_length: "Minimum post length in characters"
diff --git a/spec/models/admin_dashboard_data_spec.rb b/spec/models/admin_dashboard_data_spec.rb
new file mode 100644
index 00000000000..eb368a6df48
--- /dev/null
+++ b/spec/models/admin_dashboard_data_spec.rb
@@ -0,0 +1,24 @@
+require 'spec_helper'
+
+describe AdminDashboardData do
+
+ describe "rails_env_check" do
+ subject { AdminDashboardData.new.rails_env_check }
+
+ it 'returns nil when running in production mode' do
+ Rails.stubs(:env).returns('production')
+ subject.should be_nil
+ end
+
+ it 'returns a string when running in development mode' do
+ Rails.stubs(:env).returns('development')
+ subject.should_not be_nil
+ end
+
+ it 'returns a string when running in test mode' do
+ Rails.stubs(:env).returns('test')
+ subject.should_not be_nil
+ end
+ end
+
+end
\ No newline at end of file