From 9bada7006c7d6332232f3186a4cdffd858a59f0b Mon Sep 17 00:00:00 2001 From: szymonj98 Date: Wed, 31 May 2023 16:54:44 +0200 Subject: [PATCH] environments and quick fixes --- .../errors-correction-page.component.ts | 3 ++- .../facebook-analysis/facebook-analysis.component.ts | 5 +++-- .../sentiment-analysis/sentiment-analysis.component.ts | 3 ++- src/environments/environment.prod.ts | 6 +++++- src/environments/environment.ts | 5 ++++- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/app/demo-models-page/errors-correction-page/errors-correction-page.component.ts b/src/app/demo-models-page/errors-correction-page/errors-correction-page.component.ts index 094cde8..d50c5a7 100644 --- a/src/app/demo-models-page/errors-correction-page/errors-correction-page.component.ts +++ b/src/app/demo-models-page/errors-correction-page/errors-correction-page.component.ts @@ -2,6 +2,7 @@ import { HttpClient } from '@angular/common/http'; import { Component, OnInit } from '@angular/core'; import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; import { Router } from '@angular/router'; +import { environment } from 'src/environments/environment'; @Component({ selector: 'app-errors-correction-page', @@ -48,7 +49,7 @@ export class ErrorsCorrectionPageComponent implements OnInit { } else { sentence = this.errorsForm.value.text } - this.http.put('http://127.0.0.1:5000/get_errors', { sentence: sentence }).subscribe({ + this.http.put(environment.errors, { sentence: sentence }).subscribe({ next: (resp: any) => { this.correctedText = resp.predictions[0].generated_text this.correctedTextLoading = true; diff --git a/src/app/demo-models-page/facebook-analysis/facebook-analysis.component.ts b/src/app/demo-models-page/facebook-analysis/facebook-analysis.component.ts index 906ccad..fbfa96a 100644 --- a/src/app/demo-models-page/facebook-analysis/facebook-analysis.component.ts +++ b/src/app/demo-models-page/facebook-analysis/facebook-analysis.component.ts @@ -4,6 +4,7 @@ import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms' import { Router } from '@angular/router'; import { concatMap, tap } from 'rxjs'; import { ChartConfiguration, ChartOptions, ChartType } from 'chart.js'; +import { environment } from 'src/environments/environment'; @Component({ selector: 'app-facebook-analysis', @@ -54,9 +55,9 @@ export class FacebookAnalysisComponent implements OnInit { this.analysisStart = true this.analysisLoading = false let link = this.link.value - this.http.post('http://127.0.0.1:5000/scrapp_comments', { link: link }).pipe(concatMap((resp: any) => { + this.http.post(environment.facebook, { link: link }).pipe(concatMap((resp: any) => { this.post = resp.post - return this.http.post('http://127.0.0.1:5000/get_sentiment_data', { sentences: resp.comments }).pipe(tap((resp: any) => { + return this.http.post(environment.sentiment, { sentences: resp.sentences }).pipe(tap((resp: any) => { console.log(resp) this.results = resp.predictions this.barChartData.datasets = [ diff --git a/src/app/demo-models-page/sentiment-analysis/sentiment-analysis.component.ts b/src/app/demo-models-page/sentiment-analysis/sentiment-analysis.component.ts index fa1c063..c1f895a 100644 --- a/src/app/demo-models-page/sentiment-analysis/sentiment-analysis.component.ts +++ b/src/app/demo-models-page/sentiment-analysis/sentiment-analysis.component.ts @@ -3,6 +3,7 @@ import { Component, OnInit } from '@angular/core'; import { FormArray, FormBuilder, FormGroup, Validators } from '@angular/forms'; import { Router } from '@angular/router'; import { ChartConfiguration, ChartOptions, ChartType } from 'chart.js'; +import { environment } from 'src/environments/environment'; @Component({ selector: 'app-sentiment-analysis', @@ -77,7 +78,7 @@ export class SentimentAnalysisComponent implements OnInit { let value = this.sentimentForm.value sentences = value.sentences.map((value: any) => value.text) } - this.http.post('http://127.0.0.1:5000/get_sentiment_data', { sentences: sentences }).subscribe({ + this.http.post(environment.sentiment, { sentences: sentences }).subscribe({ next: (resp: any) => { this.results = resp.predictions console.log(resp) diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 3612073..efd6f56 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -1,3 +1,7 @@ export const environment = { - production: true + production: true, + sentiment: 'magisterka-backend.azurewebsites.net/get_sentiment_data', + errors: 'magisterka-backend.azurewebsites.net/get_errors', + facebook: 'magisterka-backend.azurewebsites.net/scrapp_comments' }; + diff --git a/src/environments/environment.ts b/src/environments/environment.ts index f56ff47..d673074 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -3,7 +3,10 @@ // The list of file replacements can be found in `angular.json`. export const environment = { - production: false + production: false, + sentiment: 'http://127.0.0.1:5000/get_sentiment_data', + errors: 'http://127.0.0.1:5000/get_errors', + facebook: 'http://127.0.0.1:5000/scrapp_comments' }; /*