Merge branch 'ui-redesign' of gitlab.eudat.eu:dmp/OpenAIRE-EUDAT-DMP-service-pilot into ui-redesign

This commit is contained in:
apapachristou 2020-07-02 19:35:26 +03:00
commit 8551e9140c
8 changed files with 115 additions and 46 deletions

View File

@ -372,6 +372,14 @@ public class DataManagementPlanManager {
apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().createOrUpdate(newDmp.getGrant()); apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().createOrUpdate(newDmp.getGrant());
newDmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp); newDmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
if (dataManagementPlan.getUsers() != null && !dataManagementPlan.getUsers().isEmpty()) {
clearUsers(newDmp);
for (UserInfoListingModel userListing : dataManagementPlan.getUsers()) {
UserInfo tempUser = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userListing.getId());
assignUser(dmp, tempUser, UserDMP.UserDMPRoles.fromInteger(userListing.getRole()));
}
}
// Dataset manipulation for when the DMP is set to be finalized. // Dataset manipulation for when the DMP is set to be finalized.
if (dataManagementPlan.getStatus() == DMP.DMPStatus.FINALISED.getValue()) { if (dataManagementPlan.getStatus() == DMP.DMPStatus.FINALISED.getValue()) {
if (dataManagementPlan.getDatasetsToBeFinalized() != null && !dataManagementPlan.getDatasetsToBeFinalized().isEmpty()) { if (dataManagementPlan.getDatasetsToBeFinalized() != null && !dataManagementPlan.getDatasetsToBeFinalized().isEmpty()) {
@ -1447,13 +1455,22 @@ public class DataManagementPlanManager {
* */ * */
private void assignUser(DMP dmp, UserInfo userInfo) { private void assignUser(DMP dmp, UserInfo userInfo) {
this.assignUser(dmp, userInfo, UserDMP.UserDMPRoles.OWNER);
}
private void assignUser(DMP dmp, UserInfo userInfo, UserDMP.UserDMPRoles role) {
UserDMP userDMP = new UserDMP(); UserDMP userDMP = new UserDMP();
userDMP.setDmp(dmp); userDMP.setDmp(dmp);
userDMP.setUser(userInfo); userDMP.setUser(userInfo);
userDMP.setRole(UserDMP.UserDMPRoles.OWNER.getValue()); userDMP.setRole(role.getValue());
databaseRepository.getUserDmpDao().createOrUpdate(userDMP); databaseRepository.getUserDmpDao().createOrUpdate(userDMP);
} }
private void clearUsers(DMP dmp) {
List<UserDMP> userDMPs = apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where(((builder, root) -> builder.equal(root.get("dmp").get("id"), dmp.getId()))).toList();
userDMPs.forEach(userDMP -> apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().delete(userDMP));
}
private void assignGrandUserIfInternal(DMP dmp, UserInfo user) { private void assignGrandUserIfInternal(DMP dmp, UserInfo user) {
if (dmp.getGrant().getCreationUser() == null && (dmp.getGrant().getReference() != null && dmp.getGrant().getReference().startsWith("dmp:"))) { if (dmp.getGrant().getCreationUser() == null && (dmp.getGrant().getReference() != null && dmp.getGrant().getReference().startsWith("dmp:"))) {
dmp.getGrant().setCreationUser(user); dmp.getGrant().setCreationUser(user);

View File

@ -72,6 +72,10 @@ export class ConfigurationService extends BaseComponent {
return this._useSplash; return this._useSplash;
} }
private _orcidPath: string;
get orcidPath(): string {
return this._orcidPath;
}
public loadConfiguration(): Promise<any> { public loadConfiguration(): Promise<any> {
return new Promise((r, e) => { return new Promise((r, e) => {
@ -110,6 +114,7 @@ export class ConfigurationService extends BaseComponent {
this._allowOrganizationCreator = config.allowOrganizationCreator; this._allowOrganizationCreator = config.allowOrganizationCreator;
this._doiLink = config.doiLink; this._doiLink = config.doiLink;
this._useSplash = config.useSplash; this._useSplash = config.useSplash;
this._orcidPath = config.orcidPath;
} }
} }

View File

@ -75,7 +75,15 @@ const routes: Routes = [
breadcrumb: true, breadcrumb: true,
title: 'GENERAL.TITLES.DATASET-UPDATE' title: 'GENERAL.TITLES.DATASET-UPDATE'
}, },
} },
// {
// path: 'overview/:id',
// component: DatasetOverviewComponent,
// data: {
// breadcrumb: true,
// title: 'GENERAL.TITLES.DATASET-OVERVIEW'
// },
// },
]; ];
@NgModule({ @NgModule({

View File

@ -86,5 +86,5 @@ export class PeopleTabComponent implements OnInit {
})); }));
} }
}); });
} }
} }

View File

@ -26,7 +26,7 @@
{{'DMP-OVERVIEW.PRIVATE' | translate}} {{'DMP-OVERVIEW.PRIVATE' | translate}}
</div> </div>
</div> </div>
<div class="d-flex mr-4" (click)="checkLockStatus(dmp.id)"> <div class="d-flex mr-4">
<div *ngIf="lockStatus" class="d-flex flex-row"> <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}}
@ -66,33 +66,23 @@
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" (click)="finalize(dmp)" mat-mini-fab <button *ngIf="isDraftDmp(dmp) && isUserOwner && !lockStatus" mat-mini-fab (click)="createOrUpdate(dmp.id)"
class="mr-3 d-flex justify-content-center align-items-center"
matTooltip="{{'DMP-LISTING.ACTIONS.FINALIZE' | translate}}" matTooltipPosition="above">
<mat-icon class="mat-mini-fab-icon">lock_outline</mat-icon>
</button> -->
<button *ngIf="isDraftDmp(dmp) && isUserOwner" 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">
<div> <mat-icon class="mat-mini-fab-icon" matTooltip="{{'DMP-OVERVIEW.LOCK' | translate}}"
<div *ngIf="checkLockStatus(dmp.id)"> matTooltipPosition="above">lock_outline
<mat-icon (click)="createOrUpdate(dmp.id)" class="mat-mini-fab-icon" </mat-icon>
matTooltip="{{'DMP-OVERVIEW.LOCK' | translate}}" matTooltipPosition="above">
lock_outline
</mat-icon>
</div>
</div>
</button> </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>
<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 dmp.researchers; let last = last" <div *ngFor="let researcher of dmp.researchers; let last = last">
class="d-flex flex-row align-items-center"> <a href="{{getOrcidPath() + dmp.id }}" target="blank" class="researcher">
<div class="id-btn">&nbsp;</div> <div class="id-btn">&nbsp;</div>
<div class="researcher" *ngIf="!last">{{ researcher.name }}, </div> <div *ngIf="!last">{{ researcher.name }}, </div>
<div class="researcher" *ngIf="last">{{ researcher.name }}</div> <div *ngIf="last">{{ researcher.name }}</div>
</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>
@ -103,13 +93,6 @@
<div class="row d-flex flex-column"> <div class="row d-flex flex-column">
<div *ngFor="let dataset of dmp.datasets; let i=index"> <div *ngFor="let dataset of dmp.datasets; let i=index">
<div *ngIf="i < 3" (click)="datasetClicked(dataset.id)"> <div *ngIf="i < 3" (click)="datasetClicked(dataset.id)">
<!-- <mat-icon *ngIf="isDraftDataset(dataset)" class="draft-bookmark">bookmark</mat-icon>
<mat-icon *ngIf="!isDraftDataset(dataset)" class="finalized-bookmark">bookmark</mat-icon>
<h4 *ngIf="isDraftDataset(dataset)">
<span>{{ 'TYPES.DMP.DRAFT' | translate }}:</span> {{ dataset.label }}</h4>
<h4 *ngIf="!isDraftDataset(dataset)">{{ dataset.label }}</h4>
<div matTooltip="{{ dataset.datasetTemplate.label }}" class="chip">
{{ dataset.datasetTemplate.label }}</div> -->
<button mat-raised-button class="mb-2 mr-2 pl-0 pr-0"> <button mat-raised-button class="mb-2 mr-2 pl-0 pr-0">
<div matTooltip="{{ dataset.datasetTemplate.label }}" class="dataset-btn"> <div matTooltip="{{ dataset.datasetTemplate.label }}" class="dataset-btn">
<div class="dataset-btn-label">{{ dataset.label }}: <div class="dataset-btn-label">{{ dataset.label }}:
@ -139,9 +122,10 @@
<p class="doi-label">{{'DMP-EDITOR.TITLE.SUBTITLE' | translate}}</p> <p class="doi-label">{{'DMP-EDITOR.TITLE.SUBTITLE' | translate}}</p>
<div class="doi-panel"> <div class="doi-panel">
<p *ngIf="!hasDoi(dmp)" class="mb-0 ml-3"> <p *ngIf="!hasDoi(dmp)" class="mb-0 ml-3">
<span class="doi-txt">{{ dmp.doi }}</span></p> <textarea #doi class="doi-txt">{{ dmp.doi }}</textarea>
</p>
<div class="d-flex justify-content-end"> <div class="d-flex justify-content-end">
<button *ngIf="isAuthenticated()" (click)="cloneClicked(dmp)" mat-mini-fab <button (click)="copyDoi(doi)" mat-mini-fab
class="mr-2 d-flex justify-content-center align-items-center" class="mr-2 d-flex justify-content-center align-items-center"
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>
@ -228,7 +212,8 @@
</button> </button>
<div> <div>
<p class="authors-label">{{ user.name }} <p class="authors-label">{{ user.name }}
<span *ngIf="!user.role"> ({{ 'DMP-OVERVIEW.YOU' | translate }})</span> <span *ngIf="isUserAuthor(user.id)">
({{ 'DMP-OVERVIEW.YOU' | translate }})</span>
</p> </p>
<p class="authors-role">{{ roleDisplay(user) }}</p> <p class="authors-role">{{ roleDisplay(user) }}</p>
</div> </div>

