Skip to content

Commit

Permalink
Merge pull request #217 from integratedmodelling/IM-500-Bad-download-…
Browse files Browse the repository at this point in the history
…certificate-link-on-hub-changed-mail-message

IM-500 feat: Add navigateTo to TagNotification
  • Loading branch information
kristinaBc3 authored Jan 9, 2025
2 parents aeb6d60 + ae8b0c5 commit ce7a6f5
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class TagNotificationController {
TagNotification tagNotification = tagNotificationService.createTagNotification(
ITagElementEnum.valueOf(tagRequest.getiTagElement()), tagRequest.getiTagElementId(),
HubNotificationMessage.Type.valueOf(tagRequest.getType()), Boolean.valueOf(tagRequest.getVisible()),
tagRequest.getName(), tagRequest.getTitle(), tagRequest.getMessage());
tagRequest.getName(), tagRequest.getTitle(), tagRequest.getMessage(), tagRequest.getNavigateTo());

return ResponseEntity.status(HttpStatus.OK).body(tagNotification);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,28 @@ public class TagNotification {
@DBRef
private MongoTag tag;

/**
* Type of notification
*/
@Enumerated(EnumType.STRING)
private Type type;

/**
* Title of notification
*/
private String title;

/**
* Message of notification
*/
private String message;

/**
* Indicates whether navigation is required and where to navigate to execute an action.
*/
private String navigateTo;


public String getTitle() {
return title;
}
Expand All @@ -44,7 +62,6 @@ public void setTitle(String title) {
this.title = title;
}

private String message;

public void setTag(MongoTag tag) {
this.tag = tag;
Expand Down Expand Up @@ -77,5 +94,7 @@ public void setType(Type type) {
public void setMessage(String message) {
this.message = message;
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class TagRequest {
private String title;
private String message;
private String visible;
private String navigateTo;

public String getId() {
return id;
Expand Down Expand Up @@ -59,5 +60,11 @@ public String getVisible() {
public void setVisible(String visible) {
this.visible = visible;
}

public String getNavigateTo() {
return navigateTo;
}
public void setNavigateTo(String navigateTo) {
this.navigateTo = navigateTo;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class TagNotificationService {
* @return
*/
public TagNotification createTagNotification(ITagElementEnum iTagElementEnum, String id,
HubNotificationMessage.Type tagNotifactionType, Boolean visible, String tagName, String title, String message) {
HubNotificationMessage.Type tagNotifactionType, Boolean visible, String tagName, String title, String message, String navigateTo) {

/* Create Mongo Tag */
MongoTag tag = new MongoTag();
Expand All @@ -71,6 +71,8 @@ public TagNotification createTagNotification(ITagElementEnum iTagElementEnum, St

tagNotification.setTitle(title);
tagNotification.setMessage(message);

tagNotification.setNavigateTo(navigateTo);

try {
tagNotificationRepository.save(tagNotification);
Expand Down Expand Up @@ -99,18 +101,19 @@ private void setITagElementById(MongoTag tag, ITagElementEnum iTagElementEnum, S
}

public TagNotification createWarningUserTagNotification(User user, String tagName, Boolean visible, String title,
String message) {
String message, String navigateTo) {
MongoTag tag = new MongoTag();
tag.setTagElementId(user.getId().isEmpty() ? null : user.getId());
tag.setITagElement(user);
tag.setName(tagName);
tag.setVisible(visible);
tag.setVisible(visible);

tag = mongoTagRepository.save(tag);
TagNotification tagNotification = new TagNotification();

tagNotification.setTag(tag);
tagNotification.setType(Type.WARNING);
tagNotification.setNavigateTo(navigateTo);

try {
tagNotificationRepository.save(tagNotification);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,7 @@ public interface UserProfileService {
* @throws MessagingException
*/
abstract ProfileResource createNewEmailRequest(String id, String requestNewEmail) throws MessagingException;
/**
* Update the email of user in mongo and ldap
* @param id
* @param email
* @return
*/
abstract ProfileResource updateUserEmail(String id, String email);

abstract User getUser(String username);

}
Original file line number Diff line number Diff line change
Expand Up @@ -168,45 +168,6 @@ public ProfileResource createNewEmailRequest(String username, String email) thro

}

@Override
public ProfileResource updateUserEmail(String username, String email) {
User user = getUser(username);
user.setEmail(email);

/* update mongo repository */
User updatedUser;

try {
updatedUser = new UpdateUser(user, userRepository).execute();
} catch (DuplicateKeyException e) {
logger.error(e.getMessage());
throw new KlabException("Duplicated key, email is already in use.");
} catch (Exception e) {
logger.error(e.getMessage());
throw new KlabException("Error updating mongo user: " + e.getMessage(), e);
}

/* update ldap */
// try {
// ldapServiceImpl.updateUserEmailAddress(username, email);
// } catch (Exception e) {
// logger.error(e.getMessage(), e);
// throw new KlabException("Error updating ldap user: " + e.getMessage(), e);
// }

try {
tagNotificationService.createWarningUserTagNotification(updatedUser,
TagNameEnum.downloadCertificateChangeEmail.toString(), false, "", "");

} catch (Exception e) {
logger.error(e.getMessage());
throw new KlabException(e.getMessage(), e);
}

ProfileResource updatedProfile = objectMapper.convertValue(updatedUser, ProfileResource.class);
return updatedProfile.getSafeProfile();
}

private User updateUserFromProfileResource(ProfileResource profile) {
User user;
try {
Expand Down
1 change: 1 addition & 0 deletions klab.hub/src/main/resources/static/ui/css/2.06bf50b4.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion klab.hub/src/main/resources/static/ui/css/2.ebab5386.css

This file was deleted.

2 changes: 1 addition & 1 deletion klab.hub/src/main/resources/static/ui/index.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<!DOCTYPE html><html><head><base href=/hub/ui/ ><title>k.Hub</title><meta charset=utf-8><meta name=description content=""><meta name=format-detection content="telephone=no"><meta name=msapplication-tap-highlight content=no><meta name=viewport content="user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1,width=device-width"><link rel=icon type=image/png href=khub-logo.png><link rel=icon type=image/ico href=favicon.ico><link rel=apple-touch-icon sizes=57x57 href=icons/apple-icon-57x57.png><link rel=apple-touch-icon sizes=60x60 href=icons/apple-icon-60x60.png><link rel=apple-touch-icon sizes=72x72 href=icons/apple-icon-72x72.png><link rel=apple-touch-icon sizes=76x76 href=icons/apple-icon-76x76.png><link rel=apple-touch-icon sizes=114x114 href=icons/apple-icon-114x114.png><link rel=apple-touch-icon sizes=120x120 href=icons/apple-icon-120x120.png><link rel=apple-touch-icon sizes=144x144 href=icons/apple-icon-144x144.png><link rel=apple-touch-icon sizes=152x152 href=icons/apple-icon-152x152.png><link rel=apple-touch-icon sizes=180x180 href=icons/apple-icon-180x180.png><link rel=icon type=image/png sizes=192x192 href=icons/android-icon-192x192.png><link rel=icon type=image/png sizes=32x32 href=icons/favicon-32x32.png><link rel=icon type=image/png sizes=96x96 href=icons/favicon-96x96.png><link rel=icon type=image/png sizes=16x16 href=icons/favicon-16x16.png><link rel=manifest href=icons/manifest.json><meta name=msapplication-TileColor content=#ffffff><meta name=msapplication-TileImage content=icons/ms-icon-144x144.png><meta name=theme-color content=#ffffff><script>var environmentPath = "false" === "true" ? "/environments" : "./environments";
document.write("<script src='" + environmentPath + "' type='text/javascript'><\/script>");</script><script defer data-domain=integratedmodelling.org/hub src=https://plausible.integratedmodelling.org/js/script.js></script><link href=/hub/ui/css/vendor.d5f84891.css rel=stylesheet><link href=/hub/ui/css/app.d2a88fe9.css rel=stylesheet></head><body><div id=q-app></div><script src=/hub/ui/js/vendor.43e6402e.js></script><script src=/hub/ui/js/app.793a1b17.js></script></body></html>
document.write("<script src='" + environmentPath + "' type='text/javascript'><\/script>");</script><script defer data-domain=integratedmodelling.org/hub src=https://plausible.integratedmodelling.org/js/script.js></script><link href=/hub/ui/css/vendor.d5f84891.css rel=stylesheet><link href=/hub/ui/css/app.d2a88fe9.css rel=stylesheet></head><body><div id=q-app></div><script src=/hub/ui/js/vendor.43e6402e.js></script><script src=/hub/ui/js/app.79b52333.js></script></body></html>
1 change: 1 addition & 0 deletions klab.hub/src/main/resources/static/ui/js/2.13d5da30.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ce7a6f5

Please sign in to comment.