[master]: Add alternative method for browse rfos/rpos.

This commit is contained in:
Konstantinos Triantafyllou 2024-03-06 12:30:58 +02:00
parent 3599f3d7d9
commit 215ac51664
4 changed files with 17 additions and 8 deletions

@ -1 +1 @@
Subproject commit 9ef3f71ea656dca035238bb4f715666348a29616
Subproject commit e0de892998d76b2236babf3439ed532e4501145d

View File

@ -1,11 +1,10 @@
import {ChangeDetectorRef, Directive, OnInit} from "@angular/core";
import {StakeholderBaseComponent} from "../openaireLibrary/monitor-admin/utils/stakeholder-base.component";
import {Stakeholder, StakeholderType} from "../openaireLibrary/monitor/entities/stakeholder";
import {StakeholderType} from "../openaireLibrary/monitor/entities/stakeholder";
import {Option} from "../openaireLibrary/sharedComponents/input/input.component";
import {FormBuilder, FormControl} from "@angular/forms";
import {debounceTime, distinctUntilChanged} from "rxjs/operators";
import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
import {StakeholderService} from "../openaireLibrary/monitor/services/stakeholder.service";
import {LayoutService} from "../openaireLibrary/dashboard/sharedComponents/sidebar/layout.service";
import {IrishMonitorService} from "./irish-monitor.service";
import {StakeholderPublication} from "./irish";
@ -33,6 +32,7 @@ export class BrowseStakeholderBaseComponent extends StakeholderBaseComponent imp
pageSize: number = 10;
parameters = {};
keywordControl: FormControl;
hasPublications: boolean = true;
/* Services */
protected irishMonitorService: IrishMonitorService;
@ -57,6 +57,11 @@ export class BrowseStakeholderBaseComponent extends StakeholderBaseComponent imp
this.subscriptions.push(this.irishMonitorService.getStakeholdersWithPublications(this.stakeholderType).subscribe(stakeholders => {
this.stakeholders = stakeholders;
this.filteredStakeholders = stakeholders;
this.hasPublications = this.stakeholders.length > 0 && this.stakeholders.filter(stakeholder => stakeholder.publications > 0).length > 0;
if(!this.hasPublications) {
this.sortBy = 'alphAsc';
this.sortOptions = this.sortOptions.filter(option => !!option.value);
}
this.sortByChanged();
this.filtering(this.keywordControl.value);
}));

View File

@ -117,7 +117,7 @@
<tr>
<th>Logo</th>
<th>Name</th>
<th># of Publications</th>
<th *ngIf="hasPublications"># of Publications</th>
<th *ngIf="stakeholderType === 'funder'">Type</th>
<!-- <th class="uk-flex uk-flex-middle">
<icon [name]="'open_access'" [flex]="true" [ratio]="0.8" class="open-access"></icon>
@ -142,7 +142,7 @@
{{item.name}}
</div>
</td>
<td>
<td *ngIf="hasPublications">
<div class="uk-text-truncate uk-text-capitalize uk-text-italic uk-text-small uk-text-bold" [title]="item.name">
{{item.publications | number}}
</div>

View File

@ -5,8 +5,9 @@ import {StakeholderPublication} from "./irish";
import {properties} from "../../environments/environment";
import {Stakeholder, StakeholderType} from "../openaireLibrary/monitor/entities/stakeholder";
import {CustomOptions} from "../openaireLibrary/services/servicesUtils/customOptions.class";
import {map} from "rxjs/operators";
import {catchError, map} from "rxjs/operators";
import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
import {StakeholderService} from "../openaireLibrary/monitor/services/stakeholder.service";
@Injectable({
providedIn: 'root'
@ -14,11 +15,14 @@ import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
export class IrishMonitorService {
constructor(private http: HttpClient) {
constructor(private http: HttpClient,
private stakeholderService: StakeholderService) {
}
public getStakeholdersWithPublications(type: StakeholderType): Observable<StakeholderPublication[]> {
return this.http.get<StakeholderPublication[]>(properties.monitorServiceAPIURL + '/publications/' + type, CustomOptions.registryOptions()).pipe(map(stakeholders => {
return this.http.get<StakeholderPublication[]>(properties.monitorServiceAPIURL + '/publications/' + type, CustomOptions.registryOptions()).pipe(catchError(err => {
return this.stakeholderService.getStakeholders(properties.monitorServiceAPIURL, type, null);
}), map(stakeholders => {
return HelperFunctions.copy(Stakeholder.checkIsUpload(stakeholders));
}));
}