This repository has been archived by the owner on Apr 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Admin::DashboardsController < AdminController | ||
def show | ||
@feedback_comments = Feedback.where.not(comment: "").order(created_at: :desc) | ||
@feedback_answers = Feedback.all.map(&:answers).inject do |mem, hash| | ||
mem.merge(hash) do |_, old_value, new_value| | ||
old_value.to_i + new_value.to_i | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class AdminController < ApplicationController | ||
before_action :require_login, :require_admin | ||
|
||
ADMINS = %w([email protected] [email protected]) | ||
|
||
private | ||
|
||
def require_admin | ||
raise ApplicationController::NotAuthorized unless ADMINS.any? { |email| current_user.email == email } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ class FeedbackMailer < ApplicationMailer | |
def notify(feedback) | ||
@feedback = feedback | ||
|
||
mail to: "[email protected]", | ||
mail to: "[email protected] [email protected]", | ||
subject: %(New feedback on Jottings) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<div class="container margin-top"> | ||
<div class="grid grid-pair"> | ||
<div class="grid-item 4/5"> | ||
<% @feedback_comments&.each do |feedback| %> | ||
<div class="margin-bottom"> | ||
<div> | ||
<span class="text-lead"><%= feedback %></span> | ||
<span class="text-muted text-small"><%= time_ago_in_words(feedback.created_at) %> ago</span> | ||
</div> | ||
|
||
<%= feedback.comment %> | ||
</div> | ||
<% end %> | ||
</div> | ||
|
||
<div class="grid-item 1/5"> | ||
<ul class="list-inline margin-bottom"> | ||
<li> | ||
<div class="text-muted text-small">Users</div> | ||
<div class="text-lead"><%= User.count %></div> | ||
</li> | ||
|
||
<li class="margin-left"> | ||
<div class="text-muted text-small">Documents</div> | ||
<div class="text-lead"><%= Document.count %></div> | ||
</li> | ||
</ul> | ||
|
||
<ul class="list-reset"> | ||
<% @feedback_answers&.each do |answer, count| %> | ||
<li> | ||
<span class="text-muted text-small"><%= answer.titleize %> - </span> | ||
<%= count %> | ||
</li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters