Add transaction skeletton
This commit is contained in:
parent
e9f1e7d38a
commit
c5e66b4720
@ -1,7 +1,7 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
const AUTH_API = 'https://aktienbot.flokaiser.com/api/user';
|
const AUTH_API = 'https://gruppe1.testsites.info/api/user';
|
||||||
const httpOptions = {
|
const httpOptions = {
|
||||||
headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
|
headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
|
||||||
};
|
};
|
||||||
|
@ -2,16 +2,23 @@ import { Injectable, OnInit } from '@angular/core';
|
|||||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||||
import { delay, Observable } from 'rxjs';
|
import { delay, Observable } from 'rxjs';
|
||||||
import { TokenStorageService } from './token.service';
|
import { TokenStorageService } from './token.service';
|
||||||
const API_URL = 'https://aktienbot.flokaiser.com/api/';
|
const API_URL = 'https://gruppe1.testsites.info/api/';
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class DataService {
|
export class DataService {
|
||||||
|
/**
|
||||||
|
* @param {HttpClient} privatehttp
|
||||||
|
* @param {TokenStorageService} privatetokenStorage
|
||||||
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
private http: HttpClient,
|
private http: HttpClient,
|
||||||
private tokenStorage: TokenStorageService
|
private tokenStorage: TokenStorageService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns Observable
|
||||||
|
*/
|
||||||
public getStockData(): Observable<any> {
|
public getStockData(): Observable<any> {
|
||||||
return this.http.get(API_URL + 'portfolio', {
|
return this.http.get(API_URL + 'portfolio', {
|
||||||
headers: new HttpHeaders({
|
headers: new HttpHeaders({
|
||||||
@ -22,6 +29,9 @@ export class DataService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns Observable
|
||||||
|
*/
|
||||||
public getTransactionData(): Observable<any> {
|
public getTransactionData(): Observable<any> {
|
||||||
return this.http.get(API_URL + 'transactions', {
|
return this.http.get(API_URL + 'transactions', {
|
||||||
headers: new HttpHeaders({
|
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<any> {
|
||||||
|
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<any> {
|
public getKeywords(): Observable<any> {
|
||||||
return this.http.get(API_URL + 'keywords', {
|
return this.http.get(API_URL + 'keywords', {
|
||||||
headers: new HttpHeaders({
|
headers: new HttpHeaders({
|
||||||
|
@ -63,6 +63,16 @@
|
|||||||
<div class="depotOverview">
|
<div class="depotOverview">
|
||||||
<div class="heading fix-right-side">
|
<div class="heading fix-right-side">
|
||||||
<div class="vertical-center">Transaktionen</div>
|
<div class="vertical-center">Transaktionen</div>
|
||||||
|
<span class="spacer"></span>
|
||||||
|
<button
|
||||||
|
mat-icon-button
|
||||||
|
class="add-icon"
|
||||||
|
aria-label="Example icon-button with heart icon"
|
||||||
|
[disableRipple]="true"
|
||||||
|
(click)="openDialog()"
|
||||||
|
>
|
||||||
|
<mat-icon>add</mat-icon>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="stockTable">
|
<div class="stockTable">
|
||||||
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8">
|
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8">
|
||||||
|
@ -62,3 +62,11 @@ table {
|
|||||||
.placeholder {
|
.placeholder {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
side-heading {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mat-ripple-element {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { throwToolbarMixedModesError } from '@angular/material/toolbar';
|
|
||||||
import { DataService } from 'src/app/Services/data.service';
|
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 {
|
export interface PeriodicElement {
|
||||||
name: string;
|
name: string;
|
||||||
@ -43,13 +43,21 @@ const ELEMENT_DATA: PeriodicElement[] = [
|
|||||||
{ position: 20, name: 'Neon', weight: 20.1797, symbol: 'Ne' },
|
{ position: 20, name: 'Neon', weight: 20.1797, symbol: 'Ne' },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export interface TransactionData {
|
||||||
|
symbol: string;
|
||||||
|
time: Date;
|
||||||
|
count: number;
|
||||||
|
price: number;
|
||||||
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dashboard',
|
selector: 'app-dashboard',
|
||||||
templateUrl: './dashboard.component.html',
|
templateUrl: './dashboard.component.html',
|
||||||
styleUrls: ['./dashboard.component.scss'],
|
styleUrls: ['./dashboard.component.scss'],
|
||||||
})
|
})
|
||||||
export class DashboardComponent implements OnInit {
|
export class DashboardComponent implements OnInit {
|
||||||
constructor(private dataService: DataService) {}
|
constructor(private dataService: DataService, public dialog: MatDialog) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.dataService.getStockData().subscribe((response: any) => {
|
this.dataService.getStockData().subscribe((response: any) => {
|
||||||
console.log(response);
|
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'];
|
displayedColumns: string[] = ['position', 'name', 'weight', 'symbol'];
|
||||||
dataSource = ELEMENT_DATA;
|
dataSource = ELEMENT_DATA;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
<h1 mat-dialog-title>Neue Transaktion hinzufügen</h1>
|
||||||
|
<form
|
||||||
|
name="form"
|
||||||
|
(ngSubmit)="f.form.valid && onSubmit()"
|
||||||
|
#f="ngForm"
|
||||||
|
novalidate
|
||||||
|
class="backgorund"
|
||||||
|
>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="symbol">Symbol</label>
|
||||||
|
<input
|
||||||
|
type="symbol"
|
||||||
|
class="form-control"
|
||||||
|
name="symbol"
|
||||||
|
[(ngModel)]="data.symbol"
|
||||||
|
required
|
||||||
|
symbol
|
||||||
|
#symbol="ngModel"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="time">Time</label>
|
||||||
|
<input
|
||||||
|
type="date"
|
||||||
|
class="form-control"
|
||||||
|
name="time"
|
||||||
|
[(ngModel)]="data.time"
|
||||||
|
required
|
||||||
|
time
|
||||||
|
#time="ngModel"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="count">Count</label>
|
||||||
|
<input
|
||||||
|
type="count"
|
||||||
|
class="form-control"
|
||||||
|
name="count"
|
||||||
|
[(ngModel)]="data.count"
|
||||||
|
required
|
||||||
|
count
|
||||||
|
#count="ngModel"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="price">Price</label>
|
||||||
|
<input
|
||||||
|
class="form-control"
|
||||||
|
name="price"
|
||||||
|
[(ngModel)]="data.price"
|
||||||
|
required
|
||||||
|
#price="ngModel"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="form-group footer-buttons">
|
||||||
|
<button class="btn btn-danger btn-block" mat-dialog-close>Cancel</button>
|
||||||
|
<span class="spacer"></span>
|
||||||
|
<button class="btn btn-primary btn-block">Confirm</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
@ -0,0 +1,9 @@
|
|||||||
|
.spacer {
|
||||||
|
flex-grow: 1;
|
||||||
|
width: 5%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-buttons {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
}
|
@ -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<UserDialogComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
declarations: [ UserDialogComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(UserDialogComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
@ -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<UserDialogComponent>,
|
||||||
|
@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();
|
||||||
|
}
|
||||||
|
}
|
@ -10,6 +10,7 @@ import { MatGridListModule } from '@angular/material/grid-list';
|
|||||||
import { MatCardModule } from '@angular/material/card';
|
import { MatCardModule } from '@angular/material/card';
|
||||||
import { MatTableModule } from '@angular/material/table';
|
import { MatTableModule } from '@angular/material/table';
|
||||||
import { MatMenuModule } from '@angular/material/menu';
|
import { MatMenuModule } from '@angular/material/menu';
|
||||||
|
import { MatDialogModule } from '@angular/material/dialog';
|
||||||
|
|
||||||
import { AppRoutingModule } from './app-routing.module';
|
import { AppRoutingModule } from './app-routing.module';
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
@ -20,6 +21,7 @@ import { DashboardComponent } from './Views/dashboard/dashboard.component';
|
|||||||
import { RegisterComponent } from './Views/register/register.component';
|
import { RegisterComponent } from './Views/register/register.component';
|
||||||
import { ProfileComponent } from './Views/profile/profile.component';
|
import { ProfileComponent } from './Views/profile/profile.component';
|
||||||
import { BotSettingsComponent } from './Views/bot-settings/bot-settings.component';
|
import { BotSettingsComponent } from './Views/bot-settings/bot-settings.component';
|
||||||
|
import { UserDialogComponent } from './Views/dashboard/user-dialog/user-dialog.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
@ -30,6 +32,7 @@ import { BotSettingsComponent } from './Views/bot-settings/bot-settings.componen
|
|||||||
RegisterComponent,
|
RegisterComponent,
|
||||||
ProfileComponent,
|
ProfileComponent,
|
||||||
BotSettingsComponent,
|
BotSettingsComponent,
|
||||||
|
UserDialogComponent,
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
@ -44,6 +47,7 @@ import { BotSettingsComponent } from './Views/bot-settings/bot-settings.componen
|
|||||||
FormsModule,
|
FormsModule,
|
||||||
HttpClientModule,
|
HttpClientModule,
|
||||||
MatMenuModule,
|
MatMenuModule,
|
||||||
|
MatDialogModule,
|
||||||
],
|
],
|
||||||
providers: [],
|
providers: [],
|
||||||
bootstrap: [AppComponent],
|
bootstrap: [AppComponent],
|
||||||
|
Loading…
Reference in New Issue
Block a user