import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; import { ActivatedRoute, Params, Router } from '@angular/router'; import { DmpStatus } from '@app/core/common/enum/dmp-status'; import { AuthService } from '@app/core/services/auth/auth.service'; import { DmpService } from '@app/core/services/dmp/dmp.service'; import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; // import {BreadcrumbItem} from '@app/ui/misc/breadcrumb/definition/breadcrumb-item'; import { Location } from '@angular/common'; import { DescriptionStatus } from '@app/core/common/enum/description-status'; import { DmpAccessType } from '@app/core/common/enum/dmp-access-type'; import { DmpUserRole } from '@app/core/common/enum/dmp-user-role'; import { DepositConfiguration } from '@app/core/model/deposit/deposit-configuration'; import { Description } from '@app/core/model/description/description'; import { Dmp, DmpUser, DmpUserRemovePersist } from '@app/core/model/dmp/dmp'; import { DmpReference } from '@app/core/model/dmp/dmp-reference'; import { EntityDoi } from '@app/core/model/entity-doi/entity-doi'; import { Reference } from '@app/core/model/reference/reference'; import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; import { DepositService } from '@app/core/services/deposit/deposit.service'; import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service'; import { FileTransformerService } from '@app/core/services/file-transformer/file-transformer.service'; import { LockService } from '@app/core/services/lock/lock.service'; import { MatomoService } from '@app/core/services/matomo/matomo-service'; import { ReferenceService } from '@app/core/services/reference/reference.service'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; import { FileUtils } from '@app/core/services/utilities/file-utils.service'; import { PopupNotificationDialogComponent } from '@app/library/notification/popup/popup-notification.component'; import { BaseComponent } from '@common/base/base.component'; import { Guid } from '@common/types/guid'; 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'; import { ReferenceTypeService } from '@app/core/services/reference-type/reference-type.service'; import { DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection } from '@app/core/model/dmp-blueprint/dmp-blueprint'; import { CloneDmpDialogComponent } from '../clone-dialog/dmp-clone-dialog.component'; import { NewVersionDmpDialogComponent } from '../new-version-dialog/dmp-new-version-dialog.component'; import { AppPermission } from '@app/core/common/enum/permission.enum'; import { ReferenceType } from '@app/core/model/reference-type/reference-type'; import { IsActive } from '@app/core/common/enum/is-active.enum'; import { DmpFinalizeDialogComponent, DmpFinalizeDialogOutput } from '../dmp-finalize-dialog/dmp-finalize-dialog.component'; import { DmpEditorResolver } from '../dmp-editor-blueprint/dmp-editor.resolver'; @Component({ selector: 'app-dmp-overview', templateUrl: './dmp-overview.component.html', styleUrls: ['./dmp-overview.component.scss'] }) export class DmpOverviewComponent extends BaseComponent implements OnInit { dmp: any; selectedBlueprint: DmpBlueprint; researchers: DmpReference[] = []; isNew = true; isFinalized = false; isPublicView = true; hasPublishButton: boolean = true; // breadCrumbs: Observable = observableOf(); // isUserOwner: boolean; isLocked: Boolean; textMessage: any; pastVersions: Dmp[]; //TODO: get these from the backend selectedModel: EntityDoi; @ViewChild('doi') doi: ElementRef; depositRepos: DepositConfiguration[] = []; descriptionStatusEnum = DescriptionStatus; dmpAccessTypeEnum = DmpAccessType; dmpStatusEnum = DmpStatus; dmpUserRoleEnum = DmpUserRole; constructor( private route: ActivatedRoute, private router: Router, private dmpService: DmpService, private dmpBlueprintService: DmpBlueprintService, private depositRepositoriesService: DepositService, private translate: TranslateService, private authentication: AuthService, private dialog: MatDialog, private language: TranslateService, private uiNotificationService: UiNotificationService, private configurationService: ConfigurationService, private location: Location, private lockService: LockService, private matomoService: MatomoService, private fileUtils: FileUtils, public referenceService: ReferenceService, public enumUtils: EnumUtils, public fileTransformerService: FileTransformerService, private referenceTypeService: ReferenceTypeService ) { super(); } ngOnInit() { this.matomoService.trackPageView('DMP Overview'); // Gets dmp data using parameter id this.route.params .pipe(takeUntil(this._destroyed)) .subscribe((params: Params) => { const itemId = params['id']; const publicId = params['publicId']; if (itemId != null) { this.isNew = false; this.isPublicView = false; this.dmpService.getSingle(itemId, this.lookupFields()) .pipe(takeUntil(this._destroyed)) .subscribe(data => { this.dmp = data; this.dmp.dmpUsers = data.dmpUsers.filter(x => x.isActive === IsActive.Active); if (this.dmp.descriptions) { if (this.dmp.status == DmpStatus.Finalized) { this.dmp.descriptions = data.descriptions.filter(x => x.isActive === IsActive.Active && x.status === DescriptionStatus.Finalized); } else { this.dmp.descriptions = data.descriptions.filter(x => x.isActive === IsActive.Active && x.status !== DescriptionStatus.Canceled); } } this.selectedBlueprint = data.blueprint; this.researchers = this.referenceService.getReferencesForTypes(this.dmp?.dmpReferences, [this.referenceTypeService.getResearcherReferenceType()]); if (!this.hasDoi()) { this.selectedModel = this.dmp.entityDois[0]; } this.checkLockStatus(this.dmp.id); // this.setIsUserOwner(); this.getAllVersions(this.dmp); // const breadCrumbs = []; // breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.MY-DMPS'), url: "/plans" }); // breadCrumbs.push({ parentComponentName: 'DmpListingComponent', label: this.dmp.label, url: '/plans/overview/' + this.dmp.id }); // this.breadCrumbs = observableOf(breadCrumbs); }, (error: any) => { if (error.status === 404) { return this.onFetchingDeletedCallbackError('/plans/'); } if (error.status === 403) { return this.onFetchingForbiddenCallbackError('/plans/'); } }); } else if (publicId != null) { this.isNew = false; this.isFinalized = true; this.isPublicView = true; this.dmpService.getPublicSingle(publicId, this.lookupFields()) .pipe(takeUntil(this._destroyed)) .subscribe(data => { this.dmp = data; this.researchers = this.referenceService.getReferencesForTypes(this.dmp?.dmpReferences, [this.referenceTypeService.getResearcherReferenceType()]); if (!this.hasDoi()) { this.selectedModel = this.dmp.entityDois[0]; } // this.checkLockStatus(this.dmp.id); this.getAllVersions(this.dmp); // const breadCrumbs = []; // breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.PUBLIC-DMPS'), url: "/explore-plans" }); // breadCrumbs.push({ parentComponentName: 'DmpListingComponent', label: this.dmp.label, url: '/plans/overview/public/' + this.dmp.id }); // this.breadCrumbs = observableOf(breadCrumbs); }, (error: any) => { if (error.status === 404) { return this.onFetchingDeletedCallbackError('/explore-plans'); } if (error.status === 403) { return this.onFetchingForbiddenCallbackError('/explore-plans'); } }); } }); if (this.isAuthenticated()) { this.depositRepositoriesService.getAvailableRepos([ nameof(x => x.depositType), nameof(x => x.repositoryId), nameof(x => x.repositoryAuthorizationUrl), nameof(x => x.repositoryRecordUrl), nameof(x => x.repositoryClientId), nameof(x => x.hasLogo), nameof(x => x.redirectUri) ]) .pipe(takeUntil(this._destroyed)) .subscribe( repos => { this.depositRepos = repos; }, error => this.depositRepos = []); } } onFetchingDeletedCallbackError(redirectRoot: string) { this.uiNotificationService.snackBarNotification(this.language.instant('DMP-OVERVIEW.ERROR.DELETED-DMP'), SnackBarNotificationLevel.Error); this.router.navigate([redirectRoot]); } onFetchingForbiddenCallbackError(redirectRoot: string) { this.uiNotificationService.snackBarNotification(this.language.instant('DMP-OVERVIEW.ERROR.FORBIDEN-DMP'), SnackBarNotificationLevel.Error); this.router.navigate([redirectRoot]); } isUserAuthor(userId: Guid): boolean { if (this.isAuthenticated()) { const principalId: Guid = this.authentication.userId(); return userId === principalId; } else return false; } canEditDmp(): boolean{ return (this.isDraftDmp()) && (this.dmp.authorizationFlags?.some(x => x === AppPermission.EditDmp) || this.authentication.hasPermission(AppPermission.EditDmp)) && this.isPublicView == false; } canCreateNewVersion(): boolean { return this.dmp.authorizationFlags?.some(x => x === AppPermission.CreateNewVersionDmp) || this.authentication.hasPermission(AppPermission.CreateNewVersionDmp) && this.isPublicView == false; } canDeleteDmp(): boolean { return this.dmp.authorizationFlags?.some(x => x === AppPermission.DeleteDmp) || this.authentication.hasPermission(AppPermission.DeleteDmp) && this.isPublicView == false; } canCloneDmp(): boolean { return this.dmp.authorizationFlags?.some(x => x === AppPermission.CloneDmp) || this.authentication.hasPermission(AppPermission.CloneDmp); } canFinalizeDmp(): boolean { return this.dmp.authorizationFlags?.some(x => x === AppPermission.FinalizeDmp) || this.authentication.hasPermission(AppPermission.FinalizeDmp) && this.isPublicView == false; } canExportDmp(): boolean { return this.dmp.authorizationFlags?.some(x => x === AppPermission.ExportDmp) || this.authentication.hasPermission(AppPermission.ExportDmp); } canInviteDmpUsers(): boolean { return this.dmp.authorizationFlags?.some(x => x === AppPermission.InviteDmpUsers) || this.authentication.hasPermission(AppPermission.InviteDmpUsers) && this.isPublicView == false; } canAssignDmpUsers(): boolean { return this.dmp.authorizationFlags?.some(x => x === AppPermission.AssignDmpUsers) || this.authentication.hasPermission(AppPermission.AssignDmpUsers) && this.isPublicView == false; } canDepositDmp(): boolean { return this.dmp.authorizationFlags?.some(x => x === AppPermission.DepositDmp) || this.authentication.hasPermission(AppPermission.DepositDmp) && this.isPublicView == false; } editClicked() { this.router.navigate(['/plans/edit/', this.dmp.id]); } cloneClicked() { const dialogRef = this.dialog.open(CloneDmpDialogComponent, { maxWidth: '700px', maxHeight: '80vh', data: { dmp: this.dmp } }); dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe((result: Dmp) => { if (result) { this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); this.router.navigate(['/plans/edit/', result.id]); } }); } newVersionClicked() { const dialogRef = this.dialog.open(NewVersionDmpDialogComponent, { maxWidth: '700px', maxHeight: '80vh', data: { dmp: this.dmp } }); dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe((result: Dmp) => { if (result) { this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); this.router.navigate(['/plans/edit/', result.id]); } }); } // private checkForGrant(blueprint: DmpBlueprintDefinition) { // let hasGrant = false; // blueprint.sections.forEach(section => section.fields.forEach( // field => { // if (field.category as unknown === DmpBlueprintFieldCategory.System && field.systemFieldType === DmpBlueprintSystemFieldType.GRANT) { // hasGrant = true; // } // } // )); // if (!hasGrant) { // this.formGroup.removeControl('grant'); // } // } // private checkForFunder(blueprint: DmpBlueprintDefinition) { // let hasFunder = false; // blueprint.sections.forEach(section => section.fields.forEach( // field => { // if (field.category as unknown === DmpBlueprintFieldCategory.System && field.systemFieldType === DmpBlueprintSystemFieldType.FUNDER) { // hasFunder = true; // } // } // )); // if (!hasFunder) { // this.formGroup.removeControl('funder'); // } // } // private checkForProject(blueprint: DmpBlueprintDefinition) { // let hasProject = false; // blueprint.sections.forEach(section => section.fields.forEach( // field => { // if (field.category as unknown === DmpBlueprintFieldCategory.System && field.systemFieldType === DmpBlueprintSystemFieldType.PROJECT) { // hasProject = true; // } // } // )); // if (!hasProject) { // this.formGroup.removeControl('project'); // } // } // openCloneDialog(isNewVersion: boolean) { // const dialogRef = this.dialog.open(CloneDialogComponent, { // maxWidth: '900px', // maxHeight: '80vh', // data: { // formGroup: this.formGroup, // descriptions: this.dmp.descriptions, // isNewVersion: isNewVersion, // confirmButton: this.language.instant('DMP-EDITOR.CLONE-DIALOG.SAVE'), // cancelButton: this.language.instant('DMP-EDITOR.CLONE-DIALOG.CANCEL'), // } // }); // dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { // if (result) { // if (!isNewVersion) { // this.dmpService.clone(this.formGroup.getRawValue(), this.dmp.id) // .pipe(takeUntil(this._destroyed)) // .subscribe( // complete => this.onCallbackSuccess(complete), // error => this.onCallbackError(error) // ); // } else if (isNewVersion) { // this.dmpService.newVersion(this.formGroup.getRawValue(), this.dmp.id) // .pipe(takeUntil(this._destroyed)) // .subscribe( // complete => this.onCallbackSuccess(complete), // error => this.onCallbackError(error) // ); // } // } // }); // } // onCallbackSuccess(dmpId: String): void { // this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); // this.router.navigate(['/plans/edit/', dmpId]); // } // onCallbackError(error: any) { // this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Error); // } deleteClicked() { const dialogRef = this.dialog.open(ConfirmationDialogComponent, { maxWidth: '300px', data: { message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.DELETE'), cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), isDeleteConfirmation: true } }); dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { if (result) { this.dmpService.delete(this.dmp.id) .pipe(takeUntil(this._destroyed)) .subscribe( complete => { this.onDeleteCallbackSuccess() }, error => this.onDeleteCallbackError(error) ); } }); } onDeleteCallbackSuccess(): void { this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DELETE'), SnackBarNotificationLevel.Success); this.router.navigate(['/plans']); } onDeleteCallbackError(error) { this.uiNotificationService.snackBarNotification(error.error.message ? this.language.instant(error.error.message) : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error); } onUpdateCallbackSuccess(): void { this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); this.reloadPage(); } onUpdateCallbackError(error) { this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('DATASET-UPLOAD.SNACK-BAR.UNSUCCESSFUL'), SnackBarNotificationLevel.Error); } downloadXml(id: string) { // this.dmpService.downloadXML(id) // .pipe(takeUntil(this._destroyed)) // .subscribe(response => { // const blob = new Blob([response.body], { type: 'application/xml' }); // const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); // FileSaver.saveAs(blob, filename); // this.matomoService.trackDownload('dmps', "xml", id); // }); } download(id: string, format: string) { this.dmpService.download(id, format) .pipe(takeUntil(this._destroyed)) .subscribe(response => { const blob = new Blob([response.body], { type: 'application/octet-stream' }); const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); FileSaver.saveAs(blob, filename); this.matomoService.trackDownload('dmps', format, id); }); } downloadPDF(id: string) { this.dmpService.downloadPDF(id) .pipe(takeUntil(this._destroyed)) .subscribe(response => { const blob = new Blob([response.body], { type: 'application/pdf' }); const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); FileSaver.saveAs(blob, filename); this.matomoService.trackDownload('dmps', "pdf", id); }); } downloadJson(id: string) { //TODO: add this // this.dmpService.downloadJson(id) // .pipe(takeUntil(this._destroyed)) // .subscribe(complete => { // const blob = new Blob([complete.body], { type: 'application/json' }); // const filename = this.fileUtils.getFilenameFromContentDispositionHeader(complete.headers.get('Content-Disposition')); // FileSaver.saveAs(blob, filename); // this.matomoService.trackDownload('dmps', "json", id); // }, async error => { // this.onExportCallbackError(error); // }); } // async onExportCallbackError(error: any) { // const errorJsonText = await error.error.text(); // const errorObj = JSON.parse(errorJsonText); // this.uiNotificationService.snackBarNotification(errorObj.message, SnackBarNotificationLevel.Error); // } isUserDmpRelated(): boolean { const principalId: Guid = this.authentication.userId(); return this.dmp.dmpUsers?.some(x => (x.user.id === principalId)); } isDraftDmp() { return this.dmp.status == DmpStatus.Draft; } isFinalizedDmp(dmp: Dmp) { return dmp.status == DmpStatus.Finalized; } isPublishedDmp() { return (this.dmp.status == DmpStatus.Finalized && this.dmp.accessType === DmpAccessType.Public); } hasDoi() { return (this.dmp.entityDois == null || this.dmp.entityDois.length == 0); } getAllVersions(dmp: Dmp) { //TODO: add this // this.dmpService.getAllVersions(dmp.groupId, this.isPublicView) // .pipe(takeUntil(this._destroyed)) // .subscribe(items => { // this.versions = items; // }); } afterDeposit(result: EntityDoi[]) { if (result.length > 0) { this.dmp.entityDois = result; this.selectedModel = this.dmp.entityDois[this.dmp.entityDois.length - 1]; } } get inputRepos() { return this.depositRepos.filter(repo => !this.dmp.entityDois?.find(doi => doi.repositoryId === repo.repositoryId)); } moreDeposit() { return (this.dmp.entityDois.length < this.depositRepos.length); } finalize() { const dialogRef = this.dialog.open(DmpFinalizeDialogComponent, { maxWidth: '500px', restoreFocus: false, autoFocus: false, data: { dmp: this.dmp } }); dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe((result: DmpFinalizeDialogOutput) => { if (result && !result.cancelled) { this.dmpService.finalize(this.dmp.id, result.descriptionsToBeFinalized) .pipe(takeUntil(this._destroyed)) .subscribe(data => { this.reloadPage(); this.onUpdateCallbackSuccess() }, (error: any) => { this.onUpdateCallbackError(error) }); } }); } // private checkIfAnyProfileIsUsedLessThanMin(dmp: Dmp): Observable { // const blueprintId = dmp.profile.id; // return this.dmpBlueprintService.getSingle(Guid.parse(blueprintId)) // .pipe(map(result => { // return result.definition.sections.some(section => { // if (!section.hasTemplates) // return false; // return section.descriptionTemplates.some(template => { // if (!(template.minMultiplicity > 0)) // return false; // let count = 0; // dmp.descriptions.filter(description => description.dmpSectionIndex === (section.ordinal - 1)).forEach(description => { // if (Guid.parse(description.profile.id) === template.descriptionTemplateId) { // count++; // } // }) // if (count < template.minMultiplicity) { // this.dialog.open(PopupNotificationDialogComponent, { // data: { // title: this.language.instant('DMP-OVERVIEW.MIN-DESCRIPTIONS-DIALOG.TITLE', { 'minMultiplicity': template.minMultiplicity }), // message: this.language.instant('DMP-OVERVIEW.MIN-DESCRIPTIONS-DIALOG.MESSAGE',) // }, maxWidth: '30em' // }); // return true; // } // else // return false; // }) // }) // }), takeUntil(this._destroyed)); // } public isAuthenticated(): boolean { return this.authentication.currentAccountIsAuthenticated(); } versionChanged(versionId: string): void { if (this.isPublicView) { this.router.navigate(['/explore-plans/overview/public/' + versionId]); } else { this.router.navigate(['/plans/overview/' + versionId]); } } openShareDialog(rowId: any, rowName: any) { const dialogRef = this.dialog.open(DmpInvitationDialogComponent, { // height: '250px', // width: '700px', autoFocus: false, restoreFocus: false, data: { dmpId: rowId, dmpName: rowName, blueprint: this.selectedBlueprint } }); } selectDoi(entityDoi: EntityDoi) { this.selectedModel = entityDoi; const foundIdx = this.dmp.entityDois.findIndex(el => el.id == entityDoi.id); this.dmp.entityDois.splice(foundIdx, 1); this.dmp.entityDois.unshift(entityDoi); } // createDoiLink(doiModel: DoiModel): string { createDoiLink(doiModel: any): string { //TODO: needs rewriting const repository = this.depositRepos.find(r => r.repositoryId == doiModel.repositoryId); if (typeof repository !== "undefined") { if (doiModel.repositoryId == "Zenodo") { const doiarr = doiModel.doi.split('.'); const id = doiarr[doiarr.length - 1]; return repository.repositoryRecordUrl + id; } else { return repository.repositoryRecordUrl + doiModel.doi; } } else { return ""; } } reverseFinalization() { const dialogRef = this.dialog.open(ConfirmationDialogComponent, { restoreFocus: false, data: { message: this.language.instant('DMP-OVERVIEW.UNDO-FINALIZATION-DIALOG.TITLE'), confirmButton: this.language.instant('DMP-OVERVIEW.UNDO-FINALIZATION-DIALOG.CONFIRM'), cancelButton: this.language.instant('DMP-OVERVIEW.UNDO-FINALIZATION-DIALOG.NEGATIVE'), isDeleteConfirmation: false } }); dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { if (result) { this.dmpService.undoFinalize(this.dmp.id, DmpEditorResolver.lookupFields()).pipe(takeUntil(this._destroyed)) .subscribe(data => { this.reloadPage(); this.onUpdateCallbackSuccess() }, (error: any) => { this.onUpdateCallbackError(error) }); } }); } goBack(): void { this.location.back(); } reloadPage(): void { const path = this.location.path(); this.router.navigateByUrl('/reload', { skipLocationChange: true }).then(() => { this.router.navigate([path]); }); } // updateUsers() { // return this.dmpService.updateUsers(this.dmp.id, this.dmp.users).pipe(takeUntil(this._destroyed)) // .subscribe( // complete => { // this.onUpdateCallbackSuccess(); // }, // error => this.onUpdateCallbackError(error) // ); // } removeUserFromDmp(dmpUser: DmpUser) { const dialogRef = this.dialog.open(ConfirmationDialogComponent, { data: { message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-USER'), confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.REMOVE'), cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), isDeleteConfirmation: false } }); dialogRef.afterClosed().subscribe(result => { if (result) { const dmpUserRemovePersist: DmpUserRemovePersist = { id: dmpUser.id, dmpId: this.dmp.id, role: dmpUser.role }; this.dmpService.removeUser(dmpUserRemovePersist).pipe(takeUntil(this._destroyed)) .subscribe(data => { this.reloadPage(); this.onUpdateCallbackSuccess() }, (error: any) => { this.onUpdateCallbackError(error) }); } }); } copyDoi(doi) { const el = document.createElement('textarea'); el.value = doi; el.setAttribute('readonly', ''); el.style.position = 'absolute'; el.style.left = '-9999px'; document.body.appendChild(el); el.select(); document.execCommand('copy'); document.body.removeChild(el); this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-COPY-TO-CLIPBOARD'), SnackBarNotificationLevel.Success); } public getOrcidPath(): string { return this.configurationService.orcidPath; } isOrcid(reference: Reference) { return reference.source === 'orcid'; } getOrcidPathForResearcher(reference: string): string { const path = this.getOrcidPath(); return path + reference; } checkLockStatus(id: Guid) { this.lockService.checkLockStatus(Guid.parse(id.toString())).pipe(takeUntil(this._destroyed)) .subscribe(lockStatus => { this.isLocked = lockStatus.status; if (this.isLocked) { this.dialog.open(PopupNotificationDialogComponent, { data: { title: this.language.instant('DMP-OVERVIEW.LOCKED-DIALOG.TITLE'), message: this.language.instant('DMP-OVERVIEW.LOCKED-DIALOG.MESSAGE') }, maxWidth: '30em' }); } }); } private lookupFields(): string[] { return [ nameof(x => x.id), nameof(x => x.label), nameof(x => x.description), nameof(x => x.status), nameof(x => x.accessType), nameof(x => x.version), nameof(x => x.groupId), nameof(x => x.version), nameof(x => x.updatedAt), nameof(x => x.entityDois), [nameof(x => x.authorizationFlags), AppPermission.CreateNewVersionDmp].join('.'), [nameof(x => x.authorizationFlags), AppPermission.DeleteDmp].join('.'), [nameof(x => x.authorizationFlags), AppPermission.CloneDmp].join('.'), [nameof(x => x.authorizationFlags), AppPermission.FinalizeDmp].join('.'), [nameof(x => x.authorizationFlags), AppPermission.ExportDmp].join('.'), [nameof(x => x.authorizationFlags), AppPermission.InviteDmpUsers].join('.'), [nameof(x => x.authorizationFlags), AppPermission.AssignDmpUsers].join('.'), [nameof(x => x.authorizationFlags), AppPermission.EditDmp].join('.'), [nameof(x => x.authorizationFlags), AppPermission.DepositDmp].join('.'), [nameof(x => x.entityDois), nameof(x => x.id)].join('.'), [nameof(x => x.entityDois), nameof(x => x.repositoryId)].join('.'), [nameof(x => x.entityDois), nameof(x => x.doi)].join('.'), [nameof(x => x.descriptions), nameof(x => x.id)].join('.'), [nameof(x => x.descriptions), nameof(x => x.label)].join('.'), [nameof(x => x.descriptions), nameof(x => x.status)].join('.'), [nameof(x => x.descriptions), nameof(x => x.isActive)].join('.'), [nameof(x => x.dmpUsers), nameof(x => x.id)].join('.'), [nameof(x => x.dmpUsers), nameof(x => x.user.id)].join('.'), [nameof(x => x.dmpUsers), nameof(x => x.user.name)].join('.'), [nameof(x => x.dmpUsers), nameof(x => x.role)].join('.'), [nameof(x => x.dmpUsers), nameof(x => x.dmp.id)].join('.'), [nameof(x => x.dmpUsers), nameof(x => x.isActive)].join('.'), [nameof(x => x.dmpReferences), nameof(x => x.id)].join('.'), [nameof(x => x.dmpReferences), nameof(x => x.reference), nameof(x => x.id)].join('.'), [nameof(x => x.dmpReferences), nameof(x => x.reference), nameof(x => x.label)].join('.'), [nameof(x => x.dmpReferences), nameof(x => x.reference), nameof(x => x.type), nameof(x => x.id)].join('.'), [nameof(x => x.dmpReferences), nameof(x => x.reference), nameof(x => x.source)].join('.'), [nameof(x => x.dmpReferences), nameof(x => x.reference), nameof(x => x.reference)].join('.'), [nameof(x => x.dmpReferences), nameof(x => x.isActive)].join('.'), [nameof(x => x.blueprint), nameof(x => x.id)].join('.'), [nameof(x => x.blueprint), nameof(x => x.definition)].join('.'), [nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.id)].join('.'), [nameof(x => x.blueprint), nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.label)].join('.'), nameof(x => x.hash), ] } }