Browse Source

Merge remote-tracking branch 'origin/main' into bugfix/portfolio-calculator-precision-issues

pull/5509/head
KenTandrian 6 days ago
parent
commit
47e0a510fc
  1. 17
      CHANGELOG.md
  2. 18
      Dockerfile
  3. 34
      apps/api/src/app/admin/admin.service.ts
  4. 2
      apps/api/src/app/app.module.ts
  5. 4
      apps/api/src/app/endpoints/assets/assets.controller.ts
  6. 4
      apps/api/src/app/endpoints/sitemap/sitemap.controller.ts
  7. 12
      apps/api/src/app/order/order.service.ts
  8. 2
      apps/api/src/app/portfolio/calculator/portfolio-calculator-test-utils.ts
  9. 2
      apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btceur.spec.ts
  10. 2
      apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btcusd-short.spec.ts
  11. 2
      apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btcusd.spec.ts
  12. 2
      apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-novn-buy-and-sell-partially.spec.ts
  13. 2
      apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-novn-buy-and-sell.spec.ts
  14. 2
      apps/api/src/app/redis-cache/redis-cache.service.ts
  15. 2
      apps/api/src/app/user/user.service.ts
  16. 2
      apps/api/src/helper/string.helper.ts
  17. 6
      apps/api/src/middlewares/html-template.middleware.ts
  18. 2
      apps/api/src/services/api-key/api-key.service.ts
  19. 85
      apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts
  20. 4
      apps/api/src/services/i18n/i18n.service.ts
  21. 3
      apps/client/src/app/pages/faq/overview/faq-overview-page.html
  22. 20
      apps/client/src/app/pages/public/public-page.html
  23. 12
      apps/client/src/app/pages/resources/personal-finance-tools/product-page.component.ts
  24. 46
      libs/common/src/lib/personal-finance-tools.ts
  25. 20
      libs/ui/src/lib/entity-logo/entity-logo-image-source.service.ts
  26. 44
      libs/ui/src/lib/entity-logo/entity-logo.component.stories.ts
  27. 13
      libs/ui/src/lib/entity-logo/entity-logo.component.ts
  28. 24
      libs/ui/src/lib/mocks/entity-logo-image-source.service.mock.ts
  29. 12
      package-lock.json
  30. 7
      package.json
  31. 11
      prisma.config.ts

17
CHANGELOG.md

@ -5,11 +5,26 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased
## 2.199.0 - 2025-09-14
### Added
- Extended the content of the performance calculation method by dividends on the Frequently Asked Questions (FAQ) page
- Added a _Storybook_ story for the entity logo image component
### Changed
- Improved the search in the _Yahoo Finance_ service
- Moved the holdings table into the holdings section on the public page
- Migrated to the _Prisma Configuration File_ approach (`prisma.config.ts`)
- Refactored the login with access token dialog component to standalone
- Prefixed the `crypto`, `fs` and `path` imports with `node:`
- Upgraded `yahoo-finance2` from version `3.8.0` to `3.10.0`
### Fixed
- Fixed a pagination issue in the market data endpoint by adding `id` as a secondary sort criterion to ensure consistent ordering in the admin control panel
- Fixed a pagination issue in the user endpoint by adding `id` as a secondary sort criterion to ensure consistent ordering in the admin control panel
## 2.198.0 - 2025-09-11

18
Dockerfile

