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';
|
|
|
|
import {ResultPreview} from "../../../utils/result-preview/result-preview";
|
|
|
|
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";
|
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>
|
|
|
|
<no-load-paging *ngIf="results.length > pageSize" [type]="type"
|
|
|
|
(pageChange)="updatePage($event)"
|
|
|
|
[page]="page" [pageSize]="pageSize"
|
|
|
|
[totalResults]="results.length">
|
|
|
|
</no-load-paging>
|
2023-02-21 15:10:21 +01:00
|
|
|
<ul class="uk-list uk-margin">
|
2022-06-16 18:37:31 +02:00
|
|
|
<li *ngFor="let result of results.slice((page-1)*pageSize, page*pageSize)">
|
2023-04-20 19:06:53 +02:00
|
|
|
<result-preview [modal]="modal" [properties]="properties" [hasLink]="false" [result]="getResultPreview(result)"
|
2023-06-07 10:09:43 +02:00
|
|
|
[showOrcid]="false" [isCard]="false" [prevPath]="prevPath" [showInline]="true"
|
|
|
|
[isDeletedByInferenceModal]="true"></result-preview>
|
2022-06-16 18:37:31 +02:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<no-load-paging *ngIf="results.length > pageSize" [type]="type"
|
|
|
|
(pageChange)="updatePage($event)"
|
|
|
|
[page]="page" [pageSize]="pageSize"
|
|
|
|
[totalResults]="results.length">
|
|
|
|
</no-load-paging>
|
|
|
|
</div>
|
2020-03-16 14:09:46 +01:00
|
|
|
`
|
2019-03-05 10:45:42 +01:00
|
|
|
})
|
|
|
|
export class DeletedByInferenceComponent {
|
2023-04-20 19:06:53 +02:00
|
|
|
@Input() prevPath: string = "";
|
2019-09-30 13:02:06 +02:00
|
|
|
public results: ResultLandingInfo[] = [];
|
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 = [];
|
2020-03-16 14:09:46 +01:00
|
|
|
properties: EnvProperties;
|
|
|
|
|
|
|
|
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-18 17:06:27 +01:00
|
|
|
|
|
|
|
this.properties = properties;
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2020-11-18 17:06:27 +01:00
|
|
|
|
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;
|
|
|
|
|
|
|
|
this.getDeletedByInference();
|
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
|
|
|
}
|
|
|
|
|
2019-03-05 10:45:42 +01:00
|
|
|
getDeletedByInference() {
|
|
|
|
this.results = [];
|
|
|
|
this.status = this.errorCodes.LOADING;
|
2020-11-11 15:43:13 +01:00
|
|
|
this.subscriptions.push(this._deletedByInferenceService.getDeletedByInferenceResults(this.id, String(this.ids.length), this.properties).subscribe(
|
2019-07-17 21:48:19 +02:00
|
|
|
data => {
|
|
|
|
this.results = data;
|
|
|
|
this.status = this.errorCodes.DONE;
|
|
|
|
},
|
|
|
|
error => {
|
2020-03-16 14:09:46 +01:00
|
|
|
if (error.status == '404') {
|
2019-07-17 21:48:19 +02:00
|
|
|
this.status = this.errorCodes.NOT_FOUND;
|
2020-03-16 14:09:46 +01:00
|
|
|
} else if (error.status == '500') {
|
2019-07-17 21:48:19 +02:00
|
|
|
this.status = this.errorCodes.ERROR;
|
|
|
|
} else {
|
|
|
|
this.status = this.errorCodes.NOT_AVAILABLE;
|
|
|
|
}
|
|
|
|
}
|
2020-11-11 15:43:13 +01:00
|
|
|
));
|
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
|
|
|
}
|
|
|
|
}
|