openaire-library/landingPages/dataProvider/relatedDatasourcesTab.compo...

153 lines
6.1 KiB
TypeScript
Raw Normal View History

import {Component, Input} from '@angular/core';
[Trunk | Library]: Merge services, fetchClasses, simple and advanced search pages for research results (publications, datasets, software, other): 1. advancedSearchResearchResults.component & advancedSearchResearchResults.module: New common advanced search page for research results. 2. searchResearchResults.component & searchResearchResults.module: New common simple search page for research results. 3. fetchResearchResults.class: New common fetch class for research results. 4. searchResearchResults.service: Update existing service to satisfy merge of research results services. 5. app.module.ts: Import one common simple and one common advanced search page for search results. 6. claimResultSearchForm & directLinking & advancedSearchDatasets & advancedSearchOrps & advancedSearchPublications & advancedSearchSoftware & searchDatasets & searchOrps & searchPublications & searchSoftware & fetchDatasets.class & fetchOrps.class & fetchPublications.class & fetchSoftware.class: Use common service for research results (searchResearchResults.service). 7. datasetsTab & orpsTab & publicationsTab & softwareTab & relatedDatasourcesTab & statisticsTab: Use common fetch class for research results (fetchResearchResults.class). 8. dataProvider & organization & project & search : Use common service and common fetch class for research results (searchResearchResults.service, fetchResearchResults.class). 9. linkingGeneric.component: Remove import of services for publications and datasets. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@57027 d315682c-612b-4755-9ff5-7f18f6832af3
2019-09-11 11:45:54 +02:00
import { FetchResearchResults } from '../../utils/fetchEntitiesClasses/fetchResearchResults.class';
import { ErrorCodes} from '../../utils/properties/errorCodes';
[Trunk | Library]: Merge services, fetchClasses, simple and advanced search pages for research results (publications, datasets, software, other): 1. advancedSearchResearchResults.component & advancedSearchResearchResults.module: New common advanced search page for research results. 2. searchResearchResults.component & searchResearchResults.module: New common simple search page for research results. 3. fetchResearchResults.class: New common fetch class for research results. 4. searchResearchResults.service: Update existing service to satisfy merge of research results services. 5. app.module.ts: Import one common simple and one common advanced search page for search results. 6. claimResultSearchForm & directLinking & advancedSearchDatasets & advancedSearchOrps & advancedSearchPublications & advancedSearchSoftware & searchDatasets & searchOrps & searchPublications & searchSoftware & fetchDatasets.class & fetchOrps.class & fetchPublications.class & fetchSoftware.class: Use common service for research results (searchResearchResults.service). 7. datasetsTab & orpsTab & publicationsTab & softwareTab & relatedDatasourcesTab & statisticsTab: Use common fetch class for research results (fetchResearchResults.class). 8. dataProvider & organization & project & search : Use common service and common fetch class for research results (searchResearchResults.service, fetchResearchResults.class). 9. linkingGeneric.component: Remove import of services for publications and datasets. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@57027 d315682c-612b-4755-9ff5-7f18f6832af3
2019-09-11 11:45:54 +02:00
import { RouterHelper } from '../../utils/routerHelper.class';
import { EnvProperties } from '../../utils/properties/env-properties';
import {AlertModal} from "../../utils/modal/alert";
import {properties} from "../../../../environments/environment";
import {OpenaireEntities} from "../../utils/properties/searchFields";
@Component({
selector: 'relatedDatasourcesTab',
template: `
<errorMessages [status]="[fetchResults.searchUtils.status]"
[type]="'related '+openaireEntities.DATASOURCES" tab_error_class=true>
</errorMessages>
<div *ngIf="fetchResults.searchUtils.status == errorCodes.DONE && !loading" class="uk-text-small">
<div class="uk-text-meta uk-margin-medium-bottom">
*Only top 100 {{openaireEntities.DATASOURCES}} that host {{openaireEntities.RESULTS}} which are also available via the Federated Research Data Repository are shown.
</div>
<results-and-pages *ngIf="results.length >pageSize" [type]="openaireEntities.DATASOURCES"
[page]="page" [pageSize]="pageSize"
[totalResults]="results.length">
</results-and-pages>
<table class="uk-table uk-table-striped">
<thead>
<tr>
<th>{{openaireEntities.DATASOURCE}}</th>
<th *ngIf="fetchResults.results.length > 0 || fetchResults.searchUtils.status == errorCodes.ERROR"
class="uk-text-center">
{{openaireEntities.RESULTS}} in Explore
</th>
</tr>
</thead>
<tbody>
<ng-container *ngIf="results">
<ng-container *ngFor="let result of results; let i=index">
<tr *ngIf="i>=(page-1)*pageSize && i<page*pageSize">
<td>
[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
<a [queryParams]="addEoscPrevInParams({datasourceId: result.id})" routerLinkActive="router-link-active" [routerLink]="dataProviderUrl"
(click)="onLinkClick()">
{{result.name}}
</a>
</td>
<td *ngIf="fetchResults.results.length > 0" class="uk-text-center">
<a *ngIf="properties.adminToolsPortalType !== 'eosc'"
[queryParams]="routerHelper.createQueryParams(['f0', 'fv0', 'f1', 'fv1', 'f2', 'fv2', 'qf'], ['collectedfromdatasourceid', dataproviderId, 'resulthostingdatasourceid,or', dataproviderId, 'resulthostingdatasourceid', result.id, 'false'])"
routerLinkActive="router-link-active" [routerLink]="properties.searchLinkToAdvancedResults"
(click)="onLinkClick()">
{{result.count | number}}
</a>
<a *ngIf="properties.adminToolsPortalType == 'eosc'" class="custom-external" target="_blank"
[href]="'https://explore.openaire.eu'+properties.searchLinkToAdvancedResults+'?f0=collectedfromdatasourceid&fv0='+dataproviderId+'&f1=resulthostingdatasourceid,or&fv1='+dataproviderId+'&f2=resulthostingdatasourceid&fv2='+result.id+'&qf=false'">
{{result.count | number}}
</a>
</td>
</tr>
</ng-container>
</ng-container>
</tbody>
</table>
<paging-no-load *ngIf="results.length >pageSize"
(pageChange)="updatePage($event)"
[currentPage]="page"
[size]="pageSize"
[totalResults]="results.length">
</paging-no-load>
</div>
`
})
export class RelatedDatasourcesTabComponent {
[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 = "";
@Input() dataproviderId: string;
// @Input() fetchPublications : FetchResearchResults;
// @Input() fetchDatasets : FetchResearchResults;
// @Input() fetchSoftware : FetchResearchResults;
// @Input() fetchOrps: FetchResearchResults;
@Input() fetchResults: FetchResearchResults;
// true: preprocessing is not over
@Input() loading: boolean = true;
// Εvery datasource's id is a single key of a map
//@Input() results: Map<string, {"name": string, "countPublications": string, "countDatasets": string, "countSoftware": string, "countOrps": string}>;
@Input() results: {"id": string, "name": string, "count": number}[];
@Input() properties:EnvProperties ;
@Input() collectedFromName: string ="[no title available]";
@Input() modal: AlertModal;
public routerHelper:RouterHelper = new RouterHelper();
public errorCodes:ErrorCodes = new ErrorCodes();
public page: number = 1;
public pageSize: number = 10;
public dataProviderUrl;
public openaireEntities = OpenaireEntities;
constructor () {}
ngOnInit() {
this.dataProviderUrl = properties.searchLinkToDataProvider.split('?')[0];
}
ngOnDestroy() {}
totalPages(totalResults: number): number {
let totalPages:any = totalResults/this.pageSize;
if(!(Number.isInteger(totalPages))) {
totalPages = (parseInt(totalPages, this.pageSize) + 1);
}
return totalPages;
}
updatePage($event) {
this.page = $event.value;
this.scrollToTabTop("relatedDatasources");
}
scrollToTabTop(tabId:string){
setTimeout(() => {
window.scrollTo({
top: document.getElementById(tabId) ? document.getElementById(tabId).offsetTop - 250 : 250,
behavior: 'smooth'
});
}, 200);
}
public getKeys( map) {
return Array.from(map.keys());
}
public onLinkClick() {
if(this.modal) {
this.modal.cancel();
}
}
[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
public addEoscPrevInParams(obj) {
if(properties.adminToolsPortalType == "eosc" && this.prevPath) {
let splitted: string[] = this.prevPath.split("?");
obj = this.routerHelper.addQueryParam("return_path", splitted[0], obj);
if(splitted.length > 0) {
obj = this.routerHelper.addQueryParam("search_params", splitted[1], obj);
}
[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
}
return obj;
}
}