Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging admin dashboard with login #102

Open
wants to merge 71 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
593dd01
Update README.md
Vinayaka2k Sep 28, 2024
861df1c
added documenation file for sprint1
Vinayaka2k Sep 28, 2024
813fa97
Update README.md
Vinayaka2k Oct 3, 2024
ec985ba
Added a page with path /admin for admin dashboard
Oct 4, 2024
21fe25a
update readme with code testing
LeoHsuProgrammingLab Oct 4, 2024
ddbb52d
Rendering survey responses in admin dashboard page
Oct 5, 2024
b470d2b
Merge pull request #1 from tamu-edu-students/feature/admin-dashboard
Vinayaka2k Oct 5, 2024
dad9e60
Update README.md
Vinayaka2k Oct 5, 2024
8f974aa
Update README.md
Vinayaka2k Oct 5, 2024
f7bd1c0
Update README.md
Vinayaka2k Oct 5, 2024
3cf5b94
solve the delete response error with survey_answer and invitations wh…
LeoHsuProgrammingLab Oct 5, 2024
aa82b26
update readme
LeoHsuProgrammingLab Oct 5, 2024
05ce1d0
Update README.md
Vinayaka2k Oct 5, 2024
255158a
Update README.md
Vinayaka2k Oct 5, 2024
19b9986
Update README.md
Vinayaka2k Oct 5, 2024
b31672d
update .gitignore
LeoHsuProgrammingLab Oct 9, 2024
0911fd4
Merge branch 'main' into dev/Leo
LeoHsuProgrammingLab Oct 10, 2024
abab049
Merge pull request #2 from tamu-edu-students/dev/Leo
LeoHsuProgrammingLab Oct 10, 2024
d18675c
Added Sprint-2 Plan
GurramManojReddy Oct 12, 2024
7f247cc
Sprint1 retrospective
Vinayaka2k Oct 12, 2024
7a088da
Sprint1 retrospective
Vinayaka2k Oct 12, 2024
70d149b
Merge branch 'dev/Leo' of https://github.com/tamu-edu-students/csce60…
LeoHsuProgrammingLab Oct 14, 2024
8eb8cdb
update README
LeoHsuProgrammingLab Oct 18, 2024
06d992c
Changed the YAML file
manojpeta-gh Oct 18, 2024
6aba51d
Merge branch 'main' of github.com:tamu-edu-students/csce606-ELRC-OLEI…
manojpeta-gh Oct 18, 2024
c6f1d57
add icon, color reminder and the specification of the tetrahydron. Th…
LeoHsuProgrammingLab Oct 19, 2024
929c909
make the spec better
LeoHsuProgrammingLab Oct 19, 2024
54c6350
Update heroku link in README
GurramManojReddy Oct 19, 2024
4ffea65
test for login error
LeoHsuProgrammingLab Oct 19, 2024
925b268
Merge branch 'main' into dev/Leo
LeoHsuProgrammingLab Oct 19, 2024
407d495
Merge pull request #3 from tamu-edu-students/dev/Leo
LeoHsuProgrammingLab Oct 19, 2024
f0779fb
test commit to push to branch.
kunal-singh-tamu Oct 19, 2024
494bdaf
check
kunal-singh-tamu Oct 19, 2024
81392c8
Added Admin Dashboard button to provide survey response access to adm…
kunal-singh-tamu Oct 19, 2024
9db79d5
update .gitignore
LeoHsuProgrammingLab Oct 20, 2024
361752d
pull from remote branch
LeoHsuProgrammingLab Oct 20, 2024
ee47412
Cucumber scenarios to test Admin Dashboard access after login and red…
kunal-singh-tamu Oct 25, 2024
ef3e6b7
step definition and rspec tests cases for admin dashboard access feat…
kunal-singh-tamu Oct 25, 2024
3e4a736
Sprint 3 Plan
manojpeta-gh Oct 26, 2024
fc48ddf
rubocop offenses corrected
SaiNithin001 Oct 26, 2024
c7eae8d
Added Retrospective for sprint 2
saiaakarsh-tamu Oct 26, 2024
ded3252
Updating sprint 2 restrospective
saiaakarsh-tamu Oct 26, 2024
2a6a5d8
Merge pull request #4 from tamu-edu-students/admin-management-display…
kunal-singh-tamu Oct 26, 2024
6a8e1ba
Changed the header as per client's requirements
SaiNithin001 Oct 29, 2024
be25ed6
Changed the header as per client's requirements
SaiNithin001 Oct 29, 2024
bfbc2a1
Admin Integration -1
GurramManojReddy Oct 30, 2024
4f8ffd1
Revert "Admin management display page"
LeoHsuProgrammingLab Oct 31, 2024
7a95457
Merge pull request #5 from tamu-edu-students/revert-4-admin-managemen…
LeoHsuProgrammingLab Oct 31, 2024
22819ef
Revert "Revert "Admin management display page""
LeoHsuProgrammingLab Oct 31, 2024
45aef29
Dynamic Admin Dashboard
GurramManojReddy Oct 31, 2024
524a2df
Merge pull request #7 from tamu-edu-students/revert-5-revert-4-admin-…
LeoHsuProgrammingLab Oct 31, 2024
1fb6554
test CI Github Action
LeoHsuProgrammingLab Oct 31, 2024
b154295
Github Action test
LeoHsuProgrammingLab Oct 31, 2024
0b0f38e
Merge branch 'main' into dev/Leo
LeoHsuProgrammingLab Oct 31, 2024
9210eb9
Update main.yml
LeoHsuProgrammingLab Nov 1, 2024
f9354a0
add new github action
LeoHsuProgrammingLab Nov 1, 2024
1633154
update upload-artifact@v3
LeoHsuProgrammingLab Nov 1, 2024
94a1535
update readme about the Github Action & Heroku Github Integration
LeoHsuProgrammingLab Nov 1, 2024
b96ff92
Cumcumber features for admin dashboard are corrected
GurramManojReddy Nov 1, 2024
fca48d0
Merge branch 'manoj850'
GurramManojReddy Nov 1, 2024
dc0f6e9
pull from dev/Leo
LeoHsuProgrammingLab Nov 1, 2024
7146daf
Merge branch 'dev/Leo' of https://github.com/tamu-edu-students/csce60…
LeoHsuProgrammingLab Nov 1, 2024
45bb119
set my branch with correct encrypted data
LeoHsuProgrammingLab Nov 1, 2024
9d21409
modify from teacher to supervisee, and superintendent to supervisor
LeoHsuProgrammingLab Nov 1, 2024
6cb56a7
Modified admin_dashboard rspec to restrict user access to admin dashb…
kunal-singh-tamu Nov 2, 2024
2ab12ed
Merge pull request #10 from tamu-edu-students/dev/Leo
LeoHsuProgrammingLab Nov 2, 2024
2f9b572
Merge pull request #11 from tamu-edu-students/admin-dashboard-login-i…
LeoHsuProgrammingLab Nov 2, 2024
b30be91
scaling for the distortion of tetrahedron
LeoHsuProgrammingLab Nov 2, 2024
550fb1b
Merge pull request #12 from tamu-edu-students/dev/Leo
LeoHsuProgrammingLab Nov 2, 2024
8953a57
Added Survey page display feature
GurramManojReddy Nov 3, 2024
b98aacf
Corrected cucumber scenarios
GurramManojReddy Nov 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ jobs:
COVERAGE=true bundle exec rspec
COVERAGE=true bundle exec cucumber

