2019-09-23 10:17:03 +02:00
|
|
|
|
2020-07-02 17:29:33 +02:00
|
|
|
import { Component, OnInit, Input, ViewChild, ElementRef } from '@angular/core';
|
2019-09-20 17:27:54 +02:00
|
|
|
import { MatDialog } from '@angular/material/dialog';
|
2019-07-01 11:35:09 +02:00
|
|
|
import { ActivatedRoute, Params, Router } from '@angular/router';
|
2019-12-11 15:51:03 +01:00
|
|
|
import { DatasetStatus } from '@app/core/common/enum/dataset-status';
|
|
|
|
import { DmpStatus } from '@app/core/common/enum/dmp-status';
|
2020-04-27 15:21:03 +02:00
|
|
|
import { Principal } from '@app/core/model/auth/principal';
|
2019-12-11 15:51:03 +01:00
|
|
|
import { DatasetOverviewModel } from '@app/core/model/dataset/dataset-overview';
|
|
|
|
import { DatasetsToBeFinalized } from '@app/core/model/dataset/datasets-toBeFinalized';
|
|
|
|
import { DmpOverviewModel } from '@app/core/model/dmp/dmp-overview';
|
|
|
|
import { UserInfoListingModel } from '@app/core/model/user/user-info-listing';
|
|
|
|
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';
|
2019-12-19 11:10:16 +01:00
|
|
|
import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component';
|
2019-12-11 15:51:03 +01:00
|
|
|
import { DmpFinalizeDialogComponent, DmpFinalizeDialogInput, DmpFinalizeDialogOutput } from '@app/ui/dmp/editor/dmp-finalize-dialog/dmp-finalize-dialog.component';
|
|
|
|
import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item';
|
|
|
|
import { BaseComponent } from '@common/base/base.component';
|
2019-05-21 15:42:28 +02:00
|
|
|
import { TranslateService } from '@ngx-translate/core';
|
2019-07-01 11:35:09 +02:00
|
|
|
import * as FileSaver from 'file-saver';
|
2020-07-02 17:29:33 +02:00
|
|
|
import { Observable, of as observableOf, interval } from 'rxjs';
|
2020-09-03 11:52:35 +02:00
|
|
|
import { takeUntil, map } from 'rxjs/operators';
|
2019-12-18 15:28:48 +01:00
|
|
|
import { Role } from "@app/core/common/enum/role";
|
2020-07-20 15:57:57 +02:00
|
|
|
import { DmpInvitationDialogComponent } from '../invitation/dmp-invitation-dialog.component';
|
2020-04-06 17:16:05 +02:00
|
|
|
import { MultipleChoiceDialogModule } from '@common/modules/multiple-choice-dialog/multiple-choice-dialog.module';
|
|
|
|
import { MultipleChoiceDialogComponent } from '@common/modules/multiple-choice-dialog/multiple-choice-dialog.component';
|
2020-04-08 15:36:06 +02:00
|
|
|
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
|
|
|
|
import { Oauth2DialogComponent } from '@app/ui/misc/oauth2-dialog/oauth2-dialog.component';
|
|
|
|
import { Oauth2DialogService } from '@app/ui/misc/oauth2-dialog/service/oauth2-dialog.service';
|
|
|
|
import { isNullOrUndefined } from 'util';
|
|
|
|
import { UserService } from '@app/core/services/user/user.service';
|
2020-06-30 17:33:01 +02:00
|
|
|
import { Location } from '@angular/common';
|
2020-09-03 11:52:35 +02:00
|
|
|
import { FormGroup, FormArray, FormControl } from '@angular/forms';
|
2020-07-01 17:32:22 +02:00
|
|
|
import { LockService } from '@app/core/services/lock/lock.service';
|
2020-07-02 17:29:33 +02:00
|
|
|
import { ReturnStatement, ConditionalExpr } from '@angular/compiler';
|
2020-07-01 17:32:22 +02:00
|
|
|
import { LockModel } from '@app/core/model/lock/lock.model';
|
2020-07-02 17:29:33 +02:00
|
|
|
import { Guid } from '@common/types/guid';
|
2020-07-09 13:28:55 +02:00
|
|
|
import { VersionListingModel } from '@app/core/model/version/version-listing.model';
|
2020-09-03 11:52:35 +02:00
|
|
|
import { CloneDialogComponent } from '../clone/clone-dialog/clone-dialog.component';
|
|
|
|
import { DmpModel } from '@app/core/model/dmp/dmp';
|
|
|
|
import { DmpEditorModel } from '../editor/dmp-editor.model';
|
|
|
|
import { FunderFormModel } from '../editor/grant-tab/funder-form-model';
|
|
|
|
import { ProjectFormModel } from '../editor/grant-tab/project-form-model';
|
|
|
|
import { GrantTabModel } from '../editor/grant-tab/grant-tab-model';
|
|
|
|
import { ExtraPropertiesFormModel } from '../editor/general-tab/extra-properties-form.model';
|
2020-09-18 13:14:48 +02:00
|
|
|
import { DatasetWizardEditorModel } from '@app/ui/dataset/dataset-wizard/dataset-wizard-editor.model';
|
|
|
|
import { StartNewDatasetDialogComponent } from '../start-new-dataset-dialogue/start-new-dataset-dialog.component';
|
|
|
|
import { StartNewDmpDialogComponent } from '../start-new-dmp-dialogue/start-new-dmp-dialog.component';
|
2019-05-21 15:42:28 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-dmp-overview',
|
|
|
|
templateUrl: './dmp-overview.component.html',
|
|
|
|
styleUrls: ['./dmp-overview.component.scss']
|
|
|
|
})
|
|
|
|
export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
|
|
|
|
|
|
|
dmp: DmpOverviewModel;
|
2020-09-03 11:52:35 +02:00
|
|
|
dmpModel: DmpEditorModel;
|
2019-05-21 15:42:28 +02:00
|
|
|
isNew = true;
|
2019-07-01 11:35:09 +02:00
|
|
|
isFinalized = false;
|
2019-07-18 16:16:12 +02:00
|
|
|
isPublicView = true;
|
2019-07-01 11:35:09 +02:00
|
|
|
hasPublishButton: boolean = true;
|
2019-09-23 10:17:03 +02:00
|
|
|
breadCrumbs: Observable<BreadcrumbItem[]> = observableOf();
|
2019-12-18 15:28:48 +01:00
|
|
|
isUserOwner: boolean;
|
2020-03-03 10:20:27 +01:00
|
|
|
expand = false;
|
2020-04-10 16:16:37 +02:00
|
|
|
hasDOIToken = false;
|
2020-07-01 17:32:22 +02:00
|
|
|
lockStatus: Boolean;
|
2020-07-02 17:29:33 +02:00
|
|
|
textMessage: any;
|
2020-07-09 13:28:55 +02:00
|
|
|
versions: VersionListingModel[];
|
2020-07-09 17:31:51 +02:00
|
|
|
version: VersionListingModel;
|
2020-10-27 11:31:45 +01:00
|
|
|
private oauthLock: boolean;
|
2020-07-02 17:29:33 +02:00
|
|
|
|
|
|
|
@ViewChild('doi', { static: false })
|
|
|
|
doi: ElementRef;
|
2020-07-01 17:32:22 +02:00
|
|
|
|
2020-09-03 11:52:35 +02:00
|
|
|
formGroup: FormGroup;
|
2019-05-21 15:42:28 +02:00
|
|
|
|
|
|
|
constructor(
|
|
|
|
private route: ActivatedRoute,
|
|
|
|
private router: Router,
|
|
|
|
private dmpService: DmpService,
|
|
|
|
private translate: TranslateService,
|
|
|
|
private authentication: AuthService,
|
|
|
|
private dialog: MatDialog,
|
|
|
|
private language: TranslateService,
|
2020-04-08 15:36:06 +02:00
|
|
|
private uiNotificationService: UiNotificationService,
|
|
|
|
private configurationService: ConfigurationService,
|
|
|
|
private oauth2DialogService: Oauth2DialogService,
|
2020-06-30 17:33:01 +02:00
|
|
|
private userService: UserService,
|
2020-07-01 17:32:22 +02:00
|
|
|
private location: Location,
|
|
|
|
private lockService: LockService
|
2019-05-21 15:42:28 +02:00
|
|
|
) {
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
// Gets dmp data using parameter id
|
|
|
|
this.route.params
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe((params: Params) => {
|
|
|
|
const itemId = params['id'];
|
2019-06-11 10:25:32 +02:00
|
|
|
const publicId = params['publicId'];
|
2019-05-21 15:42:28 +02:00
|
|
|
if (itemId != null) {
|
|
|
|
this.isNew = false;
|
2019-07-18 16:16:12 +02:00
|
|
|
this.isPublicView = false;
|
2019-05-21 15:42:28 +02:00
|
|
|
this.dmpService.getOverviewSingle(itemId)
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(data => {
|
|
|
|
this.dmp = data;
|
2020-07-02 17:29:33 +02:00
|
|
|
this.checkLockStatus(this.dmp.id);
|
2020-02-18 17:41:56 +01:00
|
|
|
this.setIsUserOwner();
|
2020-07-09 13:28:55 +02:00
|
|
|
this.getAllVersions(this.dmp);
|
2019-05-23 15:00:11 +02:00
|
|
|
const breadCrumbs = [];
|
2019-06-07 13:03:10 +02:00
|
|
|
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 });
|
2019-09-23 10:17:03 +02:00
|
|
|
this.breadCrumbs = observableOf(breadCrumbs);
|
2020-01-16 16:14:50 +01:00
|
|
|
}, (error: any) => {
|
|
|
|
if (error.status === 404) {
|
|
|
|
return this.onFetchingDeletedCallbackError('/plans/');
|
|
|
|
}
|
2020-02-26 12:36:42 +01:00
|
|
|
if (error.status === 403) {
|
|
|
|
return this.onFetchingForbiddenCallbackError('/plans/');
|
|
|
|
}
|
2020-01-16 16:14:50 +01:00
|
|
|
});
|
2019-05-21 15:42:28 +02:00
|
|
|
}
|
2019-06-11 10:25:32 +02:00
|
|
|
else if (publicId != null) {
|
|
|
|
this.isNew = false;
|
2019-07-01 11:35:09 +02:00
|
|
|
this.isFinalized = true;
|
2019-07-18 16:16:12 +02:00
|
|
|
this.isPublicView = true;
|
2019-06-11 10:25:32 +02:00
|
|
|
this.dmpService.getOverviewSinglePublic(publicId)
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(data => {
|
|
|
|
this.dmp = data;
|
2020-08-03 10:40:38 +02:00
|
|
|
// this.checkLockStatus(this.dmp.id);
|
2020-07-09 13:28:55 +02:00
|
|
|
this.getAllVersions(this.dmp);
|
2019-06-11 10:25:32 +02:00
|
|
|
const breadCrumbs = [];
|
2019-07-18 16:26:53 +02:00
|
|
|
breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.PUBLIC-DMPS'), url: "/explore-plans" });
|
2019-06-11 10:25:32 +02:00
|
|
|
breadCrumbs.push({ parentComponentName: 'DmpListingComponent', label: this.dmp.label, url: '/plans/publicOverview/' + this.dmp.id });
|
2019-09-23 10:17:03 +02:00
|
|
|
this.breadCrumbs = observableOf(breadCrumbs);
|
2020-01-16 16:14:50 +01:00
|
|
|
}, (error: any) => {
|
|
|
|
if (error.status === 404) {
|
2020-04-22 17:40:43 +02:00
|
|
|
return this.onFetchingDeletedCallbackError('/explore-plans');
|
2020-01-16 16:14:50 +01:00
|
|
|
}
|
2020-02-26 12:36:42 +01:00
|
|
|
if (error.status === 403) {
|
2020-04-22 17:40:43 +02:00
|
|
|
return this.onFetchingForbiddenCallbackError('/explore-plans');
|
2020-02-26 12:36:42 +01:00
|
|
|
}
|
2019-06-11 10:25:32 +02:00
|
|
|
});
|
|
|
|
}
|
2019-05-21 15:42:28 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-01-16 16:14:50 +01:00
|
|
|
onFetchingDeletedCallbackError(redirectRoot: string) {
|
|
|
|
this.uiNotificationService.snackBarNotification(this.language.instant('DMP-OVERVIEW.ERROR.DELETED-DMP'), SnackBarNotificationLevel.Error);
|
|
|
|
this.router.navigate([redirectRoot]);
|
|
|
|
}
|
|
|
|
|
2020-02-26 12:36:42 +01:00
|
|
|
onFetchingForbiddenCallbackError(redirectRoot: string) {
|
|
|
|
this.uiNotificationService.snackBarNotification(this.language.instant('DMP-OVERVIEW.ERROR.FORBIDEN-DMP'), SnackBarNotificationLevel.Error);
|
|
|
|
this.router.navigate([redirectRoot]);
|
|
|
|
}
|
|
|
|
|
2020-02-18 17:41:56 +01:00
|
|
|
setIsUserOwner() {
|
2019-12-18 15:28:48 +01:00
|
|
|
if (this.dmp) {
|
|
|
|
const principal: Principal = this.authentication.current();
|
2020-02-18 17:41:56 +01:00
|
|
|
if (principal) this.isUserOwner = principal.id === this.dmp.users.find(x => x.role === Role.Owner).id;
|
2019-12-18 15:28:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-02 17:29:33 +02:00
|
|
|
isUserAuthor(userId: string): boolean {
|
2020-08-03 10:40:38 +02:00
|
|
|
if (this.isAuthenticated()) {
|
|
|
|
const principal: Principal = this.authentication.current();
|
|
|
|
return userId === principal.id;
|
|
|
|
} else return false;
|
2020-07-02 17:29:33 +02:00
|
|
|
}
|
|
|
|
|
2019-05-21 15:42:28 +02:00
|
|
|
editClicked(dmp: DmpOverviewModel) {
|
2020-09-23 17:30:00 +02:00
|
|
|
this.router.navigate(['/plans/edit/', dmp.id]);
|
|
|
|
// let url = this.router.createUrlTree(['/plans/edit/', dmp.id]);
|
|
|
|
// window.open(url.toString(), '_blank');
|
2019-05-21 15:42:28 +02:00
|
|
|
}
|
|
|
|
|
2020-09-03 17:49:45 +02:00
|
|
|
cloneOrNewVersionClicked(dmp: DmpOverviewModel, isNewVersion: boolean) {
|
2020-09-03 11:52:35 +02:00
|
|
|
this.dmpService.getSingle(this.dmp.id).pipe(map(data => data as DmpModel))
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(data => {
|
|
|
|
this.dmpModel = new DmpEditorModel();
|
|
|
|
this.dmpModel.grant = new GrantTabModel();
|
|
|
|
this.dmpModel.project = new ProjectFormModel();
|
|
|
|
this.dmpModel.funder = new FunderFormModel();
|
|
|
|
this.dmpModel.extraProperties = new ExtraPropertiesFormModel();
|
|
|
|
this.dmpModel.fromModel(data);
|
|
|
|
this.dmpModel.status = DmpStatus.Draft;
|
|
|
|
this.formGroup = this.dmpModel.buildForm();
|
2020-09-03 17:49:45 +02:00
|
|
|
if (!isNewVersion) {
|
|
|
|
this.formGroup.get('label').setValue(this.dmp.label + " New");
|
|
|
|
}
|
|
|
|
this.openCloneDialog(isNewVersion);
|
2020-09-03 11:52:35 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-09-03 17:49:45 +02:00
|
|
|
openCloneDialog(isNewVersion: boolean) {
|
2020-09-03 11:52:35 +02:00
|
|
|
const dialogRef = this.dialog.open(CloneDialogComponent, {
|
2020-09-03 17:49:45 +02:00
|
|
|
maxWidth: '900px',
|
|
|
|
maxHeight: '80vh',
|
2020-09-03 11:52:35 +02:00
|
|
|
data: {
|
|
|
|
formGroup: this.formGroup,
|
|
|
|
datasets: this.dmp.datasets,
|
2020-09-03 17:49:45 +02:00
|
|
|
isNewVersion: isNewVersion,
|
|
|
|
confirmButton: this.language.instant('DMP-EDITOR.CLONE-DIALOG.SAVE'),
|
2020-09-03 11:52:35 +02:00
|
|
|
cancelButton: this.language.instant('DMP-EDITOR.CLONE-DIALOG.CANCEL'),
|
|
|
|
}
|
|
|
|
});
|
|
|
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
|
|
|
if (result) {
|
2020-09-03 17:49:45 +02:00
|
|
|
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)
|
|
|
|
);
|
|
|
|
}
|
2020-09-03 11:52:35 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-09-03 17:49:45 +02:00
|
|
|
onCallbackSuccess(dmpId: String): void {
|
2020-09-03 11:52:35 +02:00
|
|
|
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
|
2020-09-03 17:49:45 +02:00
|
|
|
this.router.navigate(['/plans/edit/', dmpId]);
|
2020-09-03 11:52:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
onCallbackError(error: any) {
|
2020-09-03 17:49:45 +02:00
|
|
|
this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Error);
|
2019-05-21 15:42:28 +02:00
|
|
|
}
|
|
|
|
|
2019-10-04 10:53:30 +02:00
|
|
|
grantClicked(grantId: String) {
|
|
|
|
// ----------- UNCOMMENT TO ADD AGAIN GRANTS --------
|
|
|
|
// this.router.navigate(['/grants/edit/' + grantId]);
|
|
|
|
}
|
2019-05-21 15:42:28 +02:00
|
|
|
|
2020-03-03 10:20:27 +01:00
|
|
|
expandDesc() {
|
|
|
|
this.expand = !this.expand;
|
|
|
|
}
|
|
|
|
|
2020-04-10 16:16:37 +02:00
|
|
|
checkOverflow(element) {
|
2020-03-03 10:20:27 +01:00
|
|
|
if (this.expand || (element.offsetHeight < element.scrollHeight ||
|
|
|
|
element.offsetWidth < element.scrollWidth)) {
|
2020-04-10 16:16:37 +02:00
|
|
|
return true;
|
2020-03-03 10:20:27 +01:00
|
|
|
} else {
|
2020-04-10 16:16:37 +02:00
|
|
|
return false;
|
2020-03-03 10:20:27 +01:00
|
|
|
}
|
2020-04-10 16:16:37 +02:00
|
|
|
}
|
2020-03-03 10:20:27 +01:00
|
|
|
|
2019-05-21 15:42:28 +02:00
|
|
|
datasetClicked(datasetId: String) {
|
2020-07-06 12:21:11 +02:00
|
|
|
// if (this.isPublicView) {
|
|
|
|
// this.router.navigate(['/datasets/publicEdit/' + datasetId]);
|
|
|
|
// } else {
|
|
|
|
// this.router.navigate(['/datasets/edit/' + datasetId]);
|
|
|
|
// }
|
|
|
|
this.router.navigate(['/datasets/overview/' + datasetId]);
|
2019-05-21 15:42:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
datasetsClicked(dmpId: String) {
|
2019-07-01 11:35:09 +02:00
|
|
|
if (!this.isFinalized)
|
2019-07-18 16:16:12 +02:00
|
|
|
this.router.navigate(['/plans/edit/' + dmpId], { queryParams: { tab: "datasetDescriptions" } });
|
2019-06-11 10:25:32 +02:00
|
|
|
else
|
|
|
|
this.router.navigate(['/explore'], { queryParams: { dmpId: dmpId } });
|
2019-05-21 15:42:28 +02:00
|
|
|
}
|
|
|
|
|
2019-05-22 11:52:53 +02:00
|
|
|
goToUri(uri: string) {
|
2019-05-21 15:42:28 +02:00
|
|
|
window.open(uri, "_blank");
|
|
|
|
}
|
|
|
|
|
|
|
|
deleteClicked() {
|
|
|
|
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
|
|
|
maxWidth: '300px',
|
|
|
|
data: {
|
|
|
|
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'),
|
2019-05-22 15:36:24 +02:00
|
|
|
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.DELETE'),
|
2019-06-26 11:24:06 +02:00
|
|
|
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'),
|
|
|
|
isDeleteConfirmation: true
|
2019-05-21 15:42:28 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
|
|
|
if (result) {
|
|
|
|
this.dmpService.delete(this.dmp.id)
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(
|
2020-07-20 11:16:23 +02:00
|
|
|
complete => { this.onDeleteCallbackSuccess() },
|
2019-09-20 17:27:54 +02:00
|
|
|
error => this.onDeleteCallbackError(error)
|
2019-05-21 15:42:28 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-07-20 11:16:23 +02:00
|
|
|
onDeleteCallbackSuccess(): void {
|
2020-07-22 13:26:49 +02:00
|
|
|
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DELETE'), SnackBarNotificationLevel.Success);
|
2019-05-21 15:42:28 +02:00
|
|
|
this.router.navigate(['/plans']);
|
|
|
|
}
|
|
|
|
|
|
|
|
onDeleteCallbackError(error) {
|
|
|
|
this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error);
|
|
|
|
}
|
|
|
|
|
2020-07-20 11:16:23 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2019-05-21 15:42:28 +02:00
|
|
|
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.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
|
|
|
|
|
|
|
|
FileSaver.saveAs(blob, filename);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
downloadDocx(id: string) {
|
|
|
|
this.dmpService.downloadDocx(id)
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(response => {
|
|
|
|
const blob = new Blob([response.body], { type: 'application/msword' });
|
|
|
|
const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
|
|
|
|
|
|
|
|
FileSaver.saveAs(blob, filename);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
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.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
|
|
|
|
|
|
|
|
FileSaver.saveAs(blob, filename);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-06-04 16:55:23 +02:00
|
|
|
downloadJson(id: string) {
|
|
|
|
this.dmpService.downloadJson(id)
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
2020-09-24 11:37:03 +02:00
|
|
|
.subscribe(complete => {
|
|
|
|
const blob = new Blob([complete.body], { type: 'application/json' });
|
|
|
|
const filename = this.getFilenameFromContentDispositionHeader(complete.headers.get('Content-Disposition'));
|
2019-06-04 16:55:23 +02:00
|
|
|
FileSaver.saveAs(blob, filename);
|
2020-09-24 11:37:03 +02:00
|
|
|
}, 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);
|
2019-06-04 16:55:23 +02:00
|
|
|
}
|
|
|
|
|
2019-05-21 15:42:28 +02:00
|
|
|
getFilenameFromContentDispositionHeader(header: string): string {
|
|
|
|
const regex: RegExp = new RegExp(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/g);
|
|
|
|
|
|
|
|
const matches = header.match(regex);
|
|
|
|
let filename: string;
|
|
|
|
for (let i = 0; i < matches.length; i++) {
|
|
|
|
const match = matches[i];
|
|
|
|
if (match.includes('filename="')) {
|
|
|
|
filename = match.substring(10, match.length - 1);
|
|
|
|
break;
|
|
|
|
} else if (match.includes('filename=')) {
|
|
|
|
filename = match.substring(9);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return filename;
|
|
|
|
}
|
|
|
|
|
2019-12-19 11:10:16 +01:00
|
|
|
roleDisplayFromList(value: UserInfoListingModel[]) {
|
2019-05-21 15:42:28 +02:00
|
|
|
const principal: Principal = this.authentication.current();
|
|
|
|
let role: number;
|
|
|
|
if (principal) {
|
|
|
|
value.forEach(element => {
|
|
|
|
if (principal.id === element.id) {
|
|
|
|
role = element.role;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-02-18 17:41:56 +01:00
|
|
|
if (role === Role.Owner) {
|
|
|
|
return this.translate.instant('DMP-LISTING.OWNER');
|
|
|
|
} else if (role === Role.Member) {
|
|
|
|
return this.translate.instant('DMP-LISTING.MEMBER');
|
|
|
|
} else {
|
|
|
|
return this.translate.instant('DMP-LISTING.OWNER');
|
2019-05-21 15:42:28 +02:00
|
|
|
}
|
2019-12-19 11:10:16 +01:00
|
|
|
}
|
|
|
|
|
2020-01-07 17:15:07 +01:00
|
|
|
isUserDMPRelated() {
|
|
|
|
const principal: Principal = this.authentication.current();
|
|
|
|
let isRelated: boolean = false;
|
|
|
|
if (this.dmp && principal) {
|
|
|
|
this.dmp.users.forEach(element => {
|
|
|
|
if (element.id === principal.id) {
|
|
|
|
isRelated = true;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
return isRelated;
|
|
|
|
}
|
|
|
|
|
2019-12-19 11:10:16 +01:00
|
|
|
roleDisplay(value: UserInfoListingModel) {
|
2020-02-18 17:41:56 +01:00
|
|
|
if (value.role === Role.Owner) {
|
|
|
|
return this.translate.instant('DMP-LISTING.OWNER');
|
|
|
|
} else if (value.role === Role.Member) {
|
|
|
|
return this.translate.instant('DMP-LISTING.MEMBER');
|
|
|
|
} else {
|
|
|
|
return this.translate.instant('DMP-LISTING.OWNER');
|
2019-05-21 15:42:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-01 11:35:09 +02:00
|
|
|
isDraftDataset(dataset: DatasetOverviewModel) {
|
|
|
|
return dataset.status == DatasetStatus.Draft;
|
|
|
|
}
|
|
|
|
|
|
|
|
isDraftDmp(dmp: DmpOverviewModel) {
|
|
|
|
return dmp.status == DmpStatus.Draft;
|
|
|
|
}
|
|
|
|
|
|
|
|
isFinalizedDmp(dmp: DmpOverviewModel) {
|
|
|
|
return dmp.status == DmpStatus.Finalized;
|
|
|
|
}
|
|
|
|
|
2019-07-18 16:16:12 +02:00
|
|
|
isPublishedDMP(dmp: DmpOverviewModel) {
|
|
|
|
return (dmp.status == DmpStatus.Finalized && dmp.isPublic);
|
|
|
|
}
|
|
|
|
|
2019-07-05 13:01:24 +02:00
|
|
|
hasDoi(dmp: DmpOverviewModel) {
|
|
|
|
return dmp.doi == null ? true : false;
|
|
|
|
}
|
|
|
|
|
2020-04-08 15:36:06 +02:00
|
|
|
getAccessUrl(): string {
|
|
|
|
const redirectUri = this.configurationService.app + 'oauth2';
|
|
|
|
const url = this.configurationService.loginProviders.zenodoConfiguration.oauthUrl
|
2020-04-10 16:16:37 +02:00
|
|
|
+ '?client_id=' + this.configurationService.loginProviders.zenodoConfiguration.clientId
|
|
|
|
+ '&response_type=code&scope=deposit:write+deposit:actions+user:email&state=astate&redirect_uri='
|
|
|
|
+ redirectUri;
|
2020-04-08 15:36:06 +02:00
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
2019-07-05 13:01:24 +02:00
|
|
|
getDoi(dmp: DmpOverviewModel) {
|
2020-04-08 15:36:06 +02:00
|
|
|
this.userService.hasDOIToken().subscribe(response => {
|
2020-04-10 16:16:37 +02:00
|
|
|
this.hasDOIToken = true;
|
2020-04-06 17:16:05 +02:00
|
|
|
this.showConfirmationDOIDialog(dmp);
|
|
|
|
}, error => {
|
2020-04-10 16:16:37 +02:00
|
|
|
this.hasDOIToken = false;
|
2020-04-06 17:16:05 +02:00
|
|
|
this.showErrorConfirmationDOIDialog(error.error.message, dmp);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-07-09 13:28:55 +02:00
|
|
|
getAllVersions(dmp: DmpOverviewModel) {
|
2020-10-12 11:45:32 +02:00
|
|
|
this.dmpService.getAllVersions(dmp.groupId, this.isPublicView)
|
2020-07-09 13:28:55 +02:00
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(items => {
|
|
|
|
this.versions = items;
|
|
|
|
});
|
|
|
|
}
|
2020-04-10 16:16:37 +02:00
|
|
|
|
2020-04-06 17:16:05 +02:00
|
|
|
showConfirmationDOIDialog(dmp: DmpOverviewModel) {
|
2019-07-05 13:01:24 +02:00
|
|
|
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
|
|
|
maxWidth: '600px',
|
2019-09-27 10:09:29 +02:00
|
|
|
restoreFocus: false,
|
2019-07-05 13:01:24 +02:00
|
|
|
data: {
|
2020-04-27 15:21:03 +02:00
|
|
|
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ZENODO-DOI', { 'username': this.hasDOIToken ? this.authentication.current().zenodoEmail : 'default' }),
|
2019-07-05 13:01:24 +02:00
|
|
|
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'),
|
|
|
|
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'),
|
|
|
|
}
|
|
|
|
});
|
|
|
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
|
|
|
if (result) {
|
|
|
|
this.dmpService.getDoi(dmp.id)
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(
|
2019-09-20 17:27:54 +02:00
|
|
|
complete => {
|
|
|
|
this.onDOICallbackSuccess();
|
|
|
|
this.dmp.doi = complete;
|
|
|
|
},
|
|
|
|
error => this.onDeleteCallbackError(error)
|
2019-07-05 13:01:24 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-04-06 17:16:05 +02:00
|
|
|
showErrorConfirmationDOIDialog(message: string, dmp: DmpOverviewModel) {
|
|
|
|
const dialogRef = this.dialog.open(MultipleChoiceDialogComponent, {
|
|
|
|
maxWidth: '600px',
|
|
|
|
restoreFocus: false,
|
|
|
|
data: {
|
|
|
|
message: message,
|
2020-04-10 16:16:37 +02:00
|
|
|
titles: [this.language.instant('DMP-OVERVIEW.MULTIPLE-DIALOG.ZENODO-LOGIN'), this.language.instant('DMP-OVERVIEW.MULTIPLE-DIALOG.USE-DEFAULT')]
|
2020-04-06 17:16:05 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
|
|
|
switch (result) {
|
|
|
|
case 0:
|
2020-04-08 15:36:06 +02:00
|
|
|
// this.authentication.logout();
|
|
|
|
// this.router.navigate(['/login/external/zenodo']);
|
|
|
|
this.showOauth2Dialog(this.getAccessUrl(), dmp);
|
2020-04-06 17:16:05 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
this.showConfirmationDOIDialog(dmp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-04-08 15:36:06 +02:00
|
|
|
showOauth2Dialog(url: string, dmp: DmpOverviewModel) {
|
|
|
|
this.oauth2DialogService.login(url)
|
2020-04-10 16:16:37 +02:00
|
|
|
.pipe(takeUntil(this._destroyed))
|
2020-10-26 17:18:26 +01:00
|
|
|
.subscribe(result => {
|
2020-10-27 11:04:57 +01:00
|
|
|
if (result !== undefined) {
|
2020-10-27 11:31:45 +01:00
|
|
|
if (result.oauthCode !== undefined && result.oauthCode !== null && !this.oauthLock) {
|
2020-10-27 11:04:57 +01:00
|
|
|
this.userService.registerDOIToken(result.oauthCode, this.configurationService.app + 'oauth2')
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(() => {
|
|
|
|
this.hasDOIToken = true;
|
|
|
|
this.showConfirmationDOIDialog(dmp);
|
|
|
|
});
|
2020-10-27 11:31:45 +01:00
|
|
|
this.oauthLock = true;
|
2020-10-27 11:04:57 +01:00
|
|
|
}
|
2020-10-27 11:31:45 +01:00
|
|
|
} else {
|
|
|
|
this.oauthLock = false;
|
2020-04-10 16:16:37 +02:00
|
|
|
}
|
|
|
|
});
|
2020-04-08 15:36:06 +02:00
|
|
|
}
|
|
|
|
|
2019-07-05 13:01:24 +02:00
|
|
|
onDOICallbackSuccess(): void {
|
|
|
|
this.uiNotificationService.snackBarNotification(this.language.instant('DMP-EDITOR.SNACK-BAR.SUCCESSFUL-DOI'), SnackBarNotificationLevel.Success);
|
|
|
|
}
|
|
|
|
|
|
|
|
onDOICallbackError(error) {
|
|
|
|
this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('DMP-EDITOR.SNACK-BAR.UNSUCCESSFUL-DOI'), SnackBarNotificationLevel.Error);
|
|
|
|
}
|
|
|
|
|
2019-07-01 11:35:09 +02:00
|
|
|
showPublishButton(dmp: DmpOverviewModel) {
|
|
|
|
return this.isFinalizedDmp(dmp) && !dmp.isPublic && this.hasPublishButton;
|
|
|
|
}
|
|
|
|
|
|
|
|
publish(dmpId: String) {
|
2019-09-20 17:27:54 +02:00
|
|
|
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
2019-11-06 15:30:15 +01:00
|
|
|
maxWidth: '500px',
|
2019-09-27 10:09:29 +02:00
|
|
|
restoreFocus: false,
|
2019-09-20 17:27:54 +02:00
|
|
|
data: {
|
|
|
|
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.PUBLISH-ITEM'),
|
2019-10-09 10:45:47 +02:00
|
|
|
privacyPolicyNames: this.language.instant('GENERAL.CONFIRMATION-DIALOG.PRIVACY-POLICY-NAMES'),
|
2019-09-20 17:27:54 +02:00
|
|
|
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'),
|
|
|
|
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'),
|
|
|
|
isDeleteConfirmation: false
|
|
|
|
}
|
|
|
|
});
|
|
|
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
|
|
|
if (result) {
|
|
|
|
this.dmpService.publish(dmpId)
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
2020-07-20 11:16:23 +02:00
|
|
|
.subscribe(() => {
|
2020-07-15 17:18:16 +02:00
|
|
|
this.hasPublishButton = false;
|
|
|
|
this.reloadPage();
|
|
|
|
});
|
2019-09-20 17:27:54 +02:00
|
|
|
}
|
|
|
|
});
|
2019-07-01 11:35:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
finalize(dmp: DmpOverviewModel) {
|
|
|
|
|
|
|
|
const dialogInputModel: DmpFinalizeDialogInput = {
|
|
|
|
dmpLabel: this.dmp.label,
|
|
|
|
dmpDescription: this.dmp.description,
|
|
|
|
datasets: this.dmp.datasets.map(x => {
|
|
|
|
return { label: x.label, id: x.id, status: x.status }
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
const dialogRef = this.dialog.open(DmpFinalizeDialogComponent, {
|
|
|
|
maxWidth: '500px',
|
2019-09-27 10:09:29 +02:00
|
|
|
restoreFocus: false,
|
2019-07-01 11:35:09 +02:00
|
|
|
data: {
|
|
|
|
dialogInputModel: dialogInputModel,
|
|
|
|
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.FINALIZE-ITEM'),
|
|
|
|
confirmButton: this.language.instant('DMP-FINALISE-DIALOG.SUBMIT'),
|
|
|
|
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'),
|
|
|
|
}
|
|
|
|
});
|
|
|
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe((result: DmpFinalizeDialogOutput) => {
|
|
|
|
if (result && !result.cancelled) {
|
|
|
|
var datasetsToBeFinalized: DatasetsToBeFinalized = {
|
|
|
|
uuids: result.datasetsToBeFinalized
|
|
|
|
};
|
|
|
|
this.dmpService.finalize(datasetsToBeFinalized, this.dmp.id)
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(
|
2019-09-20 17:27:54 +02:00
|
|
|
complete => {
|
|
|
|
this.dmp.status = DmpStatus.Finalized;
|
2020-07-20 11:16:23 +02:00
|
|
|
this.onUpdateCallbackSuccess();
|
2019-09-20 17:27:54 +02:00
|
|
|
},
|
2020-07-20 11:16:23 +02:00
|
|
|
error => this.onUpdateCallbackError(error)
|
2019-07-01 11:35:09 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
2019-05-21 15:42:28 +02:00
|
|
|
}
|
2019-07-05 14:57:28 +02:00
|
|
|
|
2020-09-03 17:49:45 +02:00
|
|
|
// newVersion(id: String, label: String) {
|
|
|
|
// let url = this.router.createUrlTree(['/plans/new_version/', id, { dmpLabel: label }])
|
|
|
|
// window.open(url.toString(), '_blank')
|
|
|
|
// }
|
2019-07-18 12:17:34 +02:00
|
|
|
|
|
|
|
viewVersions(rowId: String, rowLabel: String) {
|
2020-10-12 11:45:32 +02:00
|
|
|
if (this.isPublicView) {
|
2020-01-10 11:44:00 +01:00
|
|
|
this.router.navigate(['/explore-plans/versions/' + rowId], { queryParams: { groupLabel: rowLabel } });
|
|
|
|
} else {
|
|
|
|
this.router.navigate(['/plans/versions/' + rowId], { queryParams: { groupLabel: rowLabel } });
|
|
|
|
}
|
2019-07-18 12:17:34 +02:00
|
|
|
}
|
2019-09-25 11:44:22 +02:00
|
|
|
|
2020-01-07 17:15:07 +01:00
|
|
|
public isAuthenticated(): boolean {
|
|
|
|
return !(!this.authentication.current());
|
|
|
|
}
|
|
|
|
|
2020-07-09 17:31:51 +02:00
|
|
|
versionChanged(versionId: string): void {
|
2020-10-12 11:45:32 +02:00
|
|
|
if (this.isPublicView) {
|
|
|
|
this.router.navigate(['/explore-plans/publicOverview/' + versionId]);
|
|
|
|
} else {
|
|
|
|
this.router.navigate(['/plans/overview/' + versionId]);
|
|
|
|
}
|
2020-07-09 17:31:51 +02:00
|
|
|
}
|
|
|
|
|
2020-02-14 17:14:48 +01:00
|
|
|
openShareDialog(rowId: any, rowName: any) {
|
|
|
|
const dialogRef = this.dialog.open(DmpInvitationDialogComponent, {
|
|
|
|
// height: '250px',
|
|
|
|
// width: '700px',
|
|
|
|
restoreFocus: false,
|
|
|
|
data: {
|
|
|
|
dmpId: rowId,
|
|
|
|
dmpName: rowName
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-09-18 13:14:48 +02:00
|
|
|
openNewDmpDialog() {
|
|
|
|
if (this.dialog.openDialogs.length > 0) {
|
|
|
|
this.dialog.closeAll();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
const dialogRef = this.dialog.open(StartNewDmpDialogComponent, {
|
|
|
|
disableClose: false,
|
|
|
|
data: {
|
|
|
|
isDialog: true
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// addDataset(rowId: String) {
|
|
|
|
// this.router.navigate(['/datasets/new/' + rowId]);
|
|
|
|
// }
|
|
|
|
|
|
|
|
addNewDataset() {
|
2020-09-24 11:02:51 +02:00
|
|
|
this.router.navigate(['/datasets', 'new', this.dmp.id]);
|
2020-02-25 17:36:43 +01:00
|
|
|
}
|
|
|
|
|
2020-05-07 09:57:20 +02:00
|
|
|
createDoiLink(doi: string): string {
|
|
|
|
const doiarr = doi.split('.');
|
|
|
|
const id = doiarr[doiarr.length - 1];
|
|
|
|
return this.configurationService.doiLink + id;
|
|
|
|
}
|
|
|
|
|
2020-05-26 13:31:47 +02:00
|
|
|
reverse() {
|
2020-07-20 11:16:23 +02:00
|
|
|
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
|
|
|
restoreFocus: false,
|
|
|
|
data: {
|
|
|
|
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.UNFINALIZE-ITEM'),
|
|
|
|
confirmButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.AFFIRMATIVE'),
|
|
|
|
cancelButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.NEGATIVE'),
|
|
|
|
isDeleteConfirmation: false
|
|
|
|
}
|
|
|
|
});
|
|
|
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
|
|
|
if (result) {
|
|
|
|
this.dmpService.unfinalize(this.dmp.id).pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(
|
|
|
|
complete => {
|
|
|
|
this.dmp.status = DmpStatus.Draft;
|
|
|
|
this.onUpdateCallbackSuccess()
|
|
|
|
},
|
|
|
|
error => this.onUpdateCallbackError(error)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
2020-05-26 13:31:47 +02:00
|
|
|
}
|
|
|
|
|
2020-06-30 17:33:01 +02:00
|
|
|
goBack(): void {
|
|
|
|
this.location.back();
|
2020-07-01 17:32:22 +02:00
|
|
|
}
|
|
|
|
|
2020-07-09 15:01:49 +02:00
|
|
|
reloadPage(): void {
|
2020-07-22 13:26:49 +02:00
|
|
|
const path = this.location.path();
|
2020-07-22 10:19:25 +02:00
|
|
|
this.router.navigateByUrl('/reload', { skipLocationChange: true }).then(() => {
|
2020-07-22 13:26:49 +02:00
|
|
|
this.router.navigate([path]);
|
2020-07-09 15:01:49 +02:00
|
|
|
});
|
2020-07-10 17:28:10 +02:00
|
|
|
}
|
2020-07-09 15:01:49 +02:00
|
|
|
|
2020-07-09 09:17:49 +02:00
|
|
|
updateUsers() {
|
|
|
|
return this.dmpService.updateUsers(this.dmp.id, this.dmp.users).pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(
|
2020-07-09 15:01:49 +02:00
|
|
|
complete => {
|
2020-07-20 11:16:23 +02:00
|
|
|
this.onUpdateCallbackSuccess();
|
2020-07-10 17:28:10 +02:00
|
|
|
},
|
2020-07-20 11:16:23 +02:00
|
|
|
error => this.onUpdateCallbackError(error)
|
2020-07-09 09:17:49 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
removeUserFromDmp(user: UserInfoListingModel) {
|
|
|
|
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) {
|
2020-07-09 13:28:55 +02:00
|
|
|
const list = this.dmp.users;
|
2020-07-09 09:17:49 +02:00
|
|
|
const index = this.dmp.users.indexOf(user);
|
|
|
|
if (index > -1) {
|
|
|
|
this.dmp.users.splice(index, 1);
|
|
|
|
}
|
|
|
|
this.updateUsers();
|
|
|
|
}
|
|
|
|
});
|
2020-07-01 17:32:22 +02:00
|
|
|
}
|
2020-07-07 17:30:25 +02:00
|
|
|
|
2020-07-02 17:29:33 +02:00
|
|
|
copyDoi(doi) {
|
|
|
|
let domElement = doi.nativeElement as HTMLInputElement;
|
|
|
|
domElement.select();
|
|
|
|
document.execCommand('copy');
|
|
|
|
domElement.setSelectionRange(0, 0);
|
2020-10-27 11:00:02 +01:00
|
|
|
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-COPY-TO-CLIPBOARD'), SnackBarNotificationLevel.Success);
|
2020-07-02 17:29:33 +02:00
|
|
|
}
|
2020-07-07 17:30:25 +02:00
|
|
|
|
2020-07-02 17:29:33 +02:00
|
|
|
public getOrcidPath(): string {
|
|
|
|
return this.configurationService.orcidPath;
|
|
|
|
}
|
2020-07-01 17:32:22 +02:00
|
|
|
|
2020-09-25 16:49:19 +02:00
|
|
|
isOrcid(reference: string) {
|
|
|
|
const head = reference.split(':')[0];
|
|
|
|
return head === 'orcid';
|
|
|
|
}
|
|
|
|
|
2020-07-10 17:28:10 +02:00
|
|
|
getOrcidPathForResearcher(reference: string): string {
|
|
|
|
const path = this.getOrcidPath();
|
|
|
|
const userId = reference.split(':')[1];
|
|
|
|
return path + userId;
|
|
|
|
}
|
|
|
|
|
2020-07-07 17:30:25 +02:00
|
|
|
checkLockStatus(id: string) {
|
2020-07-02 17:29:33 +02:00
|
|
|
this.lockService.checkLockStatus(id).pipe(takeUntil(this._destroyed))
|
2020-07-07 17:30:25 +02:00
|
|
|
.subscribe(lockStatus => this.lockStatus = lockStatus);
|
2020-07-01 17:32:22 +02:00
|
|
|
}
|
|
|
|
|
2020-07-02 17:29:33 +02:00
|
|
|
getUserFromDMP(): any {
|
|
|
|
if (this.dmp) {
|
|
|
|
const principal: Principal = this.authentication.current();
|
|
|
|
return this.dmp.users.find(x => x.id === principal.id);
|
|
|
|
}
|
2020-07-01 17:32:22 +02:00
|
|
|
}
|
2020-06-30 17:33:01 +02:00
|
|
|
|
2020-07-09 13:28:55 +02:00
|
|
|
|
2020-07-09 09:17:49 +02:00
|
|
|
|
2020-07-07 17:30:25 +02:00
|
|
|
|
2019-09-25 11:44:22 +02:00
|
|
|
// advancedClicked() {
|
|
|
|
// const dialogRef = this.dialog.open(ExportMethodDialogComponent, {
|
|
|
|
// maxWidth: '500px',
|
|
|
|
// data: {
|
|
|
|
// message: "Download as:",
|
|
|
|
// XMLButton: "XML",
|
|
|
|
// documentButton: "Document",
|
|
|
|
// pdfButton: "PDF",
|
|
|
|
// jsonButton: "JSON"
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
|
|
|
// if (result == "pdf") {
|
|
|
|
// this.downloadPDF(this.dmp.id);
|
|
|
|
// } else if (result == "xml") {
|
|
|
|
// this.downloadXml(this.dmp.id);
|
|
|
|
// } else if (result == "doc") {
|
|
|
|
// this.downloadDocx(this.dmp.id);
|
|
|
|
// } else if (result == "json") {
|
|
|
|
// this.downloadJson(this.dmp.id);
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
|
|
|
|
// advancedClickedFinalized() {
|
|
|
|
// const dialogRef = this.dialog.open(ExportMethodDialogComponent, {
|
|
|
|
// maxWidth: '250px',
|
|
|
|
// data: {
|
|
|
|
// message: "Download as:",
|
|
|
|
// documentButton: "Document",
|
|
|
|
// pdfButton: "PDF",
|
|
|
|
// isFinalized: true
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
|
|
|
// if (result == "pdf") {
|
|
|
|
// this.downloadPDF(this.dmp.id);
|
|
|
|
// } else if (result == "doc") {
|
|
|
|
// this.downloadDocx(this.dmp.id);
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
|
2020-07-02 17:29:33 +02:00
|
|
|
|
2019-05-21 15:42:28 +02:00
|
|
|
}
|