Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript π€
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Task/consolidate markets pages (#7471)
Thomas Kaul52fa7c224046
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 500d00d2c7..f5fefea4da 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,10 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## Unreleased+### Added++- Added an empty state to the _Fear & Greed Index_ component+- Added a _Storybook_ story for the _Fear & Greed Index_ component+### Changed- Moved the tags to the overview tab of the account detail dialog (experimental)- Moved the tags to the overview tab of the holding detail dialog+- Consolidated the markets pages into a single route where the _Fear & Greed Index_ is controlled by permission- Refactored the line chart components to share the common chart configuration- Improved the language localization for Spanish (`es`)- Improved the language localization for Ukrainian (`uk`)diff --git a/apps/api/src/app/user/user.service.ts b/apps/api/src/app/user/user.service.tsindex 648f36cbf5..7f3631c54d 100644--- a/apps/api/src/app/user/user.service.ts+++ b/apps/api/src/app/user/user.service.ts@@ -555,7 +555,10 @@ export class UserService {}} else {if (- await this.propertyService.getByKey<string>(PROPERTY_API_KEY_GHOSTFOLIO)+ this.configurationService.get('ENABLE_FEATURE_FEAR_AND_GREED_INDEX') ||+ (await this.propertyService.getByKey<string>(+ PROPERTY_API_KEY_GHOSTFOLIO+ ))) {currentPermissions.push(permissions.readMarketDataOfMarkets);}diff --git a/apps/client/src/app/components/fear-and-greed-index/fear-and-greed-index.component.html b/apps/client/src/app/components/fear-and-greed-index/fear-and-greed-index.component.htmldeleted file mode 100644index dd2925f431..0000000000--- a/apps/client/src/app/components/fear-and-greed-index/fear-and-greed-index.component.html+++ /dev/null@@ -1,24 +0,0 @@-<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 | number: '1.0-0' }}</strong- >/100</small- >- </div>- <small class="d-block" i18n>Current Market Mood</small>- </div>- </div>- @if (!fearAndGreedIndex) {- <ngx-skeleton-loader- animation="pulse"- class="position-absolute w-100"- [theme]="{- height: '100%'- }"- />- }-</div>diff --git a/apps/client/src/app/components/fear-and-greed-index/fear-and-greed-index.component.scss b/apps/client/src/app/components/fear-and-greed-index/fear-and-greed-index.component.scssdeleted file mode 100644index dfe024a035..0000000000--- a/apps/client/src/app/components/fear-and-greed-index/fear-and-greed-index.component.scss+++ /dev/null@@ -1,8 +0,0 @@-:host {- display: block;-- ngx-skeleton-loader {- bottom: 0;- top: 0;- }-}diff --git a/apps/client/src/app/components/home-market/home-market.component.ts b/apps/client/src/app/components/home-market/home-market.component.tsdeleted file mode 100644index 0eec3f2d9e..0000000000--- a/apps/client/src/app/components/home-market/home-market.component.ts+++ /dev/null@@ -1,80 +0,0 @@-import { GfFearAndGreedIndexComponent } from '@ghostfolio/client/components/fear-and-greed-index/fear-and-greed-index.component';-import { UserService } from '@ghostfolio/client/services/user/user.service';-import { Benchmark, InfoItem, User } from '@ghostfolio/common/interfaces';-import { hasPermission, permissions } from '@ghostfolio/common/permissions';-import { GfBenchmarkComponent } from '@ghostfolio/ui/benchmark';-import { DataService } from '@ghostfolio/ui/services';--import {- ChangeDetectionStrategy,- ChangeDetectorRef,- Component,- computed,- CUSTOM_ELEMENTS_SCHEMA,- DestroyRef,- inject,- OnInit,- signal-} from '@angular/core';-import { takeUntilDestroyed } from '@angular/core/rxjs-interop';-import { DeviceDetectorService } from 'ngx-device-detector';--@Component({- changeDetection: ChangeDetectionStrategy.OnPush,- imports: [GfBenchmarkComponent, GfFearAndGreedIndexComponent],- schemas: [CUSTOM_ELEMENTS_SCHEMA],- selector: 'gf-home-market',- styleUrls: ['./home-market.scss'],- templateUrl: './home-market.html'-})-export class GfHomeMarketComponent implements OnInit {- protected readonly benchmarks = signal<Benchmark[]>([]);-- protected readonly deviceType = computed(- () => this.deviceDetectorService.deviceInfo().deviceType- );-- protected fearAndGreedIndex: number | undefined;- protected hasPermissionToAccessFearAndGreedIndex: boolean;- protected user: User;-- private readonly info: InfoItem;-- private readonly changeDetectorRef = inject(ChangeDetectorRef);- private readonly dataService = inject(DataService);- private readonly destroyRef = inject(DestroyRef);- private readonly deviceDetectorService = inject(DeviceDetectorService);- private readonly userService = inject(UserService);-- public constructor() {- this.info = this.dataService.fetchInfo();-- this.userService.stateChanged- .pipe(takeUntilDestroyed(this.destroyRef))- .subscribe((state) => {- if (state?.user) {- this.user = state.user;-- this.changeDetectorRef.markForCheck();- }- });- }-- public ngOnInit() {- this.hasPermissionToAccessFearAndGreedIndex = hasPermission(- this.info?.globalPermissions,- permissions.enableFearAndGreedIndex- );-- if (this.hasPermissionToAccessFearAndGreedIndex) {- this.fearAndGreedIndex = this.info.fearAndGreedStocksMarketPrice;- }-- this.dataService- .fetchBenchmarks()- .pipe(takeUntilDestroyed(this.destroyRef))- .subscribe(({ benchmarks }) => {- this.benchmarks.set(benchmarks);- });- }-}diff --git a/apps/client/src/app/components/home-market/home-market.html b/apps/client/src/app/components/home-market/home-market.htmldeleted file mode 100644index b1e21df955..0000000000--- a/apps/client/src/app/components/home-market/home-market.html+++ /dev/null@@ -1,35 +0,0 @@-<div class="container">- <h1 class="d-none d-sm-block h3 mb-4 text-center" i18n>Markets</h1>- @if (hasPermissionToAccessFearAndGreedIndex) {- <div class="mb-4 row">- <div class="col-xs-12 col-md-10 offset-md-1">- <gf-fear-and-greed-index- class="d-flex justify-content-center"- [fearAndGreedIndex]="fearAndGreedIndex"- />- </div>- </div>- }-- <div class="mb-3 row">- <div class="col-xs-12 col-md-10 offset-md-1">- <gf-benchmark- [benchmarks]="benchmarks()"- [deviceType]="deviceType()"- [locale]="user?.settings?.locale || undefined"- [showSymbol]="false"- [user]="user"- />- @if (benchmarks()?.length > 0) {- <div- class="gf-text-wrap-balance line-height-1 mt-3 text-center text-muted"- >- <small i18n>- Calculations are based on delayed market data and may not be- displayed in real-time.</small- >- </div>- }- </div>- </div>-</div>diff --git a/apps/client/src/app/components/markets/markets.component.ts b/apps/client/src/app/components/markets/markets.component.tsindex d2f64f3fce..27f60d86ac 100644--- a/apps/client/src/app/components/markets/markets.component.ts+++ b/apps/client/src/app/components/markets/markets.component.ts@@ -1,15 +1,17 @@-import { GfFearAndGreedIndexComponent } from '@ghostfolio/client/components/fear-and-greed-index/fear-and-greed-index.component';import { UserService } from '@ghostfolio/client/services/user/user.service';import { resetHours } from '@ghostfolio/common/helper';import {Benchmark,HistoricalDataItem,+ InfoItem,MarketDataOfMarketsResponse,ToggleOption,User} from '@ghostfolio/common/interfaces';+import { hasPermission, permissions } from '@ghostfolio/common/permissions';import { FearAndGreedIndexMode } from '@ghostfolio/common/types';import { GfBenchmarkComponent } from '@ghostfolio/ui/benchmark';+import { GfFearAndGreedIndexComponent } from '@ghostfolio/ui/fear-and-greed-index';import { GfLineChartComponent } from '@ghostfolio/ui/line-chart';import { DataService } from '@ghostfolio/ui/services';import { GfToggleComponent } from '@ghostfolio/ui/toggle';@@ -18,9 +20,12 @@ import {ChangeDetectionStrategy,ChangeDetectorRef,Component,+ computed,CUSTOM_ELEMENTS_SCHEMA,DestroyRef,- OnInit+ inject,+ OnInit,+ signal} from '@angular/core';import { takeUntilDestroyed } from '@angular/core/rxjs-interop';import { DeviceDetectorService } from 'ngx-device-detector';@@ -39,29 +44,50 @@ import { DeviceDetectorService } from 'ngx-device-detector';templateUrl: './markets.html'})export class GfMarketsComponent implements OnInit {- public benchmarks: Benchmark[];- public deviceType: string;- public fearAndGreedIndex: number;- public fearAndGreedIndexData: MarketDataOfMarketsResponse['fearAndGreedIndex'];- public fearLabel = $localize`Fear`;- public greedLabel = $localize`Greed`;- public historicalDataItems: HistoricalDataItem[];- public fearAndGreedIndexMode: FearAndGreedIndexMode = 'STOCKS';- public fearAndGreedIndexModeOptions: ToggleOption[] = [+ protected readonly benchmarks = signal<Benchmark[]>([]);++ protected readonly deviceType = computed(+ () => this.deviceDetectorService.deviceInfo().deviceType+ );++ protected readonly fearAndGreedIndexModeOptions: ToggleOption[] = [{ label: $localize`Stocks`, value: 'STOCKS' },{ label: $localize`Cryptocurrencies`, value: 'CRYPTOCURRENCIES' }];- public readonly numberOfDays = 365;- public user: User;-- public constructor(- private changeDetectorRef: ChangeDetectorRef,- private dataService: DataService,- private destroyRef: DestroyRef,- private deviceDetectorService: DeviceDetectorService,- private userService: UserService- ) {- this.deviceType = this.deviceDetectorService.getDeviceInfo().deviceType;++ protected readonly fearLabel = $localize`Fear`;+ protected readonly greedLabel = $localize`Greed`;+ protected readonly numberOfDays = 365;++ protected fearAndGreedIndex: number | undefined;+ protected fearAndGreedIndexMode: FearAndGreedIndexMode = 'STOCKS';+ protected hasPermissionToAccessFearAndGreedIndex: boolean;+ protected hasPermissionToReadMarketDataOfMarkets: boolean;+ protected historicalDataItems: HistoricalDataItem[];+ protected isLoadingFearAndGreedIndex = true;+ protected user: User;++ private fearAndGreedIndexData: MarketDataOfMarketsResponse['fearAndGreedIndex'];++ private readonly info: InfoItem;++ private readonly changeDetectorRef = inject(ChangeDetectorRef);+ private readonly dataService = inject(DataService);+ private readonly destroyRef = inject(DestroyRef);+ private readonly deviceDetectorService = inject(DeviceDetectorService);+ private readonly userService = inject(UserService);++ public constructor() {+ this.info = this.dataService.fetchInfo();++ this.hasPermissionToAccessFearAndGreedIndex = hasPermission(+ this.info?.globalPermissions,+ permissions.enableFearAndGreedIndex+ );++ if (this.hasPermissionToAccessFearAndGreedIndex) {+ this.fearAndGreedIndex = this.info.fearAndGreedStocksMarketPrice;+ }this.userService.stateChanged.pipe(takeUntilDestroyed(this.destroyRef))@@ -69,6 +95,20 @@ export class GfMarketsComponent implements OnInit {if (state?.user) {this.user = state.user;+ this.hasPermissionToReadMarketDataOfMarkets = hasPermission(+ this.user.permissions,+ permissions.readMarketDataOfMarkets+ );++ if (+ this.hasPermissionToReadMarketDataOfMarkets &&+ !this.fearAndGreedIndexData+ ) {+ this.fetchMarketDataOfMarkets();+ } else {+ this.isLoadingFearAndGreedIndex = false;+ }+this.changeDetectorRef.markForCheck();}});@@ -76,27 +116,37 @@ export class GfMarketsComponent implements OnInit {public ngOnInit() {this.dataService- .fetchMarketDataOfMarkets({ includeHistoricalData: this.numberOfDays })+ .fetchBenchmarks().pipe(takeUntilDestroyed(this.destroyRef))- .subscribe(({ fearAndGreedIndex }) => {- this.fearAndGreedIndexData = fearAndGreedIndex;+ .subscribe(({ benchmarks }) => {+ this.benchmarks.set(benchmarks);+ });+ }- this.initialize();+ protected onChangeFearAndGreedIndexMode(+ aFearAndGreedIndexMode: FearAndGreedIndexMode+ ) {+ this.fearAndGreedIndexMode = aFearAndGreedIndexMode;- this.changeDetectorRef.markForCheck();- });+ this.initializeFearAndGreedIndex();+ }+ private fetchMarketDataOfMarkets() {this.dataService- .fetchBenchmarks()+ .fetchMarketDataOfMarkets({ includeHistoricalData: this.numberOfDays }).pipe(takeUntilDestroyed(this.destroyRef))- .subscribe(({ benchmarks }) => {- this.benchmarks = benchmarks;+ .subscribe(({ fearAndGreedIndex }) => {+ this.fearAndGreedIndexData = fearAndGreedIndex;++ this.initializeFearAndGreedIndex();++ this.isLoadingFearAndGreedIndex = false;this.changeDetectorRef.markForCheck();});}- public initialize() {+ private initializeFearAndGreedIndex() {this.fearAndGreedIndex =this.fearAndGreedIndexData[this.fearAndGreedIndexMode]?.marketPrice;@@ -109,12 +159,4 @@ export class GfMarketsComponent implements OnInit {}];}-- public onChangeFearAndGreedIndexMode(- aFearAndGreedIndexMode: FearAndGreedIndexMode- ) {- this.fearAndGreedIndexMode = aFearAndGreedIndexMode;-- this.initialize();- }}diff --git a/apps/client/src/app/components/markets/markets.html b/apps/client/src/app/components/markets/markets.htmlindex 38234a7850..bd9013a00e 100644--- a/apps/client/src/app/components/markets/markets.html+++ b/apps/client/src/app/components/markets/markets.html@@ -1,52 +1,62 @@<div class="container"><h1 class="d-none d-sm-block h3 mb-4 text-center" i18n>Markets</h1>- <div class="mb-5 row">- <div class="col-xs-12 col-md-10 offset-md-1">- @if (user?.settings?.isExperimentalFeatures) {- <div class="align-items-center d-flex flex-grow-1 justify-content-end">- <gf-toggle- class="d-none d-lg-block"- [defaultValue]="fearAndGreedIndexMode"- [isLoading]="false"- [options]="fearAndGreedIndexModeOptions"- (valueChange)="onChangeFearAndGreedIndexMode($event.value)"+ @if (+ hasPermissionToAccessFearAndGreedIndex ||+ hasPermissionToReadMarketDataOfMarkets+ ) {+ <div class="mb-4 row">+ <div class="col-xs-12 col-md-10 offset-md-1">+ @if (hasPermissionToReadMarketDataOfMarkets) {+ @if (user?.settings?.isExperimentalFeatures) {+ <div+ class="align-items-center d-flex flex-grow-1 justify-content-end"+ >+ <gf-toggle+ class="d-none d-lg-block"+ [defaultValue]="fearAndGreedIndexMode"+ [isLoading]="false"+ [options]="fearAndGreedIndexModeOptions"+ (valueChange)="onChangeFearAndGreedIndexMode($event.value)"+ />+ </div>+ }+ <div class="mb-2 text-center text-muted">+ <small i18n>Last {{ numberOfDays }} Days</small>+ </div>+ <gf-line-chart+ class="mb-3"+ label="Fear & Greed Index"+ [colorScheme]="user?.settings?.colorScheme"+ [historicalDataItems]="historicalDataItems"+ [isAnimated]="true"+ [locale]="user?.settings?.locale || undefined"+ [showXAxis]="true"+ [showYAxis]="true"+ [yMax]="100"+ [yMaxLabel]="greedLabel"+ [yMin]="0"+ [yMinLabel]="fearLabel"/>- </div>- }- <div class="mb-2 text-center text-muted">- <small i18n>Last {{ numberOfDays }} Days</small>+ }+ <gf-fear-and-greed-index+ class="d-flex justify-content-center"+ [fearAndGreedIndex]="fearAndGreedIndex"+ [isLoading]="isLoadingFearAndGreedIndex"+ /></div>- <gf-line-chart- class="mb-3"- label="Fear & Greed Index"- [colorScheme]="user?.settings?.colorScheme"- [historicalDataItems]="historicalDataItems"- [isAnimated]="true"- [locale]="user?.settings?.locale || undefined"- [showXAxis]="true"- [showYAxis]="true"- [yMax]="100"- [yMaxLabel]="greedLabel"- [yMin]="0"- [yMinLabel]="fearLabel"- />- <gf-fear-and-greed-index- class="d-flex justify-content-center"- [fearAndGreedIndex]="fearAndGreedIndex"- /></div>- </div>+ }<div class="mb-3 row"><div class="col-xs-12 col-md-10 offset-md-1"><gf-benchmark- [benchmarks]="benchmarks"- [deviceType]="deviceType"+ [benchmarks]="benchmarks()"+ [deviceType]="deviceType()"[locale]="user?.settings?.locale || undefined"[showSymbol]="false"[user]="user"/>- @if (benchmarks?.length > 0) {+ @if (benchmarks()?.length > 0) {<divclass="gf-text-wrap-balance line-height-1 mt-3 text-center text-muted">diff --git a/apps/client/src/app/pages/api/api-page.component.ts b/apps/client/src/app/pages/api/api-page.component.tsindex 5568902710..8b80370e8d 100644--- a/apps/client/src/app/pages/api/api-page.component.ts+++ b/apps/client/src/app/pages/api/api-page.component.ts@@ -1,4 +1,3 @@-import { GfFearAndGreedIndexComponent } from '@ghostfolio/client/components/fear-and-greed-index/fear-and-greed-index.component';import {HEADER_KEY_SKIP_INTERCEPTOR,HEADER_KEY_TOKEN@@ -14,6 +13,7 @@ import {MarketDataOfMarketsResponse,QuotesResponse} from '@ghostfolio/common/interfaces';+import { GfFearAndGreedIndexComponent } from '@ghostfolio/ui/fear-and-greed-index';import { CommonModule } from '@angular/common';import {diff --git a/apps/client/src/app/pages/api/api-page.html b/apps/client/src/app/pages/api/api-page.htmlindex b2d9d03ac4..2153fba1e0 100644--- a/apps/client/src/app/pages/api/api-page.html+++ b/apps/client/src/app/pages/api/api-page.html@@ -179,16 +179,12 @@<mat-card-content class="pt-3">@if (isFetchFailure(marketDataOfMarkets)) {π΄ {{ marketDataOfMarkets.fetchError }}- } @else if (marketDataOfMarkets) {+ } @else {<gf-fear-and-greed-index[fearAndGreedIndex]="- marketDataOfMarkets.fearAndGreedIndex.STOCKS.marketPrice+ marketDataOfMarkets?.fearAndGreedIndex?.STOCKS?.marketPrice"- />- } @else {- <ngx-skeleton-loader- animation="pulse"- [theme]="{ height: '2.5rem', width: '100%' }"+ [isLoading]="!marketDataOfMarkets"/>}</mat-card-content>@@ -203,17 +199,13 @@<mat-card-content class="pt-3">@if (isFetchFailure(marketDataOfMarkets)) {π΄ {{ marketDataOfMarkets.fetchError }}- } @else if (marketDataOfMarkets) {+ } @else {<gf-fear-and-greed-index[fearAndGreedIndex]="- marketDataOfMarkets.fearAndGreedIndex.CRYPTOCURRENCIES- .marketPrice+ marketDataOfMarkets?.fearAndGreedIndex?.CRYPTOCURRENCIES+ ?.marketPrice"- />- } @else {- <ngx-skeleton-loader- animation="pulse"- [theme]="{ height: '2.5rem', width: '100%' }"+ [isLoading]="!marketDataOfMarkets"/>}</mat-card-content>diff --git a/apps/client/src/app/pages/home/home-page.component.ts b/apps/client/src/app/pages/home/home-page.component.tsindex 574286c826..4ef7741def 100644--- a/apps/client/src/app/pages/home/home-page.component.ts+++ b/apps/client/src/app/pages/home/home-page.component.ts@@ -1,7 +1,6 @@import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service';import { UserService } from '@ghostfolio/client/services/user/user.service';import { User } from '@ghostfolio/common/interfaces';-import { hasPermission, permissions } from '@ghostfolio/common/permissions';import { internalRoutes } from '@ghostfolio/common/routes/routes';import {GfPageTabsComponent,@@ -73,18 +72,8 @@ export class GfHomePageComponent implements OnInit {},{iconName: 'newspaper-outline',- label: hasPermission(- this.user?.permissions,- permissions.readMarketDataOfMarkets- )- ? internalRoutes.home.subRoutes.marketsPremium.title- : internalRoutes.home.subRoutes.markets.title,- routerLink: hasPermission(- this.user?.permissions,- permissions.readMarketDataOfMarkets- )- ? internalRoutes.home.subRoutes.marketsPremium.routerLink- : internalRoutes.home.subRoutes.markets.routerLink+ label: internalRoutes.home.subRoutes.markets.title,+ routerLink: internalRoutes.home.subRoutes.markets.routerLink}];}diff --git a/apps/client/src/app/pages/home/home-page.routes.ts b/apps/client/src/app/pages/home/home-page.routes.tsindex 82ef1e521f..cc444c2b00 100644--- a/apps/client/src/app/pages/home/home-page.routes.ts+++ b/apps/client/src/app/pages/home/home-page.routes.ts@@ -1,5 +1,4 @@import { GfHomeHoldingsComponent } from '@ghostfolio/client/components/home-holdings/home-holdings.component';-import { GfHomeMarketComponent } from '@ghostfolio/client/components/home-market/home-market.component';import { GfHomeOverviewComponent } from '@ghostfolio/client/components/home-overview/home-overview.component';import { GfHomeSummaryComponent } from '@ghostfolio/client/components/home-summary/home-summary.component';import { GfHomeWatchlistComponent } from '@ghostfolio/client/components/home-watchlist/home-watchlist.component';@@ -31,13 +30,8 @@ export const routes: Routes = [},{path: internalRoutes.home.subRoutes.markets.path,- component: GfHomeMarketComponent,- title: internalRoutes.home.subRoutes.markets.title- },- {- path: internalRoutes.home.subRoutes.marketsPremium.path,component: GfMarketsComponent,- title: internalRoutes.home.subRoutes.marketsPremium.title+ title: internalRoutes.home.subRoutes.markets.title},{path: internalRoutes.home.subRoutes.watchlist.path,diff --git a/apps/client/src/app/pages/markets/markets-page.component.ts b/apps/client/src/app/pages/markets/markets-page.component.tsindex 9a7576a95d..bf35c5556c 100644--- a/apps/client/src/app/pages/markets/markets-page.component.ts+++ b/apps/client/src/app/pages/markets/markets-page.component.ts@@ -1,11 +1,11 @@-import { GfHomeMarketComponent } from '@ghostfolio/client/components/home-market/home-market.component';+import { GfMarketsComponent } from '@ghostfolio/client/components/markets/markets.component';import { ChangeDetectionStrategy, Component } from '@angular/core';@Component({changeDetection: ChangeDetectionStrategy.OnPush,host: { class: 'page' },- imports: [GfHomeMarketComponent],+ imports: [GfMarketsComponent],selector: 'gf-markets-page',styleUrls: ['./markets-page.scss'],templateUrl: './markets-page.html'diff --git a/apps/client/src/app/pages/markets/markets-page.html b/apps/client/src/app/pages/markets/markets-page.htmlindex 16457b8cd5..0ff0170d7c 100644--- a/apps/client/src/app/pages/markets/markets-page.html+++ b/apps/client/src/app/pages/markets/markets-page.html@@ -1,7 +1,7 @@<div class="container"><div class="row"><div class="col">- <gf-home-market />+ <gf-markets /></div></div></div>diff --git a/libs/common/src/lib/helper.ts b/libs/common/src/lib/helper.tsindex 5d1ff538e5..b2a3ab419a 100644--- a/libs/common/src/lib/helper.ts+++ b/libs/common/src/lib/helper.ts@@ -560,8 +560,10 @@ export function resetHours(aDate: Date) {return new Date(Date.UTC(year, month, day));}-export function resolveFearAndGreedIndex(aValue: number) {- if (aValue <= 25) {+export function resolveFearAndGreedIndex(aValue?: number) {+ if (isNil(aValue)) {+ return { emoji: 'βͺ', key: 'UNKNOWN', text: 'Unknown' };+ } else if (aValue <= 25) {return { emoji: 'π₯΅', key: 'EXTREME_FEAR', text: 'Extreme Fear' };} else if (aValue <= 45) {return { emoji: 'π¨', key: 'FEAR', text: 'Fear' };diff --git a/libs/common/src/lib/routes/routes.ts b/libs/common/src/lib/routes/routes.tsindex 86cb2480b8..4d40cc5fbd 100644--- a/libs/common/src/lib/routes/routes.ts+++ b/libs/common/src/lib/routes/routes.ts@@ -94,11 +94,6 @@ export const internalRoutes = {routerLink: ['/home', 'markets'],title: $localize`Markets`},- marketsPremium: {- path: 'markets-premium',- routerLink: ['/home', 'markets-premium'],- title: $localize`Markets`- },summary: {path: 'summary',routerLink: ['/home', 'summary'],diff --git a/libs/ui/src/lib/fear-and-greed-index/fear-and-greed-index.component.html b/libs/ui/src/lib/fear-and-greed-index/fear-and-greed-index.component.htmlnew file mode 100644index 0000000000..e441c53f6b--- /dev/null+++ b/libs/ui/src/lib/fear-and-greed-index/fear-and-greed-index.component.html@@ -0,0 +1,25 @@+@if (isLoading() && !fearAndGreedIndex()) {+ <ngx-skeleton-loader+ animation="pulse"+ class="w-100"+ [theme]="{+ height: '2.5rem'+ }"+ />+} @else {+ <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() | number: '1.0-0') ?? placeholder+ }}</strong+ >/100</small+ >+ </div>+ <small class="d-block" i18n>Current Market Mood</small>+ </div>+ </div>+}diff --git a/apps/client/src/app/components/home-market/home-market.scss b/libs/ui/src/lib/fear-and-greed-index/fear-and-greed-index.component.scsssimilarity index 100%rename from apps/client/src/app/components/home-market/home-market.scssrename to libs/ui/src/lib/fear-and-greed-index/fear-and-greed-index.component.scssdiff --git a/libs/ui/src/lib/fear-and-greed-index/fear-and-greed-index.component.stories.ts b/libs/ui/src/lib/fear-and-greed-index/fear-and-greed-index.component.stories.tsnew file mode 100644index 0000000000..b5b2074da9--- /dev/null+++ b/libs/ui/src/lib/fear-and-greed-index/fear-and-greed-index.component.stories.ts@@ -0,0 +1,39 @@+import '@angular/localize/init';+import { moduleMetadata } from '@storybook/angular';+import type { Meta, StoryObj } from '@storybook/angular';+import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';++import { GfFearAndGreedIndexComponent } from './fear-and-greed-index.component';++export default {+ title: 'Fear & Greed Index',+ component: GfFearAndGreedIndexComponent,+ decorators: [+ moduleMetadata({+ imports: [NgxSkeletonLoaderModule]+ })+ ]+} as Meta<GfFearAndGreedIndexComponent>;++type Story = StoryObj<GfFearAndGreedIndexComponent>;++export const Loading: Story = {+ args: {+ fearAndGreedIndex: undefined,+ isLoading: true+ }+};++export const Default: Story = {+ args: {+ fearAndGreedIndex: 50,+ isLoading: false+ }+};++export const Unknown: Story = {+ args: {+ fearAndGreedIndex: undefined,+ isLoading: false+ }+};diff --git a/apps/client/src/app/components/fear-and-greed-index/fear-and-greed-index.component.ts b/libs/ui/src/lib/fear-and-greed-index/fear-and-greed-index.component.tssimilarity index 53%rename from apps/client/src/app/components/fear-and-greed-index/fear-and-greed-index.component.tsrename to libs/ui/src/lib/fear-and-greed-index/fear-and-greed-index.component.tsindex b507f0008b..4416752b37 100644--- a/apps/client/src/app/components/fear-and-greed-index/fear-and-greed-index.component.ts+++ b/libs/ui/src/lib/fear-and-greed-index/fear-and-greed-index.component.ts@@ -5,8 +5,8 @@ import { DecimalPipe } from '@angular/common';import {ChangeDetectionStrategy,Component,- Input,- OnChanges+ computed,+ input} from '@angular/core';import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';@@ -17,16 +17,17 @@ import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';styleUrls: ['./fear-and-greed-index.component.scss'],templateUrl: './fear-and-greed-index.component.html'})-export class GfFearAndGreedIndexComponent implements OnChanges {- @Input() fearAndGreedIndex: number;+export class GfFearAndGreedIndexComponent {+ public readonly fearAndGreedIndex = input<number>();+ public readonly isLoading = input<boolean>(false);- public fearAndGreedIndexEmoji: string;- public fearAndGreedIndexText: string;+ protected readonly placeholder = 'β';- public ngOnChanges() {- const { emoji, key } = resolveFearAndGreedIndex(this.fearAndGreedIndex);+ protected readonly fearAndGreedIndexEmoji = computed(() => {+ return resolveFearAndGreedIndex(this.fearAndGreedIndex()).emoji;+ });- this.fearAndGreedIndexEmoji = emoji;- this.fearAndGreedIndexText = translate(key);- }+ protected readonly fearAndGreedIndexText = computed(() => {+ return translate(resolveFearAndGreedIndex(this.fearAndGreedIndex()).key);+ });}diff --git a/libs/ui/src/lib/fear-and-greed-index/index.ts b/libs/ui/src/lib/fear-and-greed-index/index.tsnew file mode 100644index 0000000000..0f1db159ba--- /dev/null+++ b/libs/ui/src/lib/fear-and-greed-index/index.ts@@ -0,0 +1 @@+export * from './fear-and-greed-index.component';diff --git a/libs/ui/src/lib/i18n.ts b/libs/ui/src/lib/i18n.tsindex 26091be054..9e55a5edbf 100644--- a/libs/ui/src/lib/i18n.ts+++ b/libs/ui/src/lib/i18n.ts@@ -85,6 +85,7 @@ const locales = {FEAR: $localize`Fear`,GREED: $localize`Greed`,NEUTRAL: $localize`Neutral`,+ UNKNOWN: $localize`Unknown`,// Sectors'Basic Materials': $localize`Basic Materials`,