mirror of https://github.com/ghostfolio/ghostfolio
committed by
GitHub
9 changed files with 62 additions and 50 deletions
@ -1,30 +1,20 @@ |
|||
import { TransformDataSourceInRequestInterceptor } from '@ghostfolio/api/interceptors/transform-data-source-in-request.interceptor'; |
|||
import { TransformDataSourceInResponseInterceptor } from '@ghostfolio/api/interceptors/transform-data-source-in-response.interceptor'; |
|||
import { PropertyService } from '@ghostfolio/api/services/property/property.service'; |
|||
import { PROPERTY_BENCHMARKS } from '@ghostfolio/common/config'; |
|||
import { BenchmarkResponse, UniqueAsset } from '@ghostfolio/common/interfaces'; |
|||
import { BenchmarkResponse } from '@ghostfolio/common/interfaces'; |
|||
import { Controller, Get, UseInterceptors } from '@nestjs/common'; |
|||
|
|||
import { BenchmarkService } from './benchmark.service'; |
|||
|
|||
@Controller('benchmark') |
|||
export class BenchmarkController { |
|||
public constructor( |
|||
private readonly benchmarkService: BenchmarkService, |
|||
private readonly propertyService: PropertyService |
|||
) {} |
|||
public constructor(private readonly benchmarkService: BenchmarkService) {} |
|||
|
|||
@Get() |
|||
@UseInterceptors(TransformDataSourceInRequestInterceptor) |
|||
@UseInterceptors(TransformDataSourceInResponseInterceptor) |
|||
public async getBenchmark(): Promise<BenchmarkResponse> { |
|||
const benchmarkAssets: UniqueAsset[] = |
|||
((await this.propertyService.getByKey( |
|||
PROPERTY_BENCHMARKS |
|||
)) as UniqueAsset[]) ?? []; |
|||
|
|||
return { |
|||
benchmarks: await this.benchmarkService.getBenchmarks(benchmarkAssets) |
|||
benchmarks: await this.benchmarkService.getBenchmarks() |
|||
}; |
|||
} |
|||
} |
|||
|
@ -1,13 +1,23 @@ |
|||
<div class="align-items-center d-flex flex-row"> |
|||
<div class="h2 mb-0 mr-2">{{ fearAndGreedIndexEmoji }}</div> |
|||
<div> |
|||
<div class="h4 mb-0"> |
|||
<span class="mr-2">{{ fearAndGreedIndexText }}</span> |
|||
<small class="text-muted" |
|||
><strong>{{ fearAndGreedIndex }}</strong |
|||
>/100</small |
|||
> |
|||
<div class="position-relative"> |
|||
<div class="align-items-center d-flex flex-row" [hidden]="!fearAndGreedIndex"> |
|||
<div class="h2 mb-0 mr-2">{{ fearAndGreedIndexEmoji }}</div> |
|||
<div> |
|||
<div class="h4 mb-0"> |
|||
<span class="mr-2">{{ fearAndGreedIndexText }}</span> |
|||
<small class="text-muted" |
|||
><strong>{{ fearAndGreedIndex }}</strong |
|||
>/100</small |
|||
> |
|||
</div> |
|||
<small class="d-block" i18n>Current Market Mood</small> |
|||
</div> |
|||
<small class="d-block" i18n>Current Market Mood</small> |
|||
</div> |
|||
<ngx-skeleton-loader |
|||
*ngIf="!fearAndGreedIndex" |
|||
animation="pulse" |
|||
class="position-absolute w-100" |
|||
[theme]="{ |
|||
height: '100%' |
|||
}" |
|||
></ngx-skeleton-loader> |
|||
</div> |
|||
|
@ -1,3 +1,8 @@ |
|||
:host { |
|||
display: block; |
|||
|
|||
ngx-skeleton-loader { |
|||
bottom: 0; |
|||
top: 0; |
|||
} |
|||
} |
|||
|
@ -1,11 +1,12 @@ |
|||
import { CommonModule } from '@angular/common'; |
|||
import { NgModule } from '@angular/core'; |
|||
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; |
|||
|
|||
import { FearAndGreedIndexComponent } from './fear-and-greed-index.component'; |
|||
|
|||
@NgModule({ |
|||
declarations: [FearAndGreedIndexComponent], |
|||
exports: [FearAndGreedIndexComponent], |
|||
imports: [CommonModule] |
|||
imports: [CommonModule, NgxSkeletonLoaderModule] |
|||
}) |
|||
export class GfFearAndGreedIndexModule {} |
|||
|
Loading…
Reference in new issue