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

bug(CSTM-CPC-1017)Fixed Pet UUID Generation and Pet Type Display #592

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
vm.pets = [];

// Function to get pet type name based on petTypeId
/* vm.getPetTypeName = function (petTypeId) {
vm.getPetTypeName = function (petTypeId) {
switch (petTypeId) {
case '1':
return 'Cat';
Expand All @@ -29,10 +29,10 @@
default:
return 'Unknown';
}
};*/
};


vm.getBirthday = function(birthday) {

Check notice on line 35 in api-gateway/src/main/resources/static/scripts/owner-details/owner-details.controller.js

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Duplicated code fragment

Duplicated code
if (birthday) {
var date = new Date(birthday);
var timezoneOffset = date.getTimezoneOffset() * 60000;
Expand Down Expand Up @@ -118,7 +118,7 @@
vm.toggleActiveStatus = function (petId) {
return $http.get('api/gateway/pets/' + petId + '?_=' + new Date().getTime(), {headers: {'Cache-Control': 'no-cache'}})
.then(function (resp) {
console.log("Pet id is " + petId);

Check notice on line 121 in api-gateway/src/main/resources/static/scripts/owner-details/owner-details.controller.js

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Duplicated code fragment

Duplicated code
console.log(resp.data);
vm.pet = resp.data;
console.log("Pet id is " + vm.pet.petId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,14 @@ angular.module('petRegister')
};

function generateUUID() {
// Generate a random hexadecimal string of length 12
var randomHex = 'xxxxxxxxxxxx'.replace(/x/g, function () {
return (Math.random() * 16 | 0).toString(16);
// Generate a random hexadecimal string of length 32
var randomHex = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0,
v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});

// Format the UUID
var uuid = [
randomHex.substr(0, 8),
randomHex.substr(8, 4),
'4' + randomHex.substr(13, 3), // Set the version to 4 (random)
'89ab'[Math.floor(Math.random() * 4)] + randomHex.substr(17, 3), // Set the variant
randomHex.substr(20, 12)
].join('-');

return uuid;
return randomHex;
}

// Example usage:
Expand Down
Loading