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

feat(AUTH-CPC-755): Add More Roles Front End #573

Merged
merged 7 commits into from
Oct 23, 2023

Conversation

SamuelNguyen2121
Copy link
Collaborator

@SamuelNguyen2121 SamuelNguyen2121 commented Oct 22, 2023

JIRA: link to jira ticket
https://champlainsaintlambert.atlassian.net/browse/CPC-755

Context:

What is the ticket about and why are we doing this change.
This ticket is about adding three roles, and one of them to be assigned to users because we want them to have a restricted access in the system. It is also about the feature for the admin to update the users' role if ever a user needs a different permission on the website.

Changes

What are the various changes and what other modules do those changes effect.
This can be bullet point or sentence format.

  • A new column in the admin panel called "Role" to see the users' current role assigned
  • A new button in the admin panel called "Update Role" to navigate to the update user role form
  • A new form for updating a user's role with list of availble roles to change

Before and After UI (Required for UI-impacting PRs)

If this is a change to the UI, include before and after screenshots to show the differences.
If this is a new UI feature, include screenshots to show reviewers what it looks like.

New "Update Role" Button and New "Role" Column in Admin Panel
imageNew Update User Role Form (After Clicking Update Role Button)
image

Dev notes (Optional)

  • Specific technical changes that should be noted

Linked pull requests (Optional)

  • pull request link

@github-actions
Copy link

github-actions bot commented Oct 22, 2023

Qodana for JVM

373 new problems were found

Inspection name Severity Problems
Unused import 🔶 Warning 107
Redundant character escape 🔶 Warning 85
Dangling Javadoc comment 🔶 Warning 15
Invalid YAML configuration 🔶 Warning 11
Integer multiplication or shift implicitly cast to 'long' 🔶 Warning 10
Optional.get() is called without isPresent() check 🔶 Warning 6
Redundant local variable 🔶 Warning 6
Default annotation parameter value 🔶 Warning 5
Field can be local 🔶 Warning 5
AutoCloseable used without 'try'-with-resources 🔶 Warning 4
Deprecated API usage 🔶 Warning 4
Link specified as plain text 🔶 Warning 4
@NotNull/@Nullable problems 🔶 Warning 4
Spring Data repository method parameters errors 🔶 Warning 4
Unused assignment 🔶 Warning 4
Possibly blocking call in non-blocking context 🔶 Warning 3
Nullability and data flow problems 🔶 Warning 3
Call to 'printStackTrace()' 🔶 Warning 3
'Optional' used as field or parameter type 🔶 Warning 2
Unused publisher 🔶 Warning 2
Redundant type cast 🔶 Warning 2
Redundant 'close()' 🔶 Warning 2
Field may be 'final' 🔶 Warning 1
Lombok @Getter may be used 🔶 Warning 1
Mismatch in @PathVariable declarations and usages 🔶 Warning 1
Begin or end anchor in unexpected position 🔶 Warning 1
'size() == 0' can be replaced with 'isEmpty()' 🔶 Warning 1
Unnecessary call to 'toString()' 🔶 Warning 1
Commented out code ◽️ Notice 35
Duplicated code fragment ◽️ Notice 18
Non recommended 'field' injections ◽️ Notice 18
Constant values ◽️ Notice 2
Mismatch in @PathVariable declarations and usages ◽️ Notice 1
Throw statement in Reactive operator ◽️ Notice 1
Regular expression can be simplified ◽️ Notice 1

☁️ View the detailed Qodana report

Contact Qodana team

Contact us at [email protected]

@PaulJ2001 PaulJ2001 added feat New feature or request AUTH AUTH service labels Oct 23, 2023
@@ -12,7 +12,7 @@ const petClinicApp = angular.module('petClinicApp', [
'ui.router', 'layoutNav', 'layoutFooter', 'layoutWelcome', 'ownerList', 'ownerDetails', 'ownerForm', 'ownerRegister', 'petRegister', 'petForm'
, 'visits', 'vetList','vetForm','vetDetails', 'visitList', 'billForm', 'billUpdateForm', 'loginForm', 'rolesDetails', 'signupForm', 'productDetailsInfo',
'billDetails', 'billsByOwnerId', 'billHistory','billsByVetId','inventoryList', 'inventoryForm', 'productForm','inventoryProductList', 'inventoryUpdateForm', 'productUpdateForm',
'verification' , 'adminPanel','resetPwdForm','forgotPwdForm','petTypeList', 'petDetails','userDetails']);
'verification' , 'adminPanel','resetPwdForm','forgotPwdForm','petTypeList', 'userModule', 'petDetails','userDetails']);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is user module ? This PR is about roles.

<td>
<!-- Using a nested ng-repeat to loop over each role in the user.roles array -->
<span ng-repeat="role in user.roles">
{{ role.name }}<span ng-if="!$last">, </span>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this doing ? Is it reading from the fetched user ?

templateUrl: 'scripts/auth/update-role-form/role-update.template.html',
controller: 'UpdateUserRoleController',
bindings: {
userId: '<'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this doing ?


angular.module('userModule').service('UserService', [function() {
this.getAvailableRoles = function() {
return ['ADMIN', 'VET', 'OWNER'];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these values not fetched from the database, what happens if a new role is added ? For example I added the inventory manager ?

Comment on lines +6 to +9
<input type="checkbox" class="form-check-input" id="{{role}}" ng-model="selectedRoles[role]" ng-true-value="'{{role}}'" ng-false-value="undefined">
<label class="form-check-label" for="{{role}}">{{role}}</label>
</div>
</div>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we using checkboxes ? Radio buttons would fit better since we would want to choose only one role.

Comment on lines +30 to +33
if (rolesList.length > 1) {
alert('Please select only one role.');
return;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use radio buttons instead of this bloated logic ?

@SamuelNguyen2121 SamuelNguyen2121 force-pushed the feat/AUTH-CPC-755-Add_More_Roles_Front_End branch from 5758a2f to a82df7e Compare October 23, 2023 17:59
@SamuelNguyen2121 SamuelNguyen2121 force-pushed the feat/AUTH-CPC-755-Add_More_Roles_Front_End branch from a82df7e to 889f5cc Compare October 23, 2023 18:20
Comment on lines +1 to +5
'use strict';

angular.module('userModule').service('UserService', [function() {
this.getAvailableRoles = function() {
return ['ADMIN', 'VET', 'OWNER'];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this normally work with the default preexisting roles? New ones would prove to be an issue no?

Copy link
Collaborator

@AmirHamzahMirza AmirHamzahMirza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good just some minor questions

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dylan recently added his inventory manger story so I would recommend adding Inventory Manager as a role if you have the time.

Copy link
Collaborator

@PaulJ2001 PaulJ2001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is acceptable but definitely could be better.

@SamuelNguyen2121 SamuelNguyen2121 merged commit 4371189 into main Oct 23, 2023
3 checks passed
@SamuelNguyen2121 SamuelNguyen2121 deleted the feat/AUTH-CPC-755-Add_More_Roles_Front_End branch October 23, 2023 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AUTH AUTH service feat New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants