[Connect|Trunk]

pass properties as parameter in services in order to use cache

	add properties parameter in navbar/bottom and clean up other attributes

	Community page:
		use existing services and remove searchEntries.service.ts
		use search results component		


git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@55996 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2019-06-05 13:39:02 +00:00
parent c1b26b43e6
commit 4288d49e36
12 changed files with 123 additions and 217 deletions

View File

@ -1,10 +1,9 @@
import { Component, Directive, ElementRef, Renderer, ChangeDetectionStrategy, ViewEncapsulation, Injector } from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Component} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import { EnvProperties} from './openaireLibrary/utils/properties/env-properties';
import{MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu';
import { EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service';
import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
import {MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu';
import {EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service';
import {CommunitiesService} from "./openaireLibrary/connect/communities/communities.service";
import {Session} from './openaireLibrary/login/utils/helper.class';
import {ConnectHelper} from './openaireLibrary/connect/connectHelper';
@ -20,10 +19,10 @@ import {SubscribeService} from './openaireLibrary/utils/subscribe/subscribe.serv
`],
template: `
<navbar *ngIf= "properties && showMenu && !community" [environment]=properties.environment portal="connect" [onlyTop]=false [userMenuItems]=userMenuItems [menuItems]=menuItems
[(APIUrl)]="properties.adminToolsAPIURL" [(logInUrl)]="properties.loginUrl" [(logOutUrl)]="properties.logoutUrl" [(cookieDomain)]="properties.cookieDomain" [showMenu]=showMenu></navbar>
<navbar *ngIf= "properties && showMenu && community" [environment]=properties.environment portal="connect" [onlyTop]=false [(communityId)]="community.id" [userMenuItems]=userMenuItems [menuItems]=menuItems
[(APIUrl)]="properties.adminToolsAPIURL" [(logInUrl)]="properties.loginUrl" [(logOutUrl)]="properties.logoutUrl" [(cookieDomain)]="properties.cookieDomain" [(community)]=community [showMenu]=showMenu></navbar>
<navbar *ngIf= "properties && showMenu && !community" portal="connect" [onlyTop]=false [userMenuItems]=userMenuItems [menuItems]=menuItems
[showMenu]=showMenu [properties]="properties"></navbar>
<navbar *ngIf= "properties && showMenu && community" portal="connect" [onlyTop]=false [communityId]="community.id" [userMenuItems]=userMenuItems [menuItems]=menuItems
[community]=community [showMenu]=showMenu [properties]="properties"></navbar>
<div class="custom-main-content" >
<main>
@ -38,8 +37,8 @@ import {SubscribeService} from './openaireLibrary/utils/subscribe/subscribe.serv
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="chevron-right" ratio="1"><polyline fill="none" stroke="#000" stroke-width="1.03" points="7 4 13 10 7 16"></polyline></svg>
</span></a>
</cookie-law>
<bottom *ngIf= "properties && isClient && showMenu && !community" [environment]=properties.environment [grantAdvance]="false" ></bottom>
<bottom *ngIf= "properties && isClient && showMenu && community" [environment]=properties.environment [showSocialButtons] = "true" [showMenuItems]="true" [grantAdvance]="false" [showOpenaire]="true" [(communityId)]="community.id" [(APIUrl)]="properties.adminToolsAPIURL" [menuItems]=bottomMenuItems ></bottom>
<bottom *ngIf= "properties && isClient && showMenu && !community" [grantAdvance]="false" [properties]="properties"></bottom>
<bottom *ngIf= "properties && isClient && showMenu && community" [showSocialButtons] = "true" [showMenuItems]="true" [grantAdvance]="false" [showOpenaire]="true" [communityId]="community.id" [menuItems]=bottomMenuItems [properties]="properties"></bottom>
`
@ -323,7 +322,7 @@ export class AppComponent {
myCommunities.push( new MenuItem("","Managing communities","","/search/find/communities",false,[],[],{role:"%22manager%22"}))
}
if(Session.isLoggedIn()){
this._subscribeService.getCommunitiesSubscribedTo(Session.getUserEmail(), this.properties.adminToolsAPIURL).subscribe (
this._subscribeService.getCommunitiesSubscribedTo(this.properties, Session.getUserEmail()).subscribe (
pids => {
if(pids.length > 0 ) {
myCommunities.push( new MenuItem("","Subscribed to communities","","/search/find/communities",false,[],[],{status:"%22subscribed%22"}))

View File

@ -1,19 +1,17 @@
import {Component} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser';
import {ActivatedRoute, Router} from '@angular/router';
import {Meta, Title} from '@angular/platform-browser';
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
import {CommunitiesService} from '../openaireLibrary/connect/communities/communities.service';
import {SubscribeService} from '../openaireLibrary/utils/subscribe/subscribe.service';
import {CommunityInfo} from '../openaireLibrary/connect/community/communityInfo';
import "rxjs/add/observable/zip";
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
import {CommunitiesService} from '../openaireLibrary/connect/communities/communities.service';
import {SubscribeService} from '../openaireLibrary/utils/subscribe/subscribe.service';
import {CommunityInfo} from '../openaireLibrary/connect/community/communityInfo';
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
import {Session} from '../openaireLibrary/login/utils/helper.class';
import {StringUtils} from '../openaireLibrary/utils/string-utils.class';
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
import {Session} from '../openaireLibrary/login/utils/helper.class';
import {StringUtils} from '../openaireLibrary/utils/string-utils.class';
import {ErrorCodes} from '../openaireLibrary/utils/properties/errorCodes';
import {ErrorMessagesComponent} from '../openaireLibrary/utils/errorMessages.component';
import {ErrorCodes} from '../openaireLibrary/utils/properties/errorCodes';
import {ErrorMessagesComponent} from '../openaireLibrary/utils/errorMessages.component';
@Component({
selector: 'communities',
@ -129,7 +127,7 @@ export class CommunitiesComponent {
this.status = this.errorCodes.DONE;
if(mail != null && showCommunity) {
this._subscribeService.isSubscribedToCommunity(community.communityId, mail, this.properties.adminToolsAPIURL).subscribe (
this._subscribeService.isSubscribedToCommunity( this.properties, community.communityId, mail).subscribe (
res => {
isSubscriber = res;
if(isSubscriber) {

View File

@ -178,7 +178,9 @@
<ul id="resultTabs" class="uk-switcher" style="min-height:450px;">
<li *ngIf="isEntityEnabled('publication')">
<div class="uk-grid">
<results-comp [(results)]=publicationResults [(total)]=publicationTotal resultType="publication" [community]=community [params]=params class="uk-width-expand"></results-comp>
<results-comp [results]=publicationResults [total]=publicationTotal resultType="publication"
[community]=community [params]=params [showLoading]="showLoading" [properties]="properties"
class="uk-width-expand"></results-comp>
<div *ngIf=" activeTab == 'publication' && statistics !=null && statistics.allowedEntities &&
statistics.statisticsSum && statistics.allowedCharts && statistics.statisticsSum['publication'] &&
statistics.allowedCharts['publication'] && statistics.statisticsSum['publication'].total>0 &&
@ -193,7 +195,8 @@
</li>
<li *ngIf="isEntityEnabled('dataset')">
<div class="uk-grid">
<results-comp [(results)]=researchDataResults [(total)]=researchDataTotal resultType="dataset" [community]=community [params]=params class="uk-width-expand"></results-comp>
<results-comp [results]=researchDataResults [total]=researchDataTotal resultType="dataset"
[community]=community [params]=params [showLoading]="showLoading" [properties]="properties" class="uk-width-expand"></results-comp>
<div *ngIf="activeTab == 'dataset' && statistics !=null && statistics.allowedEntities && statistics.statisticsSum && statistics.allowedCharts &&
statistics.statisticsSum['dataset'] && statistics.allowedCharts['dataset'] && statistics.statisticsSum['dataset'].total>0 && statistics.allowedCharts['dataset'].length>0"
class="uk-width-2-5@m uk-width-1-1@s">
@ -207,7 +210,8 @@
</li>
<li *ngIf="isEntityEnabled('software')">
<div class="uk-grid">
<results-comp [(results)]=softwareResults [(total)]=softwareTotal resultType="software" [community]=community [params]=params class="uk-width-expand"></results-comp>
<results-comp [results]=softwareResults [total]=softwareTotal resultType="software"
[community]=community [params]=params [showLoading]="showLoading" [properties]="properties" class="uk-width-expand"></results-comp>
<div *ngIf="statistics !=null && statistics.allowedEntities && statistics.statisticsSum &&
statistics.allowedCharts && statistics.statisticsSum['software'] &&
statistics.allowedCharts['software'] && statistics.statisticsSum['software'].total>0 && statistics.allowedCharts['software'].length>0" class="uk-width-2-5@m uk-width-1-1@s">
@ -221,7 +225,9 @@
</li>
<li *ngIf="isEntityEnabled('orp')">
<div class="uk-grid">
<results-comp [(results)]=orpResults [(total)]=orpTotal resultType="other" [community]=community [params]=params class="uk-width-expand"></results-comp>
<results-comp [results]=orpResults [total]=orpTotal resultType="other" [community]=community
[params]=params [showLoading]="showLoading" [properties]="properties"
class="uk-width-expand"></results-comp>
<div *ngIf=" activeTab == 'orp' && statistics !=null && statistics.allowedEntities &&
statistics.statisticsSum && statistics.allowedCharts && statistics.statisticsSum['orp'] &&
statistics.allowedCharts['orp'] && statistics.statisticsSum['orp'].total>0 &&

View File

@ -2,15 +2,11 @@ import {Component, ElementRef, Input, ViewChild} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {Location} from '@angular/common';
import {Meta, Title} from '@angular/platform-browser';
import "rxjs/add/observable/zip";
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
import {CommunityService} from "../openaireLibrary/connect/community/community.service";
import {ConfigurationService} from '../openaireLibrary/utils/configuration/configuration.service';
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
import {SearchEntriesService} from '../searchEntries/searchEntries.service';
import {SearchZenodoCommunitiesService} from '../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunities.service';
import {ZenodoCommunitiesService} from '../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service';
import {Session} from '../openaireLibrary/login/utils/helper.class';
@ -19,6 +15,9 @@ import {StringUtils} from '../openaireLibrary/utils/string-utils.class';
import {PiwikHelper} from '../utils/piwikHelper';
import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
import {SearchCommunityDataprovidersService} from "../openaireLibrary/connect/contentProviders/searchDataproviders.service";
import {SearchCommunityProjectsService} from "../openaireLibrary/connect/projects/searchProjects.service";
import {SearchResearchResultsService} from "../openaireLibrary/services/searchResearchResults.service";
@Component({
selector: 'community',
@ -73,7 +72,9 @@ export class CommunityComponent {
private _piwikService: PiwikService,
private config: ConfigurationService,
private _communityService: CommunityService,
private _searchEntriesService: SearchEntriesService,
private _searchCommunityDataprovidersService:SearchCommunityDataprovidersService,
private _searchCommunityProjectsService: SearchCommunityProjectsService,
private _searchResearchResultsService: SearchResearchResultsService,
private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService,
private _ΖenodoCommunitieService: ZenodoCommunitiesService) {
@ -143,7 +144,7 @@ export class CommunityComponent {
});
this._searchEntriesService.getTotal(this.properties.searchAPIURLLAst + 'publications/count?format=json&fq=communityid=' + this.communityId).subscribe(
this._searchResearchResultsService.countTotalResults("publication", this.properties,"&fq=communityid=" + this.communityId).subscribe(
publicationTotal => {
this.publicationTotal = publicationTotal;
this.showLoading = true;
@ -154,7 +155,7 @@ export class CommunityComponent {
}
);
this._searchEntriesService.getTotal(this.properties.searchAPIURLLAst + 'datasets/count?format=json&fq=communityid=' + this.communityId).subscribe(
this._searchResearchResultsService.countTotalResults("dataset", this.properties,"&fq=communityid=" + this.communityId).subscribe(
researchDataTotal => {
this.researchDataTotal = researchDataTotal;
},
@ -163,7 +164,7 @@ export class CommunityComponent {
}
);
this._searchEntriesService.getTotal(this.properties.searchAPIURLLAst + 'software/count?format=json&fq=communityid=' + this.communityId).subscribe(
this._searchResearchResultsService.countTotalResults("software", this.properties,"&fq=communityid=" + this.communityId).subscribe(
softwareTotal => {
this.softwareTotal = softwareTotal;
},
@ -172,7 +173,7 @@ export class CommunityComponent {
}
);
this._searchEntriesService.getTotal(this.properties.searchAPIURLLAst + 'other/count?format=json&fq=communityid=' + this.communityId).subscribe(
this._searchResearchResultsService.countTotalResults("other", this.properties,"&fq=communityid=" + this.communityId).subscribe(
orpTotal => {
this.orpTotal = orpTotal;
},
@ -181,7 +182,7 @@ export class CommunityComponent {
}
);
this._searchEntriesService.countTotal(this.properties.communityAPI + this.communityId + '/projects').subscribe(
this._searchCommunityProjectsService.countTotalProjects(this.properties, this.communityId ).subscribe(
projectTotal => {
this.projectTotal = projectTotal;
//console.log(projectTotal);
@ -191,7 +192,7 @@ export class CommunityComponent {
}
);
this._searchEntriesService.countTotal(this.properties.communityAPI + this.communityId + '/contentproviders').subscribe(
this._searchCommunityDataprovidersService.countTotalDataproviders(this.properties, this.communityId ).subscribe(
contentProviderTotal => {
this.contentProviderTotal = contentProviderTotal;
//console.log(contentProviderTotal);
@ -209,7 +210,7 @@ export class CommunityComponent {
/**/
this.config.getCommunityInformation(this.properties.adminToolsAPIURL, this.communityId).subscribe(
this.config.getCommunityInformation(this.properties, this.communityId).subscribe(
res => {
this.communityInfo = res;
},
@ -225,12 +226,14 @@ export class CommunityComponent {
public searchPublications() {
this.activeTab = "publication";
if (this.publicationTotal > 0 && this.publicationResults == null) {
this._searchEntriesService.getResults(this.properties.searchAPIURLLAst + 'publications?fq=communityid%20exact%20%22' + this.communityId + '%22&sortBy=resultdateofacceptance,descending&format=json&size=5').subscribe(
//this._searchEntriesService.getResults(this.properties.searchAPIURLLAst + 'publications?fq=communityid%20exact%20%22' + this.communityId + '%22&sortBy=resultdateofacceptance,descending&format=json&size=5')
this._searchResearchResultsService.search("publication","","&fq=communityid=" + this.communityId,1,5,"resultdateofacceptance,descending",[],this.properties)
.subscribe(
publicationResults => {
this.publicationResults = publicationResults;
this.publicationResults = publicationResults[1];
this.showLoading = false;
//console.log(publicationResults);
},
},
error => {
this.handleError("Error getting publications for community with id: " + this.communityId, error);
}
@ -241,9 +244,9 @@ export class CommunityComponent {
public searchResearchData() {
this.activeTab = "dataset";
if (this.researchDataTotal > 0 && this.researchDataResults == null) {
this._searchEntriesService.getResults(this.properties.searchAPIURLLAst + 'datasets?fq=communityid%20exact%20%22' + this.communityId + '%22&sortBy=resultdateofacceptance,descending&format=json&size=5').subscribe(
this._searchResearchResultsService.search("dataset","","&fq=communityid=" + this.communityId,1,5,"resultdateofacceptance,descending",[],this.properties).subscribe(
researchDataResults => {
this.researchDataResults = researchDataResults;
this.researchDataResults = researchDataResults[1];
this.showLoading = false;
},
error => {
@ -256,9 +259,9 @@ export class CommunityComponent {
public searchSoftware() {
this.activeTab = "software";
if (this.softwareTotal > 0 && this.softwareResults == null) {
this._searchEntriesService.getResults(this.properties.searchAPIURLLAst + 'software?fq=communityid%20exact%20%22' + this.communityId + '%22&sortBy=resultdateofacceptance,descending&format=json&size=5').subscribe(
this._searchResearchResultsService.search("software","","&fq=communityid=" + this.communityId,1,5,"resultdateofacceptance,descending",[],this.properties).subscribe(
softwareResults => {
this.softwareResults = softwareResults;
this.softwareResults = softwareResults[1];
this.showLoading = false;
},
error => {
@ -271,9 +274,9 @@ export class CommunityComponent {
public searchOrps() {
this.activeTab = "orp";
if (this.orpTotal > 0 && this.orpResults == null) {
this._searchEntriesService.getResults(this.properties.searchAPIURLLAst + 'other?fq=communityid%20exact%20%22' + this.communityId + '%22&sortBy=resultdateofacceptance,descending&format=json&size=5').subscribe(
this._searchResearchResultsService.search("other","","&fq=communityid=" + this.communityId,1,5,"resultdateofacceptance,descending",[],this.properties).subscribe(
orpResults => {
this.orpResults = orpResults;
this.orpResults = orpResults[1];
this.showLoading = false;
},
error => {

View File

@ -1,13 +1,11 @@
import { NgModule} from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import{CommunityComponent} from './community.component';
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {FormsModule} from '@angular/forms';
import {RouterModule} from '@angular/router';
import {CommunityComponent} from './community.component';
import {ResultsComponent} from '../searchEntries/results/results.component';
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
import {ConfigurationService} from '../openaireLibrary/utils/configuration/configuration.service';
import {SearchEntriesService} from '../searchEntries/searchEntries.service';
import {CommunityService} from '../openaireLibrary/connect/community/community.service';
import {FreeGuard} from '../openaireLibrary/login/freeGuard.guard';
@ -19,20 +17,26 @@ import {ManageModule} from '../openaireLibrary/utils/manage/manage.module';
import {StatisticsModule} from "../statistics/statistics.module";
import {SearchZenodoCommunitiesServiceModule} from '../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunitiesService.module';
import {ZenodoCommunitiesServiceModule} from '../openaireLibrary/connect/zenodoCommunities/zenodo-communitiesService.module';
import {SearchFormModule} from '../openaireLibrary/searchPages/searchUtils/searchForm.module';
import {SearchFormModule} from '../openaireLibrary/searchPages/searchUtils/searchForm.module';
import {SearchDataprovidersServiceModule} from "../openaireLibrary/connect/contentProviders/searchDataprovidersService.module";
import {SearchProjectsServiceModule} from '../openaireLibrary/connect/projects/searchProjectsService.module';
import {SearchResearchResultsServiceModule} from "../openaireLibrary/services/searchResearchResultsService.module";
import {SearchResultsModule} from "../openaireLibrary/searchPages/searchUtils/searchResults.module";
@NgModule({
imports: [
CommonModule, FormsModule, RouterModule,
SubscribeModule, StatisticsModule, ManageModule, InviteModule,
SearchZenodoCommunitiesServiceModule, ZenodoCommunitiesServiceModule, SearchFormModule
SearchZenodoCommunitiesServiceModule, ZenodoCommunitiesServiceModule, SearchFormModule, SearchDataprovidersServiceModule, SearchProjectsServiceModule,
SearchResearchResultsServiceModule, SearchResultsModule
],
declarations: [
CommunityComponent, ResultsComponent
],
providers:[
FreeGuard, PreviousRouteRecorder,
PiwikService, CommunityService, SearchEntriesService
PiwikService, CommunityService
],
exports: [
CommunityComponent

View File

@ -1,6 +1,7 @@
import {Component, Input} from '@angular/core';
import { ResultInfo } from '../../openaireLibrary/connect/results/resultInfo';
import { CommunityInfo } from '../../openaireLibrary/connect/community/communityInfo';
import {CommunityInfo} from '../../openaireLibrary/connect/community/communityInfo';
import {EnvProperties} from "../../openaireLibrary/utils/properties/env-properties";
import {SearchResult} from "../../openaireLibrary/utils/entities/searchResult";
@Component({
selector: 'results-comp',
@ -10,54 +11,24 @@ import { CommunityInfo } from '../../openaireLibrary/connect/community/community
</div>
<div *ngIf="results != null && results.length > 0">
<div class="uk-margin uk-text-right">
<div *ngIf="resultType == 'publication'">
<a class="el-content uk-button uk-button-text" [queryParams]=params routerLinkActive="router-link-active" routerLink="/search/find/publications">
View all
</a>
</div>
<div *ngIf="resultType == 'dataset'">
<a class="el-content uk-button uk-button-text" [queryParams]=params routerLinkActive="router-link-active" routerLink="/search/find/datasets">
View all
</a>
</div>
<div *ngIf="resultType == 'software'">
<a class="el-content uk-button uk-button-text" [queryParams]=params routerLinkActive="router-link-active" routerLink="/search/find/software">
View all
</a>
</div>
<div *ngIf="resultType == 'other'">
<a class="el-content uk-button uk-button-text" [queryParams]=params routerLinkActive="router-link-active" routerLink="/search/find/other">
<div>
<a class="el-content uk-button uk-button-text" [queryParams]=params routerLinkActive="router-link-active" [routerLink]="'/search/find/'+getresultTypeLink(resultType, true)">
View all
</a>
</div>
</div>
</div>
<div *ngIf="results != null && results.length > 0">
<div class="uk-margin-remove-vertical uk-grid-match uk-child-width-1-1 uk-child-width-1-1@m uk-child-width-1-1@l uk-child-width-1-1@xl uk-grid-small uk-grid uk-grid-stack" uk-grid="">
<div *ngIf="results != null && results.length > 0 && !showLoading">
<!--<div class="uk-margin-remove-vertical uk-grid-match uk-child-width-1-1 uk-child-width-1-1@m uk-child-width-1-1@l uk-child-width-1-1@xl uk-grid-small uk-grid uk-grid-stack" uk-grid="">
<li *ngFor="let item of results; let i = index">
<div class="uk-first-column">
<div class="el-item uk-panel">
<h6 class="el-title uk-margin uk-h6 uk-text-primary uk-margin-remove-adjacent uk-margin-remove-bottom">
<div *ngIf="showLoading" class="uk-animation-fade uk-width-1-1" role="alert"><span class="loading-gif uk-align-center"></span></div>
<div *ngIf="item.type == 'publication' && community != null && community.communityId != null && !showLoading">
<a [queryParams]="{articleId: item.id}" routerLinkActive="router-link-active" routerLink="/search/publication" >
{{item.title}} </a>
</div>
<div *ngIf="showLoading" class="uk-animation-fade uk-width-1-1" role="alert"><span class="loading-gif uk-align-center"></span></div>
<div *ngIf="item.type == 'dataset' && community != null && community.communityId != null && !showLoading">
<a [queryParams]="{datasetId: item.id}" routerLinkActive="router-link-active" routerLink="/search/dataset" >
{{item.title}} </a>
</div>
<div *ngIf="showLoading" class="uk-animation-fade uk-width-1-1" role="alert"><span class="loading-gif uk-align-center"></span></div>
<div *ngIf="item.type == 'software' && community != null && community.communityId != null && !showLoading">
<a [queryParams]="{softwareId: item.id}" routerLinkActive="router-link-active" routerLink="/search/software" >
{{item.title}} </a>
</div>
<div *ngIf="showLoading" class="uk-animation-fade uk-width-1-1" role="alert"><span class="loading-gif uk-align-center"></span></div>
<div *ngIf="item.type == 'other' && community != null && community.communityId != null && !showLoading">
<a [queryParams]="{orpId: item.id}" routerLinkActive="router-link-active" routerLink="/search/other" >
<div *ngIf=" community != null && community.communityId != null">
<a [queryParams]="getParamId(resultType,item.id)" routerLinkActive="router-link-active" [routerLink]="'/search/'+getresultTypeLink(resultType, false)" >
{{item.title}} </a>
</div>
</h6>
<div *ngIf="item.accessRights" class="el-content"><span class=" uk-label label-{{item.accessRights}}">{{item.accessRights}}</span><br></div>
<div>
@ -75,7 +46,10 @@ import { CommunityInfo } from '../../openaireLibrary/connect/community/community
</div>
</div>
</li>
</div>
</div>-->
<search-result [results]="results"
[type]="resultType" [properties] = properties>
</search-result>
</div>
<div *ngIf="results != null && results.length == 0 || total == 0" class=" uk-alert uk-alert-primary"> No results available </div>
@ -86,9 +60,29 @@ import { CommunityInfo } from '../../openaireLibrary/connect/community/community
export class ResultsComponent {
@Input() public results : ResultInfo[];
@Input() public results : SearchResult[];
@Input() public resultType: string;
@Input() public params: any;
@Input() public community: CommunityInfo;
@Input() public total: any;
@Input() showLoading: boolean = true;
@Input() properties: EnvProperties;
getresultTypeLink(type:string, plural:boolean){
if((type == "publication" || type == "dataset") && plural){
return type + "s";
}
return type;
}
/* getParamId(type:string){
let param ="";
if(type == "publication"){
param="article";
}else if(type == "other"){
param="other";
}else{
param=type;
}
return param+"Id";
}*/
}

View File

@ -1,98 +0,0 @@
import { Injectable } from '@angular/core';
import {HttpClient} from "@angular/common/http";
import { Observable } from 'rxjs/Rx';
import { ResultInfo } from '../openaireLibrary/connect/results/resultInfo';
import { CommunityInfo } from '../openaireLibrary/connect/community/communityInfo';
import {map} from "rxjs/operators";
@Injectable()
export class SearchEntriesService {
private sizeOfDescription: number = 135;
constructor(private http:HttpClient) {
}
getTotal(url: string) {
return this.http.get(url)
//.map(res => <any> res.json())
.pipe(map(res => res['total']));
//.do(res => {console.log(res)});
}
countTotal(url:string) {
return this.http.get(url)
//.map(res => <any> res.json())
.pipe(map(res => res['length']));
}
getResults(url: string) {
return this.http.get(url)
//.map(res => <any> res.json())
.pipe(map(res => this.parseResults(res['results'])));
}
parseResults(data: any): ResultInfo[] {
let results: ResultInfo[] = [];
let length = Array.isArray(data) ? data.length :1;
for (let i=0; i<length; i++) {
let resData = Array.isArray(data) ? data[i]['result']['metadata']['oaf:entity']['oaf:result'] : data['result']['metadata']['oaf:entity']['oaf:result'];
var result: ResultInfo = new ResultInfo();
if(Array.isArray(resData['title'])) {
result['title'] = resData['title'][0].content;
} else {
result['title'] = resData['title'].content;
}
result['id'] = Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
if(resData['bestaccessright'] && resData['bestaccessright'].hasOwnProperty("classid")) {
result['accessRights'] = resData['bestaccessright'].classid;
}
if(resData['resulttype'].hasOwnProperty("classid")) {
result['type'] = resData['resulttype'].classid;
}
if(resData.hasOwnProperty("creator") && resData['creator'] != null) {
if(result['authors'] == undefined) {
result['authors'] = new Array<string>();
}
let authors = resData['creator'];
let length = Array.isArray(authors) ? authors.length : 1;
for(let i=0; i<length; i++) {
let author = Array.isArray(authors) ? authors[i] : authors;
result.authors[author.rank-1] = author.content;
}
result.authors = result.authors.filter(function (item) {
return (item != undefined);
});
}
var date:string = (resData.dateofacceptance)+""; // transform to string in case it is an integer
result.year = (date && (date).indexOf('-') !== -1)?date.split('-')[0]:date;
if(!Array.isArray(resData.description)) {
result.description = resData.description;
} else {
result.description = resData.description[0];
}
if(result.description.length > this.sizeOfDescription) {
result.description = result.description.substring(0, this.sizeOfDescription) + "...";
}
results.push(result);
}
return results;
}
}

View File

@ -113,7 +113,7 @@ export class SearchCommunitiesComponent {
}
}
if(Session.isLoggedIn()) {
this._subscribeService.getCommunitiesSubscribedTo(Session.getUserEmail(), this.properties["adminToolsAPIURL"]).subscribe(
this._subscribeService.getCommunitiesSubscribedTo(this.properties, Session.getUserEmail()).subscribe(
res => {
for (let i = 0; i < this.totalResults.length; i++) {
this.totalResults[i].isSubscribed = (res.indexOf(this.totalResults[i].communityId) != -1);

View File

@ -115,7 +115,7 @@ export class StatisticsComponent {
createStatisticsObjects() {
// console.log(" Stats! "+ this.properties.statisticsAPIURL);
this.status = this.errorCodes.LOADING;
this._statisticsService.getCommunityStatistics(this.properties.statisticsAPIURL,this.communityId).subscribe (
this._statisticsService.getCommunityStatistics(this.properties,this.communityId).subscribe (
res => {
this.statisticsSum = res;
if(res["other"]){ //hack because in stats API the entity name is "other" while in admin API is "orp". This component uses also "orp" name
@ -131,7 +131,7 @@ export class StatisticsComponent {
}
getDisplayOptions() {
this._statisticsService.getCommunityAdminStatisticsChoices(this.properties.adminToolsAPIURL,this.communityId)
this._statisticsService.getCommunityAdminStatisticsChoices(this.properties,this.communityId)
.subscribe(
res => {
this.statisticsDisplay = res;
@ -151,7 +151,7 @@ export class StatisticsComponent {
getCommunityInfo() {
// console.log(`calling ${this.properties.adminToolsAPIURL}/communityFull/${this.communityId}`);
this._configService.getCommunityInformation(this.properties.adminToolsAPIURL, this.communityId).subscribe(
this._configService.getCommunityInformation(this.properties, this.communityId).subscribe(
res => {
this.communityInfo = res;
/*for(let i=0; i<this.communityInfo.entities.length; i++){

View File

@ -4,6 +4,7 @@ import { Observable } from 'rxjs/Rx';
import {StatisticsDisplay, StatisticsSummary} from "../../openaireLibrary/connect/statistics/statisticsEntities";
import {catchError, map} from "rxjs/operators";
import {throwError} from "rxjs";
import {EnvProperties} from "../../openaireLibrary/utils/properties/env-properties";
@Injectable()
@ -12,18 +13,18 @@ export class StatisticsService {
constructor(private http:HttpClient) { }
getCommunityStatistics(apiUrl: string, communityId: string): Observable<StatisticsSummary> {
let url = `${apiUrl}communities/${communityId}`;
getCommunityStatistics(properties:EnvProperties, communityId: string): Observable<StatisticsSummary> {
let url = properties.statisticsAPIURL+"/communities/"+communityId;
//console.log(`getting statistics summary from: ${url}`);
return this.http.get<any>(url)
return this.http.get<any>((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
//.map(res => <any>res.json())
.pipe(map(res => res['statistics']));
}
getCommunityAdminStatisticsChoices(apiUrl: string, communityId: string): Observable<StatisticsDisplay> {
let url = `${apiUrl}/statistics/${communityId}`;
getCommunityAdminStatisticsChoices(properties: EnvProperties, communityId: string): Observable<StatisticsDisplay> {
let url = properties.adminToolsAPIURL+"/statistics/"+communityId;
//console.log(`getting admin choices for statistics from: ${url}`);
return this.http.get<StatisticsDisplay>(url)
return this.http.get<StatisticsDisplay>((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
//.map(stats => <StatisticsDisplay>stats.json())
.pipe(catchError(this.handleError));
}

View File

@ -1,7 +1,6 @@
import { Component, Input, Output, ViewChild, EventEmitter } from '@angular/core';
import { Location } from '@angular/common';
import {Component, EventEmitter, Input, Output, ViewChild} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import { EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
import {AlertModal} from '../../openaireLibrary/utils/modal/alert';
import {CommunityService} from '../../openaireLibrary/connect/community/community.service';
@ -64,12 +63,12 @@ export class SubscribeComponent {
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
if(!this.showNumbers){
var email = Session.getUserEmail();
let email = Session.getUserEmail();
if(email == null){
this.subscribed = false;
}else{
if(this.communityId){
this._subscribeService.isSubscribedToCommunity(this.communityId, email,this.properties.adminToolsAPIURL).subscribe (
this._subscribeService.isSubscribedToCommunity(this.properties, this.communityId, email).subscribe (
res => {
this.subscribed = res;
},
@ -80,7 +79,7 @@ export class SubscribeComponent {
}
}else{
if(this.communityId){
this._subscribeService.getCommunitySubscribers(this.communityId, this.properties.adminToolsAPIURL).subscribe (
this._subscribeService.getCommunitySubscribers(this.properties, this.communityId).subscribe (
res => {
this.subscribers = (res && res.subscribers && res.subscribers.length )?res.subscribers.length:0;
},

View File

@ -2,7 +2,7 @@
"environment" : "development",
"enablePiwikTrack" : false,
"enableHelper" : true,
"useCache" : false,
"useCache" : true,
"showContent" : true,
"metricsAPIURL" : "https://beta.services.openaire.eu/usagestats/",
"framesAPIURL" : "https://beta.openaire.eu/stats3/",