2020-05-31 13:26:45 +02:00
|
|
|
import {Component, Input} from '@angular/core';
|
|
|
|
import {EnvProperties} from "../../properties/env-properties";
|
|
|
|
import {ErrorCodes} from "../../properties/errorCodes";
|
2022-04-28 11:13:06 +02:00
|
|
|
import {OpenaireEntities} from "../../properties/searchFields";
|
2022-06-03 12:01:55 +02:00
|
|
|
import {StringUtils} from "../../string-utils.class";
|
2020-05-31 13:26:45 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'search-tab',
|
|
|
|
template: `
|
2023-03-09 09:54:03 +01:00
|
|
|
<a *ngIf="properties.adminToolsPortalType !== 'eosc' && fetch.searchUtils.status == errorCodes.LOADING" class="uk-invisible"
|
2022-06-10 13:56:32 +02:00
|
|
|
[queryParams]="params" [routerLink]="searchLinkToAdvancedPage"></a>
|
|
|
|
|
|
|
|
<ng-container> <!-- *ngIf="fetch.searchUtils.status != errorCodes.LOADING" -->
|
2023-02-21 23:09:12 +01:00
|
|
|
<div class="uk-flex uk-flex-between uk-flex-middle uk-margin-bottom" [class.uk-flex-column]="isMobile">
|
2022-06-10 13:56:32 +02:00
|
|
|
<div class="uk-text-meta uk-text-large uk-text-uppercase">
|
|
|
|
<span *ngIf="!customTitle && resultType"><span *ngIf="resultType != 'organization' && resultType != 'dataprovider' && resultType != 'project'">Recent</span>
|
|
|
|
{{getEntityName(resultType)}}
|
|
|
|
</span>
|
|
|
|
<span *ngIf="customTitle">{{customTitle}}</span>
|
|
|
|
</div>
|
|
|
|
<div *ngIf="searchLinkToAdvancedPage">
|
2023-03-09 09:54:03 +01:00
|
|
|
<a *ngIf="properties.adminToolsPortalType !== 'eosc'" class="el-content uk-button uk-button-text" [queryParams]="params" [routerLink]="searchLinkToAdvancedPage">
|
2022-06-10 13:56:32 +02:00
|
|
|
View all
|
|
|
|
<span *ngIf="fetch.searchUtils.totalResults <= searchNumber">in search page</span>
|
|
|
|
</a>
|
2023-03-09 09:54:03 +01:00
|
|
|
<a *ngIf="properties.adminToolsPortalType == 'eosc'" class="el-content uk-button uk-button-text custom-external"
|
|
|
|
[href]="'https://explore.openaire.eu'+searchLinkToAdvancedPage+paramsForExternalUrl" target="_blank">
|
|
|
|
View all in OpenAIRE
|
|
|
|
</a>
|
2022-06-10 13:56:32 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-05-31 13:26:45 +02:00
|
|
|
|
2022-06-10 13:56:32 +02:00
|
|
|
<ng-content></ng-content>
|
|
|
|
|
|
|
|
<div *ngIf="resultType && fetch.searchUtils.status != errorCodes.DONE" class="uk-margin-xlarge-top">
|
|
|
|
<errorMessages [status]="[fetch.searchUtils.status]" [type]="getEntityName(resultType)"
|
|
|
|
tab_error_class=true></errorMessages>
|
|
|
|
</div>
|
2022-05-06 15:31:40 +02:00
|
|
|
|
2022-06-10 13:56:32 +02:00
|
|
|
</ng-container>
|
2022-04-28 11:13:06 +02:00
|
|
|
|
2022-06-10 13:56:32 +02:00
|
|
|
<ng-container *ngIf="fetch.searchUtils.status == errorCodes.DONE">
|
2022-07-07 11:49:10 +02:00
|
|
|
<search-result [properties]="properties"
|
|
|
|
[results]="results"
|
|
|
|
[status]="fetch.searchUtils.status"
|
2023-04-20 19:06:53 +02:00
|
|
|
[type]="resultType" [showEnermaps]="showEnermaps" [prevPath]="prevPath">
|
2022-06-10 13:56:32 +02:00
|
|
|
</search-result>
|
2020-05-31 13:26:45 +02:00
|
|
|
|
2022-04-28 11:13:06 +02:00
|
|
|
<!-- <div *ngIf="searchLinkToAdvancedPage && fetch.results?.length > 0" class="uk-text-right">-->
|
|
|
|
<!-- <a class="el-content uk-button uk-button-text" [queryParams]="params" [routerLink]="searchLinkToAdvancedPage">-->
|
|
|
|
<!-- View all-->
|
|
|
|
<!-- <span *ngIf="fetch.searchUtils.totalResults <= searchNumber">in search page</span>-->
|
|
|
|
<!-- </a>-->
|
|
|
|
<!-- </div>-->
|
2022-06-10 13:56:32 +02:00
|
|
|
</ng-container>
|
2020-05-31 13:26:45 +02:00
|
|
|
`
|
|
|
|
})
|
|
|
|
|
|
|
|
export class SearchTabComponent {
|
2023-02-21 23:09:12 +01:00
|
|
|
@Input() public isMobile: boolean = false;
|
2023-04-20 19:06:53 +02:00
|
|
|
@Input() prevPath: string = "";
|
2020-05-31 13:26:45 +02:00
|
|
|
@Input() public fetch;
|
|
|
|
@Input() public resultType: string;
|
|
|
|
@Input() public params: any;
|
|
|
|
@Input() public searchNumber: number = 5;
|
|
|
|
@Input() public searchLinkToAdvancedPage: string;
|
|
|
|
@Input() properties: EnvProperties;
|
2021-03-10 11:41:38 +01:00
|
|
|
@Input() customTitle;
|
2021-04-02 11:17:00 +02:00
|
|
|
@Input() showEnermaps: boolean;
|
2022-07-07 11:49:10 +02:00
|
|
|
@Input() currentPage: number = null;
|
2021-03-10 11:41:38 +01:00
|
|
|
|
2020-05-31 13:26:45 +02:00
|
|
|
public errorCodes: ErrorCodes = new ErrorCodes();
|
|
|
|
|
2022-04-28 11:13:06 +02:00
|
|
|
public getEntityName(entityType: string): string {
|
2022-06-03 12:01:55 +02:00
|
|
|
return StringUtils.getEntityName(entityType, true);
|
2020-05-31 13:26:45 +02:00
|
|
|
}
|
2022-07-07 11:49:10 +02:00
|
|
|
|
|
|
|
get results() {
|
|
|
|
return this.currentPage ? this.fetch.results.slice((this.currentPage - 1) * this.searchNumber, this.currentPage * this.searchNumber) : this.fetch.results;
|
|
|
|
}
|
2023-03-09 09:54:03 +01:00
|
|
|
|
|
|
|
get paramsForExternalUrl() {
|
|
|
|
let parameters: string = "";
|
|
|
|
Object.keys(this.params).forEach(paramKey => {
|
|
|
|
parameters += (parameters ? "&" : "?") + paramKey+"="+this.params[paramKey];
|
|
|
|
})
|
|
|
|
return parameters;
|
|
|
|
}
|
2020-05-31 13:26:45 +02:00
|
|
|
}
|