@ -17,7 +17,8 @@ COPY ./CHANGELOG.md CHANGELOG.md
COPY ./LICENSE LICENSE
COPY ./package.json package.json
COPY ./package-lock.json package-lock.json
COPY ./prisma/schema.prisma prisma/schema.prisma
COPY ./prisma.config.ts prisma.config.ts
COPY ./prisma/schema.prisma prisma/
RUN npm install
@ -25,8 +26,8 @@ RUN npm install
COPY ./decorate-angular-cli.js decorate-angular-cli.js
RUN node decorate-angular-cli.js
COPY ./apps apps
COPY ./libs libs
COPY ./apps apps/
COPY ./libs libs/
COPY ./jest.config.ts jest.config.ts
COPY ./jest.preset.js jest.preset.js
COPY ./nx.json nx.json
@ -40,14 +41,15 @@ RUN npm run build:production
WORKDIR /ghostfolio/dist/apps/api
# package.json was generated by the build process, however the original
# package-lock.json needs to be used to ensure the same versions
COPY ./package-lock.json /ghostfolio/dist/apps/api/package-lock.json
COPY ./package-lock.json /ghostfolio/dist/apps/api/
RUN npm install
COPY prisma /ghostfolio/dist/apps/api/prisma
COPY prisma.config.ts /ghostfolio/dist/apps/api/
COPY prisma /ghostfolio/dist/apps/api/prisma/
# Overwrite the generated package.json with the original one to ensure having
# all the scripts
COPY package.json /ghostfolio/dist/apps/api
COPY package.json /ghostfolio/dist/apps/api/
RUN npm run database:generate-typings
# Image to run, copy everything needed from builder
@ -60,8 +62,8 @@ RUN apt-get update && apt-get install -y --no-install-suggests \
openssl \
&& rm -rf /var/lib/apt/lists/*
COPY --chown=node:node --from=builder /ghostfolio/dist/apps /ghostfolio/apps
COPY --chown=node:node ./docker/entrypoint.sh /ghostfolio/entrypoint.sh
COPY --chown=node:node --from=builder /ghostfolio/dist/apps /ghostfolio/apps/
COPY --chown=node:node ./docker/entrypoint.sh /ghostfolio/
WORKDIR /ghostfolio/apps/api
EXPOSE ${PORT:-3333}
USER node

34
apps/api/src/app/admin/admin.service.ts

@ -192,7 +192,7 @@ export class AdminService {
filters,
presetId,
sortColumn,
sortDirection,
sortDirection = 'asc',
skip,
take = Number.MAX_SAFE_INTEGER
}: {
@ -262,11 +262,13 @@ export class AdminService {
orderBy = [{ [sortColumn]: sortDirection }];
if (sortColumn === 'activitiesCount') {
orderBy = {
activities: {
_count: sortDirection
orderBy = [
{
activities: {
_count: sortDirection
}
}
};
];
}
}
@ -275,10 +277,10 @@ export class AdminService {
try {
const symbolProfileResult = await Promise.all([
extendedPrismaClient.symbolProfile.findMany({
orderBy,
skip,
take,
where,
orderBy: [...orderBy, { id: sortDirection }],
select: {
_count: {
select: {
@ -817,17 +819,21 @@ export class AdminService {
skip?: number;
take?: number;
}): Promise<AdminUsers['users']> {
let orderBy: Prisma.UserOrderByWithRelationInput = {
createdAt: 'desc'
};
let orderBy: Prisma.Enumerable<Prisma.UserOrderByWithRelationInput> = [
{ createdAt: 'desc' }
];
let where: Prisma.UserWhereInput;
if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) {
orderBy = {
analytics: {
lastRequestAt: 'desc'
orderBy = [
{
analytics: {
lastRequestAt: 'desc'
}
}
};
];
where = {
NOT: {
analytics: null
@ -836,10 +842,10 @@ export class AdminService {
}
const usersWithAnalytics = await this.prismaService.user.findMany({
orderBy,
skip,
take,
where,
orderBy: [...orderBy, { id: 'desc' }],
select: {
_count: {
select: { accounts: true, activities: true }

2
apps/api/src/app/app.module.ts

@ -21,7 +21,7 @@ import { EventEmitterModule } from '@nestjs/event-emitter';
import { ScheduleModule } from '@nestjs/schedule';
import { ServeStaticModule } from '@nestjs/serve-static';
import { StatusCodes } from 'http-status-codes';
import { join } from 'path';
import { join } from 'node:path';
import { AccessModule } from './access/access.module';
import { AccountModule } from './account/account.module';

4
apps/api/src/app/endpoints/assets/assets.controller.ts

@ -10,8 +10,8 @@ import {
VERSION_NEUTRAL
} from '@nestjs/common';
import { Response } from 'express';
import { readFileSync } from 'fs';
import { join } from 'path';
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
@Controller('assets')
export class AssetsController {

4
apps/api/src/app/endpoints/sitemap/sitemap.controller.ts

@ -8,8 +8,8 @@ import {
import { Controller, Get, Res, VERSION_NEUTRAL, Version } from '@nestjs/common';
import { format } from 'date-fns';
import { Response } from 'express';
import { readFileSync } from 'fs';
import { join } from 'path';
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { SitemapService } from './sitemap.service';

12
apps/api/src/app/order/order.service.ts

@ -325,7 +325,7 @@ export class OrderService {
includeDrafts = false,
skip,
sortColumn,
sortDirection,
sortDirection = 'asc',
startDate,
take = Number.MAX_SAFE_INTEGER,
types,
@ -347,9 +347,9 @@ export class OrderService {
withExcludedAccountsAndActivities?: boolean;
}): Promise<Activities> {
let orderBy: Prisma.Enumerable<Prisma.OrderOrderByWithRelationInput> = [
{ date: 'asc' },
{ id: 'asc' }
{ date: 'asc' }
];
const where: Prisma.OrderWhereInput = { userId };
if (endDate || startDate) {
@ -483,7 +483,7 @@ export class OrderService {
}
if (sortColumn) {
orderBy = [{ [sortColumn]: sortDirection }, { id: sortDirection }];
orderBy = [{ [sortColumn]: sortDirection }];
}
if (types) {
@ -506,7 +506,6 @@ export class OrderService {
const [orders, count] = await Promise.all([
this.orders({
orderBy,
skip,
take,
where,
@ -519,7 +518,8 @@ export class OrderService {
// eslint-disable-next-line @typescript-eslint/naming-convention
SymbolProfile: true,
tags: true
}
},
orderBy: [...orderBy, { id: sortDirection }]
}),
this.prismaService.order.count({ where })
]);

2
apps/api/src/app/portfolio/calculator/portfolio-calculator-test-utils.ts

@ -1,4 +1,4 @@
import { readFileSync } from 'fs';
import { readFileSync } from 'node:fs';
export const activityDummyData = {
accountId: undefined,

2
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btceur.spec.ts

@ -20,7 +20,7 @@ import { PerformanceCalculationType } from '@ghostfolio/common/types/performance
import { Tag } from '@prisma/client';
import { Big } from 'big.js';
import { join } from 'path';
import { join } from 'node:path';
jest.mock('@ghostfolio/api/app/portfolio/current-rate.service', () => {
return {

2
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btcusd-short.spec.ts

@ -20,7 +20,7 @@ import { PerformanceCalculationType } from '@ghostfolio/common/types/performance
import { Tag } from '@prisma/client';
import { Big } from 'big.js';
import { join } from 'path';
import { join } from 'node:path';
jest.mock('@ghostfolio/api/app/portfolio/current-rate.service', () => {
return {

2
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btcusd.spec.ts

@ -20,7 +20,7 @@ import { PerformanceCalculationType } from '@ghostfolio/common/types/performance
import { Tag } from '@prisma/client';
import { Big } from 'big.js';
import { join } from 'path';
import { join } from 'node:path';
jest.mock('@ghostfolio/api/app/portfolio/current-rate.service', () => {
return {

2
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-novn-buy-and-sell-partially.spec.ts

@ -20,7 +20,7 @@ import { PerformanceCalculationType } from '@ghostfolio/common/types/performance
import { Tag } from '@prisma/client';
import { Big } from 'big.js';
import { join } from 'path';
import { join } from 'node:path';
jest.mock('@ghostfolio/api/app/portfolio/current-rate.service', () => {
return {

2
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-novn-buy-and-sell.spec.ts

@ -20,7 +20,7 @@ import { PerformanceCalculationType } from '@ghostfolio/common/types/performance
import { Tag } from '@prisma/client';
import { Big } from 'big.js';
import { join } from 'path';
import { join } from 'node:path';
jest.mock('@ghostfolio/api/app/portfolio/current-rate.service', () => {
return {

2
apps/api/src/app/redis-cache/redis-cache.service.ts

@ -4,9 +4,9 @@ import { AssetProfileIdentifier, Filter } from '@ghostfolio/common/interfaces';
import { CACHE_MANAGER, Cache } from '@nestjs/cache-manager';
import { Inject, Injectable, Logger } from '@nestjs/common';
import { createHash } from 'crypto';
import Keyv from 'keyv';
import ms from 'ms';
import { createHash } from 'node:crypto';
@Injectable()
export class RedisCacheService {

2
apps/api/src/app/user/user.service.ts

@ -48,9 +48,9 @@ import { PerformanceCalculationType } from '@ghostfolio/common/types/performance
import { Injectable } from '@nestjs/common';
import { EventEmitter2 } from '@nestjs/event-emitter';
import { Prisma, Role, User } from '@prisma/client';
import { createHmac } from 'crypto';
import { differenceInDays, subDays } from 'date-fns';
import { sortBy, without } from 'lodash';
import { createHmac } from 'node:crypto';
@Injectable()
export class UserService {

2
apps/api/src/helper/string.helper.ts

@ -1,4 +1,4 @@
import { randomBytes } from 'crypto';
import { randomBytes } from 'node:crypto';
export function getRandomString(length: number) {
const bytes = randomBytes(length);

6
apps/api/src/middlewares/html-template.middleware.ts

@ -10,8 +10,8 @@ import { DATE_FORMAT, interpolate } from '@ghostfolio/common/helper';
import { Injectable, Logger, NestMiddleware } from '@nestjs/common';
import { format } from 'date-fns';
import { NextFunction, Request, Response } from 'express';
import * as fs from 'fs';
import { join } from 'path';
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
const title = 'Ghostfolio';
@ -87,7 +87,7 @@ export class HtmlTemplateMiddleware implements NestMiddleware {
this.indexHtmlMap = SUPPORTED_LANGUAGE_CODES.reduce(
(map, languageCode) => ({
...map,
[languageCode]: fs.readFileSync(
[languageCode]: readFileSync(
join(__dirname, '..', 'client', languageCode, 'index.html'),
'utf8'
)

2
apps/api/src/services/api-key/api-key.service.ts

@ -3,7 +3,7 @@ import { PrismaService } from '@ghostfolio/api/services/prisma/prisma.service';
import { ApiKeyResponse } from '@ghostfolio/common/interfaces';
import { Injectable } from '@nestjs/common';
import { pbkdf2Sync } from 'crypto';
import { pbkdf2Sync } from 'node:crypto';
@Injectable()
export class ApiKeyService {

85
apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts

@ -24,6 +24,7 @@ import {
import { Injectable, Logger } from '@nestjs/common';
import { DataSource, SymbolProfile } from '@prisma/client';
import { addDays, format, isSameDay } from 'date-fns';
import { uniqBy } from 'lodash';
import YahooFinance from 'yahoo-finance2';
import { ChartResultArray } from 'yahoo-finance2/esm/src/modules/chart';
import {
@ -34,6 +35,10 @@ import {
Quote,
QuoteResponseArray
} from 'yahoo-finance2/esm/src/modules/quote';
import {
Price,
QuoteSummaryResult
} from 'yahoo-finance2/esm/src/modules/quoteSummary';
import { SearchQuoteNonYahoo } from 'yahoo-finance2/esm/src/modules/search';
@Injectable()
@ -190,10 +195,7 @@ export class YahooFinanceService implements DataProviderInterface {
);
try {
let quotes: Pick<
Quote,
'currency' | 'marketState' | 'regularMarketPrice' | 'symbol'
>[] = [];
let quotes: Price[] | Quote[] = [];
try {
quotes = await this.yahooFinance.quote(yahooFinanceSymbols);
@ -290,7 +292,9 @@ export class YahooFinanceService implements DataProviderInterface {
try {
marketData = await this.yahooFinance.quote(
quotes.map(({ symbol }) => {
uniqBy(quotes, ({ symbol }) => {
return symbol;
}).map(({ symbol }) => {
return symbol;
})
);
@ -300,35 +304,35 @@ export class YahooFinanceService implements DataProviderInterface {
}
}
for (const marketDataItem of marketData) {
const quote = quotes.find((currentQuote) => {
return currentQuote.symbol === marketDataItem.symbol;
});
const symbol =
this.yahooFinanceDataEnhancerService.convertFromYahooFinanceSymbol(
marketDataItem.symbol
);
for (const {
currency,
longName,
quoteType,
shortName,
symbol
} of marketData) {
const { assetClass, assetSubClass } =
this.yahooFinanceDataEnhancerService.parseAssetClass({
quoteType: quote.quoteType,
shortName: quote.shortname
quoteType,
shortName
});
items.push({
assetClass,
assetSubClass,
symbol,
currency: marketDataItem.currency,
currency,
dataProviderInfo: this.getDataProviderInfo(),
dataSource: this.getName(),
name: this.yahooFinanceDataEnhancerService.formatName({
longName: quote.longname,
quoteType: quote.quoteType,
shortName: quote.shortname,
symbol: quote.symbol
})
longName,
quoteType,
shortName,
symbol
}),
symbol:
this.yahooFinanceDataEnhancerService.convertFromYahooFinanceSymbol(
symbol
)
});
}
} catch (error) {
@ -354,23 +358,28 @@ export class YahooFinanceService implements DataProviderInterface {
private async getQuotesWithQuoteSummary(aYahooFinanceSymbols: string[]) {
const quoteSummaryPromises = aYahooFinanceSymbols.map((symbol) => {
return this.yahooFinance.quoteSummary(symbol).catch(() => {
Logger.error(
`Could not get quote summary for ${symbol}`,
'YahooFinanceService'
);
return null;
});
return this.yahooFinance.quoteSummary(symbol);
});
const quoteSummaryItems = await Promise.all(quoteSummaryPromises);
const settledResults = await Promise.allSettled(quoteSummaryPromises);
return settledResults
.filter(
(result): result is PromiseFulfilledResult<QuoteSummaryResult> => {
if (result.status === 'rejected') {
Logger.error(
`Could not get quote summary: ${result.reason}`,
'YahooFinanceService'
);
return quoteSummaryItems
.filter((item) => {
return item !== null;
})
.map(({ price }) => {
return price;
return false;
}
return true;
}
)
.map(({ value }) => {
return value.price;
});
}
}

4
apps/api/src/services/i18n/i18n.service.ts

@ -2,8 +2,8 @@ import { DEFAULT_LANGUAGE_CODE } from '@ghostfolio/common/config';
import { Injectable, Logger } from '@nestjs/common';
import * as cheerio from 'cheerio';
import { readFileSync, readdirSync } from 'fs';
import { join } from 'path';
import { readFileSync, readdirSync } from 'node:fs';
import { join } from 'node:path';
@Injectable()
export class I18nService {

3
apps/client/src/app/pages/faq/overview/faq-overview-page.html

@ -52,7 +52,8 @@
calculation method based on the average amount of capital invested
over time. ROAI aims to provide a more insightful view of investment
performance than simpler approaches, especially when contributions are
made over time.</mat-card-content
made over time. Dividends are not part of the
calculation.</mat-card-content
>
</mat-card>
<mat-card appearance="outlined" class="mb-3">

20
apps/client/src/app/pages/public/public-page.html

@ -77,6 +77,14 @@
[keys]="['symbol']"
[showLabels]="deviceType !== 'mobile'"
/>
<gf-holdings-table
[deviceType]="deviceType"
[hasPermissionToOpenDetails]="false"
[hasPermissionToShowQuantities]="false"
[hasPermissionToShowValues]="false"
[holdings]="holdings"
[pageSize]="7"
/>
</mat-card-content>
</mat-card>
</div>
@ -195,18 +203,6 @@
</div>
</div>
}
<div class="row">
<div class="col-lg">
<gf-holdings-table
[deviceType]="deviceType"
[hasPermissionToOpenDetails]="false"
[hasPermissionToShowQuantities]="false"
[hasPermissionToShowValues]="false"
[holdings]="holdings"
[pageSize]="7"
/>
</div>
</div>
<div class="row my-5">
<div class="col-md-10 offset-md-1">
<h2 class="h4 mb-1 text-center" i18n>

12
apps/client/src/app/pages/resources/personal-finance-tools/product-page.component.ts

@ -76,7 +76,9 @@ export class GfProductPageComponent implements OnInit {
this.tags = [
this.product1.name,
this.product1.origin,
this.product2.name,
this.product2.origin,
$localize`Alternative`,
$localize`App`,
$localize`Budgeting`,
@ -96,8 +98,12 @@ export class GfProductPageComponent implements OnInit {
$localize`Wealth`,
$localize`Wealth Management`,
`WealthTech`
].sort((a, b) => {
return a.localeCompare(b, undefined, { sensitivity: 'base' });
});
]
.filter((item) => {
return !!item;
})
.sort((a, b) => {
return a.localeCompare(b, undefined, { sensitivity: 'base' });
});
}
}

46
libs/common/src/lib/personal-finance-tools.ts

@ -33,6 +33,16 @@ export const personalFinanceTools: Product[] = [
origin: 'Switzerland',
slogan: 'Simplicity for Complex Wealth'
},
{
founded: 2023,
hasFreePlan: false,
hasSelfHostingAbility: false,
key: 'amsflow',
name: 'Amsflow Portfolio',
origin: 'Singapore',
pricingPerYear: '$228',
slogan: 'Portfolio Visualizer'
},
{
founded: 2018,
hasFreePlan: true,
@ -97,6 +107,12 @@ export const personalFinanceTools: Product[] = [
pricingPerYear: '$100',
slogan: 'Stock Portfolio Tracker for Smart Investors'
},
{
key: 'budgetpulse',
name: 'BudgetPulse',
origin: 'United States',
slogan: 'Giving life to your finance!'
},
{
founded: 2007,
hasFreePlan: false,
@ -180,6 +196,15 @@ export const personalFinanceTools: Product[] = [
pricingPerYear: '$95',
slogan: 'Do money better with Copilot'
},
{
founded: 2014,
hasFreePlan: false,
key: 'countabout',
name: 'CountAbout',
origin: 'United States',
pricingPerYear: '$9.99',
slogan: 'Customizable and Secure Personal Finance App'
},
{
founded: 2023,
hasFreePlan: false,
@ -427,6 +452,14 @@ export const personalFinanceTools: Product[] = [
slogan: 'Die All-in-One Lösung für dein Vermögen.',
useAnonymously: true
},
{
founded: 2017,
hasSelfHostingAbility: false,
key: 'honeydue',
name: 'Honeydue',
origin: 'United States',
slogan: 'Finance App for Couples'
},
{
founded: 2022,
key: 'income-reign',
@ -608,6 +641,13 @@ export const personalFinanceTools: Product[] = [
origin: 'Germany',
slogan: 'Dein smarter Finance Assistant'
},
{
key: 'moneywiz',
name: 'MoneyWiz',
origin: 'United States',
pricingPerYear: '$29.99',
slogan: 'Get money management superpowers'
},
{
hasFreePlan: false,
hasSelfHostingAbility: false,
@ -859,6 +899,12 @@ export const personalFinanceTools: Product[] = [
pricingPerYear: '$80',
slogan: 'Simple and powerful portfolio tracker'
},
{
key: 'splashmoney',
name: 'SplashMoney',
origin: 'United States',
slogan: 'Manage your money anytime, anywhere.'
},
{
founded: 2019,
hasSelfHostingAbility: false,

20
libs/ui/src/lib/entity-logo/entity-logo-image-source.service.ts

@ -0,0 +1,20 @@
import { AssetProfileIdentifier } from '@ghostfolio/common/interfaces';
import { Injectable } from '@angular/core';
@Injectable({
// Required to allow mocking in Storybook
providedIn: 'root'
})
export class EntityLogoImageSourceService {
public getLogoUrlByAssetProfileIdentifier({
dataSource,
symbol
}: AssetProfileIdentifier) {
return `../api/v1/logo/${dataSource}/${symbol}`;
}
public getLogoUrlByUrl(url: string) {
return `../api/v1/logo?url=${url}`;
}
}

44
libs/ui/src/lib/entity-logo/entity-logo.component.stories.ts

@ -0,0 +1,44 @@
import { CommonModule } from '@angular/common';
import { importProvidersFrom } from '@angular/core';
import { provideNoopAnimations } from '@angular/platform-browser/animations';
import { applicationConfig, Meta, StoryObj } from '@storybook/angular';
import { EntityLogoImageSourceServiceMock } from '../mocks/entity-logo-image-source.service.mock';
import { EntityLogoImageSourceService } from './entity-logo-image-source.service';
import { GfEntityLogoComponent } from './entity-logo.component';
export default {
title: 'Entity Logo',
component: GfEntityLogoComponent,
decorators: [
applicationConfig({
providers: [
provideNoopAnimations(),
importProvidersFrom(CommonModule),
{
provide: EntityLogoImageSourceService,
useValue: new EntityLogoImageSourceServiceMock()
}
]
})
]
} as Meta<GfEntityLogoComponent>;
type Story = StoryObj<GfEntityLogoComponent>;
export const LogoByAssetProfileIdentifier: Story = {
args: {
dataSource: 'YAHOO',
size: 'large',
symbol: 'AAPL',
tooltip: 'Apple Inc.'
}
};
export const LogoByUrl: Story = {
args: {
size: 'large',
tooltip: 'Ghostfolio',
url: 'https://ghostfol.io'
}
};

13
libs/ui/src/lib/entity-logo/entity-logo.component.ts

@ -1,3 +1,5 @@
import { EntityLogoImageSourceService } from '@ghostfolio/ui/entity-logo/entity-logo-image-source.service';
import { CommonModule } from '@angular/common';
import {
CUSTOM_ELEMENTS_SCHEMA,
@ -25,11 +27,18 @@ export class GfEntityLogoComponent implements OnChanges {
public src: string;
public constructor(
private readonly imageSourceService: EntityLogoImageSourceService
) {}
public ngOnChanges() {
if (this.dataSource && this.symbol) {
this.src = `../api/v1/logo/${this.dataSource}/${this.symbol}`;
this.src = this.imageSourceService.getLogoUrlByAssetProfileIdentifier({
dataSource: this.dataSource,
symbol: this.symbol
});
} else if (this.url) {
this.src = `../api/v1/logo?url=${this.url}`;
this.src = this.imageSourceService.getLogoUrlByUrl(this.url);
}
}
}

24
libs/ui/src/lib/mocks/entity-logo-image-source.service.mock.ts

@ -0,0 +1,24 @@
import { AssetProfileIdentifier } from '@ghostfolio/common/interfaces';
import { DataSource } from '@prisma/client';
export class EntityLogoImageSourceServiceMock {
public getLogoUrlByAssetProfileIdentifier({
dataSource,
symbol
}: AssetProfileIdentifier) {
if (dataSource === DataSource.YAHOO && symbol === 'AAPL') {
return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAJa0lEQVR4nM2bW2wU1xnHf3vx2t61za5nL/bGKwx2jQnwUh5Q3bqyHYhzIVLUFoIaSKtGSrkkNaQJqlQSKaHQFygQJamUSomaRKpSlYekqSF1HGix6EOktIldOQs0OCEs3ssw48Ve8F77MGuwza4ve2Y3/KR92Ln8z/d9OnPmnG/OZ/jss2FKRA3QCiwDPEAtUAEkgWvAGKAAF4HPgWgpjDIXUdsF3AN0Zn/NVmuFoazMgtlswmw2YTAYyGQgnU6TSqVIpdIkEnFisRsZ4AJwGjgFfAiEi2GkQeceUAn8CPgJ0GG315hsNis2m5XycsuihCYn40xMxJiYiKGq0RRaMP4I/AW4rpfBegXAAfQAu+z2JU6HowabzYbBoIc0ZDIwMTGBokRR1bEI8ApwDO2REUI0AGbgKeB5t1uyS1ItZrNJ1KY5SSZTyPJVQiFZBfYDL6GNIwUhEoDvAr+XJMcaSXIsuouLEo/HiUQUZFkZBHYCA4XoGAu4xwS8APzD5/Ou8Xo9JXcewGKx4PV68Pm8a9DGhxezti2KxfYAF/COJDk63W5n0bv7QkkmU4RCEWRZOQU8wiLeGIvpAY3AgNvt7PR6PXeM8wBmswmv14Pb7exEexQaF3rvQgOwCjhbV+dq8XicBZhYGjweJ3V1rhbgLJrN87KQADQBJ71eT73LJYnYVxJcLgmv11MPnASa57t+vgC4gJP19e4GSXLoYV9JkCQH9fXuBuAEmg95mSsAZcBxt9vZ7HTW6mlfXsbHJzh27CU6Ojppbm7h4sWLBWs5nbW43c5m4Di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QSRyFVkWRlCm+ScKURHj7K5HuDXLpfkkCQHenxpnotEIoksK4TDsgIcQJvefiNlc9OpAZ4EehyOJW6HYwlWq1XXwslYLIaijKEoYyE0p19Gh/riYpTObgJ+Cnx/qnS2qsrKYrfgxONxxsdnlM7+E6109s/cgaWzufCg7cTqAjqMRmNzRUU5ZWVllJWZMJnyFU8nuHFjknQ6PVU8/VH2FyyGkcUMwGxqgJVoJW11gARYuL18fgQYpkTl8/8HqhBYlUKrXOwAAAAASUVORK5CYII=';
}
return '';
}
public getLogoUrlByUrl(url: string) {
if (url === 'https://ghostfol.io') {
return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAP1BMVEU2z8v////x/Pspzcn0/Px73drR8/KC3tz6/v6e5eOl5+WM4d7n+PhI08/i9/eu6edV1dJk2NVx2teV4+G87evvttLSAAABDElEQVRYhe2V3Y6EIAyFrQXlTwHd93/WpeBsdiKbtF7tJJwbCKFfDlKO0zQ0NPQJwqrn1ZO2zlk9PWPgusClRcsJmHb4pWUTItDDu4zMBJ5w0yog4HGvB0gCgOoBZrYFdL16AMsmmD5AcQ3ofj3AwbOAX38BIhMw02ZjtQ+tLnht66mCAGA2eka1G3eabUZwD/PLbeuHenKMBODVV0Dru/TTQLgKAc1BvQ/9yAEkOnlon66oehEBIHp7dbSyPoIc0NEADMDnAa4wAvVK+CADRGx/VpNSi+iF3jMTUH4rJQ0aISPmVk+JoJiZeJw1QnaqL2OmWKSFkxnrZWsbXK4TzO5tmS+8TYaGhv6xvgEEfAgHGc7HRgAAAABJRU5ErkJggg==';
}
return '';
}
}

12
package-lock.json

@ -1,12 +1,12 @@
{
"name": "ghostfolio",
"version": "2.198.0",
"version": "2.199.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "ghostfolio",
"version": "2.198.0",
"version": "2.199.0",
"hasInstallScript": true,
"license": "AGPL-3.0",
"dependencies": {
@ -93,7 +93,7 @@
"svgmap": "2.12.2",
"twitter-api-v2": "1.23.0",
"uuid": "11.1.0",
"yahoo-finance2": "3.8.0",
"yahoo-finance2": "3.10.0",
"zone.js": "0.15.1"
},
"devDependencies": {
@ -42071,9 +42071,9 @@
}
},
"node_modules/yahoo-finance2": {
"version": "3.8.0",
"resolved": "https://registry.npmjs.org/yahoo-finance2/-/yahoo-finance2-3.8.0.tgz",
"integrity": "sha512-em11JOlfSg23wevm4kXs1+A/CoSWD9eg7/hKRU3zKWuPknCfE4NkIhGVb601Nokid+KPE8Q0eoXK4qgLsMIjKA==",
"version": "3.10.0",
"resolved": "https://registry.npmjs.org/yahoo-finance2/-/yahoo-finance2-3.10.0.tgz",
"integrity": "sha512-0mnvefEAapMS6M3tnqLmQlyE2W38AQqByaTS09l2dawLaVU7NNc0hJ4qI4F3qi3C7MU+ZWAb8DFVKpW6Zsj0Nw==",
"license": "MIT",
"dependencies": {
"@deno/shim-deno": "~0.18.0",

7
package.json

@ -1,6 +1,6 @@
{
"name": "ghostfolio",
"version": "2.198.0",
"version": "2.199.0",
"homepage": "https://ghostfol.io",
"license": "AGPL-3.0",
"repository": "https://github.com/ghostfolio/ghostfolio",
@ -139,7 +139,7 @@
"svgmap": "2.12.2",
"twitter-api-v2": "1.23.0",
"uuid": "11.1.0",
"yahoo-finance2": "3.8.0",
"yahoo-finance2": "3.10.0",
"zone.js": "0.15.1"
},
"devDependencies": {
@ -209,8 +209,5 @@
},
"engines": {
"node": ">=22.18.0"
},
"prisma": {
"seed": "node prisma/seed.mts"
}
}

11
prisma.config.ts

@ -0,0 +1,11 @@
import 'dotenv/config';
import { join } from 'node:path';
import { defineConfig } from 'prisma/config';
export default defineConfig({
migrations: {
path: join('prisma', 'migrations'),
seed: `node ${join('prisma', 'seed.mts')}`
},
schema: join('prisma', 'schema.prisma')
});
Loading…
Cancel
Save