# - name: Upload coverage report
# if: '!cancelled()'
# uses: actions/upload-artifact@v2
# with:
# name: coverage
# path: coverage
- name: Upload coverage report
if: '!cancelled()'
uses: actions/upload-artifact@v3
with:
name: coverage
path: coverage

- name: Rubocop Report
if: '!cancelled()'
Expand All @@ -66,7 +66,7 @@ jobs:
uses: schneegans/dynamic-badges-action@v1.7.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: c7b2d5e19079e12445b300407e383294
gistID: ${{ secrets.GIST_ID }}
filename: badge.json
label: 'Rubocop'
message: '${{ env.rubocop_offenses }} offenses'
Expand Down
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,11 @@

# Ignore master key for decrypting credentials and more.
/config/master.key

# vscode
.vscode

# Ignore for mac
*.DS_Store
*/.DS_Store
*/*/.DS_Store
57 changes: 39 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
# Synergistic Leadership Theory Survey Application
**Link to the Team Working Agreement:**
https://drive.google.com/file/d/16uUZbFhEMnh5MCQcVUXWtCvOM4edJY95/view?usp=sharing

---

# Deployed app link:

https://elrc-6ad76821be30.herokuapp.com/

---

# Readme:

<!--[![Test Coverage](https://api.codeclimate.com/v1/badges/62f4dd4fb092b4211973/test_coverage)](https://codeclimate.com/repos/65caed0abc0d27237b1794c9/test_coverage)
[![Maintainability](https://api.codeclimate.com/v1/badges/62f4dd4fb092b4211973/maintainability)](https://codeclimate.com/repos/65caed0abc0d27237b1794c9/maintainability) -->

[![Test Coverage](https://api.codeclimate.com/v1/badges/62f4dd4fb092b4211973/test_coverage)](https://codeclimate.com/repos/65caed0abc0d27237b1794c9/test_coverage)
[![Maintainability](https://api.codeclimate.com/v1/badges/62f4dd4fb092b4211973/maintainability)](https://codeclimate.com/repos/65caed0abc0d27237b1794c9/maintainability)
![rubocop](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/barnden/c7b2d5e19079e12445b300407e383294/raw/badge.json)

- [Deployed Application](https://elrc-app-dfcfc7cd862b.herokuapp.com/)
- [Code Climate Reports](https://codeclimate.com/repos/65caed0abc0d27237b1794c9/maintainability)
- [GitHub Repo](https://github.com/tamu-edu-students/csce606-ELRC-Synergistic-Leadership-Theory)
- [Pivotal Tracker](https://www.pivotaltracker.com/n/projects/2690137)
- [Slack](https://app.slack.com/client/T06GRHECJEM/C06GY2R74KX)
- [Code Climate Reports](https://codeclimate.com/github/tamu-edu-students/csce606-ELRC-OLEI_Project)
- [GitHub Repo](https://github.com/tamu-edu-students/csce606-ELRC-OLEI_Project)
- [Pivotal Tracker](https://www.pivotaltracker.com/n/projects/2720653)
- [Slack](https://app.slack.com/client/T07NQ098G0G/C07NE1HS2BB)

<details open="open">
<summary>Table of Contents</summary>
Expand Down Expand Up @@ -36,13 +48,13 @@
Clone repository

```
git clone git@github.com:tamu-edu-students/csce606-ELRC-Synergistic-Leadership-Theory.git
git clone git@github.com:tamu-edu-students/csce606-ELRC-OLEI_Project.git
```

Install all dependencies

```
cd csce606-ELRC-Synergistic-Leadership-Theory/rails_root
cd csce606-ELRC-OLEI_Project/rails_root
bundle install
```

Expand All @@ -57,6 +69,10 @@ cd rails_root
echo "<master key here>" > ./config/master.key
```

Running database locally

`bundle config set --local without 'production' ` (Using SQLite only otherwise ``brew install pg``)

Generate database

```
Expand Down Expand Up @@ -127,15 +143,20 @@ heroku run rails db:migrate
heroku run rails db:seed
```

## Contacts
Andres Santiago <Andylsantiago20@tamu.edu>
[Github Integration with Heroku](https://devcenter.heroku.com/articles/github-integration)

Jacob Mathes <thejacobm1@tamu.edu>
Set up Github Action (Different from Github Integration with Heroku)
1. Set up ```secrets.RAILS_MASTER_KEY``` in your project Github Repository
2. Set up ```secrets.GIST_SECRET``` in your project Github Repository by valid token with gist scope
3. Set up ```secrets.GIST_ID``` (Create your own gist, and set up the gist ID in your project Github Repository)

Minseo Park <minseo.park@tamu.edu>

Brandon Nguyen <bgn@tamu.edu>

Yi-Ting Lee <lucalee207@tamu.edu>
## Contacts

Chengyuan Qian <cyqian@tamu.edu>
* Chih-Chuan Hsu <agenuinedream@tamu.edu>
* Kunal Somendrasingh
* Manoj Gurram
* Manoj Peta
* Sai Aakarsh Padma
* Sai Nithin
* Vinayaka Hegde
* [Legacy Code](https://github.com/tamu-edu-students/csce606-ELRC-Synergistic-Leadership-Theory)
Binary file added documentation/Fall2024/Sprint 1 plan.pdf
Binary file not shown.
Binary file not shown.
Binary file added documentation/Fall2024/Sprint 2 plan.pdf
Binary file not shown.
Binary file not shown.
Binary file added documentation/Fall2024/Sprint 3 Plan.pdf
Binary file not shown.
5 changes: 5 additions & 0 deletions rails_root/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,8 @@ coverage/*
sorbet

.vscode

# Ignore for mac
*.DS_Store
*/.DS_Store
*/*/.DS_Store
2 changes: 2 additions & 0 deletions rails_root/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ gem 'sprockets-rails'
# Use the Puma web server [https://github.com/puma/puma]
gem 'puma', '>= 5.0'

gem 'kaminari'

# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
gem 'importmap-rails'

Expand Down
13 changes: 13 additions & 0 deletions rails_root/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,18 @@ GEM
json (2.7.1)
jwt (2.8.1)
base64
kaminari (1.2.2)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.2.2)
kaminari-activerecord (= 1.2.2)
kaminari-core (= 1.2.2)
kaminari-actionview (1.2.2)
actionview
kaminari-core (= 1.2.2)
kaminari-activerecord (1.2.2)
activerecord
kaminari-core (= 1.2.2)
kaminari-core (1.2.2)
language_server-protocol (3.17.0.3)
launchy (3.0.0)
addressable (~> 2.8)
Expand Down Expand Up @@ -519,6 +531,7 @@ DEPENDENCIES
factory_bot_rails
importmap-rails
jbuilder
kaminari
omniauth-auth0 (~> 3.0)
omniauth-rails_csrf_protection (~> 1.0)
pg
Expand Down
16 changes: 1 addition & 15 deletions rails_root/README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
# README

This README would normally document whatever steps are necessary to get the
application up and running.

Things you may want to cover:

* Ruby version

* Ruby version: 3.3.0
* System dependencies

* Configuration

* Database creation

* Database initialization

* How to run the test suite

* Services (job queues, cache servers, search engines, etc.)

* Deployment instructions

* ...
80 changes: 80 additions & 0 deletions rails_root/app/assets/stylesheets/show.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
.section-header {
cursor: pointer;
user-select: none;
}

.section-header h4:before {
content: '\25B6';
font-size: .85em;
min-width: 1.5rem;
}

.section-header[aria-expanded="true"] h4:before {
content: '\25BC';
font-size: .85em;
min-width: 1.5rem;
}

tr {
transition: height 0.0s ease;
}

tr.collapsing {
height: auto;
transition: height 0.0s ease;
}

.table-slight-red {
background-color: #ffffff; /* Light red */
color: black;
}

