From 8ea9cd5dbc199960003705efb97b0a12cde3110d Mon Sep 17 00:00:00 2001 From: Alex Martzios Date: Thu, 20 Jun 2024 14:14:42 +0300 Subject: [PATCH] [recommendations-and-nl-search | DONE | CHANGED] move DareLAB APIs to environment properties --- src/app/home/home.component.ts | 4 +--- .../natural-language-search.component.ts | 7 ++++--- src/app/openaireLibrary | 2 +- .../category-to-item/category-to-item.component.ts | 7 ++----- src/environments/environment.beta.ts | 9 ++++++++- src/environments/environment.prod.ts | 9 ++++++++- src/environments/environment.ts | 9 ++++++++- 7 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/app/home/home.component.ts b/src/app/home/home.component.ts index 402f1b9..a831b7b 100644 --- a/src/app/home/home.component.ts +++ b/src/app/home/home.component.ts @@ -59,8 +59,6 @@ export class HomeComponent { resultsSize: number = 6; errorMessage: string; - getRecommendationsForOrcidAPI: string = 'https://darelab.athenarc.gr/api/faircore/user-to-item-recommender/recommend' - constructor ( private _router: Router, private _piwikService:PiwikService, @@ -208,7 +206,7 @@ export class HomeComponent { getOrcidRecommendations() { let orcid = Identifier.getRawORCID(this.user.orcid); - this.subs.push(this.recommendationsService.getRecommendationsForOrcid(this.getRecommendationsForOrcidAPI, orcid).subscribe(data => { + this.subs.push(this.recommendationsService.getRecommendationsForOrcid(this.properties.recommendationsForOrcidAPI, orcid).subscribe(data => { this.recommendations = data['recommendations']; }, error => { console.log(error); diff --git a/src/app/natural-language-search/natural-language-search.component.ts b/src/app/natural-language-search/natural-language-search.component.ts index e8e635a..cca27f7 100644 --- a/src/app/natural-language-search/natural-language-search.component.ts +++ b/src/app/natural-language-search/natural-language-search.component.ts @@ -1,6 +1,8 @@ import {Component} from "@angular/core"; import {Subscriber} from "rxjs"; import {NaturalLanguageSearchService} from "./natural-language-search.service"; +import {EnvProperties} from "../openaireLibrary/utils/properties/env-properties"; +import {properties} from "../../environments/environment"; @Component({ selector: 'natural-language-search', @@ -10,6 +12,7 @@ import {NaturalLanguageSearchService} from "./natural-language-search.service"; export class NaturalLanguageSearchComponent { private subscriptions = []; + properties: EnvProperties = properties; showLoading: boolean = false; errorMessage: string; @@ -18,8 +21,6 @@ export class NaturalLanguageSearchComponent { results; indexColumnId: number; - naturalLanguageSearchAPI: string = "https://darelab.athenarc.gr/nl_search/api/fc4e_get_results/"; - constructor(private naturalLanguageSearchService: NaturalLanguageSearchService) { } @@ -35,7 +36,7 @@ export class NaturalLanguageSearchComponent { this.queryPhrase = this.phrase; this.errorMessage = null; this.showLoading = true; - this.subscriptions.push(this.naturalLanguageSearchService.getResults(this.naturalLanguageSearchAPI, this.queryPhrase).subscribe(data => { + this.subscriptions.push(this.naturalLanguageSearchService.getResults(this.properties.naturalLanguageSearchAPI, this.queryPhrase).subscribe(data => { if(data && data['columns']) { for(let i = 0; i < data['columns'].length - 1; i++) { if(data['columns'][i] == 'id') { diff --git a/src/app/openaireLibrary b/src/app/openaireLibrary index 2b12959..623debc 160000 --- a/src/app/openaireLibrary +++ b/src/app/openaireLibrary @@ -1 +1 @@ -Subproject commit 2b12959a4ec134092f2d3bf58586518d85d031ae +Subproject commit 623debc84662a0e61f197efe506cf121acc5bd49 diff --git a/src/app/recommendations/category-to-item/category-to-item.component.ts b/src/app/recommendations/category-to-item/category-to-item.component.ts index aa39c5c..b290092 100644 --- a/src/app/recommendations/category-to-item/category-to-item.component.ts +++ b/src/app/recommendations/category-to-item/category-to-item.component.ts @@ -30,9 +30,6 @@ export class CategoryToItemComponent { keywordControl: FormControl; keyword: string; - getAvailableCommunitiesAPI: string = 'https://darelab.athenarc.gr/api/faircore/category-based-recommender/available-communities'; - getRecommendationsForCommunityAPI: string = 'https://darelab.athenarc.gr/api/faircore/category-based-recommender/recommend'; - constructor(private communitiesService: CommunitiesService, private recommendationsService: RecommendationsService, private router: Router, @@ -48,7 +45,7 @@ export class CategoryToItemComponent { this.getCommunities(); this.subscriptions.push(this.route.params.subscribe(params => { if(params && params['community']) { - this.subscriptions.push(this.recommendationsService.getRecommendationsForCommunity(this.getRecommendationsForCommunityAPI, params['community']).subscribe(data => { + this.subscriptions.push(this.recommendationsService.getRecommendationsForCommunity(this.properties.recommendationsForCommunityAPI, params['community']).subscribe(data => { this.recommendations = data; this.setActiveCommunity(params['community']); })); @@ -70,7 +67,7 @@ export class CategoryToItemComponent { } private getCommunities() { - this.subscriptions.push(zip(this.recommendationsService.getAvailableCommunities(this.getAvailableCommunitiesAPI), this.communitiesService.getCommunities(this.properties, this.properties.communitiesAPI)).subscribe(data => { + this.subscriptions.push(zip(this.recommendationsService.getAvailableCommunities(this.properties.availableCommunitiesAPI), this.communitiesService.getCommunities(this.properties, this.properties.communitiesAPI)).subscribe(data => { let availableCommunities: any = data[0]; this.communities = availableCommunities.map(id => { const obj = data[1].find(o => o.communityId === id); diff --git a/src/environments/environment.beta.ts b/src/environments/environment.beta.ts index 65ffc42..8f4cd17 100644 --- a/src/environments/environment.beta.ts +++ b/src/environments/environment.beta.ts @@ -25,7 +25,14 @@ let props: EnvProperties = { searchLinkToServices: "/search/find/services", searchLinkToAdvancedServices: "/search/advanced/services", reCaptchaSiteKey: null, - footerGrantText : "" + footerGrantText : "", + + naturalLanguageSearchAPI: "https://darelab.athenarc.gr/nl_search/api/fc4e_get_results/", + availableCommunitiesAPI: 'https://darelab.athenarc.gr/api/faircore/category-based-recommender/available-communities', + recommendationsForCommunityAPI: 'https://darelab.athenarc.gr/api/faircore/category-based-recommender/recommend', + recommendationsForOrcidAPI: 'https://darelab.athenarc.gr/api/faircore/user-to-item-recommender/recommend', + recommendationsForPublicationAPI: 'https://darelab.athenarc.gr/api/faircore/item-to-item-recommender/recommend/', + feedbackForRecommendationAPI: 'https://darelab.athenarc.gr/api/faircore/category-based-recommender/update/' }; export let properties: EnvProperties = { diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index afc3dc2..49b4bb9 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -25,7 +25,14 @@ let props: EnvProperties = { searchLinkToServices: "/search/find/services", searchLinkToAdvancedServices: "/search/advanced/services", reCaptchaSiteKey: null, - footerGrantText : "" + footerGrantText : "", + + naturalLanguageSearchAPI: "https://darelab.athenarc.gr/nl_search/api/fc4e_get_results/", + availableCommunitiesAPI: 'https://darelab.athenarc.gr/api/faircore/category-based-recommender/available-communities', + recommendationsForCommunityAPI: 'https://darelab.athenarc.gr/api/faircore/category-based-recommender/recommend', + recommendationsForOrcidAPI: 'https://darelab.athenarc.gr/api/faircore/user-to-item-recommender/recommend', + recommendationsForPublicationAPI: 'https://darelab.athenarc.gr/api/faircore/item-to-item-recommender/recommend/', + feedbackForRecommendationAPI: 'https://darelab.athenarc.gr/api/faircore/category-based-recommender/update/' }; export let properties: EnvProperties = { diff --git a/src/environments/environment.ts b/src/environments/environment.ts index a55fd01..06dd088 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -25,7 +25,14 @@ let props: EnvProperties = { searchLinkToServices: "/search/find/services", searchLinkToAdvancedServices: "/search/advanced/services", reCaptchaSiteKey: null, - footerGrantText : "This OpenAIRE gateway is part of a project that has received funding from the European Union's Horizon 2020 research and innovation programme under grant agreements No. 777541 and 101017452" + footerGrantText : "This OpenAIRE gateway is part of a project that has received funding from the European Union's Horizon 2020 research and innovation programme under grant agreements No. 777541 and 101017452", + + naturalLanguageSearchAPI: "https://darelab.athenarc.gr/nl_search/api/fc4e_get_results/", + availableCommunitiesAPI: 'https://darelab.athenarc.gr/api/faircore/category-based-recommender/available-communities', + recommendationsForCommunityAPI: 'https://darelab.athenarc.gr/api/faircore/category-based-recommender/recommend', + recommendationsForOrcidAPI: 'https://darelab.athenarc.gr/api/faircore/user-to-item-recommender/recommend', + recommendationsForPublicationAPI: 'https://darelab.athenarc.gr/api/faircore/item-to-item-recommender/recommend/', + feedbackForRecommendationAPI: 'https://darelab.athenarc.gr/api/faircore/category-based-recommender/update/' }; export let properties: EnvProperties = {