View File

@ -145,6 +145,7 @@
color: #008887; color: #008887;
padding-right: 0.5em; padding-right: 0.5em;
align-self: center; align-self: center;
} }
.header { .header {
@ -181,6 +182,11 @@
font-size: 0.8em; font-size: 0.8em;
letter-spacing: 0.009em; letter-spacing: 0.009em;
color: #7D7D7D; color: #7D7D7D;
width: 12em;
height: 1em;
overflow: hidden;
border: none;
padding: 0px;
} }
.doi-panel { .doi-panel {
@ -257,7 +263,7 @@
} }
.dmp-label, .dataset-btn, .add-dataset-btn, .dmp-label, .dataset-btn, .add-dataset-btn,
.doi-panel { .doi-panel, .researcher {
display: flex; display: flex;
align-items: center; align-items: center;
} }

View File

@ -1,5 +1,5 @@
import { Component, OnInit, Input } from '@angular/core'; import { Component, OnInit, Input, ViewChild, ElementRef } from '@angular/core';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, Params, Router } from '@angular/router'; import { ActivatedRoute, Params, Router } from '@angular/router';
import { DatasetStatus } from '@app/core/common/enum/dataset-status'; import { DatasetStatus } from '@app/core/common/enum/dataset-status';
@ -18,7 +18,7 @@ import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-it
import { BaseComponent } from '@common/base/base.component'; import { BaseComponent } from '@common/base/base.component';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import * as FileSaver from 'file-saver'; import * as FileSaver from 'file-saver';
import { Observable, of as observableOf } from 'rxjs'; import { Observable, of as observableOf, interval } from 'rxjs';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
import { Role } from "@app/core/common/enum/role"; import { Role } from "@app/core/common/enum/role";
import { DmpInvitationDialogComponent } from '../invitation/dmp-invitation.component'; import { DmpInvitationDialogComponent } from '../invitation/dmp-invitation.component';
@ -32,8 +32,9 @@ import { UserService } from '@app/core/services/user/user.service';
import { Location } from '@angular/common'; import { Location } from '@angular/common';
import { FormGroup } from '@angular/forms'; import { FormGroup } from '@angular/forms';
import { LockService } from '@app/core/services/lock/lock.service'; import { LockService } from '@app/core/services/lock/lock.service';
import { ReturnStatement } from '@angular/compiler'; import { ReturnStatement, ConditionalExpr } from '@angular/compiler';
import { LockModel } from '@app/core/model/lock/lock.model'; import { LockModel } from '@app/core/model/lock/lock.model';
import { Guid } from '@common/types/guid';
@Component({ @Component({
selector: 'app-dmp-overview', selector: 'app-dmp-overview',
@ -53,6 +54,10 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
hasDOIToken = false; hasDOIToken = false;
lock: LockModel; lock: LockModel;
lockStatus: Boolean; lockStatus: Boolean;
textMessage: any;
@ViewChild('doi', { static: false })
doi: ElementRef;
@Input() formGroup: FormGroup; @Input() formGroup: FormGroup;
@ -88,6 +93,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(data => { .subscribe(data => {
this.dmp = data; this.dmp = data;
this.checkLockStatus(this.dmp.id);
this.setIsUserOwner(); this.setIsUserOwner();
const breadCrumbs = []; const breadCrumbs = [];
breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.MY-DMPS'), url: "/plans" }); breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.MY-DMPS'), url: "/plans" });
@ -110,6 +116,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(data => { .subscribe(data => {
this.dmp = data; this.dmp = data;
this.checkLockStatus(this.dmp.id);
this.setIsUserOwner(); this.setIsUserOwner();
const breadCrumbs = []; const breadCrumbs = [];
breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.PUBLIC-DMPS'), url: "/explore-plans" }); breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.PUBLIC-DMPS'), url: "/explore-plans" });
@ -144,6 +151,11 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
} }
} }
isUserAuthor(userId: string): boolean {
const principal: Principal = this.authentication.current();
return userId === principal.id;
}
editClicked(dmp: DmpOverviewModel) { editClicked(dmp: DmpOverviewModel) {
this.router.navigate(['/plans/edit/' + dmp.id]); this.router.navigate(['/plans/edit/' + dmp.id]);
} }
@ -175,6 +187,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
this.router.navigate(['/datasets/publicEdit/' + datasetId]); this.router.navigate(['/datasets/publicEdit/' + datasetId]);
} else { } else {
this.router.navigate(['/datasets/edit/' + datasetId]); this.router.navigate(['/datasets/edit/' + datasetId]);
console.log('inhere')
} }
} }
@ -547,7 +560,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
this.onCallbackSuccess() this.onCallbackSuccess()
}, },
error => this.onFinalizeCallbackError(error) error => this.onFinalizeCallbackError(error)
);; );
} }
goBack(): void { goBack(): void {
@ -572,18 +585,51 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
} }
}); });
} }
checkLockStatus(id: string): Observable<boolean> { copyDoi(doi) {
return this.lockService.checkLockStatus(id); console.log(doi.nativeElement.innerHTML);
let domElement = doi.nativeElement as HTMLInputElement;
domElement.select();
document.execCommand('copy');
domElement.setSelectionRange(0, 0);
alert('Doi Copied to Clipboard');
}
public getOrcidPath(): string {
return this.configurationService.orcidPath;
} }
createOrUpdate(id: string): Observable<string> { checkLockStatus(id: string){
// this.lock = new LockModel(id, this.getUserFromDMP()); this.lockService.checkLockStatus(id).pipe(takeUntil(this._destroyed))
return this.lockService.createOrUpdate(this.lock); .subscribe(lockStatus => this.lockStatus = lockStatus);
} }
getUserFromDMP(): any {
if (this.dmp) {
const principal: Principal = this.authentication.current();
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() {
// const dialogRef = this.dialog.open(ExportMethodDialogComponent, { // const dialogRef = this.dialog.open(ExportMethodDialogComponent, {
// maxWidth: '500px', // maxWidth: '500px',
@ -627,4 +673,5 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
// }); // });
// } // }
} }

View File

@ -52,5 +52,6 @@
"guideAssets": "assets/images/guide", "guideAssets": "assets/images/guide",
"allowOrganizationCreator": true, "allowOrganizationCreator": true,
"doiLink": "https://sandbox.zenodo.org/record/", "doiLink": "https://sandbox.zenodo.org/record/",
"useSplash": false "useSplash": false,
"orcidPath": "https://orcid.org/"
} }