Browse Source

Add integration

pull/2575/head
Thomas 2 years ago
parent
commit
1b9fa252ae
  1. 1
      apps/client/src/app/components/position/position.component.html
  2. 49
      libs/ui/src/lib/benchmark/benchmark.component.html
  3. 35
      libs/ui/src/lib/benchmark/benchmark.component.ts
  4. 2
      libs/ui/src/lib/benchmark/benchmark.module.ts
  5. 10
      libs/ui/src/lib/trend-indicator/trend-indicator.component.html
  6. 1
      libs/ui/src/lib/trend-indicator/trend-indicator.component.ts

1
apps/client/src/app/components/position/position.component.html

@ -13,6 +13,7 @@
<div class="d-flex mr-2"> <div class="d-flex mr-2">
<gf-trend-indicator <gf-trend-indicator
class="d-flex" class="d-flex"
size="large"
[isLoading]="isLoading" [isLoading]="isLoading"
[marketState]="position?.marketState" [marketState]="position?.marketState"
[range]="range" [range]="range"

49
libs/ui/src/lib/benchmark/benchmark.component.html

@ -6,6 +6,54 @@
</td> </td>
</ng-container> </ng-container>
<ng-container matColumnDef="trend50d">
<th
*matHeaderCellDef
class="d-none d-lg-table-cell px-2 text-right"
mat-header-cell
>
<ng-container i18n>50-Day Trend</ng-container>
</th>
<td *matCellDef="let element" class="d-none d-lg-table-cell px-2" mat-cell>
<div class="d-flex justify-content-end">
<gf-trend-indicator
*ngIf="element?.trend50d !== 'UNKNOWN'"
[value]="
element?.trend50d === 'UP'
? 1
: element?.trend50d === 'DOWN'
? -1
: 0
"
></gf-trend-indicator>
</div>
</td>
</ng-container>
<ng-container matColumnDef="trend200d">
<th
*matHeaderCellDef
class="d-none d-lg-table-cell px-2 text-right"
mat-header-cell
>
<ng-container i18n>200-Day Trend</ng-container>
</th>
<td *matCellDef="let element" class="d-none d-lg-table-cell px-2" mat-cell>
<div class="d-flex justify-content-end">
<gf-trend-indicator
*ngIf="element?.trend200d !== 'UNKNOWN'"
[value]="
element?.trend200d === 'UP'
? 1
: element?.trend200d === 'DOWN'
? -1
: 0
"
></gf-trend-indicator>
</div>
</td>
</ng-container>
<ng-container matColumnDef="date"> <ng-container matColumnDef="date">
<th <th
*matHeaderCellDef *matHeaderCellDef
@ -35,7 +83,6 @@
<td *matCellDef="let element" class="px-2 text-right" mat-cell> <td *matCellDef="let element" class="px-2 text-right" mat-cell>
<gf-value <gf-value
class="d-inline-block justify-content-end" class="d-inline-block justify-content-end"
size="medium"
[isPercent]="true" [isPercent]="true"
[locale]="locale" [locale]="locale"
[ngClass]="{ [ngClass]="{

35
libs/ui/src/lib/benchmark/benchmark.component.ts

@ -1,12 +1,16 @@
import { import {
ChangeDetectionStrategy, ChangeDetectionStrategy,
ChangeDetectorRef,
Component, Component,
Input, Input,
OnChanges OnChanges
} from '@angular/core'; } from '@angular/core';
import { UserService } from '@ghostfolio/client/services/user/user.service';
import { locale } from '@ghostfolio/common/config'; import { locale } from '@ghostfolio/common/config';
import { resolveMarketCondition } from '@ghostfolio/common/helper'; import { resolveMarketCondition } from '@ghostfolio/common/helper';
import { Benchmark } from '@ghostfolio/common/interfaces'; import { Benchmark, User } from '@ghostfolio/common/interfaces';
import { without } from 'lodash';
import { Subject, takeUntil } from 'rxjs';
@Component({ @Component({
selector: 'gf-benchmark', selector: 'gf-benchmark',
@ -20,8 +24,35 @@ export class BenchmarkComponent implements OnChanges {
public displayedColumns = ['name', 'date', 'change', 'marketCondition']; public displayedColumns = ['name', 'date', 'change', 'marketCondition'];
public resolveMarketCondition = resolveMarketCondition; public resolveMarketCondition = resolveMarketCondition;
public user: User;
public constructor() {} private unsubscribeSubject = new Subject<void>();
public constructor(
private changeDetectorRef: ChangeDetectorRef,
private userService: UserService
) {
this.userService.stateChanged
.pipe(takeUntil(this.unsubscribeSubject))
.subscribe((state) => {
if (state?.user) {
this.user = state.user;
if (this.user?.settings?.isExperimentalFeatures) {
this.displayedColumns = [
'name',
'trend50d',
'trend200d',
'date',
'change',
'marketCondition'
];
}
this.changeDetectorRef.markForCheck();
}
});
}
public ngOnChanges() { public ngOnChanges() {
if (!this.locale) { if (!this.locale) {

2
libs/ui/src/lib/benchmark/benchmark.module.ts

@ -3,6 +3,7 @@ import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { MatTableModule } from '@angular/material/table'; import { MatTableModule } from '@angular/material/table';
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
import { GfTrendIndicatorModule } from '../trend-indicator';
import { GfValueModule } from '../value'; import { GfValueModule } from '../value';
import { BenchmarkComponent } from './benchmark.component'; import { BenchmarkComponent } from './benchmark.component';
@ -11,6 +12,7 @@ import { BenchmarkComponent } from './benchmark.component';
exports: [BenchmarkComponent], exports: [BenchmarkComponent],
imports: [ imports: [
CommonModule, CommonModule,
GfTrendIndicatorModule,
GfValueModule, GfValueModule,
MatTableModule, MatTableModule,
NgxSkeletonLoaderModule NgxSkeletonLoaderModule

10
libs/ui/src/lib/trend-indicator/trend-indicator.component.html

@ -13,7 +13,7 @@
*ngIf="marketState === 'closed' && range === '1d'; else delayed" *ngIf="marketState === 'closed' && range === '1d'; else delayed"
class="text-muted" class="text-muted"
name="pause-circle-outline" name="pause-circle-outline"
size="large" [size]="size"
> >
</ion-icon> </ion-icon>
<ng-template #delayed> <ng-template #delayed>
@ -21,7 +21,7 @@
*ngIf="marketState === 'delayed' && range === '1d'; else trend" *ngIf="marketState === 'delayed' && range === '1d'; else trend"
class="text-muted" class="text-muted"
name="time-outline" name="time-outline"
size="large" [size]="size"
> >
</ion-icon> </ion-icon>
</ng-template> </ng-template>
@ -31,21 +31,21 @@
*ngIf="value <= -0.0005" *ngIf="value <= -0.0005"
class="text-danger" class="text-danger"
name="arrow-down-circle-outline" name="arrow-down-circle-outline"
size="large"
[ngClass]="{ 'rotate-45-down': value > -0.01 }" [ngClass]="{ 'rotate-45-down': value > -0.01 }"
[size]="size"
></ion-icon> ></ion-icon>
<ion-icon <ion-icon
*ngIf="value > -0.0005 && value < 0.0005" *ngIf="value > -0.0005 && value < 0.0005"
class="text-muted" class="text-muted"
name="arrow-forward-circle-outline" name="arrow-forward-circle-outline"
size="large" [size]="size"
></ion-icon> ></ion-icon>
<ion-icon <ion-icon
*ngIf="value >= 0.0005" *ngIf="value >= 0.0005"
class="text-success" class="text-success"
name="arrow-up-circle-outline" name="arrow-up-circle-outline"
size="large"
[ngClass]="{ 'rotate-45-up': value < 0.01 }" [ngClass]="{ 'rotate-45-up': value < 0.01 }"
[size]="size"
></ion-icon> ></ion-icon>
</ng-container> </ng-container>
</ng-template> </ng-template>

1
libs/ui/src/lib/trend-indicator/trend-indicator.component.ts

@ -11,6 +11,7 @@ export class TrendIndicatorComponent {
@Input() isLoading = false; @Input() isLoading = false;
@Input() marketState: MarketState = 'open'; @Input() marketState: MarketState = 'open';
@Input() range: DateRange = 'max'; @Input() range: DateRange = 'max';
@Input() size: 'large' | 'medium' | 'small' = 'small';
@Input() value = 0; @Input() value = 0;
public constructor() {} public constructor() {}

Loading…
Cancel
Save