[develop-16-deposit | WIP ] add more fields in zenodo record, add prompt to delete

This commit is contained in:
argirok 2024-10-08 09:50:35 +03:00
parent 5b090c7087
commit 63046639cc
2 changed files with 95 additions and 28 deletions

View File

@ -6,15 +6,16 @@ import {UserManagementService} from "../../services/user-management.service";
import {HttpClient, HttpHeaders, HttpParams} from "@angular/common/http"; import {HttpClient, HttpHeaders, HttpParams} from "@angular/common/http";
import {ResultLandingInfo} from "../../utils/entities/resultLandingInfo"; import {ResultLandingInfo} from "../../utils/entities/resultLandingInfo";
import {properties} from 'src/environments/environment'; import {properties} from 'src/environments/environment';
import {AlertModal} from "../../utils/modal/alert";
declare var UIkit: any; declare var UIkit: any;
@Component({ @Component({
selector: 'deposition', selector: 'deposition',
template: ` template: `
<div class="uk-alert uk-padding-xsmall uk-text-small" *ngIf="userTokens && userTokens.zenodoDuration"> <!--<div class="uk-alert uk-padding-xsmall uk-text-small" *ngIf="userTokens && userTokens.zenodoDuration">
The session with Zenodo will be valid for {{(userTokens.zenodoDuration/3600) <24?(userTokens.zenodoDuration/3600) + (userTokens.zenodoDuration == '3600'?' hour':' hours'): (userTokens.zenodoDuration/(3600 * 24)) + ' days'}} The session with Zenodo will be valid for {{(userTokens.zenodoDuration/3600) <24?(userTokens.zenodoDuration/3600) + (userTokens.zenodoDuration == '3600'?' hour':' hours'): (userTokens.zenodoDuration/(3600 * 24)) + ' days'}}
</div> </div>-->
<div *ngIf="prevMongoRecords && prevMongoRecords.length > 0" > <div *ngIf="prevMongoRecords && prevMongoRecords.length > 0" >
<div>You have already upload the following files:</div> <div>You have already upload the following files:</div>
<!--<div class="uk-text-xsmall">Note that if the records are deleted in zenodo the links will not </div>--> <!--<div class="uk-text-xsmall">Note that if the records are deleted in zenodo the links will not </div>-->
@ -33,29 +34,50 @@ declare var UIkit: any;
</div> </div>
<div *ngIf="!space"> <div *ngIf="!space">
<div class="uk-margin-medium-top uk-text-center uk-text-meta uk-text-large"> <div class="uk-margin-medium-top uk-text-center uk-text-meta uk-text-large">
Use basic metadata (title, description, type) of this record to upload a file in Zenodo. Upload files to a Zenodo record, using basic metadata (title, description, authors, publication date) from this record.
</div> </div>
<form *ngIf="!space" class=" uk-section-small uk-flex uk-flex-center"> <form *ngIf="!space" class=" uk-section-small uk-flex uk-flex-center">
<div class="uk-float-left"> <div class="uk-float-left">
<span class="js-upload" uk-form-custom> <span class="js-upload" uk-form-custom>
<input id="exampleInputFile" class="uk-width-medium" type="file" (change)="fileChangeEvent($event)" <input id="exampleInputFile" class="uk-width-medium" type="file" (change)="fileChangeEvent($event)"
multiple="multiple"/> multiple="multiple"/>
<span class="uk-link " style="text-decoration: underline;">Upload a file to deposit </span> <span class="uk-link " style="text-decoration: underline;">Upload files to deposit </span>
</span> </span>
</div> </div>
</form> </form>
</div> </div>
<ng-container *ngIf="space"> <ng-container *ngIf="space && space.metadata">
<!-- <div><a [href]="space.links.html" target="_blank">{{space.metadata.title}}</a></div>--> <!-- <div><a [href]="space.links.html" target="_blank">{{space.metadata.title}}</a></div>-->
<div class="uk-text-center">Your file has been uploaded in Zenodo in <b>draft</b> mode. <br>You can
view, edit and publish the record <a [href]="space.links.html" target="_blank">here</a>.
<br>
<div>The preserved DOI is {{space.metadata.prereserve_doi.doi}}.</div>
</div>
<div class="uk-flex uk-flex-center uk-text-success"><icon name="file_download_done" [ratio]="3"></icon></div> <div class="uk-flex uk-flex-center uk-text-success"><icon name="file_download_done" [ratio]="3"></icon></div>
<div class="uk-text-center">Your file has been uploaded in Zenodo in <b>draft</b> mode. You can view the record <div *ngIf="space.metadata" class="uk-text-center">
<a [href]="space.links.html" target="_blank">here</a>, edit and publish it. <table class="uk-table-striped uk-text-small uk-grid-small uk-border uk-padding-xsmall uk-width-1-1" >
<div >The preserved DOI is {{space.metadata.prereserve_doi.doi}}.</div> <tr><td>Title</td><td>{{space.metadata.title}} </td></tr>
<tr><td>Publication date</td><td>{{space.metadata.publication_date}} </td></tr>
<tr *ngIf="space.metadata.description.length >0"><td>Description</td><td>{{space.metadata.description.substring(0,250)}}<span *ngIf="space.metadata.description.length > 247">...</span> </td></tr>
<tr class="uk-text-bold"><td>Access right</td><td>{{space.metadata.access_right}} </td></tr>
<tr><td>Creators</td><td><span *ngFor="let creator of space.metadata.creators; let i = index">{{creator.name}}<span *ngIf="i< space.metadata.creators.length -1">{{', '}}</span></span> </td></tr>
<tr class="uk-text-bold"><td>License</td><td>{{space.metadata.license}} </td></tr>
<tr class="uk-text-bold"><td>Upload type</td><td class="uk-text-bold">{{space.metadata.upload_type}} </td></tr>
<tr *ngIf="space.metadata['related_identifiers']"><td>Related identifiers</td><td >
<span *ngFor="let identifier of space.metadata['related_identifiers']; let i = index">{{identifier.identifier}} - {{identifier.relation}} -{{identifier.resource_type}}
<span *ngIf="i< space.metadata['related_identifiers'] -1">{{', '}}</span></span> </td></tr>
<tr *ngIf="space.metadata.journal_title"><td>Journal</td><td>{{space.metadata.journal_title}}
<span *ngIf="space.metadata.journal_volume"> {{',volume '+ space.metadata.journal_volume}} </span>
<span *ngIf="space.metadata.journal_issue"> {{',issue '+ space.metadata.journal_issue}} </span> </td></tr>
<tr *ngIf="space.metadata.imprint_publisher"><td>Publisher</td><td>{{space.metadata.imprint_publisher}} </td></tr>
<tr *ngIf="space.metadata.language"><td>Language</td><td>{{space.metadata.language}} </td></tr>
<tr><td>Files</td><td *ngIf="space.files">{{space.files.join(", ")}} </td></tr>
</table>
</div> </div>
<a (click)="deleteSpace()" <a (click)="promtToDelete()"
class="uk-button uk-button-danger uk-margin-top">Undo: This will delete your deposited file in zenodo.</a> class="uk-button uk-button-danger uk-margin-top">Undo</a>
</ng-container> </ng-container>
<div *ngIf="errorMessage" class="uk-alert uk-alert-danger">{{errorMessage}}</div> <div *ngIf="errorMessage" class="uk-alert uk-alert-danger">{{errorMessage}}</div>
@ -69,7 +91,7 @@ declare var UIkit: any;
</div> </div>
</modal-alert> </modal-alert>
<modal-alert #depositInfoModal> <modal-alert #depositInfoModal>
<ng-container *ngIf="space"> <ng-container *ngIf="space && space.metadata">
<!-- <div><a [href]="space.links.html" target="_blank">{{space.metadata.title}}</a></div>--> <!-- <div><a [href]="space.links.html" target="_blank">{{space.metadata.title}}</a></div>-->
<div>Your file has been deposited in Zenodo with the main metadata of this record. You can view the new record <div>Your file has been deposited in Zenodo with the main metadata of this record. You can view the new record
<a [href]="space.links.html" target="_blank">here</a>, edit and publish it. <a [href]="space.links.html" target="_blank">here</a>, edit and publish it.
@ -77,6 +99,8 @@ declare var UIkit: any;
<div>The preserved DOI is {{space.metadata.prereserve_doi.doi}}.</div> <div>The preserved DOI is {{space.metadata.prereserve_doi.doi}}.</div>
</ng-container> </ng-container>
</modal-alert> </modal-alert>
<modal-alert #deleteModal [overflowBody]="false" (alertOutput)="deleteSpace()"
classTitle="uk-background-primary uk-light"></modal-alert>
<!-- <a (click)="getAccessByRefresh(null)">get new Access by Refreh</a>--> <!-- <a (click)="getAccessByRefresh(null)">get new Access by Refreh</a>-->
` `
@ -86,6 +110,7 @@ export class DepositionComponent {
authorized = false; authorized = false;
properties = properties; properties = properties;
@Input() result: ResultLandingInfo; @Input() result: ResultLandingInfo;
@ViewChild('deleteModal') deleteModal: AlertModal;
authorizeUrl = this.properties.zenodoDepositAPI + authorizeUrl = this.properties.zenodoDepositAPI +
/* "oauth/authorize?response_type=code&client_id=" +*/ "oauth/authorize?response_type=token&client_id=" + /* "oauth/authorize?response_type=code&client_id=" +*/ "oauth/authorize?response_type=token&client_id=" +
@ -121,21 +146,31 @@ export class DepositionComponent {
ngOnInit() { ngOnInit() {
// this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => { this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
// this.user = user; //testing
//TODO remove later /* this.space = {};
this.user = {}; this.space.links = []
this.user.id = "034130792470362"; this.space.metadata = this.resultInfoToZenodoRecord();
this.user.firstname = "Argiro"; this.space.metadata.prereserve_doi = {doi:"123"}
this.user.lastname = "Kokogiannaki"; this.space.files = [];*/
this.user.email = "argirok@di.uoa.gr"
if (this.user) { this.user = user;
console.log(this.user) //TODO remove later
this.isAuthorizedBefore(); // this.user = {};
} else { // this.user.id = "034130792470362";
this.authorized = false; // this.user.firstname = "Argiro";
} // this.user.lastname = "Kokogiannaki";
this.getPrevUploads(); // this.user.email = "argirok@di.uoa.gr"
if (this.user) {
console.log(this.user)
this.isAuthorizedBefore();
} else {
this.authorized = false;
}
// this.getPrevUploads();
}));
} }
@ -264,8 +299,30 @@ export class DepositionComponent {
title: this.result.title, title: this.result.title,
publication_date: this.result.date, publication_date: this.result.date,
creators: [], creators: [],
description: this.result.description description: this.result.description,
imprint_publisher: this.result.publisher,
language:this.result.languages?this.result.languages.join(', '):'',
related_identifiers: []
} }
if(this.result.journal && this.result.journal){
record['journal_title'] = this.result.journal.journal;
record['journal_volume'] = this.result.journal.volume;
record['journal_issue'] = this.result.journal.issue;
}
if(this.result.identifiers) {
for (let pidType of this.result.identifiers.keys()) {
for (let pid of this.result.identifiers.get(pidType)) {
record.related_identifiers.push({
identifier: pid,
relation: 'isSupplementTo',
resource_type: this.result.resultType
})
}
}
}
// record['imprint_publisher']=this.result.publisher;
/* if (this.result.resultType == 'publication' && this.result.types[0]) { /* if (this.result.resultType == 'publication' && this.result.types[0]) {
record['publication_type'] = this.result.types[0]; record['publication_type'] = this.result.types[0];
}*/ }*/
@ -312,6 +369,7 @@ export class DepositionComponent {
// this.depositInfoModal.okButtonLeft = false; // this.depositInfoModal.okButtonLeft = false;
// this.depositInfoModal.alertTitle = "Deposit info"; // this.depositInfoModal.alertTitle = "Deposit info";
// this.depositInfoModal.open(); // this.depositInfoModal.open();
this.space.files.push(fileName);
this.showLoading = false; this.showLoading = false;
console.log(this.space) console.log(this.space)
// this.publish(); // this.publish();
@ -414,4 +472,13 @@ export class DepositionComponent {
this.prevMongoRecords = res; this.prevMongoRecords = res;
}) })
} }
promtToDelete() {
this.deleteModal.alertTitle = 'Delete Confirmation';
this.deleteModal.message = 'This action will delete your deposited file and its record in Zenodo. Are you sure you want to proceed?';
this.deleteModal.okButtonText = 'Yes';
this.deleteModal.open();
}
} }

View File

@ -90,7 +90,7 @@ import {EnvProperties} from "../properties/env-properties";
</div> </div>
</div> </div>
</modal-alert> </modal-alert>
<modal-alert *ngIf=" depositFile" #depositModal classBody="uk-flex uk-flex-center uk-flex-middle"> <modal-alert *ngIf=" depositFile" #depositModal classBody="uk-flex uk-flex-center uk-flex-middle" [large]="true">
<deposition [result]="result" class="uk-width-1-1"> </deposition> <deposition [result]="result" class="uk-width-1-1"> </deposition>
</modal-alert> </modal-alert>
` `