no message

This commit is contained in:
Ioannis Kalyvas 2018-08-27 12:00:09 +03:00
parent 3ad1c1c8f2
commit 555f8fb1e7
11 changed files with 63 additions and 19 deletions

View File

@ -1,20 +1,21 @@
package eu.eudat.logic.managers; package eu.eudat.logic.managers;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.UserRole;
import eu.eudat.data.query.items.table.userinfo.UserInfoTableRequestItem;
import eu.eudat.exceptions.security.UnauthorisedException;
import eu.eudat.logic.builders.entity.UserRoleBuilder; import eu.eudat.logic.builders.entity.UserRoleBuilder;
import eu.eudat.logic.builders.model.models.DataTableDataBuilder; import eu.eudat.logic.builders.model.models.DataTableDataBuilder;
import eu.eudat.data.entities.UserRole; import eu.eudat.logic.services.ApiContext;
import eu.eudat.exceptions.security.UnauthorisedException; import eu.eudat.logic.services.operations.AuthenticationServiceImpl;
import eu.eudat.logic.utilities.builders.XmlBuilder;
import eu.eudat.models.data.dmp.DataManagementPlan; import eu.eudat.models.data.dmp.DataManagementPlan;
import eu.eudat.models.data.helpers.common.DataTableData; import eu.eudat.models.data.helpers.common.DataTableData;
import eu.eudat.models.data.login.Credentials; import eu.eudat.models.data.login.Credentials;
import eu.eudat.models.data.security.Principal; import eu.eudat.models.data.security.Principal;
import eu.eudat.data.query.items.table.userinfo.UserInfoTableRequestItem;
import eu.eudat.models.data.userinfo.UserListingModel; import eu.eudat.models.data.userinfo.UserListingModel;
import eu.eudat.models.data.userinfo.UserProfile; import eu.eudat.models.data.userinfo.UserProfile;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.operations.AuthenticationServiceImpl;
import eu.eudat.logic.utilities.builders.XmlBuilder;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
@ -45,7 +46,8 @@ public class UserManager {
public static UserProfile getSingle(ApiContext apiContext, UUID userId) throws Exception { public static UserProfile getSingle(ApiContext apiContext, UUID userId) throws Exception {
eu.eudat.data.entities.UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userId); eu.eudat.data.entities.UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userId);
UserProfile profile = new UserProfile().fromDataModel(user); UserProfile profile = new UserProfile().fromDataModel(user);
profile.setAssociatedDmps(user.getDmps().stream().map(x-> new DataManagementPlan().fromDataModel(x)).collect(Collectors.toList())); List<DMP> dmps = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getAuthenticated(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().asQueryable(), user).take(5).toList();
profile.setAssociatedDmps(dmps.stream().map(x -> new DataManagementPlan().fromDataModel(x)).collect(Collectors.toList()));
return profile; return profile;
} }

View File

@ -71,5 +71,5 @@ http-logger.initial-delay = 0
http-logger.delay = 10 http-logger.delay = 10
http-logger.server-address = http://logstash:31311 http-logger.server-address = http://logstash:31311
#############################Elastic Search###################################### #############################Elastic Search######################################
elasticsearch.host = localhost elasticsearch.host = elasticsearch-dmp
elasticsearch.port = 9201 elasticsearch.port = 9200

View File

@ -20,6 +20,7 @@ export class DataManagementPlanModel implements Serializable<DataManagementPlanM
public groupId: String; public groupId: String;
public profile: String public profile: String
public version: number; public version: number;
public creator: DmpUsersModel;
public status: Status = Status.Active; public status: Status = Status.Active;
public description: String; public description: String;
public project: ProjectModel; public project: ProjectModel;
@ -46,6 +47,7 @@ export class DataManagementPlanModel implements Serializable<DataManagementPlanM
this.associatedUsers = JsonSerializer.fromJSONArray(item.associatedUsers, DmpUsersModel); this.associatedUsers = JsonSerializer.fromJSONArray(item.associatedUsers, DmpUsersModel);
this.definition = JsonSerializer.fromJSONObject(item.definition, DataManagementPlanProfile); this.definition = JsonSerializer.fromJSONObject(item.definition, DataManagementPlanProfile);
this.dynamicFields = JsonSerializer.fromJSONArray(item.dynamicFields, DynamicField); this.dynamicFields = JsonSerializer.fromJSONArray(item.dynamicFields, DynamicField);
this.creator = JsonSerializer.fromJSONObject(item.creator, DmpUsersModel);
return this; return this;
} }

View File

@ -8,8 +8,8 @@ import { UserDialogComponent } from '../user-dialog/user-dialog.component';
@Component({ @Component({
selector: 'app-search', selector: 'app-search',
templateUrl: 'navigation.component.html', templateUrl: 'search-bar.component.html',
styleUrls: ['./navigation.component.scss'], styleUrls: ['./search-bar.component.scss'],
}) })
export class SearchBarComponent { export class SearchBarComponent {

View File

@ -49,6 +49,7 @@ export class UserDialogComponent implements OnInit {
} }
public navigateToProfile() { public navigateToProfile() {
this.dialogRef.close();
this.router.navigate(["/users/" + this.authentication.current().id]); this.router.navigate(["/users/" + this.authentication.current().id]);
} }
} }

View File

