Browse Source

Improve transactions table

pull/187/head
Thomas 4 years ago
parent
commit
3dacc29fa6
  1. 45
      apps/client/src/app/components/transactions-table/transactions-table.component.html
  2. 10
      apps/client/src/app/components/transactions-table/transactions-table.component.ts

45
apps/client/src/app/components/transactions-table/transactions-table.component.html

@ -41,56 +41,50 @@
[dataSource]="dataSource" [dataSource]="dataSource"
> >
<ng-container matColumnDef="count"> <ng-container matColumnDef="count">
<th *matHeaderCellDef class="px-1 text-right" i18n mat-header-cell>#</th> <th
*matHeaderCellDef
class="d-none d-lg-table-cell px-1 text-right"
i18n
mat-header-cell
>
#
</th>
<td <td
*matCellDef="let element; let i = index" *matCellDef="let element; let i = index"
class="px-1 text-right" class="d-none d-lg-table-cell px-1 text-right"
mat-cell mat-cell
> >
{{ dataSource.data.length - i }} {{ dataSource.data.length - i }}
</td> </td>
</ng-container> </ng-container>
<ng-container matColumnDef="date"> <ng-container matColumnDef="date">
<th <th *matHeaderCellDef class="px-1" i18n mat-header-cell mat-sort-header>
*matHeaderCellDef
class="justify-content-center px-1"
i18n
mat-header-cell
mat-sort-header
>
Date Date
</th> </th>
<td *matCellDef="let element" class="px-1" mat-cell> <td *matCellDef="let element" class="px-1" mat-cell>
<div class="d-flex justify-content-center"> <div class="d-flex">
{{ element.date | date: defaultDateFormat }} {{ element.date | date: defaultDateFormat }}
</div> </div>
</td> </td>
</ng-container> </ng-container>
<ng-container matColumnDef="type"> <ng-container matColumnDef="type">
<th <th *matHeaderCellDef class="px-1" i18n mat-header-cell mat-sort-header>
*matHeaderCellDef
class="justify-content-center px-1"
i18n
mat-header-cell
mat-sort-header
>
Type Type
</th> </th>
<td mat-cell *matCellDef="let element" class="px-1 text-center"> <td mat-cell *matCellDef="let element" class="px-1">
<div <div
class="d-inline-flex justify-content-center pl-1 pr-2 py-1 type-badge" class="d-inline-flex p-1 type-badge"
[ngClass]="element.type == 'BUY' ? 'buy' : 'sell'" [ngClass]="element.type == 'BUY' ? 'buy' : 'sell'"
> >
<ion-icon <ion-icon
class="mr-1"
[name]=" [name]="
element.type === 'BUY' element.type === 'BUY'
? 'arrow-forward-circle-outline' ? 'arrow-forward-circle-outline'
: 'arrow-back-circle-outline' : 'arrow-back-circle-outline'
" "
></ion-icon> ></ion-icon>
<span>{{ element.type }}</span> <span class="d-none d-lg-block mx-1">{{ element.type }}</span>
</div> </div>
</td> </td>
</ng-container> </ng-container>
@ -102,7 +96,10 @@
<td *matCellDef="let element" class="px-1" mat-cell> <td *matCellDef="let element" class="px-1" mat-cell>
<div class="d-flex align-items-center"> <div class="d-flex align-items-center">
{{ element.symbol | gfSymbol }} {{ element.symbol | gfSymbol }}
<span *ngIf="element.isDraft" class="badge badge-secondary ml-1" i18n <span
*ngIf="isAfter(element.date, endOfToday)"
class="badge badge-secondary ml-1"
i18n
>Draft</span >Draft</span
> >
</div> </div>
@ -188,7 +185,9 @@
</ng-container> </ng-container>
<ng-container matColumnDef="account"> <ng-container matColumnDef="account">
<th *matHeaderCellDef class="px-1" i18n mat-header-cell>Account</th> <th *matHeaderCellDef class="px-1" mat-header-cell>
<span class="d-none d-lg-block" i18n>Account</span>
</th>
<td *matCellDef="let element" class="px-1" mat-cell> <td *matCellDef="let element" class="px-1" mat-cell>
<div class="d-flex"> <div class="d-flex">
<gf-symbol-icon <gf-symbol-icon

10
apps/client/src/app/components/transactions-table/transactions-table.component.ts

@ -23,7 +23,7 @@ import { MatTableDataSource } from '@angular/material/table';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { DEFAULT_DATE_FORMAT } from '@ghostfolio/common/config'; import { DEFAULT_DATE_FORMAT } from '@ghostfolio/common/config';
import { OrderWithAccount } from '@ghostfolio/common/types'; import { OrderWithAccount } from '@ghostfolio/common/types';
import { format } from 'date-fns'; import { endOfToday, format, isAfter } from 'date-fns';
import { BehaviorSubject, Observable, Subject, Subscription } from 'rxjs'; import { BehaviorSubject, Observable, Subject, Subscription } from 'rxjs';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
@ -39,7 +39,8 @@ const SEARCH_STRING_SEPARATOR = ',';
styleUrls: ['./transactions-table.component.scss'] styleUrls: ['./transactions-table.component.scss']
}) })
export class TransactionsTableComponent export class TransactionsTableComponent
implements OnChanges, OnDestroy, OnInit { implements OnChanges, OnDestroy, OnInit
{
@Input() baseCurrency: string; @Input() baseCurrency: string;
@Input() deviceType: string; @Input() deviceType: string;
@Input() locale: string; @Input() locale: string;
@ -54,11 +55,14 @@ export class TransactionsTableComponent
@ViewChild('searchInput') searchInput: ElementRef<HTMLInputElement>; @ViewChild('searchInput') searchInput: ElementRef<HTMLInputElement>;
@ViewChild(MatSort) sort: MatSort; @ViewChild(MatSort) sort: MatSort;
public dataSource: MatTableDataSource<OrderWithAccount> = new MatTableDataSource(); public dataSource: MatTableDataSource<OrderWithAccount> =
new MatTableDataSource();
public defaultDateFormat = DEFAULT_DATE_FORMAT; public defaultDateFormat = DEFAULT_DATE_FORMAT;
public displayedColumns = []; public displayedColumns = [];
public endOfToday = endOfToday();
public filters$: Subject<string[]> = new BehaviorSubject([]); public filters$: Subject<string[]> = new BehaviorSubject([]);
public filters: Observable<string[]> = this.filters$.asObservable(); public filters: Observable<string[]> = this.filters$.asObservable();
public isAfter = isAfter;
public isLoading = true; public isLoading = true;
public placeholder = ''; public placeholder = '';
public routeQueryParams: Subscription; public routeQueryParams: Subscription;

Loading…
Cancel
Save