fix dmp invitation dialog

This commit is contained in:
amentis 2024-01-05 15:33:27 +02:00
parent 9dd0405dc8
commit a5f88db680
8 changed files with 51 additions and 28 deletions

View File

@ -29,7 +29,6 @@ import gr.cite.tools.fieldset.BaseFieldSet;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry;
import gr.cite.tools.validation.ValidationService;
import jakarta.persistence.EntityManager;
import org.jetbrains.annotations.NotNull;
import org.slf4j.LoggerFactory;
@ -68,7 +67,6 @@ public class TenantServiceImpl implements TenantService {
private final ResponseUtilsService responseUtilsService;
private final XmlHandlingService xmlHandlingService;
private final ErrorThesaurusProperties errors;
private final ValidationService validationService;
private final EncryptionService encryptionService;
private final TenantProperties properties;
@ -84,7 +82,7 @@ public class TenantServiceImpl implements TenantService {
ResponseUtilsService responseUtilsService,
XmlHandlingService xmlHandlingService,
ErrorThesaurusProperties errors,
ValidationService validationService, EncryptionService encryptionService, TenantProperties properties) {
EncryptionService encryptionService, TenantProperties properties) {
this.entityManager = entityManager;
this.authorizationService = authorizationService;
this.deleterFactory = deleterFactory;
@ -95,7 +93,6 @@ public class TenantServiceImpl implements TenantService {
this.responseUtilsService = responseUtilsService;
this.xmlHandlingService = xmlHandlingService;
this.errors = errors;
this.validationService = validationService;
this.encryptionService = encryptionService;
this.properties = properties;
}

View File

@ -7,7 +7,6 @@ import eu.eudat.commons.enums.DmpAccessType;
import eu.eudat.commons.enums.DmpStatus;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.validation.ValidationFilterAnnotation;
import eu.eudat.file.transformer.model.file.FileFormat;
import eu.eudat.model.Description;
import eu.eudat.model.Dmp;
import eu.eudat.model.PublicDescription;
@ -21,8 +20,6 @@ import eu.eudat.query.DescriptionQuery;
import eu.eudat.query.DmpQuery;
import eu.eudat.query.lookup.DescriptionLookup;
import eu.eudat.service.description.DescriptionService;
import eu.eudat.service.description.DescriptionServiceImpl;
import eu.eudat.service.dmp.DmpService;
import eu.eudat.service.elastic.ElasticQueryHelperService;
import eu.eudat.service.transformer.FileTransformerService;
import gr.cite.tools.auditing.AuditService;

View File

@ -63,3 +63,9 @@ export interface UserCredential {
user: User;
createdAt: Date;
}
export interface DmpAssociatedUser {
id: Guid;
name: string;
email: string;
}

View File

@ -1,7 +1,7 @@
import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { IsActive } from '@app/core/common/enum/is-active.enum';
import { User, UserPersist, UserRolePatchPersist } from '@app/core/model/user/user';
import { DmpAssociatedUser, User, UserPersist, UserRolePatchPersist } from '@app/core/model/user/user';
import { UserLookup } from '@app/core/query/user.lookup';
import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration';
import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration';
@ -31,6 +31,11 @@ export class UserService {
return this.http.post<QueryResult<User>>(url, q).pipe(catchError((error: any) => throwError(error)));
}
queryDmpAssociated(q: UserLookup): Observable<QueryResult<DmpAssociatedUser>> {
const url = `${this.apiBase}/dmp-associated/query`;
return this.http.post<QueryResult<DmpAssociatedUser>>(url, q).pipe(catchError((error: any) => throwError(error)));
}
getSingle(id: Guid, reqFields: string[] = []): Observable<User> {
const url = `${this.apiBase}/${id}`;
const options = { params: { f: reqFields } };

View File

@ -21,7 +21,7 @@
<mat-form-field class="select-role">
<mat-select [formControl]="formGroup.get('role')">
<mat-option [value]="dmpUserRoleEnum.Owner">{{enumUtils.toDmpUserRoleString(dmpUserRoleEnum.Owner)}}</mat-option>
<mat-option [value]="dmpUserRoleEnum.Member">{{enumUtils.toDmpUserRoleString(dmpUserRoleEnum.Member)}}</mat-option>
<mat-option [value]="dmpUserRoleEnum.User">{{enumUtils.toDmpUserRoleString(dmpUserRoleEnum.User)}}</mat-option>
</mat-select>
</mat-form-field>
</div>

View File

@ -73,7 +73,7 @@
}
.select-role {
width: 20% !important;
width: 50% !important;
font-size: 14px;
color: #848484;
height: min-content;

View File

@ -6,8 +6,8 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { ActivatedRoute, Router } from '@angular/router';
import { DmpUserRole } from '@app/core/common/enum/dmp-user-role';
import { IsActive } from '@app/core/common/enum/is-active.enum';
import { DmpUserInvitePersist } from '@app/core/model/dmp/dmp';
import { User } from '@app/core/model/user/user';
import { DmpUserInvitePersist, DmpUserInviteTypePersist } from '@app/core/model/dmp/dmp';
import { DmpAssociatedUser, User } from '@app/core/model/user/user';
import { UserLookup } from '@app/core/query/user.lookup';
import { DmpService } from '@app/core/services/dmp/dmp.service';
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
@ -43,7 +43,7 @@ export class DmpInvitationDialogComponent extends BaseComponent implements OnIni
titleFn: (item) => typeof (item) === 'string' ? item : item.name,
subtitleFn: (item) => item.email,
valueAssign: (item) => {
const result = typeof (item) === 'string' ? item : item.email;
const result = typeof (item) === 'string' ? item : item.id;
return result;
},
autoSelectFirstOptionOnBlur: true,
@ -79,7 +79,26 @@ export class DmpInvitationDialogComponent extends BaseComponent implements OnIni
send() {
if (!this.formGroup.valid) { return; }
const value: DmpUserInvitePersist = this.formGroup.value;
let inviteTypeValues: DmpUserInviteTypePersist[] = [];
this.formGroup.get('users').value.forEach(x => {
let inviteType: DmpUserInviteTypePersist;
if (!(/^(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}$/).test(x)) {
inviteType = {
userId: null,
email: x
};
}else{
inviteType = {
userId: Guid.parse(x),
email: null
};
}
inviteTypeValues.push(inviteType)
})
const value: DmpUserInvitePersist = {
role: this.formGroup.get('role').value,
users: inviteTypeValues
}
// invitationObject.users.push(...(<any[]>this.formGroup.get('users').value).filter(user => typeof (user) === 'string').map(email => ({ email: email, name: email })));
// invitationObject.users.push(...(<any[]>this.formGroup.get('users').value).filter(user => typeof (user) !== 'string'));
// this.emails.forEach(email => {
@ -101,8 +120,7 @@ export class DmpInvitationDialogComponent extends BaseComponent implements OnIni
this.dialogRef.close();
}
filterUsers(like: string): Observable<User[]> {
//TODO: refactor. Change with a service that provides a list of the users assosiated with your account.
filterUsers(like: string): Observable<DmpAssociatedUser[]> {
const lookup: UserLookup = new UserLookup();
lookup.page = { size: 100, offset: 0 };
// if (excludedIds && excludedIds.length > 0) { lookup.excludedIds = excludedIds; }
@ -116,7 +134,7 @@ export class DmpInvitationDialogComponent extends BaseComponent implements OnIni
};
lookup.order = { items: [nameof<User>(x => x.name)] };
if (like) { lookup.like = this.filterService.transformLike(like); }
return this.userService.query(lookup).pipe(takeUntil(this._destroyed), map(x => x.items));
return this.userService.queryDmpAssociated(lookup).pipe(takeUntil(this._destroyed), map(x => x.items));
}
hasValue(): boolean {

View File

@ -37,6 +37,7 @@ import { TranslateService } from '@ngx-translate/core';
import * as FileSaver from 'file-saver';
import { takeUntil } from 'rxjs/operators';
import { nameof } from 'ts-simple-nameof';
import { DmpInvitationDialogComponent } from '../invitation/dialog/dmp-invitation-dialog.component';
@Component({
selector: 'app-dmp-overview',
@ -558,17 +559,16 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
}
openShareDialog(rowId: any, rowName: any) {
//TODO: add this
// const dialogRef = this.dialog.open(DmpInvitationDialogComponent, {
// // height: '250px',
// // width: '700px',
// autoFocus: false,
// restoreFocus: false,
// data: {
// dmpId: rowId,
// dmpName: rowName
// }
// });
const dialogRef = this.dialog.open(DmpInvitationDialogComponent, {
// height: '250px',
// width: '700px',
autoFocus: false,
restoreFocus: false,
data: {
dmpId: rowId,
dmpName: rowName
}
});
}
selectDoi(entityDoi: EntityDoi) {