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. 6
      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') @Get('details')
@UseGuards(AuthGuard('jwt'), HasPermissionGuard) @UseGuards(AuthGuard('jwt'), HasPermissionGuard)
@UseInterceptors(RedactValuesInResponseInterceptor) @UseInterceptors(RedactValuesInResponseInterceptor)
@UseInterceptors(TransformDataSourceInRequestInterceptor)
@UseInterceptors(TransformDataSourceInResponseInterceptor) @UseInterceptors(TransformDataSourceInResponseInterceptor)
public async getDetails( public async getDetails(
@Headers(HEADER_KEY_IMPERSONATION.toLowerCase()) impersonationId: string, @Headers(HEADER_KEY_IMPERSONATION.toLowerCase()) impersonationId: string,
@ -293,6 +294,7 @@ export class PortfolioController {
@Get('dividends') @Get('dividends')
@UseGuards(AuthGuard('jwt'), HasPermissionGuard) @UseGuards(AuthGuard('jwt'), HasPermissionGuard)
@UseInterceptors(TransformDataSourceInRequestInterceptor)
public async getDividends( public async getDividends(
@Headers(HEADER_KEY_IMPERSONATION.toLowerCase()) impersonationId: string, @Headers(HEADER_KEY_IMPERSONATION.toLowerCase()) impersonationId: string,
@Query('accounts') filterByAccounts?: string, @Query('accounts') filterByAccounts?: string,
@ -364,6 +366,7 @@ export class PortfolioController {
@Get('holdings') @Get('holdings')
@UseGuards(AuthGuard('jwt'), HasPermissionGuard) @UseGuards(AuthGuard('jwt'), HasPermissionGuard)
@UseInterceptors(RedactValuesInResponseInterceptor) @UseInterceptors(RedactValuesInResponseInterceptor)
@UseInterceptors(TransformDataSourceInRequestInterceptor)
@UseInterceptors(TransformDataSourceInResponseInterceptor) @UseInterceptors(TransformDataSourceInResponseInterceptor)
public async getHoldings( public async getHoldings(
@Headers(HEADER_KEY_IMPERSONATION.toLowerCase()) impersonationId: string, @Headers(HEADER_KEY_IMPERSONATION.toLowerCase()) impersonationId: string,
@ -398,6 +401,7 @@ export class PortfolioController {
@Get('investments') @Get('investments')
@UseGuards(AuthGuard('jwt'), HasPermissionGuard) @UseGuards(AuthGuard('jwt'), HasPermissionGuard)
@UseInterceptors(TransformDataSourceInRequestInterceptor)
public async getInvestments( public async getInvestments(
@Headers(HEADER_KEY_IMPERSONATION.toLowerCase()) impersonationId: string, @Headers(HEADER_KEY_IMPERSONATION.toLowerCase()) impersonationId: string,
@Query('accounts') filterByAccounts?: string, @Query('accounts') filterByAccounts?: string,
@ -467,6 +471,7 @@ export class PortfolioController {
@Get('performance') @Get('performance')
@UseGuards(AuthGuard('jwt'), HasPermissionGuard) @UseGuards(AuthGuard('jwt'), HasPermissionGuard)
@UseInterceptors(PerformanceLoggingInterceptor) @UseInterceptors(PerformanceLoggingInterceptor)
@UseInterceptors(TransformDataSourceInRequestInterceptor)
@UseInterceptors(TransformDataSourceInResponseInterceptor) @UseInterceptors(TransformDataSourceInResponseInterceptor)
@Version('2') @Version('2')
public async getPerformanceV2( 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) { for (const filter of filters) {
if (filter.type === 'ACCOUNT') { 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') { } 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') { } 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') { } 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') { } 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 { AdminService } from '@ghostfolio/client/services/admin.service';
import { DataService } from '@ghostfolio/client/services/data.service'; import { DataService } from '@ghostfolio/client/services/data.service';
import { getAssetProfileIdentifier } from '@ghostfolio/common/helper'; import { getAssetProfileIdentifier } from '@ghostfolio/common/helper';
import { import { Filter, PortfolioPosition, User } from '@ghostfolio/common/interfaces';
AssetProfileIdentifier,
Filter,
PortfolioPosition,
User
} from '@ghostfolio/common/interfaces';
import { DateRange } from '@ghostfolio/common/types'; import { DateRange } from '@ghostfolio/common/types';
import { translate } from '@ghostfolio/ui/i18n'; 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() { public async initialize() {
this.isLoading = true; this.isLoading = true;
this.keyManager = new FocusKeyManager(this.assistantListItems).withWrap(); 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() { private initializeFilterForm() {
this.dataService this.dataService
.fetchPortfolioHoldings({ .fetchPortfolioHoldings({
@ -528,8 +524,10 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
const symbol = this.user?.settings?.['filters.symbol']; const symbol = this.user?.settings?.['filters.symbol'];
const selectedHolding = this.holdings.find((holding) => { const selectedHolding = this.holdings.find((holding) => {
return ( return (
getAssetProfileIdentifier(holding) === getAssetProfileIdentifier({
getAssetProfileIdentifier({ dataSource, symbol }) dataSource: holding.dataSource,
symbol: holding.symbol
}) === getAssetProfileIdentifier({ dataSource, symbol })
); );
}); });

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

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

Loading…
Cancel
Save