Browse Source

Refactoring

pull/4031/head
Thomas Kaul 10 months ago
parent
commit
6a5d0d466a
  1. 5
      apps/api/src/app/portfolio/portfolio.controller.ts
  2. 10
      apps/client/src/app/components/header/header.component.ts
  3. 38
      libs/ui/src/lib/assistant/assistant.component.ts
  4. 20
      libs/ui/src/lib/assistant/assistant.html

5
apps/api/src/app/portfolio/portfolio.controller.ts

@ -74,6 +74,7 @@ export class PortfolioController {
@Get('details')
@UseGuards(AuthGuard('jwt'), HasPermissionGuard)
@UseInterceptors(RedactValuesInResponseInterceptor)
@UseInterceptors(TransformDataSourceInRequestInterceptor)
@UseInterceptors(TransformDataSourceInResponseInterceptor)
public async getDetails(
@Headers(HEADER_KEY_IMPERSONATION.toLowerCase()) impersonationId: string,
@ -293,6 +294,7 @@ export class PortfolioController {
@Get('dividends')
@UseGuards(AuthGuard('jwt'), HasPermissionGuard)
@UseInterceptors(TransformDataSourceInRequestInterceptor)
public async getDividends(
@Headers(HEADER_KEY_IMPERSONATION.toLowerCase()) impersonationId: string,
@Query('accounts') filterByAccounts?: string,
@ -364,6 +366,7 @@ export class PortfolioController {
@Get('holdings')
@UseGuards(AuthGuard('jwt'), HasPermissionGuard)
@UseInterceptors(RedactValuesInResponseInterceptor)
@UseInterceptors(TransformDataSourceInRequestInterceptor)
@UseInterceptors(TransformDataSourceInResponseInterceptor)
public async getHoldings(
@Headers(HEADER_KEY_IMPERSONATION.toLowerCase()) impersonationId: string,
@ -398,6 +401,7 @@ export class PortfolioController {
@Get('investments')
@UseGuards(AuthGuard('jwt'), HasPermissionGuard)
@UseInterceptors(TransformDataSourceInRequestInterceptor)
public async getInvestments(
@Headers(HEADER_KEY_IMPERSONATION.toLowerCase()) impersonationId: string,
@Query('accounts') filterByAccounts?: string,
@ -467,6 +471,7 @@ export class PortfolioController {
@Get('performance')
@UseGuards(AuthGuard('jwt'), HasPermissionGuard)
@UseInterceptors(PerformanceLoggingInterceptor)
@UseInterceptors(TransformDataSourceInRequestInterceptor)
@UseInterceptors(TransformDataSourceInResponseInterceptor)
@Version('2')
public async getPerformanceV2(

10
apps/client/src/app/components/header/header.component.ts

@ -176,15 +176,15 @@ export class HeaderComponent implements OnChanges {
for (const filter of filters) {
if (filter.type === 'ACCOUNT') {
userSetting[`filters.accounts`] = filter.id ? [filter.id] : null;
userSetting['filters.accounts'] = filter.id ? [filter.id] : null;
} else if (filter.type === 'ASSET_CLASS') {
userSetting[`filters.assetClasses`] = filter.id ? [filter.id] : null;
userSetting['filters.assetClasses'] = filter.id ? [filter.id] : null;
} else if (filter.type === 'DATA_SOURCE') {
userSetting[`filters.dataSource`] = filter.id ? filter.id : null;
userSetting['filters.dataSource'] = filter.id ? filter.id : null;
} else if (filter.type === 'SYMBOL') {
userSetting[`filters.symbol`] = filter.id ? filter.id : null;
userSetting['filters.symbol'] = filter.id ? filter.id : null;
} else if (filter.type === 'TAG') {
userSetting[`filters.tags`] = filter.id ? [filter.id] : null;
userSetting['filters.tags'] = filter.id ? [filter.id] : null;
}
}

38
libs/ui/src/lib/assistant/assistant.component.ts

@ -3,12 +3,7 @@ import { GfSymbolModule } from '@ghostfolio/client/pipes/symbol/symbol.module';
import { AdminService } from '@ghostfolio/client/services/admin.service';
import { DataService } from '@ghostfolio/client/services/data.service';
import { getAssetProfileIdentifier } from '@ghostfolio/common/helper';
import {
AssetProfileIdentifier,
Filter,
PortfolioPosition,
User
} from '@ghostfolio/common/interfaces';
import { Filter, PortfolioPosition, User } from '@ghostfolio/common/interfaces';
import { DateRange } from '@ghostfolio/common/types';
import { translate } from '@ghostfolio/ui/i18n';
@ -307,6 +302,19 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
});
}
public holdingComparisonFunction(
option: PortfolioPosition,
value: PortfolioPosition
): boolean {
if (value === null) {
return false;
}
return (
getAssetProfileIdentifier(option) === getAssetProfileIdentifier(value)
);
}
public async initialize() {
this.isLoading = true;
this.keyManager = new FocusKeyManager(this.assistantListItems).withWrap();
@ -491,18 +499,6 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
);
}
public holdingComparisonFunction(
option: AssetProfileIdentifier,
value: AssetProfileIdentifier
): boolean {
if (value === null) {
return false;
}
return (
getAssetProfileIdentifier(option) === getAssetProfileIdentifier(value)
);
}
private initializeFilterForm() {
this.dataService
.fetchPortfolioHoldings({
@ -528,8 +524,10 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
const symbol = this.user?.settings?.['filters.symbol'];
const selectedHolding = this.holdings.find((holding) => {
return (
getAssetProfileIdentifier(holding) ===
getAssetProfileIdentifier({ dataSource, symbol })
getAssetProfileIdentifier({
dataSource: holding.dataSource,
symbol: holding.symbol
}) === getAssetProfileIdentifier({ dataSource, symbol })
);
});

20
libs/ui/src/lib/assistant/assistant.html

@ -134,15 +134,17 @@
}}</mat-select-trigger>
<mat-option [value]="null" />
@for (holding of holdings; track holding.name) {
<mat-option class="line-height-1" [value]="holding">
<span class="text-truncate"
><b>{{ holding.name }}</b></span
>
<br />
<small class="text-muted"
>{{ holding.symbol | gfSymbol }} ·
{{ holding.currency }}</small
>
<mat-option [value]="holding">
<div class="line-height-1 text-truncate">
<span
><b>{{ holding.name }}</b></span
>
<br />
<small class="text-muted"
>{{ holding.symbol | gfSymbol }} ·
{{ holding.currency }}</small
>
</div>
</mat-option>
}
</mat-select>

Loading…
Cancel
Save