.table-mild-red {
background-color: #ff9999; /* Mild red */
color: black;
}

.table-medium-red {
background-color: #ff6666; /* Medium red */
color: white;
}

.table-strong-red {
background-color: #ff3333; /* Strong red */
color: white;
}

/* Center text in table headers and cells */
/* table th, table td {
text-align: center;
vertical-align: middle;
} */

/* Align the first column to the left */
table td:first-child {
text-align: left;
}

/* Optional: Adjust the padding for better spacing */
.table th, .table td {
padding: 10px;
}

/* Icon styles */
.icon {
font-size: 1.5em;
}

/* Optional styling for the invitation link */
#invitation-link-container {
margin-top: 20px;
}

#invitation-link {
font-weight: bold;
color: #007bff; /* Bootstrap primary color */
}

#invitation-link:hover {
text-decoration: underline;
}
8 changes: 8 additions & 0 deletions rails_root/app/controllers/admins_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

# admins_controller.rb
class AdminsController < ApplicationController
def index
@survey_responses = SurveyResponse.get_all_responses(page: params[:page], per_page: 20)
end
end
25 changes: 25 additions & 0 deletions rails_root/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,35 @@
# ApplicationController
class ApplicationController < ActionController::Base
before_action :log_flash
helper_method :current_user, :user_is_admin?

