Dataprovider landing: 'Related Content Providers' tab requests for both Publication and Research Data - observer added in fetch functions to preprocess when requests are over
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@48845 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
81d7666b34
commit
0b8fb9da6f
|
@ -152,9 +152,10 @@
|
||||||
</organizationsTab>
|
</organizationsTab>
|
||||||
<!--*ngIf=" tab.content=='relatedDatasourcesTab'"-->
|
<!--*ngIf=" tab.content=='relatedDatasourcesTab'"-->
|
||||||
<relatedDatasourcesTab *ngIf="activeTab=='Related Content Providers'"
|
<relatedDatasourcesTab *ngIf="activeTab=='Related Content Providers'"
|
||||||
[dataproviderId]="id"
|
[dataproviderId]="datasourceId"
|
||||||
[fetchResults]="fetchResultsAggregators"
|
[fetchPublications]="fetchAggregatorsPublications"
|
||||||
[type]="relatedDataprovidersResultsType">
|
[fetchDatasets]="fetchAggregatorsDatasets">
|
||||||
|
<!--[type]="relatedDataprovidersResultsType"-->
|
||||||
</relatedDatasourcesTab>
|
</relatedDatasourcesTab>
|
||||||
|
|
||||||
<!-- *ngIf=" tab.content=='statisticsTab' && statsClicked"-->
|
<!-- *ngIf=" tab.content=='statisticsTab' && statsClicked"-->
|
||||||
|
|
|
@ -62,7 +62,8 @@ export class DataProviderComponent {
|
||||||
public fetchDatasets: FetchDatasets;
|
public fetchDatasets: FetchDatasets;
|
||||||
public fetchProjects: FetchProjects;
|
public fetchProjects: FetchProjects;
|
||||||
public fetchDataproviders: FetchDataproviders;
|
public fetchDataproviders: FetchDataproviders;
|
||||||
public fetchResultsAggregators: any;
|
public fetchAggregatorsPublications: FetchPublications;
|
||||||
|
public fetchAggregatorsDatasets: FetchDatasets;
|
||||||
|
|
||||||
// Active tab variable for responsiveness - show tabs only if main request is completed
|
// Active tab variable for responsiveness - show tabs only if main request is completed
|
||||||
public activeTab: string = "";
|
public activeTab: string = "";
|
||||||
|
@ -254,15 +255,15 @@ export class DataProviderComponent {
|
||||||
this.pubsProjectsUrl ='https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"dtsrcProjPubs","dtsrcName":"'+this.datasourceId+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "bar", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Publications"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [""], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250';
|
this.pubsProjectsUrl ='https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"dtsrcProjPubs","dtsrcName":"'+this.datasourceId+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "bar", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Publications"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [""], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250';
|
||||||
|
|
||||||
//if({"name": "Publications", "content": "publicationsTab"} in this.dataProviderInfo.tabs) {
|
//if({"name": "Publications", "content": "publicationsTab"} in this.dataProviderInfo.tabs) {
|
||||||
if(this.dataProviderInfo.tabs.some(function (tab) {
|
//if(this.dataProviderInfo.tabs.some(function (tab) {
|
||||||
return tab.name === 'Publications';
|
// return tab.name === 'Publications';
|
||||||
})) {
|
//})) {
|
||||||
this.relatedDataprovidersResultsType = 'publications';
|
// this.relatedDataprovidersResultsType = 'publications';
|
||||||
this.fetchResultsAggregators = new FetchPublications(this._searchPublicationsService);
|
this.fetchAggregatorsPublications = new FetchPublications(this._searchPublicationsService);
|
||||||
} else {
|
//} else {
|
||||||
this.relatedDataprovidersResultsType = 'datasets';
|
// this.relatedDataprovidersResultsType = 'datasets';
|
||||||
this.fetchResultsAggregators = new FetchDatasets(this._searchDatasetsService);
|
this.fetchAggregatorsDatasets = new FetchDatasets(this._searchDatasetsService);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
if(this.dataProviderInfo.resultsBy == "collectedFrom") {
|
if(this.dataProviderInfo.resultsBy == "collectedFrom") {
|
||||||
//this.paramsForSearchLink = "?collectedFrom="+this.datasourceId+"&co=and";
|
//this.paramsForSearchLink = "?collectedFrom="+this.datasourceId+"&co=and";
|
||||||
|
@ -311,75 +312,81 @@ export class DataProviderComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
private searchPublications(page: number, size: number) {
|
private searchPublications(page: number, size: number) {
|
||||||
if(this.reloadPublications) {
|
if(this.fetchPublications.searchUtils.status == this.errorCodes.NONE) {
|
||||||
this.fetchPublications.getResultsForDataproviders(this.datasourceId, this.dataProviderInfo.resultsBy, page, size);
|
|
||||||
}
|
|
||||||
this.reloadPublications = false;
|
this.reloadPublications = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.reloadPublications) {
|
||||||
|
this.fetchPublications.getResultsForDataproviders(this.datasourceId, this.dataProviderInfo.resultsBy, page, size);
|
||||||
|
}
|
||||||
|
this.reloadPublications = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private countPublications(page: number, size: number) {
|
private countPublications(page: number, size: number) {
|
||||||
this.fetchPublications.getResultsForDataproviders(this.datasourceId, this.dataProviderInfo.resultsBy, page, size);
|
this.fetchPublications.getResultsForDataproviders(this.datasourceId, this.dataProviderInfo.resultsBy, page, size);
|
||||||
if(this.fetchPublications.searchUtils.totalResults == 0) {
|
|
||||||
this.reloadPublications = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private searchDatasets(page: number, size: number) {
|
private searchDatasets(page: number, size: number) {
|
||||||
if(this.reloadDatasets) {
|
if(this.fetchDatasets.searchUtils.status == this.errorCodes.NONE) {
|
||||||
this.fetchDatasets.getResultsForDataproviders(this.datasourceId, this.dataProviderInfo.resultsBy, page, size);
|
|
||||||
}
|
|
||||||
this.reloadDatasets = false;
|
this.reloadDatasets = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.reloadDatasets) {
|
||||||
|
this.fetchDatasets.getResultsForDataproviders(this.datasourceId, this.dataProviderInfo.resultsBy, page, size);
|
||||||
|
}
|
||||||
|
this.reloadDatasets = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private countDatasets(page: number, size: number) {
|
private countDatasets(page: number, size: number) {
|
||||||
this.fetchDatasets.getResultsForDataproviders(this.datasourceId, this.dataProviderInfo.resultsBy, page, size);
|
this.fetchDatasets.getResultsForDataproviders(this.datasourceId, this.dataProviderInfo.resultsBy, page, size);
|
||||||
if(this.fetchDatasets.searchUtils.totalResults == 0) {
|
|
||||||
this.reloadDatasets = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private searchProjects(page: number, size: number) {
|
private searchProjects(page: number, size: number) {
|
||||||
if(this.reloadProjects) {
|
if(this.fetchProjects.searchUtils.status == this.errorCodes.NONE) {
|
||||||
this.fetchProjects.getResultsForDataproviders(this.datasourceId, page, size);
|
|
||||||
}
|
|
||||||
this.reloadProjects = false;
|
this.reloadProjects = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.reloadProjects) {
|
||||||
|
this.fetchProjects.getResultsForDataproviders(this.datasourceId, page, size);
|
||||||
|
}
|
||||||
|
this.reloadProjects = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private countProjects(page: number, size: number) {
|
private countProjects(page: number, size: number) {
|
||||||
this.fetchProjects.getResultsForDataproviders(this.datasourceId, page, size);
|
this.fetchProjects.getResultsForDataproviders(this.datasourceId, page, size);
|
||||||
if(this.fetchProjects.searchUtils.totalResults == 0) {
|
|
||||||
this.reloadProjects = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private searchDatasources(page: number, size: number) {
|
private searchDatasources(page: number, size: number) {
|
||||||
if(this.reloadDataproviders) {
|
if(this.fetchDataproviders.searchUtils.status == this.errorCodes.NONE) {
|
||||||
|
|
||||||
this.fetchDataproviders.getResultsForDataproviders(this.datasourceId, page, size);
|
|
||||||
|
|
||||||
}
|
|
||||||
this.reloadDataproviders = false;
|
this.reloadDataproviders = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.reloadDataproviders) {
|
||||||
|
this.fetchDataproviders.getResultsForDataproviders(this.datasourceId, page, size);
|
||||||
|
}
|
||||||
|
this.reloadDataproviders = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private countDatasources(page: number, size: number) {
|
private countDatasources(page: number, size: number) {
|
||||||
this.fetchDataproviders.getResultsForDataproviders(this.datasourceId, page, size);
|
this.fetchDataproviders.getResultsForDataproviders(this.datasourceId, page, size);
|
||||||
if(this.fetchDataproviders.searchUtils.totalResults == 0) {
|
|
||||||
this.reloadDataproviders = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private searchRelatedDatasources(page: number, size: number) {
|
private searchRelatedDatasources(page: number, size: number) {
|
||||||
if(this.reloadRelatedDatasources) {
|
if(this.fetchAggregatorsPublications.searchUtils.status == this.errorCodes.NONE
|
||||||
this.fetchResultsAggregators.getAggregatorResults(this.datasourceId, page, size);
|
&& this.fetchAggregatorsDatasets.searchUtils.status == this.errorCodes.NONE) {
|
||||||
}
|
|
||||||
this.reloadRelatedDatasources = false;
|
this.reloadRelatedDatasources = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.reloadRelatedDatasources) {
|
||||||
|
this.fetchAggregatorsPublications.getAggregatorResults(this.datasourceId, page, size);
|
||||||
|
this.fetchAggregatorsDatasets.getAggregatorResults(this.datasourceId, page, size);
|
||||||
|
}
|
||||||
|
this.reloadRelatedDatasources = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private countRelatedDatasources(page: number, size: number) {
|
private countRelatedDatasources(page: number, size: number) {
|
||||||
this.fetchResultsAggregators.getAggregatorResults(this.datasourceId, page, size);
|
this.fetchAggregatorsPublications.getAggregatorResults(this.datasourceId, page, size);
|
||||||
if(this.fetchResultsAggregators.searchUtils.totalResults == 0) {
|
this.fetchAggregatorsDatasets.getAggregatorResults(this.datasourceId, page, size);
|
||||||
this.reloadRelatedDatasources = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public metricsResults($event) {
|
public metricsResults($event) {
|
||||||
|
|
|
@ -5,20 +5,32 @@ import { FetchDatasets } from '../../utils/fetchEntitiesClasses/fetchDatasets.cl
|
||||||
|
|
||||||
import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties';
|
import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties';
|
||||||
import {RouterHelper} from '../../utils/routerHelper.class';
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
||||||
|
import { Observable } from 'rxjs/Observable';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'relatedDatasourcesTab',
|
selector: 'relatedDatasourcesTab',
|
||||||
template: `
|
template: `
|
||||||
<div *ngIf="fetchResults.searchUtils.status == errorCodes.NONE" class="uk-alert uk-alert-primary uk-animation-fade" role="alert">No related content providers available</div>
|
<div *ngIf="fetchPublications.searchUtils.status == errorCodes.NONE && fetchDatasets.searchUtils.status == errorCodes.NONE"
|
||||||
<div *ngIf="fetchResults.searchUtils.status == errorCodes.ERROR" class="uk-alert uk-alert-warning uk-animation-fade" role="alert">An Error Occured</div>
|
class="uk-alert uk-alert-primary uk-animation-fade" role="alert">
|
||||||
<div *ngIf="fetchResults.searchUtils.status == errorCodes.NOT_AVAILABLE" class="uk-alert uk-alert-danger uk-animation-fade" role="alert">Service not available</div>
|
No related content providers available
|
||||||
<div *ngIf="fetchResults.searchUtils.status == errorCodes.LOADING" class="uk-animation-fade uk-width-1-1" role="alert"><img src="./assets/loading.gif" class="uk-align-center" alt="Loading"></div>
|
</div>
|
||||||
|
<div *ngIf="fetchPublications.searchUtils.status == errorCodes.ERROR && fetchDatasets.searchUtils.status == errorCodes.ERROR"
|
||||||
|
class="uk-alert uk-alert-warning uk-animation-fade" role="alert">
|
||||||
|
An Error Occured
|
||||||
|
</div>
|
||||||
|
<!--div *ngIf="fetchPublications.searchUtils.status == errorCodes.NOT_AVAILABLE && fetchDatasets.searchUtils.status == errorCodes.NOT_AVAILABLE"
|
||||||
|
class="uk-alert uk-alert-danger uk-animation-fade" role="alert">
|
||||||
|
Service not available
|
||||||
|
</div-->
|
||||||
|
<div *ngIf="fetchPublications.searchUtils.status == errorCodes.LOADING || fetchDatasets.searchUtils.status == errorCodes.LOADING"
|
||||||
|
class="uk-animation-fade uk-width-1-1" role="alert"><img src="./assets/loading.gif" class="uk-align-center" alt="Loading">
|
||||||
|
</div>
|
||||||
|
|
||||||
<!--div *ngIf="fetchResults.results.length == 0" class = "uk-alert">
|
<!--div *ngIf="fetchResults.results.length == 0" class = "uk-alert">
|
||||||
No related content providers available
|
No related content providers available
|
||||||
</div-->
|
</div-->
|
||||||
|
|
||||||
<div *ngIf="fetchResults.results.length > 0">
|
<div *ngIf="fetchPublications.searchUtils.status == errorCodes.DONE || fetchDatasets.searchUtils.status == errorCodes.DONE">
|
||||||
<table class="uk-table uk-table-striped">
|
<table class="uk-table uk-table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -27,22 +39,41 @@ import {RouterHelper} from '../../utils/routerHelper.class';
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<ng-container *ngIf="!results && fetchResults">
|
||||||
<tr *ngFor="let item of fetchResults.results">
|
<tr *ngFor="let item of fetchResults.results">
|
||||||
<td class="uk-text-center">
|
<td class="uk-text-center">
|
||||||
<!--a href="{{item.url}}"-->
|
|
||||||
<a [queryParams]="{datasourceId: item.id}" routerLinkActive="router-link-active" routerLink="/search/dataprovider">
|
<a [queryParams]="{datasourceId: item.id}" routerLinkActive="router-link-active" routerLink="/search/dataprovider">
|
||||||
<!--a href="{{searchLinkToDataProvider}}{{item.id}}"-->
|
|
||||||
{{item.name}}
|
{{item.name}}
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td class="uk-text-center">
|
<td class="uk-text-center">
|
||||||
<!--a href="{{linkToSearchPublications}}{{item.id}}&ho=and&collectedFrom={{dataproviderId}}&co=and"-->
|
|
||||||
<a [queryParams]="routerHelper.createQueryParams(['hostedBy', 'ho', 'collectedFrom', 'co'], [item.id, 'and', dataproviderId, 'and'])"
|
<a [queryParams]="routerHelper.createQueryParams(['hostedBy', 'ho', 'collectedFrom', 'co'], [item.id, 'and', dataproviderId, 'and'])"
|
||||||
routerLinkActive="router-link-active" [routerLink]="linkToSearchResults">
|
routerLinkActive="router-link-active" [routerLink]="linkToSearchResults">
|
||||||
{{item.count}}
|
{{item.count}}
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container *ngIf="results">
|
||||||
|
<tr *ngFor="let id of results.keys()">
|
||||||
|
<td class="uk-text-center">
|
||||||
|
<a [queryParams]="{datasourceId: id}" routerLinkActive="router-link-active" routerLink="/search/dataprovider">
|
||||||
|
{{results.get(id).name}}
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td class="uk-text-center">
|
||||||
|
<a [queryParams]="routerHelper.createQueryParams(['hostedBy', 'ho', 'collectedFrom', 'co'], [id, 'and', dataproviderId, 'and'])"
|
||||||
|
routerLinkActive="router-link-active" [routerLink]="linkToSearchPublications">
|
||||||
|
{{results.get(key).countPublications}}
|
||||||
|
</a> / <a [queryParams]="routerHelper.createQueryParams(['hostedBy', 'ho', 'collectedFrom', 'co'], [id, 'and', dataproviderId, 'and'])"
|
||||||
|
routerLinkActive="router-link-active" [routerLink]="linkToSearchResearchData">
|
||||||
|
{{results.get(key).countDatasets}}
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
@ -50,33 +81,90 @@ import {RouterHelper} from '../../utils/routerHelper.class';
|
||||||
})
|
})
|
||||||
|
|
||||||
export class RelatedDatasourcesTabComponent {
|
export class RelatedDatasourcesTabComponent {
|
||||||
@Input() type: string;
|
//@Input() type: string;
|
||||||
@Input() dataproviderId: string;
|
@Input() dataproviderId: string;
|
||||||
@Input() fetchResults : any;
|
@Input() fetchPublications : FetchPublications;
|
||||||
|
@Input() fetchDatasets : FetchDatasets;
|
||||||
|
|
||||||
public linkToSearchResults: string = "";
|
public type: string;
|
||||||
|
public linkToSearchResults: string;
|
||||||
|
public fetchResults: any;
|
||||||
|
public results: Map<string, {"name": string, "countPublications": string, "countDatasets": string}>;
|
||||||
|
|
||||||
|
public linkToSearchPublications: string = "";
|
||||||
|
public linkToSearchResearchData: string = "";
|
||||||
//public searchLinkToDataProvider: string = "";
|
//public searchLinkToDataProvider: string = "";
|
||||||
public routerHelper:RouterHelper = new RouterHelper();
|
public routerHelper:RouterHelper = new RouterHelper();
|
||||||
public errorCodes:ErrorCodes = new ErrorCodes();
|
public errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
|
|
||||||
|
public sub: any;
|
||||||
|
|
||||||
//public queryParams: string[] = [];
|
//public queryParams: string[] = [];
|
||||||
//public queryParamsIds: string[] = [];
|
//public queryParamsIds: string[] = [];
|
||||||
|
|
||||||
constructor () {}
|
constructor () {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if(this.type == "publications") {
|
//if(this.type == "publications") {
|
||||||
this.linkToSearchResults = OpenaireProperties.getLinkToAdvancedSearchPublications();//+"?&hostedBy=";//+ +"&ho=and&collectedFrom="+ +"&co=and";
|
this.linkToSearchPublications = OpenaireProperties.getLinkToAdvancedSearchPublications();//+"?&hostedBy=";//+ +"&ho=and&collectedFrom="+ +"&co=and";
|
||||||
} else {
|
//} else {
|
||||||
this.linkToSearchResults = OpenaireProperties.getLinkToAdvancedSearchDatasets();
|
this.linkToSearchResearchData = OpenaireProperties.getLinkToAdvancedSearchDatasets();
|
||||||
}
|
//}
|
||||||
//this.searchLinkToDataProvider = OpenaireProperties.getsearchLinkToDataProvider();
|
//this.searchLinkToDataProvider = OpenaireProperties.getsearchLinkToDataProvider();
|
||||||
/*queryParams.push("hostedBy");
|
/*queryParams.push("hostedBy");
|
||||||
queryParams.push("ho");
|
queryParams.push("ho");
|
||||||
queryParams.push("collectedFrom");
|
queryParams.push("collectedFrom");
|
||||||
queryParams.push("co");
|
queryParams.push("co");
|
||||||
queryParamsIds.push()*/
|
queryParamsIds.push()*/
|
||||||
|
|
||||||
|
|
||||||
|
this.sub = Observable.merge(this.fetchPublications.requestComplete, this.fetchDatasets.requestComplete)
|
||||||
|
.subscribe(
|
||||||
|
data => {
|
||||||
|
if((this.fetchPublications.results.length > 0 && this.fetchDatasets.results.length > 0)
|
||||||
|
|| (this.fetchPublications.results.length > 0 && this.fetchDatasets.searchUtils.status == this.errorCodes.ERROR)
|
||||||
|
|| (this.fetchPublications.searchUtils.status == this.errorCodes.ERROR && this.fetchDatasets.results.length > 0)) {
|
||||||
|
this.results = new Map<string, {"name": string, "countPublications": string, "countDatasets": string}>();
|
||||||
|
for(let result of this.fetchPublications.results) {
|
||||||
|
if(!this.results.has(result.id)) {
|
||||||
|
this.results.set(result.id, {"name": result.name, "countPublications": result.count, "countDatasets": "0"});
|
||||||
|
} else {
|
||||||
|
if(this.fetchPublications.searchUtils.status == this.errorCodes.ERROR) {
|
||||||
|
this.results.get(result.id).countPublications = "-";
|
||||||
|
} else {
|
||||||
|
this.results.get(result.id).countPublications = parseInt(this.results.get(result.id).countPublications) + result.count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(let result of this.fetchDatasets.results) {
|
||||||
|
if(!this.results.has(result.id)) {
|
||||||
|
this.results.set(result.id, {"name": result.name, "countPublications": "0", "countDatasets": result.count});
|
||||||
|
} else {
|
||||||
|
if(this.fetchDatasets.searchUtils.status == this.errorCodes.ERROR) {
|
||||||
|
this.results.get(result.id).countDatasets = "-";
|
||||||
|
} else {
|
||||||
|
this.results.get(result.id).countDatasets = parseInt(this.results.get(result.id).countDatasets) + result.count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.type = "Publications / Research Data"
|
||||||
|
} else if(this.fetchPublications.results.length > 0) {
|
||||||
|
this.fetchResults = this.fetchPublications;
|
||||||
|
this.type = "Publications";
|
||||||
|
this.linkToSearchResults = this.linkToSearchPublications;
|
||||||
|
} else {
|
||||||
|
this.fetchResults = this.fetchDatasets;
|
||||||
|
this.type = "Research Data";
|
||||||
|
this.linkToSearchResults = this.linkToSearchResearchData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {}
|
ngOnDestroy() {
|
||||||
|
if(this.sub) {
|
||||||
|
this.sub.unsubscribe();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,13 @@ import {SearchDatasetsService} from '../../services/searchDatasets.service';
|
||||||
import { ErrorCodes} from '../../utils/properties/openaireProperties';
|
import { ErrorCodes} from '../../utils/properties/openaireProperties';
|
||||||
import {SearchUtilsClass } from '../../searchPages/searchUtils/searchUtils.class';
|
import {SearchUtilsClass } from '../../searchPages/searchUtils/searchUtils.class';
|
||||||
import {DOI} from '../../utils/string-utils.class';
|
import {DOI} from '../../utils/string-utils.class';
|
||||||
|
import { Observable } from 'rxjs/Observable';
|
||||||
|
import {Observer} from 'rxjs/Observer';
|
||||||
|
|
||||||
export class FetchDatasets{
|
export class FetchDatasets{
|
||||||
public results =[];
|
public results =[];
|
||||||
|
public requestComplete: Observable<boolean>;
|
||||||
|
private observer: Observer<boolean>;
|
||||||
|
|
||||||
public searchUtils:SearchUtilsClass = new SearchUtilsClass();
|
public searchUtils:SearchUtilsClass = new SearchUtilsClass();
|
||||||
private sub: any;
|
private sub: any;
|
||||||
|
@ -179,12 +183,18 @@ public getResultsForDataproviders(id:string, resultsFrom:string, page: number, s
|
||||||
}
|
}
|
||||||
|
|
||||||
public getAggregatorResults(id:string, page: number, size: number){
|
public getAggregatorResults(id:string, page: number, size: number){
|
||||||
var errorCodes:ErrorCodes = new ErrorCodes();
|
this.requestComplete = new Observable<boolean>(observer => this.observer = observer);
|
||||||
this.searchUtils.status = errorCodes.LOADING;
|
|
||||||
|
var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
|
this.searchUtils.status = errorCodes.LOADING;
|
||||||
|
|
||||||
this.subResults = this._searchDatasetsService.searchAggregators(id, '&fq=collectedfromdatasourceid exact "'+id+'"',"&refine=true&fields=resulthostingdatasource" , page, size).subscribe(
|
this.subResults = this._searchDatasetsService.searchAggregators(id, '&fq=collectedfromdatasourceid exact "'+id+'"',"&refine=true&fields=resulthostingdatasource" , page, size).subscribe(
|
||||||
data => {
|
data => {
|
||||||
this.results = data;
|
this.results = data;
|
||||||
|
this.searchUtils.totalResults = this.results.length;
|
||||||
|
|
||||||
|
this.observer.next(true);
|
||||||
|
//console.info("TRUE dataset!!!");
|
||||||
|
|
||||||
var errorCodes:ErrorCodes = new ErrorCodes();
|
var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
this.searchUtils.status = errorCodes.DONE;
|
this.searchUtils.status = errorCodes.DONE;
|
||||||
|
@ -193,6 +203,7 @@ public getAggregatorResults(id:string, page: number, size: number){
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
err => {
|
err => {
|
||||||
|
this.observer.next(false);
|
||||||
console.log(err);
|
console.log(err);
|
||||||
//TODO check erros (service not available, bad request)
|
//TODO check erros (service not available, bad request)
|
||||||
// if( ){
|
// if( ){
|
||||||
|
|
|
@ -4,10 +4,13 @@ import {ErrorCodes} from '../../utils/properties/openaireProperties';
|
||||||
import {SearchFields} from '../../utils/properties/searchFields';
|
import {SearchFields} from '../../utils/properties/searchFields';
|
||||||
import {SearchUtilsClass } from '../../searchPages/searchUtils/searchUtils.class';
|
import {SearchUtilsClass } from '../../searchPages/searchUtils/searchUtils.class';
|
||||||
import {DOI} from '../../utils/string-utils.class';
|
import {DOI} from '../../utils/string-utils.class';
|
||||||
|
import { Observable } from 'rxjs/Observable';
|
||||||
|
import {Observer} from 'rxjs/Observer';
|
||||||
|
|
||||||
export class FetchPublications {
|
export class FetchPublications {
|
||||||
public results =[];
|
public results =[];
|
||||||
|
public requestComplete: Observable<boolean>;
|
||||||
|
private observer: Observer<boolean>;
|
||||||
// public filters =[];
|
// public filters =[];
|
||||||
public searchUtils:SearchUtilsClass = new SearchUtilsClass();
|
public searchUtils:SearchUtilsClass = new SearchUtilsClass();
|
||||||
// public baseUrl:string = "";
|
// public baseUrl:string = "";
|
||||||
|
@ -165,6 +168,8 @@ public getResultsForDataproviders(id:string, resultsFrom:string, page: number, s
|
||||||
}
|
}
|
||||||
|
|
||||||
public getAggregatorResults(id:string, page: number, size: number){
|
public getAggregatorResults(id:string, page: number, size: number){
|
||||||
|
this.requestComplete = new Observable<boolean>(observer => this.observer = observer);
|
||||||
|
|
||||||
var errorCodes:ErrorCodes = new ErrorCodes();
|
var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
this.searchUtils.status = errorCodes.LOADING;
|
this.searchUtils.status = errorCodes.LOADING;
|
||||||
|
|
||||||
|
@ -173,6 +178,10 @@ public getAggregatorResults(id:string, page: number, size: number){
|
||||||
this.results = data;
|
this.results = data;
|
||||||
this.searchUtils.totalResults = this.results.length;
|
this.searchUtils.totalResults = this.results.length;
|
||||||
|
|
||||||
|
//this.requestComplete = Observable.of(true);//new Observable(observer => observer = "true");
|
||||||
|
//console.info("TRUE publication!!!");
|
||||||
|
this.observer.next(true);
|
||||||
|
|
||||||
var errorCodes:ErrorCodes = new ErrorCodes();
|
var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
this.searchUtils.status = errorCodes.DONE;
|
this.searchUtils.status = errorCodes.DONE;
|
||||||
if(this.searchUtils.totalResults == 0 ){
|
if(this.searchUtils.totalResults == 0 ){
|
||||||
|
@ -180,6 +189,7 @@ public getAggregatorResults(id:string, page: number, size: number){
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
err => {
|
err => {
|
||||||
|
this.observer.next(false);
|
||||||
console.log(err);
|
console.log(err);
|
||||||
//TODO check erros (service not available, bad request)
|
//TODO check erros (service not available, bad request)
|
||||||
// if( ){
|
// if( ){
|
||||||
|
|
Loading…
Reference in New Issue