Feature/add icon and name to positions table (#1040)

* Add icon and name

* Update changelog
This commit is contained in:
Thomas Kaul 2022-06-25 11:33:59 +02:00 committed by GitHub
parent eb059a024a
commit f7bf6e652b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 61 additions and 52 deletions

View File

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased ## Unreleased
### Added
- Added an icon and name column to the positions table
### Changed ### Changed
- Changed the data gathering by symbol endpoint to delete data first - Changed the data gathering by symbol endpoint to delete data first

View File

@ -346,6 +346,7 @@ export class PortfolioController {
netPerformancePercent: portfolioPosition.netPerformancePercent, netPerformancePercent: portfolioPosition.netPerformancePercent,
sectors: hasDetails ? portfolioPosition.sectors : [], sectors: hasDetails ? portfolioPosition.sectors : [],
symbol: portfolioPosition.symbol, symbol: portfolioPosition.symbol,
url: portfolioPosition.url,
value: portfolioPosition.value / totalValue value: portfolioPosition.value / totalValue
}; };
} }

View File

@ -441,6 +441,7 @@ export class PortfolioService {
sectors: symbolProfile.sectors, sectors: symbolProfile.sectors,
symbol: item.symbol, symbol: item.symbol,
transactionCount: item.transactionCount, transactionCount: item.transactionCount,
url: symbolProfile.url,
value: value.toNumber() value: value.toNumber()
}; };
} }

View File

@ -6,6 +6,17 @@
mat-table mat-table
[dataSource]="dataSource" [dataSource]="dataSource"
> >
<ng-container matColumnDef="icon">
<th *matHeaderCellDef class="px-1" mat-header-cell></th>
<td *matCellDef="let element" class="px-1 text-center" mat-cell>
<gf-symbol-icon
*ngIf="element.url"
[tooltip]="element.name"
[url]="element.url"
></gf-symbol-icon>
</td>
</ng-container>
<ng-container matColumnDef="symbol"> <ng-container matColumnDef="symbol">
<th *matHeaderCellDef class="px-1" i18n mat-header-cell mat-sort-header> <th *matHeaderCellDef class="px-1" i18n mat-header-cell mat-sort-header>
Symbol Symbol
@ -15,6 +26,23 @@
</td> </td>
</ng-container> </ng-container>
<ng-container matColumnDef="name">
<th
*matHeaderCellDef
class="d-none d-lg-table-cell px-1"
i18n
mat-header-cell
mat-sort-header
>
Name
</th>
<td *matCellDef="let element" class="d-none d-lg-table-cell px-1" mat-cell>
<ng-container *ngIf="element.name !== element.symbol">{{
element.name
}}</ng-container>
</td>
</ng-container>
<ng-container matColumnDef="value"> <ng-container matColumnDef="value">
<th <th
*matHeaderCellDef *matHeaderCellDef
@ -36,48 +64,6 @@
</td> </td>
</ng-container> </ng-container>
<ng-container matColumnDef="performance">
<th
*matHeaderCellDef
class="d-none d-lg-table-cell px-1 text-right"
i18n
mat-header-cell
>
Performance
</th>
<td class="d-none d-lg-table-cell px-1" mat-cell *matCellDef="let element">
<div class="d-flex justify-content-end">
<gf-value
[colorizeSign]="true"
[isPercent]="true"
[locale]="locale"
[value]="isLoading ? undefined : element.netPerformancePercent"
></gf-value>
</div>
</td>
</ng-container>
<ng-container matColumnDef="allocationInvestment">
<th
*matHeaderCellDef
class="justify-content-end px-1"
i18n
mat-header-cell
mat-sort-header
>
Initial Allocation
</th>
<td mat-cell *matCellDef="let element">
<div class="d-flex justify-content-end px-1">
<gf-value
[isPercent]="true"
[locale]="locale"
[value]="isLoading ? undefined : element.allocationInvestment"
></gf-value>
</div>
</td>
</ng-container>
<ng-container matColumnDef="allocationCurrent"> <ng-container matColumnDef="allocationCurrent">
<th <th
*matHeaderCellDef *matHeaderCellDef
@ -86,7 +72,7 @@
mat-header-cell mat-header-cell
mat-sort-header mat-sort-header
> >
Current Allocation Allocation
</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-end"> <div class="d-flex justify-content-end">
@ -99,7 +85,28 @@
</td> </td>
</ng-container> </ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <ng-container matColumnDef="performance">
<th
*matHeaderCellDef
class="d-none d-lg-table-cell px-1 text-right"
i18n
mat-header-cell
>
Performance
</th>
<td *matCellDef="let element" class="d-none d-lg-table-cell px-1" mat-cell>
<div class="d-flex justify-content-end">
<gf-value
[colorizeSign]="true"
[isPercent]="true"
[locale]="locale"
[value]="isLoading ? undefined : element.netPerformancePercent"
></gf-value>
</div>
</td>
</ng-container>
<tr *matHeaderRowDef="displayedColumns" mat-header-row></tr>
<tr <tr
*matRowDef="let row; columns: displayedColumns" *matRowDef="let row; columns: displayedColumns"
mat-row mat-row

View File

@ -55,19 +55,14 @@ export class PositionsTableComponent implements OnChanges, OnDestroy, OnInit {
public ngOnInit() {} public ngOnInit() {}
public ngOnChanges() { public ngOnChanges() {
this.displayedColumns = ['symbol']; this.displayedColumns = ['icon', 'symbol', 'name'];
if (this.hasPermissionToShowValues) { if (this.hasPermissionToShowValues) {
this.displayedColumns.push('value'); this.displayedColumns.push('value');
} }
this.displayedColumns.push('performance');
if (this.hasPermissionToShowValues) {
this.displayedColumns.push('allocationInvestment');
}
this.displayedColumns.push('allocationCurrent'); this.displayedColumns.push('allocationCurrent');
this.displayedColumns.push('performance');
this.isLoading = true; this.isLoading = true;

View File

@ -35,7 +35,6 @@ import { PositionsTableComponent } from './positions-table.component';
NgxSkeletonLoaderModule, NgxSkeletonLoaderModule,
RouterModule RouterModule
], ],
providers: [],
schemas: [CUSTOM_ELEMENTS_SCHEMA] schemas: [CUSTOM_ELEMENTS_SCHEMA]
}) })
export class GfPositionsTableModule {} export class GfPositionsTableModule {}

View File

@ -18,4 +18,5 @@ export interface EnhancedSymbolProfile {
symbol: string; symbol: string;
symbolMapping?: { [key: string]: string }; symbolMapping?: { [key: string]: string };
updatedAt: Date; updatedAt: Date;
url?: string;
} }

View File

@ -13,6 +13,7 @@ export interface PortfolioPublicDetails {
| 'netPerformancePercent' | 'netPerformancePercent'
| 'sectors' | 'sectors'
| 'symbol' | 'symbol'
| 'url'
| 'value' | 'value'
>; >;
}; };