quick fixes

This commit is contained in:
szymonj98 2023-05-31 17:56:33 +02:00
parent 9e9ffb359a
commit 14f13710c9
4 changed files with 36 additions and 13 deletions

View File

@ -17,6 +17,7 @@
</div>
<div class="results-table" *ngIf="analysisStart">
<ng-container *ngIf="analysisLoading; else loading">
<ng-container *ngIf="commentStatus; else commentError">
<div class="info-container">
<div class="post-title">Treść posta</div>
<div class="post">
@ -43,6 +44,7 @@
</canvas>
</div>
</div>
</ng-container>
</ng-container>
</div>
</div>
@ -50,3 +52,6 @@
<ng-template #loading>
<div class="spinner"><mat-spinner></mat-spinner></div>
</ng-template>
<ng-template #commentError>
<div class="comment-error">Nie udało się pobrać komentarzy</div>
</ng-template>

View File

@ -96,3 +96,11 @@
justify-content: center;
align-items: center;
}
.comment-error{
display: flex;
justify-content: center;
align-items: center;
color:white;
font-size:20px
}

View File

@ -2,7 +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 { concatMap, tap } from 'rxjs';
import { concatMap, of, tap } from 'rxjs';
import { ChartConfiguration, ChartOptions, ChartType } from 'chart.js';
import { environment } from 'src/environments/environment';
@ -18,6 +18,7 @@ export class FacebookAnalysisComponent implements OnInit {
results: { label: number, score: number, sentence: string }[] = []
analysisStart = false;
analysisLoading = false;
commentStatus = false;
post!: string;
public barChartLegend = true;
public barChartPlugins = [];
@ -56,18 +57,27 @@ export class FacebookAnalysisComponent implements OnInit {
this.analysisLoading = false
let link = this.link.value
this.http.post(environment.facebook, { link: link }).pipe(concatMap((resp: any) => {
this.post = resp.post
return this.http.post(environment.sentiment, { sentences: resp.sentences }).pipe(tap((resp: any) => {
console.log(resp)
this.results = resp.predictions
this.barChartData.datasets = [
{ data: [resp.count_labels.negative], label: String(resp.count_labels.negative) + ' negatywny', backgroundColor: 'rgba(250, 66, 66, 1)', borderRadius: 15, },
{ data: [resp.count_labels.positive], label: String(resp.count_labels.positive) + ' pozytywny', backgroundColor: 'rgba(124, 136, 248, 1)', borderRadius: 15, },
{ data: [resp.count_labels.neutral], label: String(resp.count_labels.neutral) + ' neutralny', backgroundColor: 'rgba(211,211,211)', borderRadius: 15, }
]
}))
if (resp.status) {
this.commentStatus = false;
console.log(1)
return of({})
} else {
this.commentStatus = true;
this.post = resp.post
return this.http.post(environment.sentiment, { sentences: resp.sentences }).pipe(tap((resp: any) => {
console.log(resp)
this.results = resp.predictions
this.barChartData.datasets = [
{ data: [resp.count_labels.negative], label: String(resp.count_labels.negative) + ' negatywny', backgroundColor: 'rgba(250, 66, 66, 1)', borderRadius: 15, },
{ data: [resp.count_labels.positive], label: String(resp.count_labels.positive) + ' pozytywny', backgroundColor: 'rgba(124, 136, 248, 1)', borderRadius: 15, },
{ data: [resp.count_labels.neutral], label: String(resp.count_labels.neutral) + ' neutralny', backgroundColor: 'rgba(211,211,211)', borderRadius: 15, }
]
}))
}
})).subscribe({
next: () => {
console.log(2)
this.analysisLoading = true
}
})

View File

@ -1,7 +1,7 @@
<div class="jurney">
<!-- <div class="jurney">
<div class="jurney-text">START YOUR JOURNEY NOW</div>
<mat-icon (click)="scrollDown()">expand_more</mat-icon>
</div>
</div> -->
<div class="home-page">
<!-- <div class="nav-bar-container">
<div class="logo-container"><img class="logo-image" src="assets/images/logo.svg" alt=""></div>