@ -24,6 +24,7 @@ import { BreadcrumbComponent } from './components/breadcrumb/breadcrumb.componen
import { SingleAutoCompleteComponent } from './components/autocompletes/single/single-auto-complete.component'; import { SingleAutoCompleteComponent } from './components/autocompletes/single/single-auto-complete.component';
import { MultipleAutoCompleteComponent } from './components/autocompletes/multiple/multiple-auto-complete.component'; import { MultipleAutoCompleteComponent } from './components/autocompletes/multiple/multiple-auto-complete.component';
import { UserDialogComponent } from './components/user-dialog/user-dialog.component'; import { UserDialogComponent } from './components/user-dialog/user-dialog.component';
import { SearchBarComponent } from './components/search-bar/search-bar.component';
@NgModule({ @NgModule({
imports: [ imports: [
@ -54,7 +55,8 @@ import { UserDialogComponent } from './components/user-dialog/user-dialog.compon
BreadcrumbComponent, BreadcrumbComponent,
SingleAutoCompleteComponent, SingleAutoCompleteComponent,
MultipleAutoCompleteComponent, MultipleAutoCompleteComponent,
UserDialogComponent UserDialogComponent,
SearchBarComponent
], ],
exports: [ exports: [

View File

@ -17,7 +17,19 @@
<h4>{{ 'USER-PROFILE.ASSOCIATED-DMPS' | translate}}</h4> <h4>{{ 'USER-PROFILE.ASSOCIATED-DMPS' | translate}}</h4>
</div> </div>
<div> <div>
{{userProfile.associatedDmps}} <mat-list>
<mat-list-item class="clickable" (click)="navigateToDmp(dmp)" *ngFor="let dmp of userProfile.associatedDmps" fxLayout="row" fxLayoutAlign="start center">
<div>
{{ dmp.label }}
</div>
<div>
<mat-chip-list>
<mat-chip>{{ getUserRole(dmp) }}</mat-chip>
</mat-chip-list>
</div>
</mat-list-item>
</mat-list>
<button mat-button (click)="showAllDmps()"> {{'USER-PROFILE.DMPS.SHOW-ALL' | translate}}</button>
</div> </div>
</div> </div>
</mat-card-content> </mat-card-content>

View File

@ -0,0 +1,3 @@
.clickable{
cursor: pointer;
}

View File

@ -15,6 +15,7 @@ import { TranslateService } from '@ngx-translate/core';
import { DataSource } from '@angular/cdk/table'; import { DataSource } from '@angular/cdk/table';
import { RecentActivityTypes } from '../../users/activity/RecentActivityTypes'; import { RecentActivityTypes } from '../../users/activity/RecentActivityTypes';
import { AuthService } from '../../services/auth/auth.service'; import { AuthService } from '../../services/auth/auth.service';
import { DataManagementPlanModel } from '../../models/data-managemnt-plans/DataManagementPlanModel';
@Component({ @Component({
@ -28,19 +29,35 @@ import { AuthService } from '../../services/auth/auth.service';
export class UserProfileComponent implements OnInit { export class UserProfileComponent implements OnInit {
user: Observable<UserListingModel>; user: Observable<UserListingModel>;
currentUserId: string;
constructor( constructor(
private userReferenceService: UserReferenceService, private userReferenceService: UserReferenceService,
private route: ActivatedRoute, private route: ActivatedRoute,
private authService: AuthService private router: Router,
private authService: AuthService,
private language: TranslateService
) { } ) { }
ngOnInit() { ngOnInit() {
this.route.params.subscribe((params: Params) => { this.route.params.subscribe((params: Params) => {
this.currentUserId = params['id'];
let userId = params['id'] === this.authService.current().id ? 'me' : params['id'] let userId = params['id'] === this.authService.current().id ? 'me' : params['id']
this.user = this.userReferenceService.getUser(userId).map(result => { result["additionalinfo"] = JSON.parse(result["additionalinfo"]); return result }) this.user = this.userReferenceService.getUser(userId).map(result => { result["additionalinfo"] = JSON.parse(result["additionalinfo"]); return result })
}) })
} }
getUserRole(dmp: DataManagementPlanModel) {
if (dmp.creator.id === this.currentUserId) return this.language.instant('USER-PROFILE.DMPS.CREATOR')
else if (dmp.associatedUsers.map(x => x.id).indexOf(this.currentUserId) != -1) return this.language.instant('USER-PROFILE.DMPS.MEMBER');
return ''
}
showAllDmps() {
this.router.navigate(["/dmps"])
}
navigateToDmp(dmp: DataManagementPlanModel) {
this.router.navigate(["/dmps/edit/" + dmp.id])
}
} }

View File

@ -325,6 +325,11 @@
}, },
"USER-PROFILE": { "USER-PROFILE": {
"SETTINGS": "Settings", "SETTINGS": "Settings",
"ASSOCIATED-DMPS": "Associated DMPs" "ASSOCIATED-DMPS": "Associated DMPs",
"DMPS": {
"SHOW-ALL": "Show All",
"CREATOR": "Creator",
"MEMBER": "Member"
}
} }
} }

View File

@ -1,6 +1,6 @@
export const environment = { export const environment = {
production: true, production: true,
Server: 'http://dl043.madgik.di.uoa.gr:8080/api/', Server: 'http://localhost:8080/api/',
App: 'http://dl043.madgik.di.uoa.gr/', App: 'http://dl043.madgik.di.uoa.gr/',
HelpServiceUrl: 'http://dl043.madgik.di.uoa.gr:5555/' HelpServiceUrl: 'http://dl043.madgik.di.uoa.gr:5555/'
}; };