diff --git a/.gitignore b/.gitignore index cc7b141..99b9534 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ testem.log # System files .DS_Store Thumbs.db +public/ARTI_20240903_120441.jpg diff --git a/src/app/app.config.ts b/src/app/app.config.ts index aa06ab4..f046db3 100644 --- a/src/app/app.config.ts +++ b/src/app/app.config.ts @@ -7,5 +7,5 @@ import { provideHttpClient } from '@angular/common/http'; export const appConfig: ApplicationConfig = { providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes), - provideHttpClient(),] + provideHttpClient()] }; diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index e461fed..01ebc52 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -7,7 +7,7 @@ import { ChatGPTComponent } from './chat-gpt/chat-gpt.component'; export const routes: Routes = [ { path: "", title: "Kalkulator amortyzacyjny", - component:AssetCalculatorComponent }, + component:ChatGPTComponent }, { path: "about-me", title:"O mnie", component: AboutMeComponent }, diff --git a/src/app/asset-calculator/asset-calculator.component.ts b/src/app/asset-calculator/asset-calculator.component.ts index 3d02cf9..2577bd2 100644 --- a/src/app/asset-calculator/asset-calculator.component.ts +++ b/src/app/asset-calculator/asset-calculator.component.ts @@ -1,5 +1,5 @@ -import {Component, computed, effect, OnInit ,signal } from '@angular/core'; -import {FormsModule, ReactiveFormsModule, FormControl, FormGroup, Validators} from '@angular/forms'; +import {Component, effect, OnInit, signal } from '@angular/core'; +import {ReactiveFormsModule, FormGroup, Validators, FormControl} from '@angular/forms'; import {CurrencyPipe,DecimalPipe,PercentPipe} from '@angular/common'; import {AssetsModule} from './assets/assets.module' import {Asset, Positions, AssetPlanPosition, TypeDepreciation } from './assets/asset'; @@ -8,7 +8,7 @@ import {AssetService} from './assets/service/asset.service' @Component({ selector: 'app-asset-calculator', standalone: true, - imports: [FormsModule, CurrencyPipe, DecimalPipe, PercentPipe, AssetsModule, ReactiveFormsModule ] , + imports: [ CurrencyPipe, DecimalPipe, PercentPipe, AssetsModule, ReactiveFormsModule ] , templateUrl: "asset-calculator.component.html", styleUrl: 'asset-calculator.component.css' }) @@ -23,7 +23,7 @@ export class AssetCalculatorComponent implements OnInit{ year = signal( 2024 ); month = signal( 10 ); typeDepreciation = signal< TypeDepreciation>( TypeDepreciation.linear ); - factorValue = signal( 2 ); + factorValue = signal( 2 ); // Asset @@ -41,7 +41,6 @@ export class AssetCalculatorComponent implements OnInit{ constructor(private assetService : AssetService ){ effect( () => { this.calculate();}); -// this.assetsDepreciationForm.valueChanges.subscribe( (value)=> { this.calculateForAsset(value); }); } ngOnInit(): void{ diff --git a/src/app/asset-calculator/assets/service/asset.service.ts b/src/app/asset-calculator/assets/service/asset.service.ts index f736483..eb31ead 100644 --- a/src/app/asset-calculator/assets/service/asset.service.ts +++ b/src/app/asset-calculator/assets/service/asset.service.ts @@ -1,11 +1,10 @@ import { Injectable } from '@angular/core'; -import { HttpClient,HttpErrorResponse } from '@angular/common/http'; +import { HttpClient} from '@angular/common/http'; import { Asset, Positions } from '../asset'; import { Observable } from 'rxjs'; -let assetUrl: string ='https://api.arti24.eu/rest-api/assets/calculate'; //let assetUrl: string ='http://localhost:8801/rest-api/assets/calculate'; @@ -14,10 +13,14 @@ let assetUrl: string ='https://api.arti24.eu/rest-api/assets/calculate'; }) export class AssetService { + //private assetUrl: string ='http://localhost:5001/rest-api/assets/calculate'; + + private assetUrl: string ='https://api.arti24.eu/rest-api/assets/calculate'; + constructor(private http: HttpClient) { } calculate(asset: Asset) : Observable{ - return this.http.post(assetUrl, asset) ; + return this.http.post(this.assetUrl, asset) ; } } diff --git a/src/app/chat-gpt/chat-gpt.component.ts b/src/app/chat-gpt/chat-gpt.component.ts index 3d47423..a9e6450 100644 --- a/src/app/chat-gpt/chat-gpt.component.ts +++ b/src/app/chat-gpt/chat-gpt.component.ts @@ -1,12 +1,80 @@ -import { Component } from '@angular/core'; - +import { Component, effect, signal } from '@angular/core'; +import { ReactiveFormsModule, FormGroup, FormControl, FormsModule } from '@angular/forms'; +import { AiApiService } from './service/ai-api.service' +import { Sentence } from './service/chats'; @Component({ selector: 'app-chat-gpt', standalone: true, - imports: [], - templateUrl: './chat-gpt.component.html', - styleUrl: './chat-gpt.component.css' + imports: [ReactiveFormsModule], + template: + ` + + +
+

Prace w toku

+
+
+
+ + +
+
+ +
+
+
+` + }) export class ChatGPTComponent { + question :string =''; + answer = signal(''); + + isAsking = false; + + chatGPTGroup = new FormGroup( + { + askGPT : new FormControl( this.question ), + answerGPT: new FormControl( this.answer() ) + } + ); + + constructor(private aiApiService : AiApiService ){ + } + + log(txt:string){ + console.log( txt ); + } + + ask2Answer( ){ + this.isAsking = true; + const question : Sentence = { + body : this.question + } + + this.aiApiService.ask( question ).subscribe( answer => { this.answer.set( answer.body ); this.isAsking = false; } ); + } } diff --git a/src/app/chat-gpt/service/ai-api.service.spec.ts b/src/app/chat-gpt/service/ai-api.service.spec.ts new file mode 100644 index 0000000..83f6bac --- /dev/null +++ b/src/app/chat-gpt/service/ai-api.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { AiApiService } from './ai-api.service'; + +describe('AiApiService', () => { + let service: AiApiService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(AiApiService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/chat-gpt/service/ai-api.service.ts b/src/app/chat-gpt/service/ai-api.service.ts new file mode 100644 index 0000000..0db4f4e --- /dev/null +++ b/src/app/chat-gpt/service/ai-api.service.ts @@ -0,0 +1,22 @@ +import { Injectable } from '@angular/core'; + +import { HttpClient } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import { Sentence } from './chats'; + +@Injectable({ + providedIn: 'root' +}) +export class AiApiService { + + private aiApiUrl = 'http://127.0.0.1:5000/chatgpt/ask'; + // private aiApiUrl = 'http://127.0.0.1:8801/chatgpt/ask'; +// private aiApiUrl = 'http://127.0.0.1:8801/chatgpt/ask'; + + constructor(private http: HttpClient) { } + + ask(question: Sentence ) : Observable{ + + return this.http.post( this.aiApiUrl, question ) ; + } +} diff --git a/src/app/chat-gpt/service/chats.ts b/src/app/chat-gpt/service/chats.ts new file mode 100644 index 0000000..257a50c --- /dev/null +++ b/src/app/chat-gpt/service/chats.ts @@ -0,0 +1,4 @@ + +export interface Sentence{ + body : string +}