Browse Source

Added summary row to overview

pull/4370/head
Dan 2 months ago
parent
commit
7d858f8639
  1. 35
      libs/ui/src/lib/holdings-table/holdings-table.component.html
  2. 13
      libs/ui/src/lib/holdings-table/holdings-table.component.ts

35
libs/ui/src/lib/holdings-table/holdings-table.component.html

@ -16,6 +16,7 @@
[tooltip]="element.name" [tooltip]="element.name"
/> />
</td> </td>
<td *matFooterCellDef class="px-1" mat-footer-cell></td>
</ng-container> </ng-container>
<ng-container matColumnDef="nameWithSymbol"> <ng-container matColumnDef="nameWithSymbol">
@ -38,6 +39,7 @@
<small class="text-muted">{{ element.symbol }}</small> <small class="text-muted">{{ element.symbol }}</small>
</div> </div>
</td> </td>
<td *matFooterCellDef class="px-1" mat-footer-cell>Total</td>
</ng-container> </ng-container>
<ng-container matColumnDef="dateOfFirstActivity"> <ng-container matColumnDef="dateOfFirstActivity">
@ -62,6 +64,7 @@
/> />
</div> </div>
</td> </td>
<td *matFooterCellDef class="px-1" mat-footer-cell></td>
</ng-container> </ng-container>
<ng-container matColumnDef="valueInBaseCurrency"> <ng-container matColumnDef="valueInBaseCurrency">
@ -86,6 +89,14 @@
/> />
</div> </div>
</td> </td>
<td *matFooterCellDef class="px-1" mat-footer-cell>
<gf-value
[isCurrency]="true"
[locale]="locale"
[value]="totalValue"
></gf-value>
</td>
</ng-container> </ng-container>
<ng-container matColumnDef="allocationInPercentage"> <ng-container matColumnDef="allocationInPercentage">
@ -107,6 +118,7 @@
/> />
</div> </div>
</td> </td>
<td *matFooterCellDef class="px-1" mat-footer-cell></td>
</ng-container> </ng-container>
<ng-container matColumnDef="performance"> <ng-container matColumnDef="performance">
@ -130,6 +142,15 @@
/> />
</div> </div>
</td> </td>
<td *matFooterCellDef class="px-1" mat-footer-cell>
<div class="d-flex justify-content-end">
<gf-value
[isCurrency]="true"
[locale]="locale"
[value]="totalChange"
></gf-value>
</div>
</td>
</ng-container> </ng-container>
<ng-container matColumnDef="performanceInPercentage" stickyEnd> <ng-container matColumnDef="performanceInPercentage" stickyEnd>
@ -156,6 +177,15 @@
/> />
</div> </div>
</td> </td>
<td *matFooterCellDef class="px-1" mat-footer-cell>
<div class="d-flex justify-content-end">
<gf-value
[isPercent]="true"
[locale]="locale"
[value]="totalChangePercentage"
></gf-value>
</div>
</td>
</ng-container> </ng-container>
<tr *matHeaderRowDef="displayedColumns" mat-header-row></tr> <tr *matHeaderRowDef="displayedColumns" mat-header-row></tr>
@ -175,6 +205,11 @@
}) })
" "
></tr> ></tr>
<tr
*matFooterRowDef="displayedColumns"
mat-footer-row
[ngClass]="{ hidden: isLoading }"
></tr>
</table> </table>
</div> </div>

13
libs/ui/src/lib/holdings-table/holdings-table.component.ts

@ -70,6 +70,10 @@ export class GfHoldingsTableComponent implements OnChanges, OnDestroy {
public isLoading = true; public isLoading = true;
public routeQueryParams: Subscription; public routeQueryParams: Subscription;
protected totalValue = 0;
protected totalChange = 0;
protected totalChangePercentage = 0;
private unsubscribeSubject = new Subject<void>(); private unsubscribeSubject = new Subject<void>();
public ngOnChanges() { public ngOnChanges() {
@ -92,6 +96,15 @@ export class GfHoldingsTableComponent implements OnChanges, OnDestroy {
this.dataSource = new MatTableDataSource(this.holdings); this.dataSource = new MatTableDataSource(this.holdings);
this.dataSource.paginator = this.paginator; this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort; this.dataSource.sort = this.sort;
this.totalValue = this.dataSource.data.reduce(
(sum, current) => sum + current.valueInBaseCurrency,
0
);
this.totalChange = this.dataSource.data.reduce(
(sum, current) => sum + current.netPerformancePercentWithCurrencyEffect,
0
);
this.totalChangePercentage = (this.totalChange / this.totalValue) * 100;
if (this.holdings) { if (this.holdings) {
this.isLoading = false; this.isLoading = false;

Loading…
Cancel
Save