[Library|Trunk]
add cache in some services and pass properties as parameter initiate a searchResearchResultsService where it gets result type as parameter update navbar/bottom to get properties as parameter and remove attributes included in properties add spaces in search results & authors components git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@55995 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
792986be29
commit
f5d29ffc76
|
@ -1,10 +1,9 @@
|
|||
import {Injectable} from '@angular/core';
|
||||
import {Http} from '@angular/http';
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
|
||||
import {CommunityInfo} from '../community/communityInfo';
|
||||
import {EnvProperties} from '../../utils/properties/env-properties';
|
||||
import {BehaviorSubject, Observable} from "rxjs";
|
||||
import {BehaviorSubject} from "rxjs";
|
||||
import {map} from "rxjs/operators";
|
||||
|
||||
@Injectable()
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
import {Injectable} from '@angular/core';
|
||||
import {Http} from '@angular/http';
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import{EnvProperties} from '../../utils/properties/env-properties';
|
||||
import {EnvProperties} from '../../utils/properties/env-properties';
|
||||
import {map} from "rxjs/operators";
|
||||
|
||||
@Injectable()
|
||||
export class SearchCommunityDataprovidersService {
|
||||
constructor(private http: HttpClient ) {}
|
||||
|
||||
searchDataproviders (properties:EnvProperties, communityId: string):any {
|
||||
let url = properties.communityAPI+communityId+"/contentproviders";
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url);
|
||||
//.map(res => <any> res.json())
|
||||
}
|
||||
countTotalDataproviders(properties:EnvProperties,communityId:string) {
|
||||
let url = properties.communityAPI+communityId+"/contentproviders";
|
||||
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
|
||||
.pipe(map(res => res['length']));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import {Injectable} from '@angular/core';
|
|||
import {Http} from '@angular/http';
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import{EnvProperties} from '../../utils/properties/env-properties';
|
||||
import {map} from "rxjs/operators";
|
||||
|
||||
@Injectable()
|
||||
export class SearchCommunityProjectsService {
|
||||
|
@ -13,4 +14,9 @@ export class SearchCommunityProjectsService {
|
|||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url);
|
||||
//.map(res => <any> res.json())
|
||||
}
|
||||
countTotalProjects(properties:EnvProperties,communityId:string) {
|
||||
let url = properties.communityAPI+communityId+"/projects";
|
||||
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
|
||||
.pipe(map(res => res['length']));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ public subPub;public subData; public subSoftware; public subOrps; public subProj
|
|||
|
||||
|
||||
|
||||
this.config.getCommunityInformation(this.properties.adminToolsAPIURL, (this.connectCommunityId)?this.connectCommunityId:this.properties.adminToolsCommunity ).subscribe(data => {
|
||||
this.config.getCommunityInformation(this.properties, (this.connectCommunityId)?this.connectCommunityId:this.properties.adminToolsCommunity ).subscribe(data => {
|
||||
var showEntity = {};
|
||||
for(var i=0; i< data['entities'].length; i++){
|
||||
|
||||
|
|
|
@ -3,26 +3,28 @@
|
|||
|
||||
<li *ngFor="let result of results" class="uk-animation-fade">
|
||||
<!-- <h4 class = "{{result.title.accessMode}} {{result.title.sc39}}" [title] = result.title.accessMode > -->
|
||||
<h5 [title] = result.title.accessMode >
|
||||
<div [title] = result.title.accessMode class="uk-h5">
|
||||
<a [queryParams]="routerHelper.createQueryParam(urlParam,result.id)" routerLinkActive="router-link-active" routerLink="/search/{{type}}">
|
||||
<p *ngIf="result['title'].name || result.acronym"><span *ngIf="result.acronym">{{result.acronym}}</span><span *ngIf="result.acronym && result['title'].name">-</span><span *ngIf="result['title'].name" [innerHTML]="result['title'].name"></span><span *ngIf="result.code"> ({{result.code}})</span></p>
|
||||
<p *ngIf="!result['title'].name && !result.acronym">[no title available]<span *ngIf="result.code"> ({{result.code}})</span></p>
|
||||
</a>
|
||||
</h5>
|
||||
<span *ngIf="result.types && result.types.length > 0" [class]="'uk-label custom-label label-blue label-'+result.entityType" title="Type">{{result.types.join(", ")}}</span>
|
||||
<span *ngIf="result.programmingLanguages && result.programmingLanguages.length > 0" class="uk-label custom-label label-progrLanguage " title="Programming Language">{{result.programmingLanguages.join(", ")}}</span>
|
||||
<span *ngIf="result.languages && result.languages.length > 0" class="uk-label custom-label label-language " title="Language">{{result.languages.join(", ")}}</span>
|
||||
<span *ngIf="result.countriesForResults && result.countriesForResults.length > 0" class="uk-label custom-label label-country " title="Country">{{result.countriesForResults.join(", ")}}</span>
|
||||
<span *ngIf="result.title && result.title.accessMode" [class]="'uk-label custom-label label-'+ result.title.accessMode " title="Access Mode">{{result.title.accessMode}}</span>
|
||||
<span *ngIf="result['funderShortname']" class="uk-label custom-label label-funder " title="Funder">{{result['funderShortname']}}</span>
|
||||
</div>
|
||||
<span *ngIf="result.types && result.types.length > 0"
|
||||
[class]="'uk-label custom-label label-blue label-'+result.entityType"
|
||||
title="Type">{{result.types.join(", ")}}</span>{{' '}}
|
||||
<span *ngIf="result.programmingLanguages && result.programmingLanguages.length > 0" class="uk-label custom-label label-progrLanguage " title="Programming Language">{{result.programmingLanguages.join(", ")}}</span>{{' '}}
|
||||
<span *ngIf="result.languages && result.languages.length > 0" class="uk-label custom-label label-language " title="Language">{{result.languages.join(", ")}}</span>{{' '}}
|
||||
<span *ngIf="result.countriesForResults && result.countriesForResults.length > 0" class="uk-label custom-label label-country " title="Country">{{result.countriesForResults.join(", ")}}</span>{{' '}}
|
||||
<span *ngIf="result.title && result.title.accessMode" [class]="'uk-label custom-label label-'+ result.title.accessMode " title="Access Mode">{{result.title.accessMode}}</span>{{' '}}
|
||||
<span *ngIf="result['funderShortname']" class="uk-label custom-label label-funder " title="Funder">{{result['funderShortname']}}</span>{{' '}}
|
||||
<span *ngIf="result.openAccessMandatePublications != undefined && result.openAccessMandatePublications && (result.openAccessMandateDatasets == undefined || !result.openAccessMandateDatasets)"
|
||||
class="uk-label custom-label label-openaccessmandate " title="Open Access mandate for Publications">Open Access mandate for Publications</span>
|
||||
class="uk-label custom-label label-openaccessmandate " title="Open Access mandate for Publications">Open Access mandate for Publications</span>{{' '}}
|
||||
<span *ngIf="result.openAccessMandateDatasets != undefined && result.openAccessMandateDatasets && (result.openAccessMandatePublications == undefined || !result.openAccessMandatePublications)"
|
||||
class="uk-label custom-label label-openaccessmandate " title="Open Access mandate for Research Data">Open Access mandate for Research Data</span>
|
||||
class="uk-label custom-label label-openaccessmandate " title="Open Access mandate for Research Data">Open Access mandate for Research Data</span>{{' '}}
|
||||
<span *ngIf="result.openAccessMandatePublications != undefined && result.openAccessMandatePublications && result.openAccessMandateDatasets != undefined && result.openAccessMandateDatasets"
|
||||
class="uk-label custom-label label-openaccessmandate " title="Open Access mandate for Publications and Research Data">Open Access mandate for Publications and Research Data</span>
|
||||
class="uk-label custom-label label-openaccessmandate " title="Open Access mandate for Publications and Research Data">Open Access mandate for Publications and Research Data</span>{{' '}}
|
||||
|
||||
<span *ngIf="result.title && result.title.sc39" class="uk-label custom-label label-sc39 " title="Special Clause 39">Special Clause 39</span>
|
||||
<span *ngIf="result.title && result.title.sc39" class="uk-label custom-label label-sc39 " title="Special Clause 39">Special Clause 39</span>{{' '}}
|
||||
<div class="uk-margin-small">
|
||||
<!-- <span *ngIf="result['authors'] != undefined" class="resultsAuthors uk-margin-small-top" style="font-style: italic;">-->
|
||||
<!-- <span *ngFor="let author of result['authors'].slice(0,15)">-->
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
import { NgModule} from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {RouterModule} from '@angular/router';
|
||||
|
||||
import {ErrorMessagesModule} from '../../utils/errorMessages.module';
|
||||
|
||||
import {SearchResult} from '../../utils/entities/searchResult';
|
||||
import {SearchResultComponent} from './searchResult.component';
|
||||
import {ErrorMessagesModule} from '../../utils/errorMessages.module';
|
||||
import {SearchResultComponent} from './searchResult.component';
|
||||
import {ApprovedByCommunityModule} from '../../connect/approvedByCommunity/approved.module';
|
||||
import {ShowAuthorsModule} from "../../utils/authors/showAuthors.module";
|
||||
|
||||
|
|
|
@ -0,0 +1,398 @@
|
|||
import {Injectable} from '@angular/core';
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {SearchResult} from '../utils/entities/searchResult';
|
||||
import {RefineResultsUtils} from './servicesUtils/refineResults.class';
|
||||
import {DOI, StringUtils} from '../utils/string-utils.class';
|
||||
import {ParsingFunctions} from '../landingPages/landing-utils/parsingFunctions.class';
|
||||
import {EnvProperties} from '../utils/properties/env-properties';
|
||||
import {map} from "rxjs/operators";
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class SearchResearchResultsService {
|
||||
private sizeOfDescription: number = 270;
|
||||
public parsingFunctions: ParsingFunctions = new ParsingFunctions();
|
||||
|
||||
constructor(private http: HttpClient ) {}
|
||||
|
||||
search (resultType:string, params: string, refineParams:string, page: number, size: number, sortBy: string, refineFields:string[] , properties:EnvProperties):any {
|
||||
let link = properties.searchAPIURLLAst+this.getEntityName(resultType,true);
|
||||
|
||||
let url = link+"?";
|
||||
if(params!= null && params != '' ) {
|
||||
url += params;
|
||||
}
|
||||
if(refineParams!= null && refineParams != '' ) {
|
||||
url += refineParams;
|
||||
}
|
||||
if(sortBy) {
|
||||
url += "&sortBy=" + sortBy;
|
||||
}
|
||||
url += "&page="+(page-1)+"&size="+size+"&format=json";
|
||||
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "publication")]));
|
||||
}
|
||||
searchById (resultType:string, id: string, properties:EnvProperties ):any {
|
||||
|
||||
let url = properties.searchAPIURLLAst+this.getEntityName(resultType,true) +"/"+id+"?format=json";
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
.pipe(map(res => this.parseResults(resultType, res, properties)));
|
||||
}
|
||||
//???
|
||||
searchAggregators (id: string, params: string, refineParams:string, page: number, size: number, properties:EnvProperties ):any {
|
||||
|
||||
let link = properties.searchAPIURLLAst+"publications";
|
||||
|
||||
let url = link+"?"+"&format=json";
|
||||
if(params!= null && params != '' ) {
|
||||
url += params;
|
||||
}
|
||||
if(refineParams!= null && refineParams != '' ) {
|
||||
url += refineParams;
|
||||
}
|
||||
url += "&page="+(page-1)+"&size="+size;
|
||||
|
||||
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.map(res => <any> res.json())
|
||||
.pipe(map(res => this.parseRefineResults(id, res['refineResults'])));
|
||||
}
|
||||
|
||||
searchByListOfDOI (resultType:string, DOIs: string[], refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any {
|
||||
|
||||
let link = properties.searchAPIURLLAst+ this.getEntityName(resultType,true);
|
||||
|
||||
let url = link+"?"+"&format=json&";
|
||||
var doisParams = "";
|
||||
|
||||
for(var i =0 ;i < DOIs.length; i++){
|
||||
doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"';
|
||||
}
|
||||
if(doisParams.length > 0){
|
||||
url +="&"+doisParams;
|
||||
|
||||
}
|
||||
if(refineParams!= null && refineParams != '' ) {
|
||||
url += refineParams;
|
||||
}
|
||||
url += "&page="+(page-1)+"&size="+size;
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.map(res => <any> res.json())
|
||||
//.do(res => console.info(res))
|
||||
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "publication")]));
|
||||
}
|
||||
|
||||
advancedSearch (resultType:string, params: string, page: number, size: number, sortBy: string, properties:EnvProperties ):any {
|
||||
let url = properties.searchResourcesAPIURL;
|
||||
var basicQuery = "(oaftype exact result) and (resulttypeid exact "+this.getEntityName(resultType,false) + ") ";
|
||||
url += "?query=";
|
||||
if(params!= null && params != '' ) {
|
||||
url +=" ( "+basicQuery+ " ) " +" and (" + params + ")";
|
||||
}else{
|
||||
url +=" ( "+basicQuery+ " ) ";
|
||||
}
|
||||
|
||||
if(sortBy) {
|
||||
let sortOptions = sortBy.split(",");
|
||||
url += "sortBy "+sortOptions[0]+"/sort."+sortOptions[1]+" ";
|
||||
}
|
||||
|
||||
url += "&page="+(page-1)+"&size="+size;
|
||||
url += "&format=json";
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.map(res => <any> res.json())
|
||||
//.do(res => console.info(res))
|
||||
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties)]));
|
||||
}
|
||||
searchResultForEntity (resultType:string, params: string, page: number, size: number, properties:EnvProperties):any {
|
||||
let link = properties.searchAPIURLLAst;
|
||||
let url = link+params+"/"+this.getEntityName(resultType,true)+ "?format=json";
|
||||
url += "&page="+(page-1)+"&size="+size;
|
||||
|
||||
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties)]));
|
||||
}
|
||||
//???? why different from above?
|
||||
searchForDataproviders(resultType:string, params: string, page: number, size: number, properties:EnvProperties):any {
|
||||
let link = properties.searchAPIURLLAst;
|
||||
let url = link+params+ "&page="+(page-1)+"&size="+size + "&format=json";
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties)]));
|
||||
}
|
||||
|
||||
parseResults(resultType:string, data: any, properties: EnvProperties): SearchResult[] {
|
||||
let results: SearchResult[] = [];
|
||||
|
||||
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: SearchResult = new SearchResult();
|
||||
result.entityType = resultType;
|
||||
|
||||
result.types = new Array<string>();
|
||||
let types = new Set<string>();
|
||||
|
||||
let instance;
|
||||
let length = Array.isArray(resData['children']['instance']) ? resData['children']['instance'].length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
instance = Array.isArray(resData['children']['instance']) ? resData['children']['instance'][i] : resData['children']['instance'];
|
||||
this.parsingFunctions.parseTypes(result.types, types, instance);
|
||||
}
|
||||
|
||||
if(resData['language'] && resData['language'] != null) {
|
||||
result.languages = new Array<string>();
|
||||
|
||||
if(!Array.isArray(resData['language'])) {
|
||||
if(resData['language'].classname != "Undetermined" && resData['language'].classname) {
|
||||
result.languages.push(resData['language'].classname);
|
||||
}
|
||||
} else {
|
||||
for(let i=0; i<resData['language'].length; i++) {
|
||||
if(resData['language'][i].classname != "Undetermined" && resData['language'][i].classname) {
|
||||
result.languages.push(resData['language'][i].classname);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(resData['country'] && resData['country'] != null) {
|
||||
result.countriesForResults = new Array<string>();
|
||||
|
||||
if(!Array.isArray(resData['country'])) {
|
||||
if(resData['country'].classname != "Undetermined" && resData['country'].classname) {
|
||||
result.countriesForResults.push(resData['country'].classname);
|
||||
}
|
||||
} else {
|
||||
for(let i=0; i<resData['country'].length; i++) {
|
||||
if(resData['country'][i].classname != "Undetermined" && resData['country'][i].classname) {
|
||||
result.countriesForResults.push(resData['country'][i].classname);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result['title'] = {"name": '', "accessMode": '', "sc39": ''};
|
||||
|
||||
if(Array.isArray(resData['title'])) {
|
||||
// resData['title'][0].hasOwnProperty("content") {
|
||||
result['title'].name = String(resData['title'][0].content);
|
||||
// }
|
||||
} else {
|
||||
// resData['title'].hasOwnProperty("content") {
|
||||
result['title'].name = String(resData['title'].content);
|
||||
// }
|
||||
}
|
||||
|
||||
//result['title'].url = OpenaireProperties.getsearchLinkToPublication();
|
||||
//result['title'].url += Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
|
||||
result['id'] = Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
|
||||
if(resData['bestaccessright'] && resData['bestaccessright'].hasOwnProperty("classid")) {
|
||||
result['title'].accessMode = resData['bestaccessright'].classid;
|
||||
}
|
||||
|
||||
if(resData['rels'].hasOwnProperty("rel")) {
|
||||
let relLength = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'].length : 1;
|
||||
|
||||
for(let j=0; j<relLength; j++) {
|
||||
let relation = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'][j] : resData['rels']['rel'];
|
||||
|
||||
if(relation.hasOwnProperty("to")) {
|
||||
/*if(relation['to'].class == "hasAuthor") {
|
||||
if(result['authors'] == undefined) {
|
||||
result['authors'] = new Array<{"name": string, "id": string}>();
|
||||
}
|
||||
|
||||
result['authors'].push({"name": relation.fullname, "id": relation['to'].content});
|
||||
} else */if(relation['to'].class == "isProducedBy") {
|
||||
result['projects'] = this.parseProjects(result['projects'], relation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(resData.hasOwnProperty("creator") && resData['creator'] != null) {
|
||||
if(result['authors'] == undefined) {
|
||||
result['authors'] = new Array<{"fullName": string, "orcid": 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;
|
||||
if(author) {
|
||||
/*if (author.ORCID && author.ORCID.indexOf(properties.orcidURL) != -1) {
|
||||
author.ORCID = author.ORCID.substr(properties.orcidURL.length);
|
||||
}*/
|
||||
result['authors'][author.rank] = {"fullName": author.content, "orcid": author.ORCID};
|
||||
}
|
||||
}
|
||||
result.authors = result.authors.filter(function (item) {
|
||||
return (item != undefined && item.fullName != 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 = String(resData.description);
|
||||
} else {
|
||||
result.description = String(resData.description[0]);
|
||||
}
|
||||
|
||||
if(result.description && result.description.length > this.sizeOfDescription) {
|
||||
result.description = result.description.substring(0, this.sizeOfDescription) + "...";
|
||||
}
|
||||
|
||||
|
||||
result.embargoEndDate = resData.embargoenddate;
|
||||
|
||||
results.push(result);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
parseProjects(projects: { "id": string, "acronym": string, "title": string,
|
||||
"funderShortname": string, "funderName": string,
|
||||
"code": string }[], relation: any ) : {
|
||||
"id": string, "acronym": string, "title": string,
|
||||
"funderShortname": string, "funderName": string,
|
||||
"code": string }[] {
|
||||
if(projects == undefined) {
|
||||
projects = new Array<
|
||||
{ "id": string, "acronym": string, "title": string,
|
||||
"funderShortname": string, "funderName": string,
|
||||
"code": string
|
||||
}>();
|
||||
}
|
||||
|
||||
let countProjects = projects.length;
|
||||
|
||||
projects[countProjects] = {
|
||||
"id": "", "acronym": "", "title": "",
|
||||
"funderShortname": "", "funderName": "",
|
||||
"code": ""
|
||||
}
|
||||
|
||||
if(relation.title != 'unidentified') {
|
||||
projects[countProjects]['id'] =
|
||||
/*OpenaireProperties.getsearchLinkToProject() + */relation['to'].content;
|
||||
projects[countProjects]['acronym'] = relation.acronym;
|
||||
projects[countProjects]['title'] = relation.title;
|
||||
projects[countProjects]['code'] = relation.code;
|
||||
} else {
|
||||
projects[countProjects]['id'] = "";
|
||||
projects[countProjects]['acronym'] = "";
|
||||
projects[countProjects]['title'] = "";
|
||||
projects[countProjects]['code'] = "";
|
||||
}
|
||||
|
||||
if(relation.hasOwnProperty("funding")) {
|
||||
let fundingLength = Array.isArray(relation['funding']) ? relation['funding'].length : 1;
|
||||
|
||||
for(let z=0; z<fundingLength; z++) {
|
||||
let fundingData = Array.isArray(relation['funding']) ? relation['funding'][z] : relation['funding'];
|
||||
|
||||
if(fundingData.hasOwnProperty("funder")) {
|
||||
projects[countProjects]['funderShortname'] = fundingData['funder'].shortname;
|
||||
projects[countProjects]['funderName'] = fundingData['funder'].name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return projects;
|
||||
}
|
||||
parseRefineResults(id: string, data: any): any {
|
||||
var results:any = [];
|
||||
if(data.hasOwnProperty("resulthostingdatasource")) {
|
||||
let length = Array.isArray(data['resulthostingdatasource']) ? data['resulthostingdatasource'].length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
let datasource = Array.isArray(data['resulthostingdatasource']) ? data['resulthostingdatasource'][i] : data['resulthostingdatasource'];
|
||||
|
||||
let result: {"name": string, "id": string, "count": number} = {"name": "", "id": "", "count": 0};
|
||||
result['name'] = datasource.name;
|
||||
result['id'] = datasource.id.split("||")[0];
|
||||
//result['url'] = OpenaireProperties.getsearchLinkToDataProvider()+result['id'];
|
||||
result['count'] = datasource.count;
|
||||
|
||||
if(result['id'] != id && result['name'] != "Unknown Repository") {
|
||||
results.push(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
private numOfResults(url: string, properties:EnvProperties): any {
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.map(res => <any> res.json())
|
||||
.pipe(map(res => res['total']));
|
||||
}
|
||||
|
||||
numOfEntityResults(resultType:string, id: string, entity: string, properties:EnvProperties):any {
|
||||
var parameters: string = "";
|
||||
parameters = this.getEntityName(entity, true) + "/"+id+"/"+this.getEntityName(resultType, true)+"/count";
|
||||
let url = properties.searchAPIURLLAst+parameters+"?format=json";
|
||||
return this.numOfResults(url , properties);
|
||||
}
|
||||
|
||||
numOfSearchResults(resultType:string, params: string, properties:EnvProperties, refineParams:string=null):any {
|
||||
let url = properties.searchAPIURLLAst+this.getEntityName(resultType, true)+"/count?format=json";
|
||||
if(params.length > 0){
|
||||
var DOIs:string[] = DOI.getDOIsFromString(params);
|
||||
var doisParams = "";
|
||||
|
||||
for(var i =0 ;i < DOIs.length; i++){
|
||||
doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"';
|
||||
}
|
||||
if(doisParams.length > 0){
|
||||
url += "&"+doisParams;
|
||||
}else{
|
||||
url += "&q=" + StringUtils.URIEncode(params);
|
||||
}
|
||||
}
|
||||
// if(params != "") {
|
||||
// url += "&q=" + StringUtils.URIEncode(params);
|
||||
// }
|
||||
if(refineParams!= null && refineParams != '' ) {
|
||||
url += refineParams;
|
||||
}
|
||||
return this.numOfResults(url, properties);
|
||||
}
|
||||
countTotalResults(resultType:string, properties:EnvProperties, refineParams:string=null):any {
|
||||
let url = properties.searchAPIURLLAst+this.getEntityName(resultType, true)+"/count?format=json"+refineParams;
|
||||
return this.numOfResults(url, properties);
|
||||
}
|
||||
/*
|
||||
private quote(word: any): string {
|
||||
return '"'+word+'"';
|
||||
}
|
||||
*/
|
||||
|
||||
private getEntityName (entityType:string, plural:boolean){
|
||||
if(entityType == "publication" ||entityType == "dataset" || entityType == "organization" || entityType == "datasource" || entityType == "project" ){
|
||||
if(plural){
|
||||
return entityType+ "s";
|
||||
}else{
|
||||
return entityType;
|
||||
}
|
||||
}else{
|
||||
return entityType;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
import { NgModule} from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import {SearchResearchResultsService} from "./searchResearchResults.service";
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, FormsModule
|
||||
],
|
||||
declarations: [
|
||||
],
|
||||
providers: [
|
||||
SearchResearchResultsService
|
||||
],
|
||||
exports: [
|
||||
]
|
||||
})
|
||||
|
||||
export class SearchResearchResultsServiceModule { }
|
|
@ -99,10 +99,10 @@
|
|||
<div id="footer#10" class="uk-width-medium uk-text-left@s uk-text-center uk-panel">
|
||||
<h3 class="el-title uk-h6">Dashboards</h3>
|
||||
<ul class="uk-nav uk-nav-default uk-nav-parent-icon uk-nav-accordion" uk-nav="">
|
||||
<li><a [href]="'https://'+(environment =='beta' || environment =='development'?'beta.':'')+'explore.openaire.eu'" target="_blank">Explore</a></li>
|
||||
<li><a [href]="'https://'+(environment =='beta' || environment =='development'?'beta.':'')+'provide.openaire.eu'" target="_blank">Provide</a></li>
|
||||
<li><a [href]="'https://'+(environment =='beta' || environment =='development'?'beta.':'')+'connect.openaire.eu'" target="_blank">Connect</a></li>
|
||||
<li><a [href]="'https://'+(environment =='beta' || environment =='development'?'beta.openaire.eu/monitor':'monitor.openaire.eu')" target="_blank">Monitor</a></li>
|
||||
<li><a [href]="'https://'+(properties.environment =='beta' || properties.environment =='development'?'beta.':'')+'explore.openaire.eu'" target="_blank">Explore</a></li>
|
||||
<li><a [href]="'https://'+(properties.environment =='beta' || properties.environment =='development'?'beta.':'')+'provide.openaire.eu'" target="_blank">Provide</a></li>
|
||||
<li><a [href]="'https://'+(properties.environment =='beta' || properties.environment =='development'?'beta.':'')+'connect.openaire.eu'" target="_blank">Connect</a></li>
|
||||
<li><a [href]="'https://'+(properties.environment =='beta' || properties.environment =='development'?'beta.openaire.eu/monitor':'monitor.openaire.eu')" target="_blank">Monitor</a></li>
|
||||
<li><a href="https://develop.openaire.eu" target="_blank">Develop</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -3,6 +3,7 @@ import {ActivatedRoute} from '@angular/router';
|
|||
import 'rxjs';
|
||||
import{MenuItem} from './menu';
|
||||
import { ConfigurationService } from '../utils/configuration/configuration.service';
|
||||
import {EnvProperties} from "../utils/properties/env-properties";
|
||||
|
||||
@Component({
|
||||
selector: 'bottom',
|
||||
|
@ -17,14 +18,13 @@ export class BottomComponent {
|
|||
@Input() assetsPath:string ='assets/common-assets/';
|
||||
@Input() menuItems:MenuItem [];
|
||||
|
||||
@Input() APIUrl;
|
||||
@Input() communityId;
|
||||
@Input() environment:string = "beta";
|
||||
// @Input() environment:string = "beta";
|
||||
showPage ={};
|
||||
@Input() grantAdvance:boolean = true;
|
||||
grantAdvanceText = "OpenAIRE-Advance receives funding from the European Union's Horizon 2020 Research and Innovation programme under Grant Agreement No. 777541."
|
||||
grantConenctText = "OpenAIRE-Connect receives funding from the European Union's Horizon 2020 Research and Innovation programme under grant agreement No. 731011."
|
||||
|
||||
@Input() properties:EnvProperties;
|
||||
|
||||
constructor(private config: ConfigurationService, private route: ActivatedRoute,) {
|
||||
}
|
||||
|
@ -32,8 +32,8 @@ constructor(private config: ConfigurationService, private route: ActivatedRoute
|
|||
ngOnInit() {
|
||||
this.route.queryParams.subscribe(params => {
|
||||
if(this.showMenuItems){
|
||||
if( this.APIUrl && this.communityId ){
|
||||
this.config.getCommunityInformation(this.APIUrl, this.communityId ).subscribe(data => {
|
||||
if( this.properties.adminToolsAPIURL && this.communityId ){
|
||||
this.config.getCommunityInformation(this.properties, this.communityId ).subscribe(data => {
|
||||
for(var i=0; i< data['pages'].length; i++){
|
||||
this.showPage[data['pages'][i]["route"]] = data['pages'][i]["isEnabled"];
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<a *ngIf="!community" class="uk-navbar-item uk-logo" routerLinkActive="uk-link" routerLink="/" >
|
||||
<img src="{{logoPath}}logo-small-{{portal}}.png" alt="OpenAIRE" class="uk-responsive-height">
|
||||
</a>
|
||||
<a *ngIf="community && !homeurl" class="uk-navbar-item uk-logo" [href]="'https://'+(environment =='beta'?'beta.':'')+community.id+'.openaire.eu'" target="_blank">
|
||||
<a *ngIf="community && !homeurl" class="uk-navbar-item uk-logo" [href]="'https://'+(properties.environment =='beta'?'beta.':'')+community.id+'.openaire.eu'" target="_blank">
|
||||
<img *ngIf="community.logoUrl && community.logoUrl.length > 0" src="{{community.logoUrl}}" [alt]=community.name class="uk-responsive-height">
|
||||
<div *ngIf="!community.logoUrl || community.logoUrl.length == 0" class="uk-margin-left uk-text-large"> {{community.name}} </div>
|
||||
</a>
|
||||
|
@ -34,10 +34,10 @@
|
|||
<li class="uk-nav-header uk-parent" >
|
||||
Dashboards
|
||||
<ul class="uk-nav-sub">
|
||||
<li *ngIf="portal!='explore'"><a [href]="'https://'+(environment =='beta' || environment =='development' ?'beta.':'')+'explore.openaire.eu'" target="_blank" class="uk-heading-bullet explore-heading-bullet">EXPLORE</a></li>
|
||||
<li *ngIf="portal!='provide'"><a [href]="'https://'+(environment =='beta' || environment =='development'?'beta.':'')+'provide.openaire.eu'" target="_blank" class="uk-heading-bullet provide-heading-bullet">PROVIDE</a></li>
|
||||
<li *ngIf="portal!='connect'"><a [href]="'https://'+(environment =='beta' || environment =='development'?'beta.':'')+'connect.openaire.eu'" target="_blank" class="uk-heading-bullet connect-heading-bullet">CONNECT</a></li>
|
||||
<li *ngIf="portal!='monitor'"><a [href]="'https://'+(environment =='beta' || environment =='development'?'beta.openaire.eu/monitor':'monitor.openaire.eu')" target="_blank" class="uk-heading-bullet monitor-heading-bullet">MONITOR</a></li>
|
||||
<li *ngIf="portal!='explore'"><a [href]="'https://'+(properties.environment =='beta' || properties.environment =='development' ?'beta.':'')+'explore.openaire.eu'" target="_blank" class="uk-heading-bullet explore-heading-bullet">EXPLORE</a></li>
|
||||
<li *ngIf="portal!='provide'"><a [href]="'https://'+(properties.environment =='beta' || properties.environment =='development'?'beta.':'')+'provide.openaire.eu'" target="_blank" class="uk-heading-bullet provide-heading-bullet">PROVIDE</a></li>
|
||||
<li *ngIf="portal!='connect'"><a [href]="'https://'+(properties.environment =='beta' || properties.environment =='development'?'beta.':'')+'connect.openaire.eu'" target="_blank" class="uk-heading-bullet connect-heading-bullet">CONNECT</a></li>
|
||||
<li *ngIf="portal!='monitor'"><a [href]="'https://'+(properties.environment =='beta' || properties.environment =='development'?'beta.openaire.eu/monitor':'monitor.openaire.eu')" target="_blank" class="uk-heading-bullet monitor-heading-bullet">MONITOR</a></li>
|
||||
<li *ngIf="portal!='develop'"><a href="https://develop.openaire.eu" target="_blank" class="uk-heading-bullet develop-heading-bullet">DEVELOP</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
@ -64,7 +64,7 @@
|
|||
</ng-container>
|
||||
</ng-container>
|
||||
<ng-container *ngIf="userMenu">
|
||||
<user-mini mobileView=true [userMenuItems]=userMenuItems [logInUrl]=logInUrl [logOutUrl]=logOutUrl [cookieDomain]=cookieDomain></user-mini>
|
||||
<user-mini mobileView=true [userMenuItems]=userMenuItems [logInUrl]=properties.loginUrl [logOutUrl]=properties.logoutUrl [cookieDomain]=properties.cookieDomain></user-mini>
|
||||
</ng-container>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -84,13 +84,13 @@
|
|||
<div class="uk-first-column">
|
||||
<div class="uk-panel inner" id="module-119">
|
||||
<ul class="uk-subnav uk-subnav-line">
|
||||
<li ><a [href]="'https://'+(environment =='beta'?'beta':'www')+'.openaire.eu'" target="_blank" class="home-icon"><span class="uk-responsive-height" >
|
||||
<li ><a [href]="'https://'+(properties.environment =='beta'?'beta':'www')+'.openaire.eu'" target="_blank" class="home-icon"><span class="uk-responsive-height" >
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" enable-background="new 0 0 20 20" height="20px" id="Layer_1" version="1.1" viewBox="0 0 48 48" width="20px" xml:space="preserve"><path id="home" clip-rule="evenodd" d="M44.715,23.711c-0.381,0.382-1,0.382-1.381,0l-8.939-8.938 c-0.064-0.051-0.119-0.106-0.17-0.171l-3.83-3.829c-0.064-0.051-0.119-0.106-0.17-0.171L24,4.377L4.667,23.711 c-0.381,0.382-1,0.382-1.381,0c-0.381-0.381-0.381-1,0-1.381L23.191,2.425c0.031-0.047,0.053-0.101,0.094-0.144 C23.482,2.085,23.742,1.994,24,2c0.258-0.006,0.518,0.084,0.715,0.281c0.043,0.042,0.062,0.096,0.096,0.144L30,7.616V4.997 c0,0,0,0,0,0c0-0.552,0.447-1,1-1h4c0.277,0,0.527,0.112,0.707,0.293C35.889,4.471,36,4.721,36,4.997v8.619l8.715,8.714 C45.096,22.711,45.096,23.33,44.715,23.711z M34,5.997h-2v3.619l2,2V5.997z M10,21.997c0.552,0,1,0.448,1,1v19c0,1.105,0.896,2,2,2 h6l0,0v-13c0-0.553,0.447-1,1-1h8c0.553,0,1,0.447,1,1v13l0,0h6c1.105,0,2-0.895,2-2v-19c0-0.552,0.447-1,1-1s1,0.448,1,1v19 c0,2.209-1.791,4-4,4H13c-2.209,0-4-1.791-4-4v-19C9,22.444,9.448,21.997,10,21.997z M27,43.996v-12h-6v12l0,0H27L27,43.996z" fill-rule="evenodd" fill="#fff"/></svg>
|
||||
</span></a></li>
|
||||
<li [class]="(portal=='explore')?'custom-'+portal+'-li':''"><a [href]="'https://'+(environment =='beta' || environment =='development'?'beta.':'')+'explore.openaire.eu'" title="Search in OA. Link your research">Explore</a></li>
|
||||
<li [class]="(portal=='provide')?'custom-'+portal+'-li':''"><a [href]="'https://'+(environment =='beta' || environment =='development'?'beta.':'')+'provide.openaire.eu'" target="_blank" title="Content Provider Dashboard">Provide</a></li>
|
||||
<li [class]="(portal=='connect'||portal=='connect-admin')?'custom-'+portal+'-li':''"><a [href]="'https://'+(environment =='beta' || environment =='development' ?'beta.':'')+'connect.openaire.eu'" target="_blank" title="Research Community Dashboard">Connect</a></li>
|
||||
<li [class]="(portal=='monitor')?'custom-'+portal+'-li':''"><a [href]="'https://'+(environment =='beta' || environment =='development'?'beta.openaire.eu/monitor':'monitor.openaire.eu')" target="_blank" title="Monitoring Dashboard">Monitor</a></li>
|
||||
<li [class]="(portal=='explore')?'custom-'+portal+'-li':''"><a [href]="'https://'+(properties.environment =='beta' || properties.environment =='development'?'beta.':'')+'explore.openaire.eu'" title="Search in OA. Link your research">Explore</a></li>
|
||||
<li [class]="(portal=='provide')?'custom-'+portal+'-li':''"><a [href]="'https://'+(properties.environment =='beta' || properties.environment =='development'?'beta.':'')+'provide.openaire.eu'" target="_blank" title="Content Provider Dashboard">Provide</a></li>
|
||||
<li [class]="(portal=='connect'||portal=='connect-admin')?'custom-'+portal+'-li':''"><a [href]="'https://'+(properties.environment =='beta' || properties.environment =='development' ?'beta.':'')+'connect.openaire.eu'" target="_blank" title="Research Community Dashboard">Connect</a></li>
|
||||
<li [class]="(portal=='monitor')?'custom-'+portal+'-li':''"><a [href]="'https://'+(properties.environment =='beta' || properties.environment =='development'?'beta.openaire.eu/monitor':'monitor.openaire.eu')" target="_blank" title="Monitoring Dashboard">Monitor</a></li>
|
||||
<li [class]="(portal=='develop')?'custom-'+portal+'-li':''"><a href="https://develop.openaire.eu" target="_blank" title="APIs">Develop</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -116,7 +116,7 @@
|
|||
<img *ngIf="community.logoUrl && community.logoUrl.length > 0" src="{{community.logoUrl}}" [alt]=community.name class="uk-responsive-height">
|
||||
<div *ngIf="!community.logoUrl || community.logoUrl.length == 0" class="uk-margin-left uk-text-large"> {{community.name}} </div>
|
||||
</a>
|
||||
<a *ngIf="community && !homeurl" [href]="'https://'+(environment =='beta'?'beta.':'')+community.id+'.openaire.eu'" target="_blank" class="uk-logo uk-navbar-item">
|
||||
<a *ngIf="community && !homeurl" [href]="'https://'+(properties.environment =='beta'?'beta.':'')+community.id+'.openaire.eu'" target="_blank" class="uk-logo uk-navbar-item">
|
||||
|
||||
<img *ngIf="community.logoUrl && community.logoUrl.length > 0" src="{{community.logoUrl}}" [alt]=community.name class="uk-responsive-height">
|
||||
<div *ngIf="!community.logoUrl || community.logoUrl.length == 0" class="uk-margin-left uk-text-large"> {{community.name}} </div>
|
||||
|
@ -130,7 +130,7 @@
|
|||
<img *ngIf="community.logoUrl && community.logoUrl.length > 0" src="{{community.logoUrl}}" [alt]=community.name class="uk-responsive-height">
|
||||
<div *ngIf="!community.logoUrl || community.logoUrl.length == 0" class="uk-margin-left uk-text-large"> {{community.name}} </div>
|
||||
</a>
|
||||
<a *ngIf="community && !homeurl" [href]="'https://'+(environment =='beta'?'beta.':'')+community.id+'.openaire.eu'" target="_blank" class="uk-logo uk-navbar-item">
|
||||
<a *ngIf="community && !homeurl" [href]="'https://'+(properties.environment =='beta'?'beta.':'')+community.id+'.openaire.eu'" target="_blank" class="uk-logo uk-navbar-item">
|
||||
<img *ngIf="community.logoUrl && community.logoUrl.length > 0" src="{{community.logoUrl}}" [alt]=community.name class="uk-responsive-height">
|
||||
<div *ngIf="!community.logoUrl || community.logoUrl.length == 0" class="uk-margin-left uk-text-large"> {{community.name}} </div>
|
||||
</a>
|
||||
|
@ -170,7 +170,7 @@
|
|||
<!-- </div> -->
|
||||
<!-- <div *ngIf="userMenu" class="uk-navbar-right"> -->
|
||||
<!-- <div *ngIf="userMenu" class="uk-navbar-right"> -->
|
||||
<user-mini *ngIf="userMenu" [userMenuItems]=userMenuItems [logInUrl]=logInUrl [logOutUrl]=logOutUrl [cookieDomain]=cookieDomain></user-mini>
|
||||
<user-mini *ngIf="userMenu" [userMenuItems]=userMenuItems [logInUrl]=properties.loginUrl [logOutUrl]=properties.logoutUrl [cookieDomain]=properties.cookieDomain></user-mini>
|
||||
|
||||
</div>
|
||||
</nav>
|
||||
|
|
|
@ -6,26 +6,27 @@ import {Observable} from 'rxjs';
|
|||
import {Session} from '../login/utils/helper.class';
|
||||
import { ConfigurationService } from '../utils/configuration/configuration.service';
|
||||
import{MenuItem,RootMenuItem} from './menu';
|
||||
import {EnvProperties} from "../utils/properties/env-properties";
|
||||
@Component({
|
||||
selector: 'navbar',
|
||||
templateUrl: 'navigationBar.component.html'
|
||||
})
|
||||
export class NavigationBarComponent {
|
||||
// [APIUrl]="properties.adminToolsAPIURL" [logOutUrl]="properties.logoutUrl" [cookieDomain]="properties.cookieDomain"
|
||||
@Input() portal:string = "connect";
|
||||
@Input() onlyTop:boolean ;
|
||||
@Input() logoPath:string = "assets/common-assets/";
|
||||
@Input() userMenu:boolean = true;
|
||||
@Input() logInUrl;
|
||||
@Input() logOutUrl;
|
||||
@Input() APIUrl;
|
||||
// @Input() logOutUrl;
|
||||
// @Input() APIUrl;
|
||||
@Input() communityId;
|
||||
@Input() cookieDomain;
|
||||
// @Input() cookieDomain;
|
||||
@Input() userMenuItems:MenuItem[] ;
|
||||
@Input() menuItems:RootMenuItem [] ;
|
||||
@Input() community: {id:string, name:string, logoUrl:string};
|
||||
@Input() showMenu:boolean = true;
|
||||
@Input() homeurl:boolean = true;
|
||||
@Input() environment:string = "beta";
|
||||
@Input() properties:EnvProperties;
|
||||
|
||||
public isAuthorized: boolean = false;
|
||||
sub:any;
|
||||
|
@ -61,8 +62,8 @@ export class NavigationBarComponent {
|
|||
this.isAuthorized = false;
|
||||
}
|
||||
|
||||
if( this.APIUrl && this.communityId ){
|
||||
this.config.getCommunityInformation(this.APIUrl, this.communityId ).subscribe(data => {
|
||||
if( this.properties.adminToolsAPIURL && this.communityId ){
|
||||
this.config.getCommunityInformation(this.properties, this.communityId ).subscribe(data => {
|
||||
for(var i=0; i< data['entities'].length; i++){
|
||||
|
||||
this.showEntity[""+data['entities'][i]["pid"]+""] = data['entities'][i]["isEnabled"];
|
||||
|
|
|
@ -63,7 +63,7 @@ import {EnvProperties} from '../properties/env-properties';
|
|||
</a>
|
||||
</div>
|
||||
</div
|
||||
><span>;</span>
|
||||
><span>;{{" "}}</span>
|
||||
</span>
|
||||
<span *ngIf="numberOfAuthors == authorsLimit && authors.length > authorsLimit"> ... </span>
|
||||
<span *ngIf="showAll && numberOfAuthors == authorsLimit && authors.length > authorsLimit">
|
||||
|
|
|
@ -7,14 +7,16 @@ import {Observable} from 'rxjs';
|
|||
// import 'rxjs/add/operator/do';
|
||||
// import 'rxjs/add/operator/share';
|
||||
import {map, mapTo} from 'rxjs/operators';
|
||||
import {EnvProperties} from "../properties/env-properties";
|
||||
|
||||
@Injectable()
|
||||
export class ConfigurationService {
|
||||
|
||||
|
||||
constructor(private http: HttpClient ) {}
|
||||
getCommunityInformation(APIUrl:string, community:string){
|
||||
return this.http.get(APIUrl + "/communityFull/" + community);
|
||||
getCommunityInformation(properties:EnvProperties, community:string){
|
||||
let url = properties.adminToolsAPIURL +"/communityFull/" + community;
|
||||
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url);
|
||||
//.map(res => res.json());
|
||||
}
|
||||
|
||||
|
@ -30,8 +32,9 @@ export class ConfigurationService {
|
|||
.pipe(map(res => true));
|
||||
}
|
||||
|
||||
isPageEnabled(APIUrl:string, community:string,router: string){
|
||||
return this.http.get(APIUrl + "/community/" + community+"/pages?page_route="+router)
|
||||
isPageEnabled(properties:EnvProperties, community:string,router: string){
|
||||
let url = properties.adminToolsAPIURL + "/community/" + community+"/pages?page_route="+router;
|
||||
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
|
||||
//.map(res => res.json())
|
||||
.pipe(map(res => {
|
||||
let result = false;
|
||||
|
|
|
@ -1,26 +1,22 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { Http, Response, Headers, RequestOptions } from '@angular/http';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { HttpHeaders } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import {COOKIE} from "../../login/utils/helper.class"
|
||||
import { map } from "rxjs/operators";
|
||||
import {Injectable} from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {map} from "rxjs/operators";
|
||||
import {CustomOptions} from "../../services/servicesUtils/customOptions.class";
|
||||
import {EnvProperties} from "../properties/env-properties";
|
||||
|
||||
@Injectable()
|
||||
export class SubscribeService {
|
||||
|
||||
constructor(private http:HttpClient) {
|
||||
}
|
||||
getCommunitySubscribers(pid:string, url:string){
|
||||
return this.http.get<any>(url+"/community/"+pid+"/subscribers");
|
||||
//.map(res => <any> res.json());
|
||||
getCommunitySubscribers(properties: EnvProperties, pid:string){
|
||||
let url = properties.adminToolsAPIURL+ "/community/"+pid+"/subscribers";
|
||||
return this.http.get<any>((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url);
|
||||
}
|
||||
|
||||
isSubscribedToCommunity(pid:string, email:string, url:string){
|
||||
return this.http.get(url+"/community/"+pid+"/subscribers")
|
||||
//.map(res => ((<any>res =="")?{}:<any> res.json()))
|
||||
|
||||
isSubscribedToCommunity(properties: EnvProperties, pid:string, email:string){
|
||||
let url = properties.adminToolsAPIURL + "/community/"+pid+"/subscribers";
|
||||
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
|
||||
.pipe(map(res => {
|
||||
if(res['status'] && res['status'] != 200) {
|
||||
return null;
|
||||
|
@ -38,36 +34,14 @@ export class SubscribeService {
|
|||
}));
|
||||
}
|
||||
subscribeToCommunity(pid:string, email:string, url:string){
|
||||
var subscriber = {"email":email};
|
||||
let subscriber = {"email":email};
|
||||
return this.http.post<any>(url+"/community/"+pid+"/subscribers", JSON.stringify(subscriber), CustomOptions.getAuthOptionsWithBody());
|
||||
//.map(res => <any> res.json());
|
||||
}
|
||||
unSubscribeToCommunity(pid:string, email:string, url:string){
|
||||
|
||||
return this.http.post<any>(url+"/community/"+pid+"/subscribers/delete", JSON.stringify([email]), CustomOptions.getAuthOptionsWithBody());
|
||||
//.map(res => <any> res.json());
|
||||
}
|
||||
getCommunitiesSubscribedTo(email:string, url:string){
|
||||
return this.http.get<any>(url+"/subscriber/communities?email="+email);
|
||||
//.map(res => <any> res.json());
|
||||
getCommunitiesSubscribedTo(properties: EnvProperties, email:string){
|
||||
let url = properties.adminToolsAPIURL+"/subscriber/communities?email="+email;
|
||||
return this.http.get<any>((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url);
|
||||
}
|
||||
|
||||
/*
|
||||
public getAuthOptionsWithBody():RequestOptions{
|
||||
let headers = new Headers();
|
||||
headers.append('Content-Type', 'application/json');
|
||||
headers.append('X-XSRF-TOKEN', COOKIE.getCookie(COOKIE.cookieName_id));
|
||||
let options = new RequestOptions({ headers: headers, withCredentials:true });
|
||||
return options;
|
||||
}
|
||||
*/
|
||||
|
||||
public getAuthOptionsWithBody():any {
|
||||
return {
|
||||
headers: new HttpHeaders({
|
||||
'Content-Type': 'application/json',
|
||||
'X-XSRF-TOKEN': COOKIE.getCookie(COOKIE.cookieName_id)
|
||||
}), withCredentials: true
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue