From 6b13f191b0130b7f9f6ab4245f223f1c38b72a29 Mon Sep 17 00:00:00 2001 From: gkolokythas Date: Fri, 17 May 2019 11:42:30 +0300 Subject: [PATCH] Adds the missing information to User Dashboard (Ticket #83) --- .../models/data/dmp/DataManagementPlan.java | 4 +-- .../data/userinfo/UserListingModel.java | 34 +++++++----------- .../recent-edited-activity.component.html | 4 +-- .../recent-edited-activity.component.ts | 35 ++++++++++++++++++- 4 files changed, 51 insertions(+), 26 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java index 55c571266..8f6800dde 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java @@ -274,7 +274,7 @@ public class DataManagementPlan implements DataModel { if (this.dynamicFields != null) dataManagementPlanEntity.setDmpProperties(JSONObject.toJSONString(this.dynamicFields.stream().filter(item -> item.getValue() != null).collect(Collectors.toMap(DynamicFieldWithValue::getId, DynamicFieldWithValue::getValue)))); - if (this.associatedUsers != null && !this.associatedUsers.isEmpty()) { + /*if (this.associatedUsers != null && !this.associatedUsers.isEmpty()) { List userDMPList = new LinkedList<>(); for(UserListingModel userListingModel: this.associatedUsers) { UserDMP userDMP = new UserDMP(); @@ -282,7 +282,7 @@ public class DataManagementPlan implements DataModel { userDMPList.add(userDMP); } dataManagementPlanEntity.setUsers((Set) userDMPList); - } + }*/ return dataManagementPlanEntity; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/userinfo/UserListingModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/userinfo/UserListingModel.java index 80429c80b..15b887765 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/userinfo/UserListingModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/userinfo/UserListingModel.java @@ -1,38 +1,28 @@ package eu.eudat.models.data.userinfo; import eu.eudat.data.entities.UserInfo; +import eu.eudat.data.entities.UserRole; import eu.eudat.models.DataModel; -import java.util.Date; -import java.util.List; -import java.util.UUID; +import java.util.*; import java.util.stream.Collectors; public class UserListingModel implements DataModel { private UUID id; - private String email; - private Short usertype; - private Boolean verified_email; - private String name; - private Date created; - private Date lastloggedin; - private String additionalinfo; - private List appRoles; public UUID getId() { return id; } - public void setId(UUID id) { this.id = id; } @@ -40,7 +30,6 @@ public class UserListingModel implements DataModel getAppRoles() { return appRoles; } - public void setAppRoles(List appRoles) { this.appRoles = appRoles; } @@ -117,7 +99,17 @@ public class UserListingModel implements DataModel{{ activity.label }}
- -- + {{ dmpProfileDisplay(activity.profile) }}
{{ activity.project }} - Role Name + {{roleDisplay(activity.users)}} {{ activity.organisations }}
diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts b/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts index 835296824..75c1b4ea8 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts @@ -7,6 +7,8 @@ import { DmpCriteria } from '../../../core/query/dmp/dmp-criteria'; import { DmpService } from '../../../core/services/dmp/dmp.service'; import { RecentActivityType } from '../../../core/common/enum/recent-activity-type'; import { Router } from '@angular/router'; +import { Principal } from '../../../core/model/auth/Principal'; +import { TranslateService } from '@ngx-translate/core'; @Component({ selector: 'app-recent-edited-activity', @@ -21,7 +23,8 @@ export class RecentEditedActivityComponent implements OnInit { private router: Router, public enumUtils: EnumUtils, private authentication: AuthService, - private dmpService: DmpService + private dmpService: DmpService, + private language: TranslateService ) { } ngOnInit() { @@ -62,4 +65,34 @@ export class RecentEditedActivityComponent implements OnInit { } navigateToUrl() { } + + roleDisplay(value: any) { + const principal: Principal = this.authentication.current(); + let role: number; + if (principal) { + value.forEach(element => { + if (principal.id === element.id) { + role = element.role; + } + }); + } + if (role === 0) { + return this.language.instant('DMP-LISTING.OWNER'); + } + else if (role === 1) { + return this.language.instant('DMP-LISTING.MEMBER'); + } + else { + return this.language.instant('DMP-LISTING.OWNER'); + } + } + + dmpProfileDisplay(value: any) { + if (value != null) { + return value; + } + else { + return "--"; + } + } }