2020-07-03 15:58:13 +02:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
|
|
|
import { BaseComponent } from '@common/base/base.component';
|
|
|
|
import { DatasetOverviewModel } from '@app/core/model/dataset/dataset-overview';
|
|
|
|
import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item';
|
2020-07-24 16:40:53 +02:00
|
|
|
import { Observable, of as observableOf } from 'rxjs';
|
2020-07-03 15:58:13 +02:00
|
|
|
import { ActivatedRoute, Router, Params } from '@angular/router';
|
|
|
|
import { DatasetService } from '@app/core/services/dataset/dataset.service';
|
|
|
|
import { TranslateService } from '@ngx-translate/core';
|
|
|
|
import { AuthService } from '@app/core/services/auth/auth.service';
|
|
|
|
import { MatDialog } from '@angular/material';
|
|
|
|
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
|
|
|
|
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
|
|
|
|
import { Oauth2DialogService } from '@app/ui/misc/oauth2-dialog/service/oauth2-dialog.service';
|
|
|
|
import { UserService } from '@app/core/services/user/user.service';
|
|
|
|
import { takeUntil } from 'rxjs/operators';
|
|
|
|
import { Principal } from '@app/core/model/auth/principal';
|
|
|
|
import { Role } from '@app/core/common/enum/role';
|
|
|
|
import { Location } from '@angular/common';
|
|
|
|
import { UserInfoListingModel } from '@app/core/model/user/user-info-listing';
|
|
|
|
import { DatasetStatus } from '@app/core/common/enum/dataset-status';
|
|
|
|
import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component';
|
2020-07-06 12:21:11 +02:00
|
|
|
import * as FileSaver from 'file-saver';
|
2020-07-20 15:57:57 +02:00
|
|
|
import { DmpInvitationDialogComponent } from '@app/ui/dmp/invitation/dmp-invitation-dialog.component';
|
2020-07-06 12:21:11 +02:00
|
|
|
import { DatasetWizardEditorModel } from '../dataset-wizard/dataset-wizard-editor.model';
|
|
|
|
import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-wizard.service';
|
|
|
|
import { FormControl } from '@angular/forms';
|
|
|
|
import { DatasetCopyDialogueComponent } from '../dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component';
|
2020-07-06 17:42:54 +02:00
|
|
|
import { DmpService } from '@app/core/services/dmp/dmp.service';
|
|
|
|
import { ResearcherModel } from '@app/core/model/researcher/researcher';
|
|
|
|
import { LockService } from '@app/core/services/lock/lock.service';
|
2020-07-15 17:18:16 +02:00
|
|
|
import { DatasetsToBeFinalized } from '@app/core/model/dataset/datasets-toBeFinalized';
|
|
|
|
import { DatasetModel } from '@app/core/model/dataset/dataset';
|
|
|
|
import { DatasetWizardModel } from '@app/core/model/dataset/dataset-wizard';
|
2020-07-20 11:16:23 +02:00
|
|
|
import { DmpStatus } from '@app/core/common/enum/dmp-status';
|
2020-07-03 15:58:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-dataset-overview',
|
|
|
|
templateUrl: './dataset-overview.component.html',
|
|
|
|
styleUrls: ['./dataset-overview.component.scss']
|
|
|
|
})
|
|
|
|
export class DatasetOverviewComponent extends BaseComponent implements OnInit {
|
|
|
|
|
|
|
|
dataset: DatasetOverviewModel;
|
2020-07-15 17:18:16 +02:00
|
|
|
datasetWizardEditorModel: DatasetWizardEditorModel;
|
|
|
|
datasetWizardModel: DatasetWizardModel;
|
2020-07-03 15:58:13 +02:00
|
|
|
isNew = true;
|
|
|
|
isFinalized = false;
|
|
|
|
isPublicView = true;
|
|
|
|
hasPublishButton: boolean = true;
|
|
|
|
breadCrumbs: Observable<BreadcrumbItem[]> = observableOf();
|
|
|
|
isUserOwner: boolean;
|
|
|
|
expand = false;
|
|
|
|
hasDOIToken = false;
|
2020-07-06 17:42:54 +02:00
|
|
|
researchers: ResearcherModel[];
|
2020-07-09 09:17:49 +02:00
|
|
|
users: UserInfoListingModel[];
|
2020-07-09 15:01:49 +02:00
|
|
|
lockStatus: Boolean;
|
2020-07-03 15:58:13 +02:00
|
|
|
|
|
|
|
constructor(
|
|
|
|
private route: ActivatedRoute,
|
|
|
|
private router: Router,
|
|
|
|
private datasetService: DatasetService,
|
|
|
|
private translate: TranslateService,
|
|
|
|
private authentication: AuthService,
|
|
|
|
private dialog: MatDialog,
|
|
|
|
private language: TranslateService,
|
|
|
|
private uiNotificationService: UiNotificationService,
|
|
|
|
private configurationService: ConfigurationService,
|
|
|
|
private oauth2DialogService: Oauth2DialogService,
|
|
|
|
private userService: UserService,
|
2020-07-06 17:42:54 +02:00
|
|
|
private dmpService: DmpService,
|
2020-07-06 12:21:11 +02:00
|
|
|
private location: Location,
|
2020-07-06 17:42:54 +02:00
|
|
|
private datasetWizardService: DatasetWizardService,
|
|
|
|
private lockService: LockService
|
2020-07-03 15:58:13 +02:00
|
|
|
) {
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
// Gets dataset 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.datasetService.getOverviewSingle(itemId)
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(data => {
|
|
|
|
this.dataset = data;
|
2020-07-06 17:42:54 +02:00
|
|
|
this.getDmpResearchers();
|
2020-07-09 09:17:49 +02:00
|
|
|
this.getDmpUsers();
|
2020-07-15 17:18:16 +02:00
|
|
|
this.getDatasetWizardModel(this.dataset.id);
|
2020-07-09 15:01:49 +02:00
|
|
|
this.checkLockStatus(this.dataset.id);
|
2020-07-03 15:58:13 +02:00
|
|
|
this.setIsUserOwner();
|
|
|
|
const breadCrumbs = [];
|
|
|
|
breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS'), url: "/datasets" });
|
|
|
|
breadCrumbs.push({ parentComponentName: 'DatasetListingComponent', label: this.dataset.label, url: '/datasets/overview/' + this.dataset.id });
|
|
|
|
this.breadCrumbs = observableOf(breadCrumbs);
|
|
|
|
}, (error: any) => {
|
|
|
|
if (error.status === 404) {
|
|
|
|
return this.onFetchingDeletedCallbackError('/datasets/');
|
|
|
|
}
|
|
|
|
if (error.status === 403) {
|
|
|
|
return this.onFetchingForbiddenCallbackError('/datasets/');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else if (publicId != null) {
|
|
|
|
this.isNew = false;
|
|
|
|
this.isFinalized = true;
|
|
|
|
this.isPublicView = true;
|
|
|
|
this.datasetService.getOverviewSinglePublic(publicId)
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(data => {
|
|
|
|
this.dataset = data;
|
2020-07-06 17:42:54 +02:00
|
|
|
this.getDmpResearchers();
|
2020-07-09 09:17:49 +02:00
|
|
|
this.getDmpUsers();
|
2020-07-15 17:18:16 +02:00
|
|
|
this.getDatasetWizardModel(this.dataset.id);
|
2020-07-09 15:01:49 +02:00
|
|
|
this.checkLockStatus(this.dataset.id);
|
2020-07-03 15:58:13 +02:00
|
|
|
this.setIsUserOwner();
|
|
|
|
const breadCrumbs = [];
|
|
|
|
breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.PUBLIC DATASETS'), url: "/explore" });
|
|
|
|
breadCrumbs.push({ parentComponentName: 'DatasetListingComponent', label: this.dataset.label, url: '/datasets/publicOverview/' + this.dataset.id });
|
|
|
|
this.breadCrumbs = observableOf(breadCrumbs);
|
|
|
|
}, (error: any) => {
|
|
|
|
if (error.status === 404) {
|
|
|
|
return this.onFetchingDeletedCallbackError('/explore');
|
|
|
|
}
|
|
|
|
if (error.status === 403) {
|
|
|
|
return this.onFetchingForbiddenCallbackError('/explore');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-07-15 17:18:16 +02:00
|
|
|
getDatasetWizardModel(id: string) {
|
2020-07-22 10:21:03 +02:00
|
|
|
this.datasetWizardService.getSingle(id)
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
2020-07-15 17:18:16 +02:00
|
|
|
.subscribe(data => {
|
|
|
|
this.datasetWizardEditorModel = new DatasetWizardEditorModel().fromModel(data);
|
|
|
|
this.datasetWizardModel = data;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-07-09 09:17:49 +02:00
|
|
|
checkLockStatus(id: string) {
|
|
|
|
this.lockService.checkLockStatus(id).pipe(takeUntil(this._destroyed))
|
2020-07-24 16:40:53 +02:00
|
|
|
.subscribe(lockStatus => this.lockStatus = lockStatus);
|
2020-07-09 09:17:49 +02:00
|
|
|
}
|
2020-07-03 15:58:13 +02:00
|
|
|
|
2020-07-06 17:42:54 +02:00
|
|
|
onFetchingDeletedCallbackError(redirectRoot: string) {
|
|
|
|
this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-OVERVIEW.ERROR.DELETED-DATASET'), SnackBarNotificationLevel.Error);
|
|
|
|
this.router.navigate([redirectRoot]);
|
|
|
|
}
|
|
|
|
|
|
|
|
onFetchingForbiddenCallbackError(redirectRoot: string) {
|
|
|
|
this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-OVERVIEW.ERROR.FORBIDEN-DATASET'), SnackBarNotificationLevel.Error);
|
|
|
|
this.router.navigate([redirectRoot]);
|
2020-07-03 15:58:13 +02:00
|
|
|
}
|
2020-07-06 17:42:54 +02:00
|
|
|
|
2020-07-03 15:58:13 +02:00
|
|
|
goBack(): void {
|
2020-07-06 17:42:54 +02:00
|
|
|
this.location.back();
|
|
|
|
}
|
|
|
|
|
2020-07-09 15:01:49 +02:00
|
|
|
reloadPage(): void {
|
2020-07-24 16:40:53 +02:00
|
|
|
const path = this.location.path();
|
|
|
|
this.router.navigateByUrl('/reload', { skipLocationChange: true }).then(() => this.router.navigate([path]));
|
|
|
|
}
|
2020-07-09 09:17:49 +02:00
|
|
|
|
2020-07-06 17:42:54 +02:00
|
|
|
getDmpResearchers() {
|
|
|
|
this.dmpService.getSingle(this.dataset.dmp.id).pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(data => {
|
|
|
|
this.researchers = data.researchers;
|
|
|
|
});
|
|
|
|
}
|
2020-07-03 15:58:13 +02:00
|
|
|
|
2020-07-09 09:17:49 +02:00
|
|
|
getDmpUsers() {
|
|
|
|
this.dmpService.getSingle(this.dataset.dmp.id).pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(data => {
|
|
|
|
this.users = data.users;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-07-03 15:58:13 +02:00
|
|
|
setIsUserOwner() {
|
2020-07-06 17:42:54 +02:00
|
|
|
if (this.dataset) {
|
|
|
|
const principal: Principal = this.authentication.current();
|
|
|
|
if (principal) this.isUserOwner = principal.id === this.dataset.users.find(x => x.role === Role.Owner).id;
|
|
|
|
}
|
2020-07-03 15:58:13 +02:00
|
|
|
}
|
2020-07-06 17:42:54 +02:00
|
|
|
|
2020-07-06 12:21:11 +02:00
|
|
|
isUserAuthor(userId: string): boolean {
|
2020-07-06 17:42:54 +02:00
|
|
|
const principal: Principal = this.authentication.current();
|
|
|
|
return userId === principal.id;
|
2020-07-06 12:21:11 +02:00
|
|
|
}
|
2020-07-06 17:42:54 +02:00
|
|
|
|
2020-07-03 15:58:13 +02:00
|
|
|
isUserDatasetRelated() {
|
2020-07-06 17:42:54 +02:00
|
|
|
const principal: Principal = this.authentication.current();
|
|
|
|
let isRelated: boolean = false;
|
|
|
|
if (this.dataset && principal) {
|
|
|
|
this.dataset.users.forEach(element => {
|
|
|
|
if (element.id === principal.id) {
|
|
|
|
isRelated = true;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
return isRelated;
|
2020-07-03 15:58:13 +02:00
|
|
|
}
|
2020-07-06 12:21:11 +02:00
|
|
|
|
|
|
|
roleDisplay(value: UserInfoListingModel) {
|
2020-07-06 17:42:54 +02: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');
|
|
|
|
}
|
2020-07-06 12:21:11 +02:00
|
|
|
}
|
|
|
|
|
2020-07-06 17:42:54 +02:00
|
|
|
|
2020-07-03 15:58:13 +02:00
|
|
|
roleDisplayFromList(value: UserInfoListingModel[]) {
|
2020-07-06 17:42:54 +02:00
|
|
|
const principal: Principal = this.authentication.current();
|
|
|
|
let role: number;
|
|
|
|
if (principal) {
|
|
|
|
value.forEach(element => {
|
|
|
|
if (principal.id === element.id) {
|
|
|
|
role = element.role;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
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');
|
|
|
|
}
|
2020-07-03 15:58:13 +02:00
|
|
|
}
|
2020-07-06 12:21:11 +02:00
|
|
|
|
|
|
|
openShareDialog(rowId: any, rowName: any) {
|
2020-07-06 17:42:54 +02:00
|
|
|
const dialogRef = this.dialog.open(DmpInvitationDialogComponent, {
|
|
|
|
restoreFocus: false,
|
|
|
|
data: {
|
|
|
|
dmpId: rowId,
|
|
|
|
dmpName: rowName
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-07-03 15:58:13 +02:00
|
|
|
public isAuthenticated(): boolean {
|
2020-07-06 17:42:54 +02:00
|
|
|
return !(!this.authentication.current());
|
2020-07-03 15:58:13 +02:00
|
|
|
}
|
2020-07-06 17:42:54 +02:00
|
|
|
|
2020-07-03 15:58:13 +02:00
|
|
|
isDraftDataset(dataset: DatasetOverviewModel) {
|
2020-07-06 17:42:54 +02:00
|
|
|
return dataset.status == DatasetStatus.Draft;
|
2020-07-03 15:58:13 +02:00
|
|
|
}
|
2020-07-06 12:21:11 +02:00
|
|
|
|
|
|
|
isFinalizedDataset(dataset: DatasetOverviewModel) {
|
2020-07-06 17:42:54 +02:00
|
|
|
return dataset.status == DatasetStatus.Finalized;
|
|
|
|
}
|
|
|
|
|
2020-07-03 15:58:13 +02:00
|
|
|
editClicked(dataset: DatasetOverviewModel) {
|
2020-07-06 12:21:11 +02:00
|
|
|
if (dataset.public) {
|
2020-07-22 10:21:03 +02:00
|
|
|
let url = this.router.createUrlTree(['/datasets/publicEdit/', dataset.id])
|
2020-07-24 16:40:53 +02:00
|
|
|
window.open(url.toString(), '_blank')
|
2020-07-06 17:42:54 +02:00
|
|
|
} else {
|
2020-07-22 10:21:03 +02:00
|
|
|
let url = this.router.createUrlTree(['/datasets/edit/', dataset.id])
|
2020-07-24 16:40:53 +02:00
|
|
|
window.open(url.toString(), '_blank')
|
2020-07-06 17:42:54 +02:00
|
|
|
}
|
2020-07-03 15:58:13 +02:00
|
|
|
}
|
2020-07-06 17:42:54 +02:00
|
|
|
|
2020-07-03 15:58:13 +02:00
|
|
|
deleteClicked() {
|
2020-07-06 17:42:54 +02:00
|
|
|
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.datasetService.delete(this.dataset.id)
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(
|
2020-07-09 09:17:49 +02:00
|
|
|
complete => {
|
2020-07-15 17:18:16 +02:00
|
|
|
this.onDeleteCallbackSuccess();
|
2020-07-09 09:17:49 +02:00
|
|
|
},
|
2020-07-06 17:42:54 +02:00
|
|
|
error => this.onDeleteCallbackError(error)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
2020-07-03 15:58:13 +02:00
|
|
|
}
|
2020-07-06 12:21:11 +02:00
|
|
|
|
|
|
|
dmpClicked(dmpId: String) {
|
2020-07-06 17:42:54 +02:00
|
|
|
this.router.navigate(['/plans/overview/' + dmpId]);
|
|
|
|
}
|
|
|
|
|
2020-07-15 17:18:16 +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);
|
2020-07-15 17:18:16 +02:00
|
|
|
this.router.navigate(['/datasets']);
|
|
|
|
}
|
|
|
|
|
2020-07-20 11:16:23 +02:00
|
|
|
onDeleteCallbackError(error) {
|
|
|
|
this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error);
|
|
|
|
}
|
|
|
|
|
2020-07-15 17:18:16 +02:00
|
|
|
onUpdateCallbackSuccess(): void {
|
|
|
|
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
|
|
|
|
this.reloadPage();
|
2020-07-06 17:42:54 +02:00
|
|
|
}
|
2020-07-03 15:58:13 +02:00
|
|
|
|
2020-07-15 17:18:16 +02:00
|
|
|
onUpdateCallbackError(error) {
|
|
|
|
this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('DATASET-UPLOAD.SNACK-BAR.UNSUCCESSFUL'), SnackBarNotificationLevel.Error);
|
|
|
|
}
|
|
|
|
|
2020-07-03 15:58:13 +02:00
|
|
|
public getOrcidPath(): string {
|
2020-07-06 17:42:54 +02:00
|
|
|
return this.configurationService.orcidPath;
|
2020-07-03 17:31:35 +02:00
|
|
|
}
|
2020-07-06 12:21:11 +02:00
|
|
|
|
2020-07-10 17:28:10 +02:00
|
|
|
getOrcidPathForResearcher(reference: string): string {
|
2020-07-15 17:18:16 +02:00
|
|
|
const path = this.getOrcidPath();
|
|
|
|
const userId = reference.split(':')[1];
|
|
|
|
return path + userId;
|
|
|
|
}
|
2020-07-10 17:28:10 +02:00
|
|
|
|
2020-07-06 12:21:11 +02:00
|
|
|
downloadPDF(id: string) {
|
2020-07-06 17:42:54 +02:00
|
|
|
this.datasetService.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);
|
|
|
|
});
|
2020-07-06 12:21:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
downloadDocx(id: string) {
|
2020-07-06 17:42:54 +02:00
|
|
|
this.datasetService.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);
|
|
|
|
});
|
2020-07-06 12:21:11 +02:00
|
|
|
}
|
2020-07-06 17:42:54 +02:00
|
|
|
|
2020-07-06 12:21:11 +02:00
|
|
|
downloadXml(id: string) {
|
2020-07-06 17:42:54 +02:00
|
|
|
this.datasetService.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);
|
|
|
|
});
|
2020-07-06 12:21:11 +02:00
|
|
|
}
|
2020-07-06 17:42:54 +02:00
|
|
|
|
2020-07-15 11:35:22 +02:00
|
|
|
//GK: NO
|
2020-07-20 11:16:23 +02:00
|
|
|
// downloadJson(id: string) {
|
|
|
|
// this.datasetService.downloadJson(id)
|
|
|
|
// .pipe(takeUntil(this._destroyed))
|
|
|
|
// .subscribe(response => {
|
|
|
|
// const blob = new Blob([response.body], { type: 'application/json' });
|
|
|
|
// const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
|
|
|
|
// FileSaver.saveAs(blob, filename);
|
|
|
|
// })
|
|
|
|
// }
|
2020-07-06 17:42:54 +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;
|
2020-07-06 12:21:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
openDmpSearchDialogue() {
|
2020-07-06 17:42:54 +02:00
|
|
|
const formControl = new FormControl();
|
|
|
|
const dialogRef = this.dialog.open(DatasetCopyDialogueComponent, {
|
|
|
|
width: '500px',
|
|
|
|
restoreFocus: false,
|
|
|
|
data: {
|
|
|
|
formControl: formControl,
|
|
|
|
datasetId: this.dataset.id,
|
2020-07-15 17:18:16 +02:00
|
|
|
datasetProfileId: this.datasetWizardEditorModel.profile,
|
2020-07-06 17:42:54 +02:00
|
|
|
datasetProfileExist: false,
|
|
|
|
confirmButton: this.language.instant('DATASET-WIZARD.DIALOGUE.COPY'),
|
|
|
|
cancelButton: this.language.instant('DATASET-WIZARD.DIALOGUE.CANCEL')
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(result => {
|
|
|
|
if (result && result.datasetProfileExist) {
|
|
|
|
const newDmpId = result.formControl.value.id
|
2020-07-24 16:40:53 +02:00
|
|
|
let url = this.router.createUrlTree(['/datasets/copy/', result.datasetId, { newDmpId: newDmpId }])
|
|
|
|
window.open(url.toString(), '_blank')
|
2020-07-06 17:42:54 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-07-09 09:17:49 +02:00
|
|
|
updateUsers() {
|
|
|
|
return this.dmpService.updateUsers(this.dataset.dmp.id, this.users).pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(
|
|
|
|
complete => {
|
2020-07-15 17:18:16 +02:00
|
|
|
this.onUpdateCallbackSuccess();
|
2020-07-09 09:17:49 +02:00
|
|
|
},
|
2020-07-15 17:18:16 +02:00
|
|
|
error => this.onUpdateCallbackError(error)
|
2020-07-09 09:17:49 +02:00
|
|
|
);
|
|
|
|
}
|
2020-07-07 17:30:25 +02:00
|
|
|
|
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) {
|
|
|
|
const index = this.users.findIndex(x => x.id === user.id);
|
|
|
|
if (index > -1) {
|
2020-07-15 17:18:16 +02:00
|
|
|
this.users.splice(index, 1);
|
2020-07-09 09:17:49 +02:00
|
|
|
}
|
|
|
|
this.updateUsers();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-07-06 17:42:54 +02:00
|
|
|
|
2020-07-15 17:18:16 +02:00
|
|
|
showPublishButton(dataset: DatasetOverviewModel) {
|
|
|
|
return this.isFinalizedDataset(dataset) && !dataset.public && this.hasPublishButton;
|
|
|
|
}
|
|
|
|
|
2020-07-17 16:50:05 +02:00
|
|
|
// publish(id: String) {
|
|
|
|
// const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
|
|
|
// maxWidth: '500px',
|
|
|
|
// restoreFocus: false,
|
|
|
|
// data: {
|
|
|
|
// message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.PUBLISH-ITEM'),
|
|
|
|
// privacyPolicyNames: this.language.instant('GENERAL.CONFIRMATION-DIALOG.PRIVACY-POLICY-NAMES'),
|
|
|
|
// 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.datasetService.publish(id)
|
|
|
|
// .pipe(takeUntil(this._destroyed))
|
|
|
|
// .subscribe(() => {
|
|
|
|
// this.hasPublishButton = false;
|
|
|
|
// this.reloadPage();
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// }
|
2020-07-15 17:18:16 +02:00
|
|
|
|
|
|
|
finalize(dataset: DatasetOverviewModel) {
|
|
|
|
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
|
|
|
restoreFocus: false,
|
|
|
|
data: {
|
|
|
|
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.FINALIZE-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.getDatasetWizardModel(this.dataset.id);
|
|
|
|
this.datasetWizardModel.status = DatasetStatus.Finalized;
|
|
|
|
this.datasetWizardService.createDataset(this.datasetWizardModel)
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(
|
2020-07-16 11:59:34 +02:00
|
|
|
data => this.onUpdateCallbackSuccess(),
|
2020-07-15 17:18:16 +02:00
|
|
|
error => this.onUpdateCallbackError(error)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-07-03 15:58:13 +02:00
|
|
|
|
2020-07-20 11:16:23 +02:00
|
|
|
hasReversableStatus(dataset: DatasetOverviewModel): boolean {
|
|
|
|
return dataset.dmp.status == DmpStatus.Draft && dataset.status == DatasetStatus.Finalized
|
|
|
|
}
|
|
|
|
|
|
|
|
reverse(dataset: DatasetOverviewModel) {
|
|
|
|
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.getDatasetWizardModel(this.dataset.id);
|
|
|
|
this.datasetWizardModel.status = DatasetStatus.Draft;
|
|
|
|
this.datasetWizardService.createDataset(this.datasetWizardModel)
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(
|
|
|
|
data => this.onUpdateCallbackSuccess(),
|
|
|
|
error => this.onUpdateCallbackError(error)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-07-03 15:58:13 +02:00
|
|
|
}
|