Skip to content

Commit

Permalink
Added Admin Dashboard button to provide survey response access to adm…
Browse files Browse the repository at this point in the history
…ins through home page.
  • Loading branch information
kunal-singh-tamu committed Oct 19, 2024
1 parent 494bdaf commit 81392c8
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,3 @@ heroku run rails db:seed
* [Legacy Code](https://github.com/tamu-edu-students/csce606-ELRC-Synergistic-Leadership-Theory)


# demo check commit
# second demo push
1 change: 1 addition & 0 deletions rails_root/app/controllers/survey_responses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def index
def show
return return_to_root 'You are not logged in.' if current_user_id.nil?
return return_to_root 'You cannot view this result.' if current_user_id != @survey_response.profile.user_id


flash.keep(:warning)
end
Expand Down
28 changes: 16 additions & 12 deletions rails_root/app/views/admins/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,26 @@
<div class="table-responsive">
<table class = "table">
<thead>
<tr>
<th>ID</th>
<th>Profile</th>
<th>Share Code</th>
<th>Created At</th>
</tr>
<tr>
<th>ID</th>
<th>Profile</th>
<th>Share Code</th>
<th>Created At</th>
<th>View Survey</th>
</tr>
</thead>
<% if @survey_responses.present? %>
<tbody>
<% @survey_responses.each do |response| %>
<tr>
<td><%= response.id %></td>
<td><%= response.profile.user_id %></td>
<td><%= response.share_code %></td>
<td><%= response.created_at.strftime('%Y-%m-%d %H:%M:%S') %></td>
</tr>
<tr>
<td><%= response.id %></td>
<td><%= response.profile.user_id %></td>
<td><%= response.share_code %></td>
<td><%= response.created_at.strftime('%Y-%m-%d %H:%M:%S') %></td>
<td>
<%= link_to 'View Survey', survey_response_path(response) %>
</td>
</tr>
<% end %>
</tbody>
<% end %>
Expand Down
4 changes: 4 additions & 0 deletions rails_root/app/views/layouts/_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
<li class="nav-item">
<%= link_to "About", about_path, class: "nav-link #{'active' if current_page?(about_path)}" %>
</li>
<li class="nav-item">
<%= link_to "Admin Dashboard", admin_dashboard_path, class: "nav-link" %> <!-- Admin Dashboard Link -->
</li>

<li class="nav-item">
<%# <%= link_to "Survey Responses", survey_responses_path, class: "nav-link #{'active' if current_page?(survey_responses_path)}" %>
</li>
Expand Down
4 changes: 3 additions & 1 deletion rails_root/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

get 'home/index'
get 'about', to: 'about#index'
get '/admin', to: 'admins#index'
get '/admin', to: 'admins#index', as: 'admin_dashboard'
#get 'survey_responses/:id', to: 'survey_responses#show', as: 'survey_response'


# get 'survey', to: 'survey_responses#new', as: 'survey'
# get 'survey/page/:page', to: 'survey_responses#survey', as: 'survey_page'
Expand Down

0 comments on commit 81392c8

Please sign in to comment.