[develop-16-deposit | WIP ] add grants, better error handling

This commit is contained in:
argirok 2024-10-09 12:09:53 +03:00
parent 53a8f5dde7
commit 1479178920
1 changed files with 42 additions and 13 deletions

View File

@ -68,17 +68,23 @@ declare var UIkit: any;
<tr><td>Publication date</td><td>{{space.metadata.publication_date}} </td></tr> <tr><td>Publication date</td><td>{{space.metadata.publication_date}} </td></tr>
<tr *ngIf="space.metadata.description && 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 *ngIf="space.metadata.description && 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 uk-text-warning"><td>Access right</td><td>{{space.metadata.access_right}} </td></tr> <tr class="uk-text-bold uk-text-warning"><td>Access right</td><td>{{space.metadata.access_right}} </td></tr>
<tr *ngIf="space.metadata.creators && space.metadata.creators.length > 0"><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 *ngIf="space.metadata.creators && space.metadata.creators.length > 0"><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 uk-text-warning"><td>License</td><td>{{space.metadata.license}} </td></tr> <tr class="uk-text-bold uk-text-warning"><td>License</td><td>{{space.metadata.license}} </td></tr>
<tr class="uk-text-bold uk-text-warning"><td>Upload type</td><td class="uk-text-bold">{{space.metadata.upload_type}} </td></tr> <tr class="uk-text-bold uk-text-warning"><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 > <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}} - <span class="uk-text-warning">{{identifier.relation}}</span> -{{identifier.resource_type}} <span *ngFor="let identifier of space.metadata['related_identifiers']; let i = index">{{identifier.identifier + ' - ' }}
<span *ngIf="i< space.metadata['related_identifiers'] -1">{{', '}}</span></span> </td></tr> <span class="uk-text-warning">{{identifier.relation}}</span> {{' - ' + identifier.resource_type}}
<span *ngIf="i< space.metadata['related_identifiers'].length -1">{{', '}}</span></span> </td></tr>
<tr *ngIf="space.metadata.journal_title"><td>Journal</td><td>{{space.metadata.journal_title}} <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_volume"> {{',volume '+ space.metadata.journal_volume}} </span>
<span *ngIf="space.metadata.journal_issue"> {{',issue '+ space.metadata.journal_issue}} </span> </td></tr> <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.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 *ngIf="space.metadata.language"><td>Language</td><td>{{space.metadata.language}} </td></tr>
<tr *ngIf="space.metadata.grants"><td>Grants</td><td>
<span *ngFor="let grant of space.metadata['grants']; let i = index">{{grant.id}}
<span *ngIf="i< space.metadata['grants'].length -1">{{', '}}</span></span>
</td></tr>
<tr><td>Files</td><td *ngIf="space.files">{{space.files.join(", ")}} </td></tr> <tr><td>Files</td><td *ngIf="space.files">{{space.files.join(", ")}} </td></tr>
</table> </table>
</div> </div>
@ -88,7 +94,7 @@ declare var UIkit: any;
class="uk-button uk-button-default uk-margin-top uk-float-right">Continue to Zenodo</a> class="uk-button uk-button-default uk-margin-top uk-float-right">Continue to Zenodo</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" [innerHTML]="errorMessage"></div>
<div *ngIf="message" [innerHTML]="message"></div> <div *ngIf="message" [innerHTML]="message"></div>
<div *ngIf="showLoading" class="uk-animation-fade uk-margin-top uk-width-1-1" role="alert"> <div *ngIf="showLoading" class="uk-animation-fade uk-margin-top uk-width-1-1" role="alert">
<loading></loading> <loading></loading>
@ -295,10 +301,23 @@ export class DepositionComponent {
this.saveRecord(record, this.filesToUpload, this.space); this.saveRecord(record, this.filesToUpload, this.space);
this.filesToUpload = []; this.filesToUpload = [];
}, error => { }, error => {
console.error(error.message) console.error(error)
// this.errorMessage = error.message; if(error.status == '400'){
// this.showLoading = false; this.showLoading = false;
this.authorize(); this.errorMessage = "Zenodo API:<br>" +error.error.message + "<br>";
if(error.error.errors) {
for (let err of error.error.errors) {
if (err.field && err.messages && err.messages.length > 0) {
this.errorMessage += err.field + ": " + err.messages.join(", ") + "<br>";
}
}
}
}else if(error.status == 401 || error.status == 403){
this.authorize();
}else{
this.showLoading = false;
this.errorMessage = "Zenodo API:<br>" + error.error.message;
}
}) })
} }
} }
@ -313,9 +332,10 @@ export class DepositionComponent {
imprint_publisher: this.result.publisher, imprint_publisher: this.result.publisher,
related_identifiers: [] related_identifiers: []
} }
if(this.result.languages){ /*if(this.result.languages){
// metadata.language: Language must be either ISO-639-1 or 639-2 compatible.
record['language'] = this.result.languages[0]; record['language'] = this.result.languages[0];
} }*/
if(this.result.journal && this.result.journal){ if(this.result.journal && this.result.journal){
record['journal_title'] = this.result.journal.journal; record['journal_title'] = this.result.journal.journal;
record['journal_volume'] = this.result.journal.volume; record['journal_volume'] = this.result.journal.volume;
@ -326,15 +346,24 @@ export class DepositionComponent {
for (let pid of this.result.identifiers.get(pidType)) { for (let pid of this.result.identifiers.get(pidType)) {
record.related_identifiers.push({ record.related_identifiers.push({
identifier: pid, identifier: pid,
relation: 'isSupplementTo', relation: 'hasMetadata',
resource_type: this.result.resultType resource_type: this.result.resultType
}) })
} }
} }
} }
if(this.result.fundedByProjects){
// record['imprint_publisher']=this.result.publisher; record['grants']=[];
for(let project of this.result.fundedByProjects){
if(project.funderShortname == 'EC') {
record['grants'].push({id: '10.13039/501100000780::' + project.code})
}
}
}
console.log(record['grants'])
record['imprint_publisher']=this.result.publisher;
/* if (this.result.resultType == 'publication' && this.result.types[0]) { /* if (this.result.resultType == 'publication' && this.result.types[0]) {
//has to be match to their vocabulary
record['publication_type'] = this.result.types[0]; record['publication_type'] = this.result.types[0];
}*/ }*/
if(this.result.authors) { if(this.result.authors) {