[develop-16-deposit | WIP ] add my upload page, add deposit table component, add deposit info classes, add checks for user if allowed to deposit
This commit is contained in:
parent
84ea746b3a
commit
7155acc998
|
@ -7,16 +7,39 @@ import {HttpClient, HttpHeaders, HttpParams} from "@angular/common/http";
|
|||
import {ResultLandingInfo} from "../../utils/entities/resultLandingInfo";
|
||||
import {properties} from 'src/environments/environment';
|
||||
import {AlertModal} from "../../utils/modal/alert";
|
||||
import {Session} from "../../login/utils/helper.class";
|
||||
import {DepositRecord, ZenodoRecord} from "../utils/depositRecord.class";
|
||||
|
||||
declare var UIkit: any;
|
||||
|
||||
@Component({
|
||||
selector: 'deposition',
|
||||
template: `
|
||||
<!--<div class="uk-alert uk-padding-xsmall uk-text-small" *ngIf="userTokens && userTokens.zenodoDuration">
|
||||
<span [attr.uk-tooltip]="showTooltip ? 'title: Deposit: upload a file in Zenodo. '+(!user?'Please log in first.':'')
|
||||
+ (user && !isAllowedToUpload?'User is not allowed to upload for this record.':'') + '; pos: bottom; cls: uk-active uk-text-small uk-padding-small' : 'cls: uk-invisible'">
|
||||
<a (click)="openDepositModal()"
|
||||
class="uk-flex uk-flex-middle uk-button-link" [class.uk-disabled]="!user || !isAllowedToUpload"
|
||||
[class.uk-text-muted]="!user || !isAllowedToUpload"
|
||||
[ngClass]="isMobile ? 'uk-margin-left uk-margin-xsmall-bottom' : 'uk-text-bolder uk-flex-center'">
|
||||
<icon class="uk-text-bolder" [flex]="true" [ratio]="0.8" name="upload" visuallyHidden="upload"></icon>
|
||||
<span *ngIf="!compactView" class="uk-margin-xsmall-left">Upload a file</span>
|
||||
</a>
|
||||
</span>
|
||||
<modal-alert #depositModal classBody="uk-flex uk-flex-center uk-flex-middle" [large]="true">
|
||||
<div class="uk-width-1-1">
|
||||
<!--<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'}}
|
||||
</div>-->
|
||||
<div *ngIf="prevMongoRecords && prevMongoRecords.length > 0" >
|
||||
</div>-->
|
||||
<div class="uk-alert uk-alert-warning uk-padding-xsmall uk-text-small"
|
||||
*ngIf="properties.zenodoDepositAPI.indexOf('sandbox') != -1">
|
||||
<div class="uk-flex uk-flex-middle">
|
||||
<icon name="warning"></icon>
|
||||
This will upload to the <b>Zenodo Sandbox instance</b>, used for testing purposes
|
||||
<icon name="warning"></icon>
|
||||
<br></div>
|
||||
DOIs created in this instance are not real and will not resolve.
|
||||
</div>
|
||||
<div *ngIf="prevMongoRecords && prevMongoRecords.length > 0">
|
||||
<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-small">
|
||||
|
@ -34,7 +57,8 @@ declare var UIkit: any;
|
|||
</div>
|
||||
<div *ngIf="!space">
|
||||
<div class="uk-margin-medium-top uk-text-center uk-text-meta uk-text-large">
|
||||
Upload files to a Zenodo record, using basic metadata (title, description, authors, publication date) from this record.
|
||||
Upload files to a Zenodo record, using basic metadata (title, description, authors, publication date) from
|
||||
this record.
|
||||
</div>
|
||||
<form *ngIf="!space" class=" uk-section-small uk-flex uk-flex-center">
|
||||
<div class="uk-float-left">
|
||||
|
@ -48,10 +72,10 @@ declare var UIkit: any;
|
|||
</div>
|
||||
|
||||
<ng-container *ngIf="space && space.metadata">
|
||||
<!-- <div><a [href]="space.links.html" target="_blank">{{space.metadata.title}}</a></div>-->
|
||||
<div class="uk-text-center">
|
||||
|
||||
<span class="uk-text-large">Your file has been uploaded to Zenodo in <b class="uk-text-warning">draft mode</b>.<br>
|
||||
<span class="uk-text-large">Your file has been uploaded to Zenodo in <b
|
||||
class="uk-text-warning">draft mode</b>.<br>
|
||||
Please visit Zenodo to review the metadata, make any necessary edits, and publish the record.</span><br>
|
||||
Note that it has been uploaded with license
|
||||
<span class="uk-text-warning">{{space.metadata.license}}</span>, classified as
|
||||
|
@ -61,37 +85,17 @@ declare var UIkit: any;
|
|||
<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 *ngIf="space.metadata" class="uk-text-center">
|
||||
<table class="uk-table-striped uk-text-small uk-grid-small uk-border uk-padding-xsmall uk-width-1-1 uk-text-left" >
|
||||
<tr><td class="uk-width-small">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 && 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 *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>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 + ' - ' }}
|
||||
<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}}
|
||||
<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 *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>
|
||||
</table>
|
||||
<deposit-record-table [record]="space.metadata" [files]="space.files"></deposit-record-table>
|
||||
</div>
|
||||
|
||||
<a (click)="promtToDelete()"
|
||||
class="uk-button uk-button-danger uk-margin-top">Cancel</a> <a (click)="this.depositInfoModal.cancel()" [href]="space.links.html" target="_blank"
|
||||
class="uk-button uk-button-default uk-margin-top uk-float-right">Continue to Zenodo</a>
|
||||
class="uk-button uk-button-danger uk-margin-top">Undo</a> <a [href]="space.links.html" target="_blank"
|
||||
class="uk-button uk-button-default uk-margin-top uk-float-right">Continue
|
||||
to Zenodo</a>
|
||||
|
||||
</ng-container>
|
||||
<div *ngIf="errorMessage" class="uk-alert uk-alert-danger" [innerHTML]="errorMessage"></div>
|
||||
|
@ -99,25 +103,12 @@ declare var UIkit: any;
|
|||
<div *ngIf="showLoading" class="uk-animation-fade uk-margin-top uk-width-1-1" role="alert">
|
||||
<loading></loading>
|
||||
</div>
|
||||
<!--<modal-alert #grantModal [overflowBody]=false (alertOutput)="authorize()">
|
||||
<div>
|
||||
<!– <div>{{requestGrantMessage}}</div>–>
|
||||
</div>
|
||||
</modal-alert>
|
||||
<modal-alert #depositInfoModal>
|
||||
<ng-container *ngIf="space && space.metadata">
|
||||
<!– <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
|
||||
<a [href]="space.links.html" target="_blank">here</a>, edit and publish it.
|
||||
</div>
|
||||
<div>The preserved DOI is {{space.metadata.prereserve_doi.doi}}.</div>
|
||||
</ng-container>
|
||||
</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>-->
|
||||
<modal-alert #depositInfoModal>
|
||||
</modal-alert>
|
||||
<!-- <a (click)="getAccessByRefresh(null)">get new Access by Refreh</a>-->
|
||||
|
||||
`
|
||||
})
|
||||
|
||||
|
@ -126,7 +117,10 @@ export class DepositionComponent {
|
|||
properties = properties;
|
||||
@Input() result: ResultLandingInfo;
|
||||
@ViewChild('deleteModal') deleteModal: AlertModal;
|
||||
|
||||
@ViewChild('depositModal') depositModal;
|
||||
@Input() showTooltip: boolean = true;
|
||||
@Input() compactView: boolean = false; // if true, do not show label for actions
|
||||
@Input() isMobile: boolean = false;
|
||||
authorizeUrl = this.properties.zenodoDepositAPI +
|
||||
/* "oauth/authorize?response_type=code&client_id=" +*/ "oauth/authorize?response_type=token&client_id=" +
|
||||
this.properties.zenodoDepositClientId + "&scope=deposit%3Awrite+deposit%3Aactions&state=step1&redirect_uri=" +
|
||||
|
@ -144,14 +138,14 @@ export class DepositionComponent {
|
|||
public code: string = "";
|
||||
public gotToken: boolean = false;
|
||||
public space = null;
|
||||
public mongoRecord = null;
|
||||
public prevMongoRecords = null;
|
||||
public mongoRecord: DepositRecord = null;
|
||||
public prevMongoRecords: DepositRecord [] = null;
|
||||
public window: any;
|
||||
user//: User;
|
||||
isAllowedToUpload: boolean = false;
|
||||
userTokens;
|
||||
funders;
|
||||
// @ViewChild('grantModal') grantModal;
|
||||
@ViewChild('depositInfoModal') depositInfoModal;
|
||||
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
private _router: Router,
|
||||
|
@ -162,31 +156,29 @@ export class DepositionComponent {
|
|||
ngOnInit() {
|
||||
this.getFunders();
|
||||
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
||||
//testing
|
||||
/* this.space = {};
|
||||
this.space.links = []
|
||||
this.space.metadata = this.resultInfoToZenodoRecord();
|
||||
this.space.metadata.prereserve_doi = {doi:"123"}
|
||||
this.space.files = [];*/
|
||||
if (this.depositModal) {
|
||||
this.depositModal.open();
|
||||
}
|
||||
this.user = user;
|
||||
if (this.user) {
|
||||
this.checkUserAccess();
|
||||
this.isAuthorizedBefore();
|
||||
}else if(properties.environment == 'development'){
|
||||
} else if (properties.environment == 'development') {
|
||||
//TODO remove later
|
||||
this.user = {};
|
||||
this.user.id = "034130792470362";
|
||||
this.user.firstname = "Argiro";
|
||||
this.user.lastname = "Kokogiannaki";
|
||||
this.user.email = "argirok@di.uoa.gr"
|
||||
this.user.role = ['PORTAL_ADMINISTRATOR'];
|
||||
this.checkUserAccess();
|
||||
this.isAuthorizedBefore();
|
||||
} else {
|
||||
this.authorized = false;
|
||||
}
|
||||
// this.getPrevUploads();
|
||||
}));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
|
@ -210,13 +202,9 @@ export class DepositionComponent {
|
|||
authorize() {
|
||||
this.window = window.open(this.authorizeUrl, '_blank',
|
||||
'location=yes,height=700,width=540,left=500,top=100,scrollbars=yes,status=yes');
|
||||
// this.requestGrant = false;
|
||||
// this.closeGrantModal();
|
||||
|
||||
let self = this;
|
||||
window.onmessage = function (ev) {
|
||||
if (ev.isTrusted && ev.origin == location.origin) {
|
||||
console.log(ev.data)
|
||||
let user = {
|
||||
_id: self.user.id,
|
||||
firstName: self.user.firstname,
|
||||
|
@ -224,10 +212,9 @@ export class DepositionComponent {
|
|||
email: self.user.email,
|
||||
zenodoToken: ev.data['access_token'],
|
||||
zenodoDuration: ev.data['expires_in'],
|
||||
zenodoRefresh: ev.data['refresh_token']?ev.data['refresh_token']:"",
|
||||
zenodoRefresh: ev.data['refresh_token'] ? ev.data['refresh_token'] : "",
|
||||
zenodoUserId: ev.data['user']['id'],
|
||||
code: ev.data['code']?ev.data['code']:""
|
||||
|
||||
code: ev.data['code'] ? ev.data['code'] : ""
|
||||
};
|
||||
|
||||
self._http.post(self.properties.depositAPI + "deposit/user/save", user).subscribe(res => {
|
||||
|
@ -243,19 +230,6 @@ export class DepositionComponent {
|
|||
}
|
||||
}
|
||||
|
||||
/* openGrantModal(title: string) {
|
||||
this.grantModal.cancelButton = true;
|
||||
this.grantModal.okButton = true;
|
||||
this.grantModal.okButtonText = "Grant OpenAIRE";
|
||||
this.grantModal.okButtonLeft = false;
|
||||
this.grantModal.alertTitle = title;
|
||||
this.grantModal.open();
|
||||
}
|
||||
|
||||
closeGrantModal() {
|
||||
this.grantModal.cancel();
|
||||
}*/
|
||||
|
||||
public getInfo(func) {
|
||||
if (this.userTokens.zenodoToken) {
|
||||
this._http.get(this.properties.zenodoDepositAPI + "api/deposit/depositions?access_token=" + this.userTokens.zenodoToken).subscribe(res => {
|
||||
|
@ -299,19 +273,19 @@ export class DepositionComponent {
|
|||
this.filesToUpload = [];
|
||||
}, error => {
|
||||
console.error(error)
|
||||
if(error.status == '400'){
|
||||
if (error.status == '400') {
|
||||
this.showLoading = false;
|
||||
this.errorMessage = "Zenodo API:<br>" +error.error.message + "<br>";
|
||||
if(error.error.errors) {
|
||||
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){
|
||||
} else if (error.status == 401 || error.status == 403) {
|
||||
this.authorize();
|
||||
}else{
|
||||
} else {
|
||||
this.showLoading = false;
|
||||
this.errorMessage = "Zenodo API:<br>" + error.error.message;
|
||||
}
|
||||
|
@ -319,26 +293,24 @@ export class DepositionComponent {
|
|||
}
|
||||
}
|
||||
|
||||
private resultInfoToZenodoRecord() {
|
||||
let record = {
|
||||
"upload_type": this.result.resultType,
|
||||
title: this.result.title,
|
||||
publication_date: this.result.date,
|
||||
creators: [],
|
||||
description: this.result.description,
|
||||
imprint_publisher: this.result.publisher,
|
||||
related_identifiers: []
|
||||
}
|
||||
private resultInfoToZenodoRecord(): ZenodoRecord {
|
||||
let record: ZenodoRecord = new ZenodoRecord();
|
||||
record.upload_type = this.result.resultType;
|
||||
record.title = this.result.title;
|
||||
record.publication_date = this.result.date;
|
||||
record.description = this.result.description;
|
||||
record.imprint_publisher = this.result.publisher;
|
||||
|
||||
/*if(this.result.languages){
|
||||
// metadata.language: Language must be either ISO-639-1 or 639-2 compatible.
|
||||
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_volume'] = this.result.journal.volume;
|
||||
record['journal_issue'] = this.result.journal.issue;
|
||||
}
|
||||
if(this.result.identifiers) {
|
||||
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({
|
||||
|
@ -349,16 +321,16 @@ export class DepositionComponent {
|
|||
}
|
||||
}
|
||||
}
|
||||
if(this.result.fundedByProjects && this.funders){
|
||||
record['grants']=[];
|
||||
for(let project of this.result.fundedByProjects){
|
||||
if(project.funderShortname == 'EC') {
|
||||
if (this.result.fundedByProjects && this.funders) {
|
||||
record['grants'] = [];
|
||||
for (let project of this.result.fundedByProjects) {
|
||||
if (project.funderShortname == 'EC') {
|
||||
record['grants'].push({id: '10.13039/501100000780::' + project.code})
|
||||
}else{
|
||||
for(let funder of this.funders){
|
||||
if((project.funderShortname == funder.legalShortName || project.funderName == funder.legalName ) && funder.pids){
|
||||
for(let pid of funder.pids){
|
||||
if(pid.type == 'FundRef'){
|
||||
} else {
|
||||
for (let funder of this.funders) {
|
||||
if ((project.funderShortname == funder.legalShortName || project.funderName == funder.legalName) && funder.pids) {
|
||||
for (let pid of funder.pids) {
|
||||
if (pid.type == 'FundRef') {
|
||||
record['grants'].push({id: '10.13039/' + pid.value + '::' + project.code})
|
||||
break;
|
||||
}
|
||||
|
@ -369,12 +341,12 @@ export class DepositionComponent {
|
|||
}
|
||||
}
|
||||
}
|
||||
record['imprint_publisher']=this.result.publisher;
|
||||
record['imprint_publisher'] = this.result.publisher;
|
||||
/* if (this.result.resultType == 'publication' && this.result.types[0]) {
|
||||
//has to be match to their vocabulary
|
||||
record['publication_type'] = this.result.types[0];
|
||||
}*/
|
||||
if(this.result.authors) {
|
||||
if (this.result.authors) {
|
||||
for (let author of this.result.authors) {
|
||||
record.creators.push({name: author.fullName, orcid: author.orcid})
|
||||
}
|
||||
|
@ -422,24 +394,18 @@ export class DepositionComponent {
|
|||
});
|
||||
}
|
||||
|
||||
saveRecord(record, files, res) {
|
||||
let mongoRecord = {
|
||||
saveRecord(record: ZenodoRecord, files, res) {
|
||||
let mongoRecord: DepositRecord = new DepositRecord();
|
||||
mongoRecord.aaiId = this.user.id;
|
||||
mongoRecord.record = record;
|
||||
mongoRecord.openAIREId = this.result.relcanId;
|
||||
mongoRecord.recordId = this.space.record_id;
|
||||
mongoRecord.ownerId = this.userTokens.zenodoUserId;
|
||||
|
||||
aaiId: this.user.id,
|
||||
title: record.title,
|
||||
description: record.description,
|
||||
type: record["upload_type"],
|
||||
date: record.publication_date,
|
||||
authors: [],
|
||||
filenames: [],
|
||||
pids: [],
|
||||
openAIREId: this.result.relcanId,
|
||||
recordId: this.space.record_id,
|
||||
ownerId: this.userTokens.zenodoUserId
|
||||
};
|
||||
for (let file of files) {
|
||||
mongoRecord.filenames.push(file.name)
|
||||
}
|
||||
if (this.result.identifiers) {
|
||||
for (let pidtype of this.result.identifiers.keys()) {
|
||||
for (let pid of this.result.identifiers.get(pidtype)) {
|
||||
if (mongoRecord.pids.indexOf(pid) == -1) {
|
||||
|
@ -447,30 +413,41 @@ export class DepositionComponent {
|
|||
}
|
||||
}
|
||||
}
|
||||
for (let author of record.creators) {
|
||||
mongoRecord.authors.push({name: author.name, orcid: author.orcid ? author.orcid : ""})
|
||||
}
|
||||
|
||||
this._http.post(this.properties.depositAPI + "deposit/record/save", mongoRecord).subscribe(res => {
|
||||
if (res instanceof DepositRecord) {
|
||||
this.mongoRecord = res;
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
public openDepositModal() {
|
||||
// this.depositClicked = true;
|
||||
this.depositModal.cancelButton = false;
|
||||
this.depositModal.okButton = false;
|
||||
this.depositModal.alertTitle = "Deposit";
|
||||
this.depositModal.open();
|
||||
}
|
||||
|
||||
deleteSpace() {
|
||||
this._http.delete(this.properties.zenodoDepositAPI + "api/deposit/depositions/" + this.space.id + "?access_token=" + this.userTokens.zenodoToken,
|
||||
).subscribe(res => {
|
||||
this.space = null;
|
||||
this._http.delete(this.properties.depositAPI + "deposit/record/delete?id=" + this.mongoRecord._id).subscribe(res => {
|
||||
this.depositInfoModal.cancel()
|
||||
this.openDepositModal();
|
||||
})
|
||||
}, error => {
|
||||
console.error(error.message)
|
||||
UIkit.notification({
|
||||
message: 'An error occured while uploading your file. The deposition may not be completed.',
|
||||
message: 'An error occurred while deleting the record',
|
||||
status: 'danger',
|
||||
timeout: 6000,
|
||||
pos: 'bottom-right'
|
||||
});
|
||||
|
||||
this.openDepositModal();
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -495,19 +472,6 @@ export class DepositionComponent {
|
|||
})
|
||||
}
|
||||
|
||||
getPrevUploads() {
|
||||
let pids = [];
|
||||
for (let pidtype of this.result.identifiers.keys()) {
|
||||
for (let pid of this.result.identifiers.get(pidtype)) {
|
||||
if (pids.indexOf(pid) == -1) {
|
||||
pids.push(pid)
|
||||
}
|
||||
}
|
||||
}
|
||||
this._http.get(this.properties.depositAPI + "deposit/record/get?aaiId=" + this.user.id + (pids.length > 0 ? "&pid=" + pids.join("&pid=") : "") + "&openaireId=" + this.result.relcanId).subscribe(res => {
|
||||
this.prevMongoRecords = res;
|
||||
})
|
||||
}
|
||||
|
||||
promtToDelete() {
|
||||
|
||||
|
@ -516,10 +480,26 @@ export class DepositionComponent {
|
|||
this.deleteModal.okButtonText = 'Yes';
|
||||
this.deleteModal.open();
|
||||
}
|
||||
getFunders(){
|
||||
let fundersMap = {};
|
||||
this._http.get("https://services.openaire.eu/openaire/funders").subscribe(res => {
|
||||
|
||||
getFunders() {
|
||||
this._http.get(properties.fundersApi).subscribe(res => {
|
||||
this.funders = res;
|
||||
})
|
||||
}
|
||||
|
||||
checkUserAccess() {
|
||||
this.isAllowedToUpload = false;
|
||||
if (Session.isPortalAdministrator(this.user)) {
|
||||
this.isAllowedToUpload = true;
|
||||
return;
|
||||
}
|
||||
if (this.user && this.user.orcid) {
|
||||
for (let author of this.result.authors) {
|
||||
if (author.fullName.toLowerCase().indexOf(this.user.lastname.toLowerCase()) != -1) {
|
||||
this.isAllowedToUpload = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import {DepositionComponent} from "./deposit-file.component";
|
|||
import {AlertModalModule} from "../../utils/modal/alertModal.module";
|
||||
import {LoadingModule} from "../../utils/loading/loading.module";
|
||||
import {IconsModule} from "../../utils/icons/icons.module";
|
||||
import {DepositRecordTableComponent} from "../utils/depositRecordTable.component";
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
@ -11,6 +12,7 @@ import {IconsModule} from "../../utils/icons/icons.module";
|
|||
AlertModalModule,
|
||||
LoadingModule,
|
||||
IconsModule,
|
||||
DepositRecordTableComponent
|
||||
],
|
||||
declarations: [
|
||||
DepositionComponent
|
||||
|
|
|
@ -0,0 +1,185 @@
|
|||
import {Component, ViewChild} from '@angular/core';
|
||||
import {ActivatedRoute, Router, RouterModule} from "@angular/router";
|
||||
import {Subscriber, Subscription} from "rxjs";
|
||||
import {Meta, Title} from "@angular/platform-browser";
|
||||
import {UserManagementService} from "../../services/user-management.service";
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {properties} from 'src/environments/environment';
|
||||
import {AlertModal} from "../../utils/modal/alert";
|
||||
import {DepositRecord} from "../utils/depositRecord.class";
|
||||
import {CommonModule} from "@angular/common";
|
||||
import {DepositRecordTableComponent} from "../utils/depositRecordTable.component";
|
||||
import {RouterHelper} from "../../utils/routerHelper.class";
|
||||
import {OpenaireEntities} from "../../utils/properties/searchFields";
|
||||
|
||||
declare var UIkit: any;
|
||||
|
||||
@Component({
|
||||
selector: 'my-uploads',
|
||||
standalone: true,
|
||||
template: `
|
||||
<div class="uk-section">
|
||||
<div class="uk-container uk-container-large">
|
||||
<span *ngIf="authorNameParam" class="uk-width-1-1 uk-width-expand@m">
|
||||
<a class="uk-button uk-button-text uk-align-left uk-align-right@m" [queryParams]="authorNameParam"
|
||||
[routerLink]="properties.searchLinkToAdvancedResults" routerLinkActive="router-link-active">
|
||||
Discover {{openaireEntities.RESULTS | lowercase}} related to you
|
||||
</a>
|
||||
|
||||
</span>
|
||||
<h1 class="uk-h2 uk-margin-remove">
|
||||
My uploads
|
||||
</h1>
|
||||
<ng-container *ngIf="!showLoading">
|
||||
<div class="uk-margin-top">
|
||||
<ul class="uk-list uk-list-striped">
|
||||
<li *ngFor="let record of depositRecords">
|
||||
<h6>
|
||||
<a [href]="properties.zenodoDepositAPI + 'uploads/' + record.recordId" target="_blank"
|
||||
class="uk-link uk-link-heading ">
|
||||
<icon name="external-link"></icon>
|
||||
{{record['record'].title}}</a>
|
||||
</h6>
|
||||
<div class="uk-text-small">
|
||||
<span class="uk-text-meta">Upload date:</span>
|
||||
<span class="uk-margin-xsmall-left">{{record.depositDate | date:'yyyy/MM/dd HH:mm:ss'}} </span>
|
||||
</div>
|
||||
<div class="uk-text-small">
|
||||
<span class="uk-text-meta">Uploaded files:</span>
|
||||
<span class="uk-margin-xsmall-left">{{record.filenames.join(', ')}} </span>
|
||||
</div>
|
||||
<ul uk-accordion>
|
||||
<li>
|
||||
<a class="uk-accordion-title" href>View metadata</a>
|
||||
<div class="uk-accordion-content">
|
||||
<div class="uk-card uk-card-default">
|
||||
<div class="uk-padding-xsmall uk-margin-xsmall-left">
|
||||
<deposit-record-table [record]="record['record']" [files]="record.files"
|
||||
[style]="'uk-margin-xsmall-left'"></deposit-record-table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div *ngIf="depositRecords.length == 0" class="uk-alert uk-alert-primary">No uploads yet.</div>
|
||||
<div *ngIf="errorMessage" class="uk-alert uk-alert-danger" [innerHTML]="errorMessage"></div>
|
||||
<div *ngIf="message" [innerHTML]="message"></div>
|
||||
</ng-container>
|
||||
<div *ngIf="showLoading" class="uk-animation-fade uk-margin-top uk-width-1-1" role="alert">
|
||||
<loading></loading>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- <modal-alert #deleteModal [overflowBody]="false" (alertOutput)="deleteSpace(selectedRecord)"
|
||||
classTitle="uk-background-primary uk-light"></modal-alert>-->
|
||||
<!-- <a (click)="getAccessByRefresh(null)">get new Access by Refreh</a>-->
|
||||
|
||||
`,
|
||||
imports: [CommonModule, DepositRecordTableComponent, RouterModule]
|
||||
})
|
||||
|
||||
export class MyUploadsComponent {
|
||||
properties = properties;
|
||||
|
||||
@ViewChild('deleteModal') deleteModal: AlertModal;
|
||||
|
||||
public subscriptions: Subscription[] = [];
|
||||
|
||||
public showLoading: boolean = true;
|
||||
public message: string = "";
|
||||
public errorMessage: string = "";
|
||||
|
||||
public selectedRecord = null;
|
||||
|
||||
public depositRecords: DepositRecord [] = null;
|
||||
|
||||
user//: User;
|
||||
public openaireEntities = OpenaireEntities;
|
||||
|
||||
public routerHelper: RouterHelper = new RouterHelper();
|
||||
public authorNameParam: any = null;
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
private _router: Router,
|
||||
private userManagementService: UserManagementService,
|
||||
private _meta: Meta, private _title: Title, private _http: HttpClient) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
||||
this.user = user;
|
||||
if (this.user) {
|
||||
this.getUserUploads();
|
||||
this.authorNameParam = this.routerHelper.createQueryParams(['f0', 'fv0'], ['resultauthor', this.user.fullname]);
|
||||
} else if (properties.environment == 'development') {
|
||||
//TODO remove later
|
||||
this.user = {};
|
||||
this.user.id = "034130792470362";
|
||||
this.user.firstname = "Argiro";
|
||||
this.user.lastname = "Kokogiannaki";
|
||||
this.user.fullname = "Argiro Kokogiannaki";
|
||||
this.user.email = "argirok@di.uoa.gr"
|
||||
this.user.role = ['PORTAL_ADMINISTRATOR'];
|
||||
|
||||
this.getUserUploads();
|
||||
this.authorNameParam = this.routerHelper.createQueryParams(['f0', 'fv0'], ['resultauthor', this.user.fullname]);
|
||||
} else {
|
||||
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.subscriptions.forEach(subscription => {
|
||||
if (subscription instanceof Subscriber) {
|
||||
subscription.unsubscribe();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
deleteSpace(record) {
|
||||
/* this._http.delete(this.properties.zenodoDepositAPI + "api/deposit/depositions/" + this.space.id + "?access_token=" + this.userTokens.zenodoToken,
|
||||
).subscribe(res => {
|
||||
this.space = null;*/
|
||||
this._http.delete(this.properties.depositAPI + "deposit/record/delete?id=" + record._id).subscribe(res => {
|
||||
|
||||
})
|
||||
/*}, error => {
|
||||
console.error(error.message)
|
||||
UIkit.notification({
|
||||
message: 'An error occurred while deleting the record',
|
||||
status: 'danger',
|
||||
timeout: 6000,
|
||||
pos: 'bottom-right'
|
||||
});
|
||||
|
||||
|
||||
})*/
|
||||
}
|
||||
|
||||
|
||||
getUserUploads() {
|
||||
this.showLoading = true;
|
||||
this._http.get<DepositRecord[]>(this.properties.depositAPI + "deposit/record/user?aaiId=" + this.user.id).subscribe(res => {
|
||||
this.depositRecords = res;
|
||||
this.showLoading = false;
|
||||
})
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
export class DepositRecord{
|
||||
_id:string;
|
||||
aaiId: string;
|
||||
record:any | ZenodoRecord;
|
||||
filenames: string[] = [];
|
||||
pids: string[] = [];
|
||||
openAIREId: string;
|
||||
recordId: string;
|
||||
ownerId: string;
|
||||
depositDate: string;
|
||||
}
|
||||
|
||||
export class ZenodoRecord{
|
||||
//https://developers.zenodo.org/#representation
|
||||
title?:string;
|
||||
publication_date?:string;
|
||||
description?:string;
|
||||
access_right?:string;
|
||||
creators:{name:string,orcid?:string}[] = [];
|
||||
license?:string;
|
||||
upload_type:string;
|
||||
related_identifiers:{identifier:string, relation:string, resource_type:string}[] = [];
|
||||
journal_title?:string;
|
||||
journal_volume?:string;
|
||||
journal_issue?:string;
|
||||
imprint_publisher?:string;
|
||||
language?:string;
|
||||
grants:{id:string}[] =[];
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
import {Component, Input} from '@angular/core';
|
||||
import {properties} from 'src/environments/environment';
|
||||
import {ZenodoRecord} from "../utils/depositRecord.class";
|
||||
import {CommonModule} from "@angular/common";
|
||||
|
||||
declare var UIkit: any;
|
||||
|
||||
@Component({
|
||||
selector: 'deposit-record-table',
|
||||
standalone: true,
|
||||
template: `
|
||||
<table
|
||||
[class]="'uk-table-striped uk-text-small uk-grid-small uk-padding-xsmall uk-width-1-1 uk-text-left ' + style">
|
||||
<tr>
|
||||
<td class="uk-width-small">Title</td>
|
||||
<td>{{record.title}} </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Publication date</td>
|
||||
<td>{{record.publication_date}} </td>
|
||||
</tr>
|
||||
<tr *ngIf="record.description && record.description.length >0">
|
||||
<td>Description</td>
|
||||
<td>{{record.description.substring(0, 250)}}<span
|
||||
*ngIf="record.description.length > 247">...</span></td>
|
||||
</tr>
|
||||
<tr class="uk-text-bold uk-text-warning">
|
||||
<td>Access right</td>
|
||||
<td>{{record.access_right}} </td>
|
||||
</tr>
|
||||
<tr *ngIf="record.creators && record.creators.length > 0">
|
||||
<td>Creators</td>
|
||||
<td>
|
||||
<span *ngFor="let creator of record.creators; let i = index">{{creator.name}}<span
|
||||
*ngIf="i< record.creators.length -1">{{', '}}</span></span></td>
|
||||
</tr>
|
||||
<tr class="uk-text-bold uk-text-warning">
|
||||
<td>License</td>
|
||||
<td>{{record.license}} </td>
|
||||
</tr>
|
||||
<tr class="uk-text-bold uk-text-warning">
|
||||
<td>Upload type</td>
|
||||
<td class="uk-text-bold">{{record.upload_type}} </td>
|
||||
</tr>
|
||||
<tr *ngIf="record['related_identifiers']">
|
||||
<td>Related identifiers</td>
|
||||
<td>
|
||||
<span
|
||||
*ngFor="let identifier of record['related_identifiers']; let i = index">{{identifier.identifier + ' - ' }}
|
||||
<span class="uk-text-warning">{{identifier.relation}}</span> {{' - ' + identifier.resource_type}}
|
||||
<span *ngIf="i< record['related_identifiers'].length -1">{{', '}}</span></span></td>
|
||||
</tr>
|
||||
<tr *ngIf="record.journal_title">
|
||||
<td>Journal</td>
|
||||
<td>{{record.journal_title}}
|
||||
<span *ngIf="record.journal_volume"> {{',volume ' + record.journal_volume}} </span>
|
||||
<span *ngIf="record.journal_issue"> {{',issue ' + record.journal_issue}} </span></td>
|
||||
</tr>
|
||||
<tr *ngIf="record.imprint_publisher">
|
||||
<td>Publisher</td>
|
||||
<td>{{record.imprint_publisher}} </td>
|
||||
</tr>
|
||||
<tr *ngIf="record.language">
|
||||
<td>Language</td>
|
||||
<td>{{record.language}} </td>
|
||||
</tr>
|
||||
<tr *ngIf="record.grants">
|
||||
<td>Grants</td>
|
||||
<td>
|
||||
<span *ngFor="let grant of record['grants']; let i = index">{{grant.id}}
|
||||
<span *ngIf="i< record['grants'].length -1">{{', '}}</span></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Files</td>
|
||||
<td *ngIf="files">{{files.join(", ")}} </td>
|
||||
</tr>
|
||||
</table>
|
||||
`,
|
||||
imports: [CommonModule]
|
||||
})
|
||||
|
||||
export class DepositRecordTableComponent {
|
||||
properties = properties;
|
||||
|
||||
@Input() record: ZenodoRecord;
|
||||
@Input() files: string[];
|
||||
@Input() style: string = 'uk-border';
|
||||
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -36,12 +36,7 @@ import {EnvProperties} from "../properties/env-properties";
|
|||
</a>
|
||||
</div>
|
||||
<div *ngIf="(depositFile && properties.zenodoDepositClientId)">
|
||||
<a (click)="openDepositModal()"
|
||||
[attr.uk-tooltip]="showTooltip ? 'title: Deposit: upload a file in Zenodo; pos: bottom; cls: uk-active uk-text-small uk-padding-small' : 'cls: uk-invisible'"
|
||||
class="uk-flex uk-flex-middle uk-button-link" [ngClass]="isMobile ? 'uk-margin-left uk-margin-xsmall-bottom' : 'uk-text-bolder uk-flex-center'">
|
||||
<icon class="uk-text-bolder" [flex]="true" [ratio]="0.8" name="upload" visuallyHidden="upload"></icon>
|
||||
<span *ngIf="!compactView" class="uk-margin-xsmall-left">Upload a file</span>
|
||||
</a>
|
||||
<deposition [result]="result" [compactView]="compactView" [showTooltip]="showTooltip" [isMobile]="isMobile"> </deposition>
|
||||
</div>
|
||||
<div *ngIf="deposit && isRouteAvailable('participate/deposit/learn-how')">
|
||||
<a routerLinkActive="router-link-active" routerLink="/participate/deposit/learn-how"
|
||||
|
@ -90,9 +85,6 @@ import {EnvProperties} from "../properties/env-properties";
|
|||
</div>
|
||||
</div>
|
||||
</modal-alert>
|
||||
<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>
|
||||
</modal-alert>
|
||||
`
|
||||
})
|
||||
export class EntityActionsComponent implements OnInit {
|
||||
|
@ -117,7 +109,7 @@ export class EntityActionsComponent implements OnInit {
|
|||
@ViewChild('citeModal') citeModal;
|
||||
@ViewChild('embedResultsModal') embedResultsModal;
|
||||
@ViewChild('addThisModal') addThisModal;
|
||||
@ViewChild('depositModal') depositModal;
|
||||
// @ViewChild('depositModal') depositModal;
|
||||
properties: EnvProperties = properties;
|
||||
openaireEntities = OpenaireEntities;
|
||||
|
||||
|
@ -162,13 +154,13 @@ export class EntityActionsComponent implements OnInit {
|
|||
this.addThisModal.alertTitle = "Share this " + this.getTypeName() + " in your social networks";
|
||||
this.addThisModal.open();
|
||||
}
|
||||
public openDepositModal() {
|
||||
/*public openDepositModal() {
|
||||
// this.depositClicked = true;
|
||||
this.depositModal.cancelButton = false;
|
||||
this.depositModal.okButton = false;
|
||||
this.depositModal.alertTitle = "Deposit";
|
||||
this.depositModal.open();
|
||||
}
|
||||
}*/
|
||||
|
||||
public openEmbedResultsModal() {
|
||||
this.embedResultsModal.cancelButton = false;
|
||||
|
|
Loading…
Reference in New Issue