Add transaction skeletton
This commit is contained in:
@@ -63,6 +63,16 @@
|
||||
<div class="depotOverview">
|
||||
<div class="heading fix-right-side">
|
||||
<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 class="stockTable">
|
||||
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8">
|
||||
|
@@ -62,3 +62,11 @@ table {
|
||||
.placeholder {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
side-heading {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.mat-ripple-element {
|
||||
display: none !important;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user