2020-11-11 15:43:13 +01:00
|
|
|
import {Component} from '@angular/core';
|
2020-03-16 14:09:46 +01:00
|
|
|
import {ElementRef, Input} from '@angular/core';
|
|
|
|
import {ActivatedRoute, Router} from '@angular/router';
|
2019-03-05 10:45:42 +01:00
|
|
|
|
2020-03-16 14:09:46 +01:00
|
|
|
import {EnvProperties} from '../../../utils/properties/env-properties';
|
|
|
|
import {ResultLandingInfo} from '../../../utils/entities/resultLandingInfo';
|
|
|
|
import {RouterHelper} from '../../../utils/routerHelper.class';
|
|
|
|
import {ErrorCodes} from '../../../utils/properties/errorCodes';
|
2019-03-05 10:45:42 +01:00
|
|
|
|
2020-03-16 14:09:46 +01:00
|
|
|
import {DeletedByInferenceService} from './deletedByInference.service';
|
2024-07-01 23:25:35 +02:00
|
|
|
import {HostedByCollectedFrom, ResultPreview} from "../../../utils/result-preview/result-preview";
|
2020-03-16 14:09:46 +01:00
|
|
|
import {AlertModal} from "../../../utils/modal/alert";
|
2020-11-11 15:43:13 +01:00
|
|
|
import {Subscriber} from "rxjs";
|
2020-11-18 17:06:27 +01:00
|
|
|
import {properties} from "../../../../../environments/environment";
|
2022-06-16 18:37:31 +02:00
|
|
|
import {HelperFunctions} from "../../../utils/HelperFunctions.class";
|
2024-07-01 23:25:35 +02:00
|
|
|
import {Dates, StringUtils} from "../../../utils/string-utils.class";
|
|
|
|
import {ParsingFunctions} from "../../landing-utils/parsingFunctions.class";
|
2019-03-05 10:45:42 +01:00
|
|
|
|
|
|
|
@Component({
|
2020-03-16 14:09:46 +01:00
|
|
|
selector: 'deletedByInference',
|
|
|
|
template: `
|
2022-06-16 18:37:31 +02:00
|
|
|
<div id="versions_container">
|
|
|
|
<errorMessages [status]="[status]" [type]="type" tab_error_class=true></errorMessages>
|
2024-07-01 23:25:35 +02:00
|
|
|
|
|
|
|
<no-load-paging *ngIf="resultsPreview.length > pageSize" [type]="type"
|
2022-06-16 18:37:31 +02:00
|
|
|
(pageChange)="updatePage($event)"
|
|
|
|
[page]="page" [pageSize]="pageSize"
|
2024-07-01 23:25:35 +02:00
|
|
|
[totalResults]="resultsPreview.length">
|
2022-06-16 18:37:31 +02:00
|
|
|
</no-load-paging>
|
2023-02-21 15:10:21 +01:00
|
|
|
<ul class="uk-list uk-margin">
|
2024-07-01 23:25:35 +02:00
|
|
|
<li *ngFor="let result of resultsPreview.slice((page-1)*pageSize, page*pageSize)">
|
|
|
|
<result-preview [modal]="modal" [properties]="properties" [hasLink]="false" [result]="result"
|
|
|
|
[showOrcid]="false" [prevPath]="prevPath" [showInline]="true"
|
2024-04-22 16:14:46 +02:00
|
|
|
[isDeletedByInferenceModal]="true" [isMobile]="isMobile"></result-preview>
|
2022-06-16 18:37:31 +02:00
|
|
|
</li>
|
|
|
|
</ul>
|
2024-07-01 23:25:35 +02:00
|
|
|
<no-load-paging *ngIf="resultsPreview.length > pageSize" [type]="type"
|
2022-06-16 18:37:31 +02:00
|
|
|
(pageChange)="updatePage($event)"
|
|
|
|
[page]="page" [pageSize]="pageSize"
|
2024-07-01 23:25:35 +02:00
|
|
|
[totalResults]="resultsPreview.length">
|
2022-06-16 18:37:31 +02:00
|
|
|
</no-load-paging>
|
|
|
|
</div>
|
2020-03-16 14:09:46 +01:00
|
|
|
`
|
2019-03-05 10:45:42 +01:00
|
|
|
})
|
|
|
|
export class DeletedByInferenceComponent {
|
2024-04-22 16:14:46 +02:00
|
|
|
@Input() isMobile: boolean = false;
|
2023-04-20 19:06:53 +02:00
|
|
|
@Input() prevPath: string = "";
|
2024-07-01 23:25:35 +02:00
|
|
|
public resultsPreview: ResultPreview[] = [];
|
|
|
|
@Input() children = [];
|
2019-03-05 10:45:42 +01:00
|
|
|
@Input() id: string;
|
|
|
|
@Input() ids: string[] = [];
|
|
|
|
@Input() type: string;
|
2020-03-16 14:09:46 +01:00
|
|
|
@Input() resultType: string;
|
|
|
|
@Input() modal: AlertModal;
|
|
|
|
|
2019-03-05 10:45:42 +01:00
|
|
|
// Custom tab paging variables
|
|
|
|
public page: number = 1;
|
2019-09-05 10:49:33 +02:00
|
|
|
public pageSize: number = 5;
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-03-05 10:45:42 +01:00
|
|
|
public status: number;
|
2020-03-16 14:09:46 +01:00
|
|
|
public routerHelper: RouterHelper = new RouterHelper();
|
|
|
|
public errorCodes: ErrorCodes = new ErrorCodes();
|
|
|
|
|
2020-11-11 15:43:13 +01:00
|
|
|
subscriptions = [];
|
2024-07-02 12:51:15 +02:00
|
|
|
properties: EnvProperties = properties;
|
2020-03-16 14:09:46 +01:00
|
|
|
|
|
|
|
constructor(private element: ElementRef,
|
|
|
|
private _deletedByInferenceService: DeletedByInferenceService,
|
2020-11-18 17:06:27 +01:00
|
|
|
private route: ActivatedRoute) {
|
2019-03-05 10:45:42 +01:00
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-03-05 10:45:42 +01:00
|
|
|
ngOnInit() {
|
2020-11-11 15:43:13 +01:00
|
|
|
this.subscriptions.push(this.route.queryParams.subscribe(data => {
|
2020-03-16 14:09:46 +01:00
|
|
|
this.errorCodes = new ErrorCodes();
|
|
|
|
this.status = this.errorCodes.LOADING;
|
|
|
|
|
2024-07-01 23:25:35 +02:00
|
|
|
this.parseDeletedByInference();
|
2020-11-11 15:43:13 +01:00
|
|
|
}));
|
2019-03-05 10:45:42 +01:00
|
|
|
}
|
2020-11-11 15:43:13 +01:00
|
|
|
|
2020-03-16 14:09:46 +01:00
|
|
|
ngOnDestroy() {
|
2020-11-11 15:43:13 +01:00
|
|
|
this.subscriptions.forEach(subscription => {
|
|
|
|
if (subscription instanceof Subscriber) {
|
|
|
|
subscription.unsubscribe();
|
|
|
|
}
|
|
|
|
});
|
2020-03-16 14:09:46 +01:00
|
|
|
}
|
2024-07-01 23:25:35 +02:00
|
|
|
|
|
|
|
public parseDeletedByInference() {
|
|
|
|
let parsingFunctions: ParsingFunctions = new ParsingFunctions();
|
|
|
|
let length = Array.isArray(this.children) ? this.children.length : 1;
|
|
|
|
for (let i = 0; i < length; i++) {
|
|
|
|
let result = Array.isArray(this.children) ? this.children[i] : this.children;
|
|
|
|
let preview = new ResultPreview();
|
|
|
|
if(result.hasOwnProperty("creator")) {
|
|
|
|
preview.authors = [];
|
|
|
|
let authorsLength = Array.isArray(result.creator) ? result.creator.length : 1;
|
|
|
|
for (let j = 0; j < authorsLength; j++) {
|
|
|
|
let author = {"fullName": Array.isArray(result.creator) ? result.creator[j] : result.creator, "orcid": null, "orcid_pending": null};
|
|
|
|
preview.authors.push(author);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(result.hasOwnProperty("dateofacceptance")) {
|
|
|
|
preview.year = new Date(result.dateofacceptance).getFullYear().toString();
|
|
|
|
}
|
|
|
|
if(result.hasOwnProperty("title")) {
|
|
|
|
let titleLength = Array.isArray(result.title) ? result.title.length : 1;
|
|
|
|
for (let j = 0; j < titleLength; j++) {
|
|
|
|
let title = Array.isArray(result.title) ? result.title[j] : result.title;
|
|
|
|
if (!preview.title || title.classid == "main title") {
|
|
|
|
preview.title = StringUtils.HTMLToString(String(title.content));
|
|
|
|
}
|
2019-07-17 21:48:19 +02:00
|
|
|
}
|
|
|
|
}
|
2024-07-01 23:25:35 +02:00
|
|
|
if(result.hasOwnProperty("description")) {
|
|
|
|
preview.description = result.description;
|
|
|
|
}
|
|
|
|
preview.resultType = result?.resulttype?.classid ? result.resulttype.classid : this.resultType;
|
|
|
|
|
|
|
|
|
|
|
|
if (result.hasOwnProperty("instance")) {
|
|
|
|
preview.hostedBy_collectedFrom = new Array<HostedByCollectedFrom>();
|
|
|
|
|
|
|
|
preview.types = new Array<string>();
|
|
|
|
let types = new Set<string>();
|
|
|
|
|
|
|
|
let counter = 0;
|
|
|
|
let instance;
|
|
|
|
|
|
|
|
let instanesLength = Array.isArray(result['instance']) ? result['instance'].length : 1;
|
|
|
|
|
|
|
|
for (let j = 0; j < instanesLength; j++) {
|
|
|
|
instance = Array.isArray(result['instance']) ? result['instance'][j] : result['instance'];
|
|
|
|
if(result.hasOwnProperty('collectedfrom')) {
|
|
|
|
if(Array.isArray(result['collectedfrom'])) {
|
|
|
|
// not sure if this is correct mapping
|
|
|
|
instance['collectedfrom'] = result['collectedfrom'].length >= j ? result['collectedfrom'][j] : result['collectedfrom'][result['collectedfrom'].length - 1];
|
|
|
|
} else {
|
|
|
|
instance['collectedfrom'] = result['collectedfrom'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
parsingFunctions.parseTypes(preview.types, types, instance);
|
|
|
|
|
|
|
|
if (instance.hasOwnProperty("webresource")) {
|
|
|
|
let url;
|
|
|
|
if (!Array.isArray(instance['webresource'])) {
|
|
|
|
url = instance['webresource'].url;
|
|
|
|
} else {
|
|
|
|
url = instance['webresource'][0].url;
|
|
|
|
}
|
|
|
|
if (url.includes('&')) {
|
|
|
|
url = url.replace(/&/gmu, '&');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************/
|
|
|
|
if (instance.hasOwnProperty("hostedby")) {
|
|
|
|
parsingFunctions.parseHostedBy_collectedFrom(preview.hostedBy_collectedFrom, instance, url, null);
|
|
|
|
}
|
|
|
|
/**********************************************************/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// /* Order Download from via openness*/
|
|
|
|
preview.hostedBy_collectedFrom.sort(parsingFunctions.compareHostedByCollectedFrom);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.resultsPreview.push(preview);
|
|
|
|
}
|
|
|
|
this.status = this.errorCodes.DONE;
|
2019-03-05 10:45:42 +01:00
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
|
|
|
public getResultPreview(result: ResultLandingInfo): ResultPreview {
|
|
|
|
return ResultPreview.resultLandingInfoConvert(result, this.resultType);
|
|
|
|
}
|
|
|
|
|
2019-03-05 10:45:42 +01:00
|
|
|
public totalPages(totalResults: number): number {
|
2020-03-16 14:09:46 +01:00
|
|
|
let totalPages: any = totalResults / this.pageSize;
|
|
|
|
if (!(Number.isInteger(totalPages))) {
|
|
|
|
totalPages = (parseInt(totalPages, this.pageSize) + 1);
|
2019-03-05 10:45:42 +01:00
|
|
|
}
|
|
|
|
return totalPages;
|
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-03-05 10:45:42 +01:00
|
|
|
public updatePage($event) {
|
|
|
|
this.page = $event.value;
|
2022-06-16 18:37:31 +02:00
|
|
|
HelperFunctions.scrollToId("versions_container");
|
2019-03-05 10:45:42 +01:00
|
|
|
}
|
|
|
|
}
|