openaire-library/landingPages/result/deletedByInference/deletedByInference.componen...

126 lines
4.3 KiB
TypeScript
Raw Normal View History

import {Component} from '@angular/core';
import {ElementRef, Input} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
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';
import {DeletedByInferenceService} from './deletedByInference.service';
import {ResultPreview} from "../../../utils/result-preview/result-preview";
import {AlertModal} from "../../../utils/modal/alert";
import {Subscriber} from "rxjs";
import {properties} from "../../../../../environments/environment";
import {HelperFunctions} from "../../../utils/HelperFunctions.class";
@Component({
selector: 'deletedByInference',
template: `
<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>
<ul class="uk-list uk-margin">
<li *ngFor="let result of results.slice((page-1)*pageSize, page*pageSize)">
[Library | develop & Eosc Explore | develop]: Added font-family "Inter" to align with Marketplace | Updated how back button "Go to search" is build - combine referrer and the new url parameter "pv", which is expected to have the previous url path and params. 1. /assets: Added /media/fonts/inter folder with the "Inter" font-family. 2. eosc-custom.less: Override the default font family to use 'Inter', sans-serif. 3. routerHelper.class.ts: Added method "addQueryParam()" to add a query parameter in already existing or not object with parameters. 4. search-tab.component.ts & searchResult.component & projects-in-modal.component.ts & result/deletedByInference/deletedByInference.component.ts & organization/deletedByInference/deletedByInference.component.ts: Added @Input() prevPath: string = ""; and pass it to the appropriate children components. 5. result-preview.component & fundedBy.component.ts & availableOn.component.ts & relatedDatasourcesTab.component.ts: Added @Input() prevPath: string = ""; and method "addEoscPrevInParams()" and call it when building queryParams of internal links. 6. metrics.component.ts: Added @Input() prevPath: string = ""; and use it when building internal urls. 7. resultLanding.component.ts & project.component.ts & organization.component.ts & dataProvider.component.ts: a. Added fields public referrer: string; and public prevPath: string; b. Read "pv" url property and get referrer. c. Added methods "addEoscPrevInParams()" and "eoscBackLink()". 8. resultLanding.component.html & project.component.html & organization.component.html & dataProvider.component.html: a. Update "Go to Search" back link. b. Call "addEoscPrevInParams()" method when building queryParams of internal links. c. Pass "prevPath" to the appropriate children components.
2023-04-20 19:06:53 +02:00
<result-preview [modal]="modal" [properties]="properties" [hasLink]="false" [result]="getResultPreview(result)"
2024-02-14 14:43:27 +01:00
[showOrcid]="false" [prevPath]="prevPath" [showInline]="true"
[isDeletedByInferenceModal]="true" [isMobile]="isMobile"></result-preview>
</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>
`
})
export class DeletedByInferenceComponent {
@Input() isMobile: boolean = false;
[Library | develop & Eosc Explore | develop]: Added font-family "Inter" to align with Marketplace | Updated how back button "Go to search" is build - combine referrer and the new url parameter "pv", which is expected to have the previous url path and params. 1. /assets: Added /media/fonts/inter folder with the "Inter" font-family. 2. eosc-custom.less: Override the default font family to use 'Inter', sans-serif. 3. routerHelper.class.ts: Added method "addQueryParam()" to add a query parameter in already existing or not object with parameters. 4. search-tab.component.ts & searchResult.component & projects-in-modal.component.ts & result/deletedByInference/deletedByInference.component.ts & organization/deletedByInference/deletedByInference.component.ts: Added @Input() prevPath: string = ""; and pass it to the appropriate children components. 5. result-preview.component & fundedBy.component.ts & availableOn.component.ts & relatedDatasourcesTab.component.ts: Added @Input() prevPath: string = ""; and method "addEoscPrevInParams()" and call it when building queryParams of internal links. 6. metrics.component.ts: Added @Input() prevPath: string = ""; and use it when building internal urls. 7. resultLanding.component.ts & project.component.ts & organization.component.ts & dataProvider.component.ts: a. Added fields public referrer: string; and public prevPath: string; b. Read "pv" url property and get referrer. c. Added methods "addEoscPrevInParams()" and "eoscBackLink()". 8. resultLanding.component.html & project.component.html & organization.component.html & dataProvider.component.html: a. Update "Go to Search" back link. b. Call "addEoscPrevInParams()" method when building queryParams of internal links. c. Pass "prevPath" to the appropriate children components.
2023-04-20 19:06:53 +02:00
@Input() prevPath: string = "";
public results: ResultLandingInfo[] = [];
@Input() id: string;
@Input() ids: string[] = [];
@Input() type: string;
@Input() resultType: string;
@Input() modal: AlertModal;
// Custom tab paging variables
public page: number = 1;
public pageSize: number = 5;
public status: number;
public routerHelper: RouterHelper = new RouterHelper();
public errorCodes: ErrorCodes = new ErrorCodes();
subscriptions = [];
properties: EnvProperties;
constructor(private element: ElementRef,
private _deletedByInferenceService: DeletedByInferenceService,
private route: ActivatedRoute) {
}
ngOnInit() {
this.properties = properties;
this.subscriptions.push(this.route.queryParams.subscribe(data => {
this.errorCodes = new ErrorCodes();
this.status = this.errorCodes.LOADING;
this.getDeletedByInference();
}));
}
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
}
getDeletedByInference() {
this.results = [];
this.status = this.errorCodes.LOADING;
this.subscriptions.push(this._deletedByInferenceService.getDeletedByInferenceResults(this.id, String(this.ids.length), this.properties).subscribe(
data => {
this.results = data;
this.status = this.errorCodes.DONE;
},
error => {
if (error.status == '404') {
this.status = this.errorCodes.NOT_FOUND;
} else if (error.status == '500') {
this.status = this.errorCodes.ERROR;
} else {
this.status = this.errorCodes.NOT_AVAILABLE;
}
}
));
}
public getResultPreview(result: ResultLandingInfo): ResultPreview {
return ResultPreview.resultLandingInfoConvert(result, this.resultType);
}
public totalPages(totalResults: number): number {
let totalPages: any = totalResults / this.pageSize;
if (!(Number.isInteger(totalPages))) {
totalPages = (parseInt(totalPages, this.pageSize) + 1);
}
return totalPages;
}
public updatePage($event) {
this.page = $event.value;
HelperFunctions.scrollToId("versions_container");
}
}