private

def log_flash
Rails.logger.info "Flash: #{flash.to_hash}"
end

def current_user
return nil unless session[:userinfo]
@current_user ||= OpenStruct.new(session[:userinfo])
end

def user_is_admin?
return false unless session[:userinfo]

# Get roles from the same path used in your Auth0Controller
user_roles = session[:userinfo]['https://myapp.com/123456789012/roles/roles']
user_roles&.include?('Admin')
end

def authenticate_user!
redirect_to '/auth/auth0' unless current_user
end

def require_admin!
unless user_is_admin?
flash[:error] = "You must be an administrator to access this section"
redirect_to root_path
end
end
end
23 changes: 6 additions & 17 deletions rails_root/app/controllers/auth0_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,21 @@
# ./app/controllers/auth0_controller.rb
class Auth0Controller < ApplicationController
def callback
# OmniAuth stores the information returned from Auth0 and the IdP in request.env['omniauth.auth'].
# In this code, you will pull the raw_info supplied from the id_token and assign it to the session.
# Refer to https://github.com/auth0/omniauth-auth0/blob/master/EXAMPLES.md#example-of-the-resulting-authentication-hash for complete information on 'omniauth.auth' contents.

auth_info = request.env['omniauth.auth']
# puts JSON.pretty_generate(auth_info)
user_roles = auth_info['extra']['raw_info']['https://myapp.com/123456789012/roles/roles']
session[:userinfo] = auth_info['extra']['raw_info']

