dataset-overview_update v4

This commit is contained in:
gpapavgeri 2020-07-06 18:42:54 +03:00
parent 3051b6ba0a
commit 7c3f06d9f4
7 changed files with 226 additions and 330 deletions

View File

@ -1,5 +1,6 @@
import { DatasetProfileModel } from "./dataset-profile"; import { DatasetProfileModel } from "./dataset-profile";
import { GrantOverviewModel } from '../grant/grant-overview'; import { GrantOverviewModel } from '../grant/grant-overview';
import { DmpOverviewModel } from '../dmp/dmp-overview';
export interface DatasetOverviewModel { export interface DatasetOverviewModel {
id: string; id: string;
@ -8,7 +9,7 @@ export interface DatasetOverviewModel {
datasetTemplate: DatasetProfileModel; datasetTemplate: DatasetProfileModel;
users: any[]; users: any[];
dmp: String; dmp: DmpOverviewModel;
grant: GrantOverviewModel; grant: GrantOverviewModel;
description: String; description: String;
public: boolean; public: boolean;

View File

@ -1,5 +1,5 @@
export interface ResearcherModel { export interface ResearcherModel {
id: String; id: string;
name: String; name: String;
reference: String; reference: String;
lastName: String; lastName: String;

View File

@ -8,8 +8,8 @@
<div class="row"> <div class="row">
<div class="col-md-8 col-lg-8 pl-4"> <div class="col-md-8 col-lg-8 pl-4">
<div class="row"> <div class="row">
<span class="dataset-logo">{{ 'NAV-BAR.DATASET' | translate }}</span> <span class="col-auto dataset-logo">{{ 'NAV-BAR.DATASET' | translate }}</span>
<p class="dataset-label ml-3 mb-0">{{ dataset.label }}</p> <p class="col dataset-label p-0 ml-3 mb-0">{{ dataset.label }}</p>
</div> </div>
<div class="row d-flex align-items-center mt-3 mb-4 label-txt"> <div class="row d-flex align-items-center mt-3 mb-4 label-txt">
<div *ngIf="isUserDatasetRelated()" class="d-flex"> <div *ngIf="isUserDatasetRelated()" class="d-flex">
@ -27,20 +27,10 @@
{{'DMP-OVERVIEW.PRIVATE' | translate}} {{'DMP-OVERVIEW.PRIVATE' | translate}}
</div> </div>
</div> </div>
<!-- <div class="d-flex mr-4"> <div *ngIf="lockStatus" class="d-flex flex-row mr-4">
<div *ngIf="lockStatus" class="d-flex flex-row"> <mat-icon class="status-icon">lock_outline</mat-icon>
<mat-icon class="status-icon">lock_outline</mat-icon> {{'DMP-OVERVIEW.LOCKED' | translate}}
{{'DMP-OVERVIEW.LOCKED' | translate}} </div>
</div>
<div *ngIf="!lockStatus" class="d-flex flex-row">
<mat-icon class="status-icon">lock_open</mat-icon>
{{'DMP-OVERVIEW.UNLOCKED' | translate}}
</div>
</div> -->
<!-- <button class="d-flex mr-4 version-btn label2-txt"
(click)="viewVersions(dmp.groupId, dmp.label)">
{{'DMP-LISTING.ACTIONS.VIEW-VERSION' | translate}}
</button> -->
<div class="d-flex mr-3">{{'GENERAL.STATUSES.EDIT' | translate}} : <div class="d-flex mr-3">{{'GENERAL.STATUSES.EDIT' | translate}} :
{{dataset.modified | date:"longDate"}} {{dataset.modified | date:"longDate"}}
</div> </div>
@ -49,10 +39,6 @@
<mat-icon class="status-icon">check</mat-icon> <mat-icon class="status-icon">check</mat-icon>
{{'TYPES.DATASET-STATUS.FINALISED' | translate}} {{'TYPES.DATASET-STATUS.FINALISED' | translate}}
</div> </div>
<div *ngIf="!dataset.status" class="d-flex flex-row uppercase">
<mat-icon class="status-icon">create</mat-icon>
{{'TYPES.DATASET-STATUS.DRAFT' | translate}}
</div>
</div> </div>
</div> </div>
<div class="row mb-4 pb-3"> <div class="row mb-4 pb-3">
@ -71,17 +57,10 @@
matTooltipPosition="above"> matTooltipPosition="above">
<mat-icon class="mat-mini-fab-icon">delete</mat-icon> <mat-icon class="mat-mini-fab-icon">delete</mat-icon>
</button> </button>
<!-- <button *ngIf="isDraftDmp(dmp) && isUserOwner && !lockStatus" mat-mini-fab (click)="createOrUpdate(dmp.id)"
class="mr-3 actions-btn">
<mat-icon class="mat-mini-fab-icon" matTooltip="{{'DMP-OVERVIEW.LOCK' | translate}}"
matTooltipPosition="above">lock_outline
</mat-icon>
</button> -->
</div> </div>
<div class="row header">{{'DATASET-LISTING.TOOLTIP.PART-OF' | translate}}</div> <div class="row header">{{'DATASET-LISTING.TOOLTIP.PART-OF' | translate}}</div>
<div class="row "> <div class="row ">
<button class="dmp-btn"> <button class="dmp-btn" (click)="dmpClicked(dataset.dmp.id)">
<!-- <button class="dmp-btn" (click)="dmpClicked(dataset.dmp.id)"> -->
<div class="dmp-btn-label"> <div class="dmp-btn-label">
{{ 'DATASET-LISTING.TOOLTIP.DMP-FOR' | translate }}: {{ dataset.datasetTemplate.label }} {{ 'DATASET-LISTING.TOOLTIP.DMP-FOR' | translate }}: {{ dataset.datasetTemplate.label }}
</div> </div>
@ -90,17 +69,16 @@
</div> </div>
<div class="row header">{{'DMP-OVERVIEW.GRANT' | translate}}</div> <div class="row header">{{'DMP-OVERVIEW.GRANT' | translate}}</div>
<div class="row dataset-label">Grant label</div> <div class="row dataset-label">{{ dataset.grant.label }}</div>
<!-- <div class="row dmp-label">{{ dataset.grant.label }}</div> -->
<div class="row header">{{'DMP-OVERVIEW.RESEARCHERS' | translate}}</div> <div class="row header">{{'DMP-OVERVIEW.RESEARCHERS' | translate}}</div>
<div class="row"> <div class="row">
<!-- <div *ngFor="let researcher of dataset.dmp.researchers; let last = last"> <div *ngFor="let researcher of researchers; let last = last">
<a href="{{getOrcidPath() + researcher.id }}" target="blank" class="researcher"> <a href="{{ getOrcidPath() + researcher.id }}" target="blank" class="researcher">
<div class="id-btn">&nbsp;</div> <div class="id-btn">&nbsp;</div>
<div *ngIf="!last">{{ researcher.name }}, </div> <div *ngIf="!last">{{ researcher.name }}, </div>
<div *ngIf="last">{{ researcher.name }}</div> <div *ngIf="last">{{ researcher.name }}</div>
</a> </a>
</div> --> </div>
</div> </div>
<div class="row header">{{'DATASET-LISTING.COLUMNS.DESCRIPTION' | translate}}</div> <div class="row header">{{'DATASET-LISTING.COLUMNS.DESCRIPTION' | translate}}</div>
@ -109,28 +87,6 @@
</div> </div>
</div> </div>
<div class="col-md-4 col-lg-4 p-0"> <div class="col-md-4 col-lg-4 p-0">
<!-- <div *ngIf="!hasDoi(dmp)" class="row d-flex flex-column ml-0 mr-0 mb-3">
<p class="doi-label">{{'DMP-EDITOR.TITLE.SUBTITLE' | translate}}</p>
<div class="doi-panel">
<p *ngIf="!hasDoi(dmp)" class="mb-0 ml-3">
<textarea #doi class="doi-txt">{{ dmp.doi }}</textarea>
</p>
<div class="d-flex justify-content-end">
<button (click)="copyDoi(doi)" mat-mini-fab
class="mr-2 d-flex justify-content-center align-items-center"
matTooltip="{{'DMP-LISTING.ACTIONS.CLONE' | translate}}" matTooltipPosition="above">
<mat-icon class="mat-mini-fab-icon">content_copy</mat-icon>
</button>
<button mat-mini-fab class="mr-2 d-flex justify-content-center align-items-center"
matTooltip="{{'GRANT-EDITOR.ACTIONS.VISIT-WEBSITE' | translate}}"
matTooltipPosition="above">
<a [href]="createDoiLink(dmp.doi)" class="doi-link" target="_blank">
<mat-icon class="mat-mini-fab-icon">launch</mat-icon>
</a>
</button>
</div>
</div>
</div> -->
<div class="frame mb-3 pt-4 pl-3 pr-5 pb-1"> <div class="frame mb-3 pt-4 pl-3 pr-5 pb-1">
<!-- <div *ngIf="!dataset.status && isDraftDataset(dataset) && isUserOwner"> <!-- <div *ngIf="!dataset.status && isDraftDataset(dataset) && isUserOwner">
<div class="row ml-0 mr-0 pl-4 d-flex align-items-center" (click)="finalize(dataset)"> <div class="row ml-0 mr-0 pl-4 d-flex align-items-center" (click)="finalize(dataset)">
@ -143,13 +99,6 @@
<hr class="hr-line"> <hr class="hr-line">
</div> </div>
</div> --> </div> -->
<!-- <div *ngIf="hasDoi(dmp) && isFinalizedDmp(dmp) && !this.isPublicView && isUserOwner"
(click)="getDoi(dmp)" class="row ml-0 mr-0 pl-4 pb-3 d-flex align-items-center">
<button mat-mini-fab class="frame-btn">
<mat-icon class="mat-mini-fab-icon">archive</mat-icon>
</button>
<p class="mb-0 pl-2 frame-txt">{{ 'DMP-LISTING.ACTIONS.DEPOSIT' | translate }}</p>
</div> -->
<div class="row ml-0 mr-0 pl-4 pb-3 d-flex align-items-center"> <div class="row ml-0 mr-0 pl-4 pb-3 d-flex align-items-center">
<button mat-mini-fab class="frame-btn" [matMenuTriggerFor]="exportMenu"> <button mat-mini-fab class="frame-btn" [matMenuTriggerFor]="exportMenu">
<mat-icon class="mat-mini-fab-icon">open_in_new</mat-icon> <mat-icon class="mat-mini-fab-icon">open_in_new</mat-icon>
@ -157,21 +106,6 @@
<p class="mb-0 mr-0 pl-2 frame-txt" [matMenuTriggerFor]="exportMenu"> <p class="mb-0 mr-0 pl-2 frame-txt" [matMenuTriggerFor]="exportMenu">
{{ 'DMP-LISTING.ACTIONS.EXPORT' | translate }}</p> {{ 'DMP-LISTING.ACTIONS.EXPORT' | translate }}</p>
</div> </div>
<!-- <div class="row ml-0 mr-0 pl-4 pb-3 d-flex align-items-center" *ngIf="isUserOwner"
(click)="newVersion(dmp.id, dmp.label)">
<button mat-mini-fab class="frame-btn">
<mat-icon class="mat-mini-fab-icon">add_to_photos</mat-icon>
</button>
<p class="mb-0 pl-2 frame-txt">{{ 'DMP-LISTING.ACTIONS.START-NEW-VERSION' | translate }}
</p>
</div> -->
<div *ngIf="!dataset.public && showPublishButton(dataset) && isUserOwner"
class="row ml-0 mr-0 pl-4 pb-3 d-flex align-items-center" (click)="publish(dataset.id)">
<button mat-mini-fab class="frame-btn">
<mat-icon class="mat-mini-fab-icon">public</mat-icon>
</button>
<p class="mb-0 pl-2 frame-txt">{{ 'DMP-LISTING.ACTIONS.MAKE-PUBLIC' | translate }}</p>
</div>
<mat-menu #exportMenu="matMenu" xPosition="before"> <mat-menu #exportMenu="matMenu" xPosition="before">
<button mat-menu-item (click)="downloadPDF(dataset.id)"> <button mat-menu-item (click)="downloadPDF(dataset.id)">
<i class="fa fa-file-pdf-o pr-2"></i> <i class="fa fa-file-pdf-o pr-2"></i>
@ -213,7 +147,7 @@
class="remove-btn">{{ 'GENERAL.CONFIRMATION-DIALOG.ACTIONS.REMOVE' | translate}}</button> class="remove-btn">{{ 'GENERAL.CONFIRMATION-DIALOG.ACTIONS.REMOVE' | translate}}</button>
</div> </div>
</div> </div>
<div *ngIf="isUserOwner" (click)="openShareDialog(dataset.id, dataset.label)" <div *ngIf="isUserOwner" (click)="openShareDialog(dataset.dmp.id, dataset.dmp.label)"
class="row mt-3 mb-3 d-flex align-items-center justify-content-center"> class="row mt-3 mb-3 d-flex align-items-center justify-content-center">
<button mat-raised-button class="invite-btn"> <button mat-raised-button class="invite-btn">
<mat-icon>group_add</mat-icon> <mat-icon>group_add</mat-icon>

View File

@ -139,6 +139,7 @@
.dataset-label { .dataset-label {
font-weight: bold; font-weight: bold;
width: auto;
} }
.uppercase { .uppercase {
@ -149,7 +150,7 @@
font-size: 0.875em; font-size: 0.875em;
color: #008887; color: #008887;
padding-right: 0.5em; padding-right: 0.5em;
align-self: center; align-self: center;;
} }
.header { .header {

View File

@ -25,6 +25,9 @@ import { DatasetWizardEditorModel } from '../dataset-wizard/dataset-wizard-edito
import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-wizard.service'; import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-wizard.service';
import { FormControl } from '@angular/forms'; import { FormControl } from '@angular/forms';
import { DatasetCopyDialogueComponent } from '../dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component'; import { DatasetCopyDialogueComponent } from '../dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component';
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';
@Component({ @Component({
@ -44,6 +47,8 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
isUserOwner: boolean; isUserOwner: boolean;
expand = false; expand = false;
hasDOIToken = false; hasDOIToken = false;
researchers: ResearcherModel[];
lockStatus: Boolean;
constructor( constructor(
private route: ActivatedRoute, private route: ActivatedRoute,
@ -57,8 +62,10 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
private configurationService: ConfigurationService, private configurationService: ConfigurationService,
private oauth2DialogService: Oauth2DialogService, private oauth2DialogService: Oauth2DialogService,
private userService: UserService, private userService: UserService,
private dmpService: DmpService,
private location: Location, private location: Location,
private datasetWizardService: DatasetWizardService private datasetWizardService: DatasetWizardService,
private lockService: LockService
) { ) {
super(); super();
} }
@ -77,11 +84,12 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(data => { .subscribe(data => {
this.dataset = data; this.dataset = data;
this.getDmpResearchers();
this.datasetWizardService.getSingle(this.dataset.id).pipe(takeUntil(this._destroyed)) this.datasetWizardService.getSingle(this.dataset.id).pipe(takeUntil(this._destroyed))
.subscribe(data => { .subscribe(data => {
this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data); this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data);
}); });
// this.checkLockStatus(this.dataset.id); this.checkLockStatus(this.dataset.id);
this.setIsUserOwner(); this.setIsUserOwner();
const breadCrumbs = []; const breadCrumbs = [];
breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS'), url: "/datasets" }); breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.MY-DATASET-DESCRIPTIONS'), url: "/datasets" });
@ -104,11 +112,12 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(data => { .subscribe(data => {
this.dataset = data; this.dataset = data;
this.getDmpResearchers();
this.datasetWizardService.getSingle(this.dataset.id).pipe(takeUntil(this._destroyed)) this.datasetWizardService.getSingle(this.dataset.id).pipe(takeUntil(this._destroyed))
.subscribe(data => { .subscribe(data => {
this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data); this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data);
}); });
// this.checkLockStatus(this.dataset.id); this.checkLockStatus(this.dataset.id);
this.setIsUserOwner(); this.setIsUserOwner();
const breadCrumbs = []; const breadCrumbs = [];
breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.PUBLIC DATASETS'), url: "/explore" }); breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.PUBLIC DATASETS'), url: "/explore" });
@ -126,255 +135,241 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
}); });
} }
onFetchingDeletedCallbackError(redirectRoot: string) { checkLockStatus(id: string){
this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-OVERVIEW.ERROR.DELETED-DATASET'), SnackBarNotificationLevel.Error); this.lockService.checkLockStatus(id).pipe(takeUntil(this._destroyed))
this.router.navigate([redirectRoot]); .subscribe(lockStatus => this.lockStatus = lockStatus);
} }
onFetchingForbiddenCallbackError(redirectRoot: string) { onFetchingDeletedCallbackError(redirectRoot: string) {
this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-OVERVIEW.ERROR.FORBIDEN-DATASET'), SnackBarNotificationLevel.Error); this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-OVERVIEW.ERROR.DELETED-DATASET'), SnackBarNotificationLevel.Error);
this.router.navigate([redirectRoot]); this.router.navigate([redirectRoot]);
} }
onFetchingForbiddenCallbackError(redirectRoot: string) {
this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-OVERVIEW.ERROR.FORBIDEN-DATASET'), SnackBarNotificationLevel.Error);
this.router.navigate([redirectRoot]);
}
goBack(): void { goBack(): void {
this.location.back(); this.location.back();
} }
getDmpResearchers() {
this.dmpService.getSingle(this.dataset.dmp.id).pipe(takeUntil(this._destroyed))
.subscribe(data => {
this.researchers = data.researchers;
});
}
setIsUserOwner() { setIsUserOwner() {
if (this.dataset) { if (this.dataset) {
const principal: Principal = this.authentication.current(); const principal: Principal = this.authentication.current();
if (principal) this.isUserOwner = principal.id === this.dataset.users.find(x => x.role === Role.Owner).id; if (principal) this.isUserOwner = principal.id === this.dataset.users.find(x => x.role === Role.Owner).id;
} }
} }
isUserAuthor(userId: string): boolean { isUserAuthor(userId: string): boolean {
const principal: Principal = this.authentication.current(); const principal: Principal = this.authentication.current();
return userId === principal.id; return userId === principal.id;
} }
isUserDatasetRelated() { isUserDatasetRelated() {
const principal: Principal = this.authentication.current(); const principal: Principal = this.authentication.current();
let isRelated: boolean = false; let isRelated: boolean = false;
if (this.dataset && principal) { if (this.dataset && principal) {
this.dataset.users.forEach(element => { this.dataset.users.forEach(element => {
if (element.id === principal.id) { if (element.id === principal.id) {
isRelated = true; isRelated = true;
} }
}) })
} }
return isRelated; return isRelated;
} }
roleDisplay(value: UserInfoListingModel) { roleDisplay(value: UserInfoListingModel) {
if (value.role === Role.Owner) { if (value.role === Role.Owner) {
return this.translate.instant('DMP-LISTING.OWNER'); return this.translate.instant('DMP-LISTING.OWNER');
} else if (value.role === Role.Member) { } else if (value.role === Role.Member) {
return this.translate.instant('DMP-LISTING.MEMBER'); return this.translate.instant('DMP-LISTING.MEMBER');
} else { } else {
return this.translate.instant('DMP-LISTING.OWNER'); return this.translate.instant('DMP-LISTING.OWNER');
} }
} }
roleDisplayFromList(value: UserInfoListingModel[]) { roleDisplayFromList(value: UserInfoListingModel[]) {
const principal: Principal = this.authentication.current(); const principal: Principal = this.authentication.current();
let role: number; let role: number;
if (principal) { if (principal) {
value.forEach(element => { value.forEach(element => {
if (principal.id === element.id) { if (principal.id === element.id) {
role = element.role; role = element.role;
} }
}); });
} }
if (role === Role.Owner) { if (role === Role.Owner) {
return this.translate.instant('DMP-LISTING.OWNER'); return this.translate.instant('DMP-LISTING.OWNER');
} else if (role === Role.Member) { } else if (role === Role.Member) {
return this.translate.instant('DMP-LISTING.MEMBER'); return this.translate.instant('DMP-LISTING.MEMBER');
} else { } else {
return this.translate.instant('DMP-LISTING.OWNER'); return this.translate.instant('DMP-LISTING.OWNER');
} }
} }
openShareDialog(rowId: any, rowName: any) { openShareDialog(rowId: any, rowName: any) {
const dialogRef = this.dialog.open(DmpInvitationDialogComponent, { const dialogRef = this.dialog.open(DmpInvitationDialogComponent, {
// height: '250px', restoreFocus: false,
// width: '700px', data: {
restoreFocus: false, dmpId: rowId,
data: { dmpName: rowName
dmpId: rowId, }
dmpName: rowName });
}
});
}
public isAuthenticated(): boolean {
return !(!this.authentication.current());
} }
public isAuthenticated(): boolean {
return !(!this.authentication.current());
}
isDraftDataset(dataset: DatasetOverviewModel) { isDraftDataset(dataset: DatasetOverviewModel) {
return dataset.status == DatasetStatus.Draft; return dataset.status == DatasetStatus.Draft;
} }
isFinalizedDataset(dataset: DatasetOverviewModel) { isFinalizedDataset(dataset: DatasetOverviewModel) {
return dataset.status == DatasetStatus.Finalized; return dataset.status == DatasetStatus.Finalized;
} }
editClicked(dataset: DatasetOverviewModel) { editClicked(dataset: DatasetOverviewModel) {
if (dataset.public) { if (dataset.public) {
this.router.navigate(['/datasets/publicEdit/' + dataset.id]); this.router.navigate(['/datasets/publicEdit/' + dataset.id]);
} else { } else {
this.router.navigate(['/datasets/edit/' + dataset.id]); this.router.navigate(['/datasets/edit/' + dataset.id]);
} }
} }
deleteClicked() { deleteClicked() {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, { const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
maxWidth: '300px', maxWidth: '300px',
data: { data: {
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'),
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.DELETE'), confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.DELETE'),
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'),
isDeleteConfirmation: true isDeleteConfirmation: true
} }
}); });
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
if (result) { if (result) {
this.datasetService.delete(this.dataset.id) this.datasetService.delete(this.dataset.id)
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe( .subscribe(
complete => { this.onCallbackSuccess() }, complete => { this.onCallbackSuccess() },
error => this.onDeleteCallbackError(error) error => this.onDeleteCallbackError(error)
); );
} }
}); });
} }
dmpClicked(dmpId: String) { dmpClicked(dmpId: String) {
this.router.navigate(['/plans/overview/' + dmpId]); this.router.navigate(['/plans/overview/' + dmpId]);
}
onCallbackSuccess(): void {
this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
this.router.navigate(['/datasets']);
}
onDeleteCallbackError(error) {
this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error);
} }
onCallbackSuccess(): void {
this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
this.router.navigate(['/datasets']);
}
onDeleteCallbackError(error) {
this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error);
}
public getOrcidPath(): string { public getOrcidPath(): string {
return this.configurationService.orcidPath; return this.configurationService.orcidPath;
} }
downloadPDF(id: string) { downloadPDF(id: string) {
this.datasetService.downloadPDF(id) this.datasetService.downloadPDF(id)
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(response => { .subscribe(response => {
const blob = new Blob([response.body], { type: 'application/pdf' }); const blob = new Blob([response.body], { type: 'application/pdf' });
const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
FileSaver.saveAs(blob, filename); FileSaver.saveAs(blob, filename);
}); });
} }
downloadDocx(id: string) { downloadDocx(id: string) {
this.datasetService.downloadDocx(id) this.datasetService.downloadDocx(id)
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(response => { .subscribe(response => {
const blob = new Blob([response.body], { type: 'application/msword' }); const blob = new Blob([response.body], { type: 'application/msword' });
const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
FileSaver.saveAs(blob, filename); FileSaver.saveAs(blob, filename);
}); });
} }
downloadXml(id: string) { downloadXml(id: string) {
this.datasetService.downloadXML(id) this.datasetService.downloadXML(id)
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(response => { .subscribe(response => {
const blob = new Blob([response.body], { type: 'application/xml' }); const blob = new Blob([response.body], { type: 'application/xml' });
const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
FileSaver.saveAs(blob, filename); FileSaver.saveAs(blob, filename);
}); });
} }
downloadJson(id: string) { downloadJson(id: string) {
this.datasetService.downloadJson(id) this.datasetService.downloadJson(id)
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(response => { .subscribe(response => {
const blob = new Blob([response.body], { type: 'application/json' }); const blob = new Blob([response.body], { type: 'application/json' });
const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
FileSaver.saveAs(blob, filename); FileSaver.saveAs(blob, filename);
}) })
}
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;
}
showPublishButton(dataset: DatasetOverviewModel) {
return this.isFinalizedDataset(dataset) && !dataset.public && this.hasPublishButton;
} }
publish(datasetId: String) { getFilenameFromContentDispositionHeader(header: string): string {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, { const regex: RegExp = new RegExp(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/g);
maxWidth: '500px',
restoreFocus: false, const matches = header.match(regex);
data: { let filename: string;
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.PUBLISH-ITEM'), for (let i = 0; i < matches.length; i++) {
privacyPolicyNames: this.language.instant('GENERAL.CONFIRMATION-DIALOG.PRIVACY-POLICY-NAMES'), const match = matches[i];
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'), if (match.includes('filename="')) {
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), filename = match.substring(10, match.length - 1);
isDeleteConfirmation: false break;
} } else if (match.includes('filename=')) {
}); filename = match.substring(9);
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { break;
if (result) { }
this.datasetService.publish(datasetId) }
.pipe(takeUntil(this._destroyed)) return filename;
.subscribe(() => { this.hasPublishButton = false });
}
});
} }
openDmpSearchDialogue() { openDmpSearchDialogue() {
const formControl = new FormControl(); const formControl = new FormControl();
const dialogRef = this.dialog.open(DatasetCopyDialogueComponent, { const dialogRef = this.dialog.open(DatasetCopyDialogueComponent, {
width: '500px', width: '500px',
restoreFocus: false, restoreFocus: false,
data: { data: {
formControl: formControl, formControl: formControl,
datasetId: this.dataset.id, datasetId: this.dataset.id,
datasetProfileId: this.datasetWizardModel.profile, datasetProfileId: this.datasetWizardModel.profile,
datasetProfileExist: false, datasetProfileExist: false,
confirmButton: this.language.instant('DATASET-WIZARD.DIALOGUE.COPY'), confirmButton: this.language.instant('DATASET-WIZARD.DIALOGUE.COPY'),
cancelButton: this.language.instant('DATASET-WIZARD.DIALOGUE.CANCEL') 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
this.router.navigate(['/datasets/copy/' + result.datasetId], { queryParams: { newDmpId: newDmpId } });
}
});
}
dialogRef.afterClosed().pipe(takeUntil(this._destroyed))
.subscribe(result => {
if (result && result.datasetProfileExist) {
const newDmpId = result.formControl.value.id
this.router.navigate(['/datasets/copy/' + result.datasetId], { queryParams: { newDmpId: newDmpId } });
}
});
}
} }

View File

@ -26,15 +26,9 @@
{{'DMP-OVERVIEW.PRIVATE' | translate}} {{'DMP-OVERVIEW.PRIVATE' | translate}}
</div> </div>
</div> </div>
<div class="d-flex mr-4"> <div *ngIf="lockStatus" class="d-flex flex-row mr-4">
<div *ngIf="lockStatus" class="d-flex flex-row"> <mat-icon class="status-icon">lock_outline</mat-icon>
<mat-icon class="status-icon">lock_outline</mat-icon> {{'DMP-OVERVIEW.LOCKED' | translate}}
{{'DMP-OVERVIEW.LOCKED' | translate}}
</div>
<div *ngIf="!lockStatus" class="d-flex flex-row">
<mat-icon class="status-icon">lock_open</mat-icon>
{{'DMP-OVERVIEW.UNLOCKED' | translate}}
</div>
</div> </div>
<button class="d-flex mr-4 version-btn label2-txt" <button class="d-flex mr-4 version-btn label2-txt"
(click)="viewVersions(dmp.groupId, dmp.label)"> (click)="viewVersions(dmp.groupId, dmp.label)">
@ -48,10 +42,6 @@
<mat-icon class="status-icon">check</mat-icon> <mat-icon class="status-icon">check</mat-icon>
{{'TYPES.DMP.FINALISED' | translate}} {{'TYPES.DMP.FINALISED' | translate}}
</div> </div>
<div *ngIf="!dmp.status" class="d-flex flex-row uppercase">
<mat-icon class="status-icon">create</mat-icon>
{{'TYPES.DMP.DRAFT' | translate}}
</div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
@ -60,22 +50,16 @@
matTooltip="{{'DMP-LISTING.ACTIONS.CLONE' | translate}}" matTooltipPosition="above"> matTooltip="{{'DMP-LISTING.ACTIONS.CLONE' | translate}}" matTooltipPosition="above">
<mat-icon class="mat-mini-fab-icon">content_copy</mat-icon> <mat-icon class="mat-mini-fab-icon">content_copy</mat-icon>
</button> </button>
<button *ngIf="isDraftDmp(dmp) && isUserOwner" (click)="editClicked(dmp)" mat-mini-fab <button *ngIf="isDraftDmp(dmp) && isUserOwner && !lockStatus" (click)="editClicked(dmp)" mat-mini-fab
class="mr-3 d-flex justify-content-center align-items-center" class="mr-3 d-flex justify-content-center align-items-center"
matTooltip="{{'DMP-LISTING.ACTIONS.EDIT' | translate}}" matTooltipPosition="above"> matTooltip="{{'DMP-LISTING.ACTIONS.EDIT' | translate}}" matTooltipPosition="above">
<mat-icon class="mat-mini-fab-icon">create</mat-icon> <mat-icon class="mat-mini-fab-icon">create</mat-icon>
</button> </button>
<button *ngIf="isDraftDmp(dmp) && isUserOwner" (click)="deleteClicked()" mat-mini-fab <button *ngIf="isDraftDmp(dmp) && isUserOwner && !lockStatus" (click)="deleteClicked()" mat-mini-fab
class="mr-3 d-flex justify-content-center align-items-center" class="mr-3 d-flex justify-content-center align-items-center"
matTooltip="{{'DMP-LISTING.ACTIONS.DELETE' | translate}}" matTooltipPosition="above"> matTooltip="{{'DMP-LISTING.ACTIONS.DELETE' | translate}}" matTooltipPosition="above">
<mat-icon class="mat-mini-fab-icon">delete</mat-icon> <mat-icon class="mat-mini-fab-icon">delete</mat-icon>
</button> </button>
<button *ngIf="isDraftDmp(dmp) && isUserOwner && !lockStatus" mat-mini-fab (click)="createOrUpdate(dmp.id)"
class="mr-3 d-flex justify-content-center align-items-center">
<mat-icon class="mat-mini-fab-icon" matTooltip="{{'DMP-OVERVIEW.LOCK' | translate}}"
matTooltipPosition="above">lock_outline
</mat-icon>
</button>
</div> </div>
<div class="row header">{{'DMP-OVERVIEW.GRANT' | translate}}</div> <div class="row header">{{'DMP-OVERVIEW.GRANT' | translate}}</div>
<div class="row dmp-label">{{ dmp.grant.label }}</div> <div class="row dmp-label">{{ dmp.grant.label }}</div>
@ -145,7 +129,7 @@
</div> </div>
</div> </div>
<div class="frame mb-3 pt-4 pl-3 pr-5 pb-1"> <div class="frame mb-3 pt-4 pl-3 pr-5 pb-1">
<div *ngIf="!dmp.status && isDraftDmp(dmp) && isUserOwner"> <div *ngIf="!dmp.status && isDraftDmp(dmp) && isUserOwner && !lockStatus">
<div class="row ml-0 mr-0 pl-4 d-flex align-items-center" (click)="finalize(dmp)"> <div class="row ml-0 mr-0 pl-4 d-flex align-items-center" (click)="finalize(dmp)">
<button mat-mini-fab class="finalize-btn"> <button mat-mini-fab class="finalize-btn">
<mat-icon class="mat-mini-fab-icon">check</mat-icon> <mat-icon class="mat-mini-fab-icon">check</mat-icon>

View File

@ -52,7 +52,6 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
isUserOwner: boolean; isUserOwner: boolean;
expand = false; expand = false;
hasDOIToken = false; hasDOIToken = false;
lock: LockModel;
lockStatus: Boolean; lockStatus: Boolean;
textMessage: any; textMessage: any;
@ -610,24 +609,6 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
return this.dmp.users.find(x => x.id === principal.id); return this.dmp.users.find(x => x.id === principal.id);
} }
} }
createOrUpdate(id: string): void {
if (!this.lockStatus) {
this.lock = new LockModel(id, this.getUserFromDMP());
this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => {
this.lock.id = Guid.parse(result);
this.checkLockStatus(id);
// interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock());
});
}
}
// private pumpLock() {
// this.lock.touchedAt = new Date();
// this.lockStatus = true;
// this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => this.lock.id = Guid.parse(result));
// }
// advancedClicked() { // advancedClicked() {