-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into bug/CSTM-CPC-1014-Fix-pet-date-and-update-pe…
…t-form
- Loading branch information
Showing
45 changed files
with
703 additions
and
157 deletions.
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
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
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
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
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
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
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
10 changes: 10 additions & 0 deletions
10
api-gateway/src/main/resources/static/scripts/auth/update-role-form/role-update.component.js
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 @@ | ||
'use strict'; | ||
|
||
angular.module('userModule') | ||
.component('updateUserRoleComponent', { | ||
templateUrl: 'scripts/auth/update-role-form/role-update.template.html', | ||
controller: 'UpdateUserRoleController', | ||
bindings: { | ||
userId: '<' | ||
} | ||
}); |
16 changes: 16 additions & 0 deletions
16
api-gateway/src/main/resources/static/scripts/auth/update-role-form/role-update.config.js
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,16 @@ | ||
'use strict'; | ||
|
||
angular.module('userModule', ['ui.router']) | ||
.config(['$stateProvider', function($stateProvider) { | ||
$stateProvider | ||
.state('updateUserRole', { | ||
parent: 'app', | ||
url: '/users/:userId/updateRole', | ||
component: 'updateUserRoleComponent', | ||
resolve: { | ||
userId: ['$stateParams', function($stateParams) { | ||
return $stateParams.userId; | ||
}] | ||
} | ||
}); | ||
}]); |
56 changes: 56 additions & 0 deletions
56
...gateway/src/main/resources/static/scripts/auth/update-role-form/role-update.controller.js
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,56 @@ | ||
'use strict'; | ||
|
||
angular.module('userModule') | ||
.controller('UpdateUserRoleController', ['$scope', '$http', 'UserService', '$state', function($scope, $http, UserService, $state) { | ||
var ctrl = this; // Capture the controller instance | ||
|
||
$scope.roles = UserService.getAvailableRoles(); | ||
$scope.selectedRole = {}; | ||
|
||
// Use $onInit lifecycle hook to set $scope.userId | ||
ctrl.$onInit = function() { | ||
$scope.userId = ctrl.userId; | ||
}; | ||
|
||
$scope.selectedRoles = {}; | ||
|
||
$scope.updateRole = function() { | ||
var rolesList = []; | ||
for (var role in $scope.selectedRoles) { | ||
if ($scope.selectedRoles[role]) { | ||
rolesList.push(role); | ||
} | ||
} | ||
|
||
if (rolesList.length === 0) { | ||
alert('Please select at least one role.'); | ||
return; | ||
} | ||
|
||
if (rolesList.length > 1) { | ||
alert('Please select only one role.'); | ||
return; | ||
} | ||
|
||
var rolesChangeRequest = { | ||
roles: rolesList | ||
}; | ||
|
||
// Send the PATCH request | ||
$http({ | ||
method: 'PATCH', | ||
url: 'api/gateway/users/' + $scope.userId, | ||
data: rolesChangeRequest, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
// Add token headers if needed | ||
} | ||
}) | ||
.then(function successCallback(response) { | ||
alert('Roles updated successfully!'); | ||
$state.go('AdminPanel'); | ||
}, function errorCallback(response) { | ||
alert('Failed to update roles. ' + response.data.message); | ||
}); | ||
}; | ||
}]); |
8 changes: 8 additions & 0 deletions
8
api-gateway/src/main/resources/static/scripts/auth/update-role-form/role-update.service.js
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,8 @@ | ||
'use strict'; | ||
|
||
angular.module('userModule').service('UserService', [function() { | ||
this.getAvailableRoles = function() { | ||
return ['ADMIN', 'VET', 'OWNER']; | ||
}; | ||
|
||
}]); |
12 changes: 12 additions & 0 deletions
12
...gateway/src/main/resources/static/scripts/auth/update-role-form/role-update.template.html
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,12 @@ | ||
<h2>Update User Role</h2> | ||
<form style="background-color: #f5f5f5; padding: 20px; border-radius: 10px; box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);"> | ||
<div class="form-group"> | ||
<label>Select Role:</label> | ||
<div ng-repeat="role in roles" class="form-check"> | ||
<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> | ||
<button type="button" class="btn btn-warning" ng-click="updateRole()">Update Roles</button> | ||
<a ui-sref="AdminPanel" class="btn btn-secondary">Cancel</a> | ||
</form> |
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
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
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
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
Oops, something went wrong.