fix dmp invitation dialog
This commit is contained in:
parent
9dd0405dc8
commit
a5f88db680
|
@ -29,7 +29,6 @@ import gr.cite.tools.fieldset.BaseFieldSet;
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import gr.cite.tools.logging.MapLogEntry;
|
import gr.cite.tools.logging.MapLogEntry;
|
||||||
import gr.cite.tools.validation.ValidationService;
|
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -68,7 +67,6 @@ public class TenantServiceImpl implements TenantService {
|
||||||
private final ResponseUtilsService responseUtilsService;
|
private final ResponseUtilsService responseUtilsService;
|
||||||
private final XmlHandlingService xmlHandlingService;
|
private final XmlHandlingService xmlHandlingService;
|
||||||
private final ErrorThesaurusProperties errors;
|
private final ErrorThesaurusProperties errors;
|
||||||
private final ValidationService validationService;
|
|
||||||
private final EncryptionService encryptionService;
|
private final EncryptionService encryptionService;
|
||||||
|
|
||||||
private final TenantProperties properties;
|
private final TenantProperties properties;
|
||||||
|
@ -84,7 +82,7 @@ public class TenantServiceImpl implements TenantService {
|
||||||
ResponseUtilsService responseUtilsService,
|
ResponseUtilsService responseUtilsService,
|
||||||
XmlHandlingService xmlHandlingService,
|
XmlHandlingService xmlHandlingService,
|
||||||
ErrorThesaurusProperties errors,
|
ErrorThesaurusProperties errors,
|
||||||
ValidationService validationService, EncryptionService encryptionService, TenantProperties properties) {
|
EncryptionService encryptionService, TenantProperties properties) {
|
||||||
this.entityManager = entityManager;
|
this.entityManager = entityManager;
|
||||||
this.authorizationService = authorizationService;
|
this.authorizationService = authorizationService;
|
||||||
this.deleterFactory = deleterFactory;
|
this.deleterFactory = deleterFactory;
|
||||||
|
@ -95,7 +93,6 @@ public class TenantServiceImpl implements TenantService {
|
||||||
this.responseUtilsService = responseUtilsService;
|
this.responseUtilsService = responseUtilsService;
|
||||||
this.xmlHandlingService = xmlHandlingService;
|
this.xmlHandlingService = xmlHandlingService;
|
||||||
this.errors = errors;
|
this.errors = errors;
|
||||||
this.validationService = validationService;
|
|
||||||
this.encryptionService = encryptionService;
|
this.encryptionService = encryptionService;
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import eu.eudat.commons.enums.DmpAccessType;
|
||||||
import eu.eudat.commons.enums.DmpStatus;
|
import eu.eudat.commons.enums.DmpStatus;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.validation.ValidationFilterAnnotation;
|
import eu.eudat.commons.validation.ValidationFilterAnnotation;
|
||||||
import eu.eudat.file.transformer.model.file.FileFormat;
|
|
||||||
import eu.eudat.model.Description;
|
import eu.eudat.model.Description;
|
||||||
import eu.eudat.model.Dmp;
|
import eu.eudat.model.Dmp;
|
||||||
import eu.eudat.model.PublicDescription;
|
import eu.eudat.model.PublicDescription;
|
||||||
|
@ -21,8 +20,6 @@ import eu.eudat.query.DescriptionQuery;
|
||||||
import eu.eudat.query.DmpQuery;
|
import eu.eudat.query.DmpQuery;
|
||||||
import eu.eudat.query.lookup.DescriptionLookup;
|
import eu.eudat.query.lookup.DescriptionLookup;
|
||||||
import eu.eudat.service.description.DescriptionService;
|
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.elastic.ElasticQueryHelperService;
|
||||||
import eu.eudat.service.transformer.FileTransformerService;
|
import eu.eudat.service.transformer.FileTransformerService;
|
||||||
import gr.cite.tools.auditing.AuditService;
|
import gr.cite.tools.auditing.AuditService;
|
||||||
|
|
|
@ -63,3 +63,9 @@ export interface UserCredential {
|
||||||
user: User;
|
user: User;
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface DmpAssociatedUser {
|
||||||
|
id: Guid;
|
||||||
|
name: string;
|
||||||
|
email: string;
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http';
|
import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { IsActive } from '@app/core/common/enum/is-active.enum';
|
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 { UserLookup } from '@app/core/query/user.lookup';
|
||||||
import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration';
|
import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration';
|
||||||
import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-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)));
|
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> {
|
getSingle(id: Guid, reqFields: string[] = []): Observable<User> {
|
||||||
const url = `${this.apiBase}/${id}`;
|
const url = `${this.apiBase}/${id}`;
|
||||||
const options = { params: { f: reqFields } };
|
const options = { params: { f: reqFields } };
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
<mat-form-field class="select-role">
|
<mat-form-field class="select-role">
|
||||||
<mat-select [formControl]="formGroup.get('role')">
|
<mat-select [formControl]="formGroup.get('role')">
|
||||||
<mat-option [value]="dmpUserRoleEnum.Owner">{{enumUtils.toDmpUserRoleString(dmpUserRoleEnum.Owner)}}</mat-option>
|
<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-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -73,7 +73,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.select-role {
|
.select-role {
|
||||||
width: 20% !important;
|
width: 50% !important;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
color: #848484;
|
color: #848484;
|
||||||
height: min-content;
|
height: min-content;
|
||||||
|
|
|
@ -6,8 +6,8 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { DmpUserRole } from '@app/core/common/enum/dmp-user-role';
|
import { DmpUserRole } from '@app/core/common/enum/dmp-user-role';
|
||||||
import { IsActive } from '@app/core/common/enum/is-active.enum';
|
import { IsActive } from '@app/core/common/enum/is-active.enum';
|
||||||
import { DmpUserInvitePersist } from '@app/core/model/dmp/dmp';
|
import { DmpUserInvitePersist, DmpUserInviteTypePersist } from '@app/core/model/dmp/dmp';
|
||||||
import { User } from '@app/core/model/user/user';
|
import { DmpAssociatedUser, User } from '@app/core/model/user/user';
|
||||||
import { UserLookup } from '@app/core/query/user.lookup';
|
import { UserLookup } from '@app/core/query/user.lookup';
|
||||||
import { DmpService } from '@app/core/services/dmp/dmp.service';
|
import { DmpService } from '@app/core/services/dmp/dmp.service';
|
||||||
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-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,
|
titleFn: (item) => typeof (item) === 'string' ? item : item.name,
|
||||||
subtitleFn: (item) => item.email,
|
subtitleFn: (item) => item.email,
|
||||||
valueAssign: (item) => {
|
valueAssign: (item) => {
|
||||||
const result = typeof (item) === 'string' ? item : item.email;
|
const result = typeof (item) === 'string' ? item : item.id;
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
autoSelectFirstOptionOnBlur: true,
|
autoSelectFirstOptionOnBlur: true,
|
||||||
|
@ -79,7 +79,26 @@ export class DmpInvitationDialogComponent extends BaseComponent implements OnIni
|
||||||
|
|
||||||
send() {
|
send() {
|
||||||
if (!this.formGroup.valid) { return; }
|
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').map(email => ({ email: email, name: email })));
|
||||||
// invitationObject.users.push(...(<any[]>this.formGroup.get('users').value).filter(user => typeof (user) !== 'string'));
|
// invitationObject.users.push(...(<any[]>this.formGroup.get('users').value).filter(user => typeof (user) !== 'string'));
|
||||||
// this.emails.forEach(email => {
|
// this.emails.forEach(email => {
|
||||||
|
@ -101,8 +120,7 @@ export class DmpInvitationDialogComponent extends BaseComponent implements OnIni
|
||||||
this.dialogRef.close();
|
this.dialogRef.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
filterUsers(like: string): Observable<User[]> {
|
filterUsers(like: string): Observable<DmpAssociatedUser[]> {
|
||||||
//TODO: refactor. Change with a service that provides a list of the users assosiated with your account.
|
|
||||||
const lookup: UserLookup = new UserLookup();
|
const lookup: UserLookup = new UserLookup();
|
||||||
lookup.page = { size: 100, offset: 0 };
|
lookup.page = { size: 100, offset: 0 };
|
||||||
// if (excludedIds && excludedIds.length > 0) { lookup.excludedIds = excludedIds; }
|
// 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)] };
|
lookup.order = { items: [nameof<User>(x => x.name)] };
|
||||||
if (like) { lookup.like = this.filterService.transformLike(like); }
|
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 {
|
hasValue(): boolean {
|
||||||
|
|
|
@ -37,6 +37,7 @@ import { TranslateService } from '@ngx-translate/core';
|
||||||
import * as FileSaver from 'file-saver';
|
import * as FileSaver from 'file-saver';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil } from 'rxjs/operators';
|
||||||
import { nameof } from 'ts-simple-nameof';
|
import { nameof } from 'ts-simple-nameof';
|
||||||
|
import { DmpInvitationDialogComponent } from '../invitation/dialog/dmp-invitation-dialog.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dmp-overview',
|
selector: 'app-dmp-overview',
|
||||||
|
@ -558,17 +559,16 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
openShareDialog(rowId: any, rowName: any) {
|
openShareDialog(rowId: any, rowName: any) {
|
||||||
//TODO: add this
|
const dialogRef = this.dialog.open(DmpInvitationDialogComponent, {
|
||||||
// const dialogRef = this.dialog.open(DmpInvitationDialogComponent, {
|
// height: '250px',
|
||||||
// // height: '250px',
|
// width: '700px',
|
||||||
// // width: '700px',
|
autoFocus: false,
|
||||||
// autoFocus: false,
|
restoreFocus: false,
|
||||||
// restoreFocus: false,
|
data: {
|
||||||
// data: {
|
dmpId: rowId,
|
||||||
// dmpId: rowId,
|
dmpName: rowName
|
||||||
// dmpName: rowName
|
}
|
||||||
// }
|
});
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
selectDoi(entityDoi: EntityDoi) {
|
selectDoi(entityDoi: EntityDoi) {
|
||||||
|
|
Loading…
Reference in New Issue