# print session info in pretty JSON format
# puts JSON.pretty_generate(session[:userinfo])

# create new survey profile if the user is 'new'
# if no survey profile contains unique user_id, create a new survey profile
# puts 'trying to find survey profile'
# puts SurveyProfile.find_by(user_id: session[:userinfo]['sub'])

if SurveyProfile.find_by(user_id: session[:userinfo]['sub']).nil?

# Check if the user has an Admin role
if user_roles && user_roles.include?('Admin')
redirect_to admin_dashboard_path
elsif SurveyProfile.find_by(user_id: session[:userinfo]['sub']).nil?
redirect_to new_survey_profile_path
elsif session[:invitation] && claim_invitation
# Nothing to do here, claim_invitation already did the redirect
else
# Redirect to the URL you want after successful auth
redirect_to root_url
end
end

def failure
# Handles failed authentication -- Show a failure page (you can also handle with a redirect)
@error_msg = request.params['message']
Expand Down
4 changes: 2 additions & 2 deletions rails_root/app/controllers/survey_responses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def set_survey_sections
]
end

if @survey_profile.role == 'Teacher'
if @survey_profile.role == 'Supervisee'

@sections = [
{
Expand Down Expand Up @@ -229,7 +229,7 @@ def set_survey_sections
}
]
end
return unless @survey_profile.role == 'Superintendent'
return unless @survey_profile.role == 'Supervisor'

@sections = [
{
Expand Down
5 changes: 5 additions & 0 deletions rails_root/app/helpers/admins_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

# helper method for the admin controller
module AdminsHelper
end
Loading
Loading