diff --git a/frontend/src/app/Services/auth.service.ts b/frontend/src/app/Services/auth.service.ts index 85ad53a..4d0ed48 100644 --- a/frontend/src/app/Services/auth.service.ts +++ b/frontend/src/app/Services/auth.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { HttpClient, HttpHeaders } from '@angular/common/http'; import { Observable } from 'rxjs'; -const AUTH_API = 'https://aktienbot.flokaiser.com/api/user'; +const AUTH_API = 'https://gruppe1.testsites.info/api/user'; const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }), }; diff --git a/frontend/src/app/Services/data.service.ts b/frontend/src/app/Services/data.service.ts index bbd1863..412efb7 100644 --- a/frontend/src/app/Services/data.service.ts +++ b/frontend/src/app/Services/data.service.ts @@ -2,16 +2,23 @@ import { Injectable, OnInit } from '@angular/core'; import { HttpClient, HttpHeaders } from '@angular/common/http'; import { delay, Observable } from 'rxjs'; import { TokenStorageService } from './token.service'; -const API_URL = 'https://aktienbot.flokaiser.com/api/'; +const API_URL = 'https://gruppe1.testsites.info/api/'; @Injectable({ providedIn: 'root', }) export class DataService { + /** + * @param {HttpClient} privatehttp + * @param {TokenStorageService} privatetokenStorage + */ constructor( private http: HttpClient, private tokenStorage: TokenStorageService ) {} + /** + * @returns Observable + */ public getStockData(): Observable { return this.http.get(API_URL + 'portfolio', { headers: new HttpHeaders({ @@ -22,6 +29,9 @@ export class DataService { }); } + /** + * @returns Observable + */ public getTransactionData(): Observable { return this.http.get(API_URL + 'transactions', { headers: new HttpHeaders({ @@ -32,6 +42,34 @@ export class DataService { }); } + /** + * @param {string} symbol + * @param {Date} time + * @param {number} count + * @param {number} price + * @returns Observable + */ + public createTransaction( + symbol: string, + time: Date, + count: number, + price: number + ): Observable { + return this.http.post(API_URL + 'transactions', { + headers: new HttpHeaders({ + 'Content-Type': 'application/json', + Authorization: 'Bearer ' + this.tokenStorage.getToken(), + }), + symbol, + time, + count, + price, + }); + } + + /** + * @returns Observable + */ public getKeywords(): Observable { return this.http.get(API_URL + 'keywords', { headers: new HttpHeaders({ diff --git a/frontend/src/app/Views/dashboard/dashboard.component.html b/frontend/src/app/Views/dashboard/dashboard.component.html index 5c1b401..3b2f32b 100644 --- a/frontend/src/app/Views/dashboard/dashboard.component.html +++ b/frontend/src/app/Views/dashboard/dashboard.component.html @@ -63,6 +63,16 @@
Transaktionen
+ +
diff --git a/frontend/src/app/Views/dashboard/dashboard.component.scss b/frontend/src/app/Views/dashboard/dashboard.component.scss index 7bc1360..85474ee 100644 --- a/frontend/src/app/Views/dashboard/dashboard.component.scss +++ b/frontend/src/app/Views/dashboard/dashboard.component.scss @@ -62,3 +62,11 @@ table { .placeholder { height: 100%; } + +side-heading { + display: inline; +} + +.mat-ripple-element { + display: none !important; +} diff --git a/frontend/src/app/Views/dashboard/dashboard.component.ts b/frontend/src/app/Views/dashboard/dashboard.component.ts index 27a6140..a04fd72 100644 --- a/frontend/src/app/Views/dashboard/dashboard.component.ts +++ b/frontend/src/app/Views/dashboard/dashboard.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit } from '@angular/core'; -import { throwToolbarMixedModesError } from '@angular/material/toolbar'; import { DataService } from 'src/app/Services/data.service'; -import { TokenStorageService } from 'src/app/Services/token.service'; +import { MatDialog } from '@angular/material/dialog'; +import { UserDialogComponent } from './user-dialog/user-dialog.component'; export interface PeriodicElement { name: string; @@ -43,13 +43,21 @@ const ELEMENT_DATA: PeriodicElement[] = [ { position: 20, name: 'Neon', weight: 20.1797, symbol: 'Ne' }, ]; +export interface TransactionData { + symbol: string; + time: Date; + count: number; + price: number; +} + @Component({ selector: 'app-dashboard', templateUrl: './dashboard.component.html', styleUrls: ['./dashboard.component.scss'], }) export class DashboardComponent implements OnInit { - constructor(private dataService: DataService) {} + constructor(private dataService: DataService, public dialog: MatDialog) {} + ngOnInit() { this.dataService.getStockData().subscribe((response: any) => { console.log(response); @@ -61,6 +69,28 @@ export class DashboardComponent implements OnInit { }); } + symbol: string = ''; + time: Date = new Date(); + count: number = 0.0; + price: number = 0.0; + + openDialog(): void { + const dialogRef = this.dialog.open(UserDialogComponent, { + width: '50vw', + height: '55vh', + data: { + symbol: this.symbol, + time: this.time, + count: this.count, + price: this.price, + }, + }); + + dialogRef.afterClosed().subscribe((result) => { + console.log('The dialog was closed'); + }); + } + displayedColumns: string[] = ['position', 'name', 'weight', 'symbol']; dataSource = ELEMENT_DATA; } diff --git a/frontend/src/app/Views/dashboard/user-dialog/user-dialog.component.html b/frontend/src/app/Views/dashboard/user-dialog/user-dialog.component.html new file mode 100644 index 0000000..67e6e52 --- /dev/null +++ b/frontend/src/app/Views/dashboard/user-dialog/user-dialog.component.html @@ -0,0 +1,60 @@ +

Neue Transaktion hinzufügen

+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+ + diff --git a/frontend/src/app/Views/dashboard/user-dialog/user-dialog.component.scss b/frontend/src/app/Views/dashboard/user-dialog/user-dialog.component.scss new file mode 100644 index 0000000..80e25e5 --- /dev/null +++ b/frontend/src/app/Views/dashboard/user-dialog/user-dialog.component.scss @@ -0,0 +1,9 @@ +.spacer { + flex-grow: 1; + width: 5%; +} + +.footer-buttons { + display: flex; + width: 100%; +} diff --git a/frontend/src/app/Views/dashboard/user-dialog/user-dialog.component.spec.ts b/frontend/src/app/Views/dashboard/user-dialog/user-dialog.component.spec.ts new file mode 100644 index 0000000..4db6f9c --- /dev/null +++ b/frontend/src/app/Views/dashboard/user-dialog/user-dialog.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { UserDialogComponent } from './user-dialog.component'; + +describe('UserDialogComponent', () => { + let component: UserDialogComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ UserDialogComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(UserDialogComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/frontend/src/app/Views/dashboard/user-dialog/user-dialog.component.ts b/frontend/src/app/Views/dashboard/user-dialog/user-dialog.component.ts new file mode 100644 index 0000000..ef4b05b --- /dev/null +++ b/frontend/src/app/Views/dashboard/user-dialog/user-dialog.component.ts @@ -0,0 +1,36 @@ +import { Component, Inject, OnInit } from '@angular/core'; +import { + MatDialog, + MatDialogRef, + MAT_DIALOG_DATA, +} from '@angular/material/dialog'; +import { DataService } from 'src/app/Services/data.service'; + +import { TransactionData } from '../dashboard.component'; + +@Component({ + selector: 'app-user-dialog', + templateUrl: './user-dialog.component.html', + styleUrls: ['./user-dialog.component.scss'], +}) +export class UserDialogComponent implements OnInit { + constructor( + private dataService: DataService, + public dialog: MatDialog, + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: TransactionData + ) {} + + ngOnInit(): void {} + + onSubmit() { + console.log(this.data); + this.dataService.createTransaction( + this.data.symbol, + this.data.time, + this.data.count, + this.data.price + ); + this.dialog.closeAll(); + } +} diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index 1e925aa..17f8e27 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -10,6 +10,7 @@ import { MatGridListModule } from '@angular/material/grid-list'; import { MatCardModule } from '@angular/material/card'; import { MatTableModule } from '@angular/material/table'; import { MatMenuModule } from '@angular/material/menu'; +import { MatDialogModule } from '@angular/material/dialog'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; @@ -20,6 +21,7 @@ import { DashboardComponent } from './Views/dashboard/dashboard.component'; import { RegisterComponent } from './Views/register/register.component'; import { ProfileComponent } from './Views/profile/profile.component'; import { BotSettingsComponent } from './Views/bot-settings/bot-settings.component'; +import { UserDialogComponent } from './Views/dashboard/user-dialog/user-dialog.component'; @NgModule({ declarations: [ @@ -30,6 +32,7 @@ import { BotSettingsComponent } from './Views/bot-settings/bot-settings.componen RegisterComponent, ProfileComponent, BotSettingsComponent, + UserDialogComponent, ], imports: [ BrowserModule, @@ -44,6 +47,7 @@ import { BotSettingsComponent } from './Views/bot-settings/bot-settings.componen FormsModule, HttpClientModule, MatMenuModule, + MatDialogModule, ], providers: [], bootstrap: [AppComponent],