Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
fe4013830d | |||
11be6f630f | |||
85d123e1b1 | |||
c5e9804c25 | |||
1f042ee791 | |||
da6eaa0d77 | |||
3f31cec859 | |||
6c07759eb7 | |||
fcf07a0fd1 | |||
2f402c0c8e | |||
a24a094407 | |||
dc9b2ce194 | |||
72067459d6 | |||
705441ecf8 | |||
fbd1475402 | |||
4dc4f13f40 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -23,6 +23,7 @@
|
|||||||
!.vscode/settings.json
|
!.vscode/settings.json
|
||||||
|
|
||||||
# misc
|
# misc
|
||||||
|
/.angular/cache
|
||||||
/.sass-cache
|
/.sass-cache
|
||||||
/connect.lock
|
/connect.lock
|
||||||
/coverage
|
/coverage
|
||||||
|
47
CHANGELOG.md
47
CHANGELOG.md
@ -5,6 +5,53 @@ 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/),
|
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).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## 1.84.0 - 30.11.2021
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Exposed the data gathering by symbol as an endpoint
|
||||||
|
|
||||||
|
## 1.83.0 - 29.11.2021
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Removed the experimental API
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Eliminated the redundant storage of historical exchange rates
|
||||||
|
|
||||||
|
## 1.82.0 - 28.11.2021
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added tabs with routing to the admin control panel
|
||||||
|
- Added a new tab to manage historical data to the admin control panel
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Introduced tabs with routing to the home page
|
||||||
|
|
||||||
|
## 1.81.0 - 27.11.2021
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added the value to the position detail dialog
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Upgraded `angular` from version `12.2.4` to `13.0.2`
|
||||||
|
- Upgraded `angular-material-css-vars` from version `2.1.2` to `3.0.0`
|
||||||
|
- Upgraded `nestjs` from version `7.6.18` to `8.2.3`
|
||||||
|
- Upgraded `Nx` from version `12.8.0` to `13.2.2`
|
||||||
|
- Upgraded `rxjs` from version `6.6.7` to `7.4.0`
|
||||||
|
- Upgraded `storybook` from version `6.3.8` to `6.4.0-rc.3`
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed the broken line charts showing value labels if openend from the allocations page
|
||||||
|
- Fixed the click event for drafts in the transactions table
|
||||||
|
|
||||||
## 1.80.0 - 23.11.2021
|
## 1.80.0 - 23.11.2021
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
37
angular.json
37
angular.json
@ -1,22 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": 1,
|
"version": 1,
|
||||||
"cli": {
|
|
||||||
"defaultCollection": "@nrwl/nest"
|
|
||||||
},
|
|
||||||
"defaultProject": "api",
|
|
||||||
"schematics": {
|
|
||||||
"@nrwl/angular:application": {
|
|
||||||
"linter": "eslint",
|
|
||||||
"unitTestRunner": "jest",
|
|
||||||
"e2eTestRunner": "cypress"
|
|
||||||
},
|
|
||||||
"@nrwl/angular:library": {
|
|
||||||
"linter": "eslint",
|
|
||||||
"unitTestRunner": "jest"
|
|
||||||
},
|
|
||||||
"@nrwl/nest": {},
|
|
||||||
"@nrwl/angular:component": {}
|
|
||||||
},
|
|
||||||
"projects": {
|
"projects": {
|
||||||
"api": {
|
"api": {
|
||||||
"root": "apps/api",
|
"root": "apps/api",
|
||||||
@ -69,7 +52,8 @@
|
|||||||
},
|
},
|
||||||
"outputs": ["coverage/apps/api"]
|
"outputs": ["coverage/apps/api"]
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"tags": []
|
||||||
},
|
},
|
||||||
"client": {
|
"client": {
|
||||||
"projectType": "application",
|
"projectType": "application",
|
||||||
@ -201,7 +185,8 @@
|
|||||||
},
|
},
|
||||||
"outputs": ["coverage/apps/client"]
|
"outputs": ["coverage/apps/client"]
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"tags": []
|
||||||
},
|
},
|
||||||
"client-e2e": {
|
"client-e2e": {
|
||||||
"root": "apps/client-e2e",
|
"root": "apps/client-e2e",
|
||||||
@ -221,7 +206,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"tags": [],
|
||||||
|
"implicitDependencies": ["client"]
|
||||||
},
|
},
|
||||||
"common": {
|
"common": {
|
||||||
"root": "libs/common",
|
"root": "libs/common",
|
||||||
@ -242,7 +229,8 @@
|
|||||||
"passWithNoTests": true
|
"passWithNoTests": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"tags": []
|
||||||
},
|
},
|
||||||
"ui": {
|
"ui": {
|
||||||
"projectType": "library",
|
"projectType": "library",
|
||||||
@ -300,7 +288,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"tags": []
|
||||||
},
|
},
|
||||||
"ui-e2e": {
|
"ui-e2e": {
|
||||||
"root": "apps/ui-e2e",
|
"root": "apps/ui-e2e",
|
||||||
@ -326,7 +315,9 @@
|
|||||||
"lintFilePatterns": ["apps/ui-e2e/**/*.{js,ts}"]
|
"lintFilePatterns": ["apps/ui-e2e/**/*.{js,ts}"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"tags": [],
|
||||||
|
"implicitDependencies": ["ui"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
import { DataGatheringService } from '@ghostfolio/api/services/data-gathering.service';
|
import { DataGatheringService } from '@ghostfolio/api/services/data-gathering.service';
|
||||||
import { AdminData } from '@ghostfolio/common/interfaces';
|
import {
|
||||||
|
AdminData,
|
||||||
|
AdminMarketData,
|
||||||
|
AdminMarketDataDetails
|
||||||
|
} from '@ghostfolio/common/interfaces';
|
||||||
import {
|
import {
|
||||||
getPermissions,
|
getPermissions,
|
||||||
hasPermission,
|
hasPermission,
|
||||||
@ -11,11 +15,13 @@ import {
|
|||||||
Get,
|
Get,
|
||||||
HttpException,
|
HttpException,
|
||||||
Inject,
|
Inject,
|
||||||
|
Param,
|
||||||
Post,
|
Post,
|
||||||
UseGuards
|
UseGuards
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { REQUEST } from '@nestjs/core';
|
import { REQUEST } from '@nestjs/core';
|
||||||
import { AuthGuard } from '@nestjs/passport';
|
import { AuthGuard } from '@nestjs/passport';
|
||||||
|
import { DataSource } from '@prisma/client';
|
||||||
import { StatusCodes, getReasonPhrase } from 'http-status-codes';
|
import { StatusCodes, getReasonPhrase } from 'http-status-codes';
|
||||||
|
|
||||||
import { AdminService } from './admin.service';
|
import { AdminService } from './admin.service';
|
||||||
@ -67,6 +73,29 @@ export class AdminController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Post('gather/:dataSource/:symbol')
|
||||||
|
@UseGuards(AuthGuard('jwt'))
|
||||||
|
public async gatherSymbol(
|
||||||
|
@Param('dataSource') dataSource: DataSource,
|
||||||
|
@Param('symbol') symbol: string
|
||||||
|
): Promise<void> {
|
||||||
|
if (
|
||||||
|
!hasPermission(
|
||||||
|
getPermissions(this.request.user.role),
|
||||||
|
permissions.accessAdminControl
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
throw new HttpException(
|
||||||
|
getReasonPhrase(StatusCodes.FORBIDDEN),
|
||||||
|
StatusCodes.FORBIDDEN
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.dataGatheringService.gatherSymbol({ dataSource, symbol });
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
@Post('gather/profile-data')
|
@Post('gather/profile-data')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
@UseGuards(AuthGuard('jwt'))
|
||||||
public async gatherProfileData(): Promise<void> {
|
public async gatherProfileData(): Promise<void> {
|
||||||
@ -86,4 +115,42 @@ export class AdminController {
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get('market-data')
|
||||||
|
@UseGuards(AuthGuard('jwt'))
|
||||||
|
public async getMarketData(): Promise<AdminMarketData> {
|
||||||
|
if (
|
||||||
|
!hasPermission(
|
||||||
|
getPermissions(this.request.user.role),
|
||||||
|
permissions.accessAdminControl
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
throw new HttpException(
|
||||||
|
getReasonPhrase(StatusCodes.FORBIDDEN),
|
||||||
|
StatusCodes.FORBIDDEN
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.adminService.getMarketData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('market-data/:symbol')
|
||||||
|
@UseGuards(AuthGuard('jwt'))
|
||||||
|
public async getMarketDataBySymbol(
|
||||||
|
@Param('symbol') symbol
|
||||||
|
): Promise<AdminMarketDataDetails> {
|
||||||
|
if (
|
||||||
|
!hasPermission(
|
||||||
|
getPermissions(this.request.user.role),
|
||||||
|
permissions.accessAdminControl
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
throw new HttpException(
|
||||||
|
getReasonPhrase(StatusCodes.FORBIDDEN),
|
||||||
|
StatusCodes.FORBIDDEN
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.adminService.getMarketDataBySymbol(symbol);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ import { ConfigurationModule } from '@ghostfolio/api/services/configuration.modu
|
|||||||
import { DataGatheringModule } from '@ghostfolio/api/services/data-gathering.module';
|
import { DataGatheringModule } from '@ghostfolio/api/services/data-gathering.module';
|
||||||
import { DataProviderModule } from '@ghostfolio/api/services/data-provider/data-provider.module';
|
import { DataProviderModule } from '@ghostfolio/api/services/data-provider/data-provider.module';
|
||||||
import { ExchangeRateDataModule } from '@ghostfolio/api/services/exchange-rate-data.module';
|
import { ExchangeRateDataModule } from '@ghostfolio/api/services/exchange-rate-data.module';
|
||||||
|
import { MarketDataModule } from '@ghostfolio/api/services/market-data.module';
|
||||||
import { PrismaModule } from '@ghostfolio/api/services/prisma.module';
|
import { PrismaModule } from '@ghostfolio/api/services/prisma.module';
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
|
|
||||||
@ -15,6 +16,7 @@ import { AdminService } from './admin.service';
|
|||||||
DataGatheringModule,
|
DataGatheringModule,
|
||||||
DataProviderModule,
|
DataProviderModule,
|
||||||
ExchangeRateDataModule,
|
ExchangeRateDataModule,
|
||||||
|
MarketDataModule,
|
||||||
PrismaModule,
|
PrismaModule,
|
||||||
SubscriptionModule
|
SubscriptionModule
|
||||||
],
|
],
|
||||||
|
@ -2,9 +2,14 @@ import { SubscriptionService } from '@ghostfolio/api/app/subscription/subscripti
|
|||||||
import { ConfigurationService } from '@ghostfolio/api/services/configuration.service';
|
import { ConfigurationService } from '@ghostfolio/api/services/configuration.service';
|
||||||
import { DataGatheringService } from '@ghostfolio/api/services/data-gathering.service';
|
import { DataGatheringService } from '@ghostfolio/api/services/data-gathering.service';
|
||||||
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data.service';
|
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data.service';
|
||||||
|
import { MarketDataService } from '@ghostfolio/api/services/market-data.service';
|
||||||
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
||||||
import { baseCurrency } from '@ghostfolio/common/config';
|
import { baseCurrency } from '@ghostfolio/common/config';
|
||||||
import { AdminData } from '@ghostfolio/common/interfaces';
|
import {
|
||||||
|
AdminData,
|
||||||
|
AdminMarketData,
|
||||||
|
AdminMarketDataDetails
|
||||||
|
} from '@ghostfolio/common/interfaces';
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { differenceInDays } from 'date-fns';
|
import { differenceInDays } from 'date-fns';
|
||||||
|
|
||||||
@ -14,6 +19,7 @@ export class AdminService {
|
|||||||
private readonly configurationService: ConfigurationService,
|
private readonly configurationService: ConfigurationService,
|
||||||
private readonly dataGatheringService: DataGatheringService,
|
private readonly dataGatheringService: DataGatheringService,
|
||||||
private readonly exchangeRateDataService: ExchangeRateDataService,
|
private readonly exchangeRateDataService: ExchangeRateDataService,
|
||||||
|
private readonly marketDataService: MarketDataService,
|
||||||
private readonly prismaService: PrismaService,
|
private readonly prismaService: PrismaService,
|
||||||
private readonly subscriptionService: SubscriptionService
|
private readonly subscriptionService: SubscriptionService
|
||||||
) {}
|
) {}
|
||||||
@ -45,6 +51,31 @@ export class AdminService {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async getMarketData(): Promise<AdminMarketData> {
|
||||||
|
return {
|
||||||
|
marketData: await (
|
||||||
|
await this.dataGatheringService.getSymbolsMax()
|
||||||
|
).map((symbol) => {
|
||||||
|
return symbol;
|
||||||
|
})
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getMarketDataBySymbol(
|
||||||
|
aSymbol: string
|
||||||
|
): Promise<AdminMarketDataDetails> {
|
||||||
|
return {
|
||||||
|
marketData: await this.marketDataService.marketDataItems({
|
||||||
|
orderBy: {
|
||||||
|
date: 'asc'
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
symbol: aSymbol
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private async getLastDataGathering() {
|
private async getLastDataGathering() {
|
||||||
const lastDataGathering =
|
const lastDataGathering =
|
||||||
await this.dataGatheringService.getLastDataGathering();
|
await this.dataGatheringService.getLastDataGathering();
|
||||||
|
@ -19,7 +19,6 @@ import { AdminModule } from './admin/admin.module';
|
|||||||
import { AppController } from './app.controller';
|
import { AppController } from './app.controller';
|
||||||
import { AuthModule } from './auth/auth.module';
|
import { AuthModule } from './auth/auth.module';
|
||||||
import { CacheModule } from './cache/cache.module';
|
import { CacheModule } from './cache/cache.module';
|
||||||
import { ExperimentalModule } from './experimental/experimental.module';
|
|
||||||
import { ExportModule } from './export/export.module';
|
import { ExportModule } from './export/export.module';
|
||||||
import { ImportModule } from './import/import.module';
|
import { ImportModule } from './import/import.module';
|
||||||
import { InfoModule } from './info/info.module';
|
import { InfoModule } from './info/info.module';
|
||||||
@ -42,7 +41,6 @@ import { UserModule } from './user/user.module';
|
|||||||
DataGatheringModule,
|
DataGatheringModule,
|
||||||
DataProviderModule,
|
DataProviderModule,
|
||||||
ExchangeRateDataModule,
|
ExchangeRateDataModule,
|
||||||
ExperimentalModule,
|
|
||||||
ExportModule,
|
ExportModule,
|
||||||
ImportModule,
|
ImportModule,
|
||||||
InfoModule,
|
InfoModule,
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
import { Type } from '@prisma/client';
|
|
||||||
import { IsISO8601, IsNumber, IsString } from 'class-validator';
|
|
||||||
|
|
||||||
export class CreateOrderDto {
|
|
||||||
@IsString()
|
|
||||||
currency: string;
|
|
||||||
|
|
||||||
@IsISO8601()
|
|
||||||
date: string;
|
|
||||||
|
|
||||||
@IsNumber()
|
|
||||||
quantity: number;
|
|
||||||
|
|
||||||
@IsString()
|
|
||||||
symbol: string;
|
|
||||||
|
|
||||||
@IsString()
|
|
||||||
type: Type;
|
|
||||||
|
|
||||||
@IsNumber()
|
|
||||||
unitPrice: number;
|
|
||||||
}
|
|
@ -1,69 +0,0 @@
|
|||||||
import { baseCurrency, benchmarks } from '@ghostfolio/common/config';
|
|
||||||
import { DATE_FORMAT } from '@ghostfolio/common/helper';
|
|
||||||
import { isApiTokenAuthorized } from '@ghostfolio/common/permissions';
|
|
||||||
import type { RequestWithUser } from '@ghostfolio/common/types';
|
|
||||||
import {
|
|
||||||
Body,
|
|
||||||
Controller,
|
|
||||||
Get,
|
|
||||||
Headers,
|
|
||||||
HttpException,
|
|
||||||
Inject,
|
|
||||||
Param,
|
|
||||||
Post
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { REQUEST } from '@nestjs/core';
|
|
||||||
import { parse } from 'date-fns';
|
|
||||||
import { StatusCodes, getReasonPhrase } from 'http-status-codes';
|
|
||||||
|
|
||||||
import { CreateOrderDto } from './create-order.dto';
|
|
||||||
import { ExperimentalService } from './experimental.service';
|
|
||||||
import { Data } from './interfaces/data.interface';
|
|
||||||
|
|
||||||
@Controller('experimental')
|
|
||||||
export class ExperimentalController {
|
|
||||||
public constructor(
|
|
||||||
private readonly experimentalService: ExperimentalService,
|
|
||||||
@Inject(REQUEST) private readonly request: RequestWithUser
|
|
||||||
) {}
|
|
||||||
|
|
||||||
@Get('benchmarks')
|
|
||||||
public async getBenchmarks(
|
|
||||||
@Headers('Authorization') apiToken: string
|
|
||||||
): Promise<string[]> {
|
|
||||||
if (!isApiTokenAuthorized(apiToken)) {
|
|
||||||
throw new HttpException(
|
|
||||||
getReasonPhrase(StatusCodes.FORBIDDEN),
|
|
||||||
StatusCodes.FORBIDDEN
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return benchmarks.map(({ symbol }) => {
|
|
||||||
return symbol;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Get('benchmarks/:symbol')
|
|
||||||
public async getBenchmark(
|
|
||||||
@Headers('Authorization') apiToken: string,
|
|
||||||
@Param('symbol') symbol: string
|
|
||||||
): Promise<{ date: Date; marketPrice: number }[]> {
|
|
||||||
if (!isApiTokenAuthorized(apiToken)) {
|
|
||||||
throw new HttpException(
|
|
||||||
getReasonPhrase(StatusCodes.FORBIDDEN),
|
|
||||||
StatusCodes.FORBIDDEN
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const marketData = await this.experimentalService.getBenchmark(symbol);
|
|
||||||
|
|
||||||
if (marketData?.length === 0) {
|
|
||||||
throw new HttpException(
|
|
||||||
getReasonPhrase(StatusCodes.NOT_FOUND),
|
|
||||||
StatusCodes.NOT_FOUND
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return marketData;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
import { AccountService } from '@ghostfolio/api/app/account/account.service';
|
|
||||||
import { RedisCacheModule } from '@ghostfolio/api/app/redis-cache/redis-cache.module';
|
|
||||||
import { ConfigurationModule } from '@ghostfolio/api/services/configuration.module';
|
|
||||||
import { DataProviderModule } from '@ghostfolio/api/services/data-provider/data-provider.module';
|
|
||||||
import { ExchangeRateDataModule } from '@ghostfolio/api/services/exchange-rate-data.module';
|
|
||||||
import { PrismaModule } from '@ghostfolio/api/services/prisma.module';
|
|
||||||
import { Module } from '@nestjs/common';
|
|
||||||
|
|
||||||
import { ExperimentalController } from './experimental.controller';
|
|
||||||
import { ExperimentalService } from './experimental.service';
|
|
||||||
|
|
||||||
@Module({
|
|
||||||
imports: [
|
|
||||||
ConfigurationModule,
|
|
||||||
DataProviderModule,
|
|
||||||
ExchangeRateDataModule,
|
|
||||||
RedisCacheModule,
|
|
||||||
PrismaModule
|
|
||||||
],
|
|
||||||
controllers: [ExperimentalController],
|
|
||||||
providers: [AccountService, ExperimentalService]
|
|
||||||
})
|
|
||||||
export class ExperimentalModule {}
|
|
@ -1,23 +0,0 @@
|
|||||||
import { AccountService } from '@ghostfolio/api/app/account/account.service';
|
|
||||||
import { DataProviderService } from '@ghostfolio/api/services/data-provider/data-provider.service';
|
|
||||||
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data.service';
|
|
||||||
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class ExperimentalService {
|
|
||||||
public constructor(
|
|
||||||
private readonly accountService: AccountService,
|
|
||||||
private readonly dataProviderService: DataProviderService,
|
|
||||||
private readonly exchangeRateDataService: ExchangeRateDataService,
|
|
||||||
private readonly prismaService: PrismaService
|
|
||||||
) {}
|
|
||||||
|
|
||||||
public async getBenchmark(aSymbol: string) {
|
|
||||||
return this.prismaService.marketData.findMany({
|
|
||||||
orderBy: { date: 'asc' },
|
|
||||||
select: { date: true, marketPrice: true },
|
|
||||||
where: { symbol: aSymbol }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
export interface Data {
|
|
||||||
currency: string;
|
|
||||||
value: number;
|
|
||||||
}
|
|
@ -1,11 +1,11 @@
|
|||||||
import { DataProviderService } from '@ghostfolio/api/services/data-provider/data-provider.service';
|
import { DataProviderService } from '@ghostfolio/api/services/data-provider/data-provider.service';
|
||||||
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data.service';
|
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data.service';
|
||||||
|
import { MarketDataService } from '@ghostfolio/api/services/market-data.service';
|
||||||
import { DataSource, MarketData } from '@prisma/client';
|
import { DataSource, MarketData } from '@prisma/client';
|
||||||
|
|
||||||
import { CurrentRateService } from './current-rate.service';
|
import { CurrentRateService } from './current-rate.service';
|
||||||
import { MarketDataService } from './market-data.service';
|
|
||||||
|
|
||||||
jest.mock('./market-data.service', () => {
|
jest.mock('@ghostfolio/api/services/market-data.service', () => {
|
||||||
return {
|
return {
|
||||||
MarketDataService: jest.fn().mockImplementation(() => {
|
MarketDataService: jest.fn().mockImplementation(() => {
|
||||||
return {
|
return {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { DataProviderService } from '@ghostfolio/api/services/data-provider/data-provider.service';
|
import { DataProviderService } from '@ghostfolio/api/services/data-provider/data-provider.service';
|
||||||
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data.service';
|
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data.service';
|
||||||
|
import { MarketDataService } from '@ghostfolio/api/services/market-data.service';
|
||||||
import { resetHours } from '@ghostfolio/common/helper';
|
import { resetHours } from '@ghostfolio/common/helper';
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { isBefore, isToday } from 'date-fns';
|
import { isBefore, isToday } from 'date-fns';
|
||||||
@ -8,7 +9,6 @@ import { flatten } from 'lodash';
|
|||||||
import { GetValueObject } from './interfaces/get-value-object.interface';
|
import { GetValueObject } from './interfaces/get-value-object.interface';
|
||||||
import { GetValueParams } from './interfaces/get-value-params.interface';
|
import { GetValueParams } from './interfaces/get-value-params.interface';
|
||||||
import { GetValuesParams } from './interfaces/get-values-params.interface';
|
import { GetValuesParams } from './interfaces/get-values-params.interface';
|
||||||
import { MarketDataService } from './market-data.service';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CurrentRateService {
|
export class CurrentRateService {
|
||||||
|
@ -19,6 +19,7 @@ export interface PortfolioPositionDetail {
|
|||||||
quantity: number;
|
quantity: number;
|
||||||
symbol: string;
|
symbol: string;
|
||||||
transactionCount: number;
|
transactionCount: number;
|
||||||
|
value: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface HistoricalDataContainer {
|
export interface HistoricalDataContainer {
|
||||||
|
@ -516,7 +516,7 @@ export class PortfolioCalculator {
|
|||||||
);
|
);
|
||||||
} else if (!currentPosition.quantity.eq(0)) {
|
} else if (!currentPosition.quantity.eq(0)) {
|
||||||
Logger.error(
|
Logger.error(
|
||||||
`Initial value is missing for symbol ${currentPosition.symbol}`
|
`Missing initial value for symbol ${currentPosition.symbol} at ${currentPosition.firstBuyDate}`
|
||||||
);
|
);
|
||||||
hasErrors = true;
|
hasErrors = true;
|
||||||
}
|
}
|
||||||
|
@ -370,7 +370,8 @@ export class PortfolioController {
|
|||||||
'grossPerformance',
|
'grossPerformance',
|
||||||
'investment',
|
'investment',
|
||||||
'netPerformance',
|
'netPerformance',
|
||||||
'quantity'
|
'quantity',
|
||||||
|
'value'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,12 +7,12 @@ import { DataGatheringModule } from '@ghostfolio/api/services/data-gathering.mod
|
|||||||
import { DataProviderModule } from '@ghostfolio/api/services/data-provider/data-provider.module';
|
import { DataProviderModule } from '@ghostfolio/api/services/data-provider/data-provider.module';
|
||||||
import { ExchangeRateDataModule } from '@ghostfolio/api/services/exchange-rate-data.module';
|
import { ExchangeRateDataModule } from '@ghostfolio/api/services/exchange-rate-data.module';
|
||||||
import { ImpersonationModule } from '@ghostfolio/api/services/impersonation.module';
|
import { ImpersonationModule } from '@ghostfolio/api/services/impersonation.module';
|
||||||
|
import { MarketDataModule } from '@ghostfolio/api/services/market-data.module';
|
||||||
import { PrismaModule } from '@ghostfolio/api/services/prisma.module';
|
import { PrismaModule } from '@ghostfolio/api/services/prisma.module';
|
||||||
import { SymbolProfileModule } from '@ghostfolio/api/services/symbol-profile.module';
|
import { SymbolProfileModule } from '@ghostfolio/api/services/symbol-profile.module';
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
|
|
||||||
import { CurrentRateService } from './current-rate.service';
|
import { CurrentRateService } from './current-rate.service';
|
||||||
import { MarketDataService } from './market-data.service';
|
|
||||||
import { PortfolioController } from './portfolio.controller';
|
import { PortfolioController } from './portfolio.controller';
|
||||||
import { PortfolioService } from './portfolio.service';
|
import { PortfolioService } from './portfolio.service';
|
||||||
import { RulesService } from './rules.service';
|
import { RulesService } from './rules.service';
|
||||||
@ -26,6 +26,7 @@ import { RulesService } from './rules.service';
|
|||||||
DataProviderModule,
|
DataProviderModule,
|
||||||
ExchangeRateDataModule,
|
ExchangeRateDataModule,
|
||||||
ImpersonationModule,
|
ImpersonationModule,
|
||||||
|
MarketDataModule,
|
||||||
OrderModule,
|
OrderModule,
|
||||||
PrismaModule,
|
PrismaModule,
|
||||||
SymbolProfileModule,
|
SymbolProfileModule,
|
||||||
@ -35,7 +36,6 @@ import { RulesService } from './rules.service';
|
|||||||
providers: [
|
providers: [
|
||||||
AccountService,
|
AccountService,
|
||||||
CurrentRateService,
|
CurrentRateService,
|
||||||
MarketDataService,
|
|
||||||
PortfolioService,
|
PortfolioService,
|
||||||
RulesService
|
RulesService
|
||||||
]
|
]
|
||||||
|
@ -391,7 +391,8 @@ export class PortfolioService {
|
|||||||
netPerformancePercent: undefined,
|
netPerformancePercent: undefined,
|
||||||
quantity: undefined,
|
quantity: undefined,
|
||||||
symbol: aSymbol,
|
symbol: aSymbol,
|
||||||
transactionCount: undefined
|
transactionCount: undefined,
|
||||||
|
value: undefined
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -527,7 +528,12 @@ export class PortfolioService {
|
|||||||
historicalData: historicalDataArray,
|
historicalData: historicalDataArray,
|
||||||
netPerformancePercent: position.netPerformancePercentage.toNumber(),
|
netPerformancePercent: position.netPerformancePercentage.toNumber(),
|
||||||
quantity: quantity.toNumber(),
|
quantity: quantity.toNumber(),
|
||||||
symbol: aSymbol
|
symbol: aSymbol,
|
||||||
|
value: this.exchangeRateDataService.toCurrency(
|
||||||
|
quantity.mul(marketPrice).toNumber(),
|
||||||
|
currency,
|
||||||
|
userCurrency
|
||||||
|
)
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
const currentData = await this.dataProviderService.get([
|
const currentData = await this.dataProviderService.get([
|
||||||
@ -584,7 +590,8 @@ export class PortfolioService {
|
|||||||
netPerformancePercent: undefined,
|
netPerformancePercent: undefined,
|
||||||
quantity: 0,
|
quantity: 0,
|
||||||
symbol: aSymbol,
|
symbol: aSymbol,
|
||||||
transactionCount: undefined
|
transactionCount: undefined,
|
||||||
|
value: 0
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,22 +20,20 @@ async function bootstrap() {
|
|||||||
const port = process.env.PORT || 3333;
|
const port = process.env.PORT || 3333;
|
||||||
await app.listen(port, () => {
|
await app.listen(port, () => {
|
||||||
logLogo();
|
logLogo();
|
||||||
Logger.log(`Listening at http://localhost:${port}`, '', false);
|
Logger.log(`Listening at http://localhost:${port}`);
|
||||||
Logger.log('', '', false);
|
Logger.log('');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function logLogo() {
|
function logLogo() {
|
||||||
Logger.log(' ________ __ ____ ___', '', false);
|
Logger.log(' ________ __ ____ ___');
|
||||||
Logger.log(' / ____/ /_ ____ _____/ /_/ __/___ / (_)___', '', false);
|
Logger.log(' / ____/ /_ ____ _____/ /_/ __/___ / (_)___');
|
||||||
Logger.log(' / / __/ __ \\/ __ \\/ ___/ __/ /_/ __ \\/ / / __ \\', '', false);
|
Logger.log(' / / __/ __ \\/ __ \\/ ___/ __/ /_/ __ \\/ / / __ \\');
|
||||||
Logger.log('/ /_/ / / / / /_/ (__ ) /_/ __/ /_/ / / / /_/ /', '', false);
|
Logger.log('/ /_/ / / / / /_/ (__ ) /_/ __/ /_/ / / / /_/ /');
|
||||||
Logger.log(
|
Logger.log(
|
||||||
`\\____/_/ /_/\\____/____/\\__/_/ \\____/_/_/\\____/ ${environment.version}`,
|
`\\____/_/ /_/\\____/____/\\__/_/ \\____/_/_/\\____/ ${environment.version}`
|
||||||
'',
|
|
||||||
false
|
|
||||||
);
|
);
|
||||||
Logger.log('', '', false);
|
Logger.log('');
|
||||||
}
|
}
|
||||||
|
|
||||||
bootstrap();
|
bootstrap();
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
import { SymbolProfileService } from '@ghostfolio/api/services/symbol-profile.service';
|
import { SymbolProfileService } from '@ghostfolio/api/services/symbol-profile.service';
|
||||||
import {
|
import { ghostfolioFearAndGreedIndexSymbol } from '@ghostfolio/common/config';
|
||||||
benchmarks,
|
|
||||||
ghostfolioFearAndGreedIndexSymbol
|
|
||||||
} from '@ghostfolio/common/config';
|
|
||||||
import { DATE_FORMAT, resetHours } from '@ghostfolio/common/helper';
|
import { DATE_FORMAT, resetHours } from '@ghostfolio/common/helper';
|
||||||
import { Inject, Injectable, Logger } from '@nestjs/common';
|
import { Inject, Injectable, Logger } from '@nestjs/common';
|
||||||
import { DataSource } from '@prisma/client';
|
import { DataSource } from '@prisma/client';
|
||||||
@ -123,6 +120,63 @@ export class DataGatheringService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async gatherSymbol({
|
||||||
|
dataSource,
|
||||||
|
symbol
|
||||||
|
}: {
|
||||||
|
dataSource: DataSource;
|
||||||
|
symbol: string;
|
||||||
|
}) {
|
||||||
|
const isDataGatheringLocked = await this.prismaService.property.findUnique({
|
||||||
|
where: { key: 'LOCKED_DATA_GATHERING' }
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!isDataGatheringLocked) {
|
||||||
|
Logger.log(`Symbol data gathering for ${symbol} has been started.`);
|
||||||
|
console.time('data-gathering-symbol');
|
||||||
|
|
||||||
|
await this.prismaService.property.create({
|
||||||
|
data: {
|
||||||
|
key: 'LOCKED_DATA_GATHERING',
|
||||||
|
value: new Date().toISOString()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const symbols = (await this.getSymbolsMax()).filter(
|
||||||
|
(dataGatheringItem) => {
|
||||||
|
return (
|
||||||
|
dataGatheringItem.dataSource === dataSource &&
|
||||||
|
dataGatheringItem.symbol === symbol
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await this.gatherSymbols(symbols);
|
||||||
|
|
||||||
|
await this.prismaService.property.upsert({
|
||||||
|
create: {
|
||||||
|
key: 'LAST_DATA_GATHERING',
|
||||||
|
value: new Date().toISOString()
|
||||||
|
},
|
||||||
|
update: { value: new Date().toISOString() },
|
||||||
|
where: { key: 'LAST_DATA_GATHERING' }
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
Logger.error(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.prismaService.property.delete({
|
||||||
|
where: {
|
||||||
|
key: 'LOCKED_DATA_GATHERING'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Logger.log(`Symbol data gathering for ${symbol} has been completed.`);
|
||||||
|
console.timeEnd('data-gathering-symbol');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async gatherProfileData(aDataGatheringItems?: IDataGatheringItem[]) {
|
public async gatherProfileData(aDataGatheringItems?: IDataGatheringItem[]) {
|
||||||
Logger.log('Profile data gathering has been started.');
|
Logger.log('Profile data gathering has been started.');
|
||||||
console.time('data-gathering-profile');
|
console.time('data-gathering-profile');
|
||||||
@ -313,6 +367,52 @@ export class DataGatheringService {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async getSymbolsMax(): Promise<IDataGatheringItem[]> {
|
||||||
|
const startDate =
|
||||||
|
(
|
||||||
|
await this.prismaService.order.findFirst({
|
||||||
|
orderBy: [{ date: 'asc' }]
|
||||||
|
})
|
||||||
|
)?.date ?? new Date();
|
||||||
|
|
||||||
|
const currencyPairsToGather = this.exchangeRateDataService
|
||||||
|
.getCurrencyPairs()
|
||||||
|
.map(({ dataSource, symbol }) => {
|
||||||
|
return {
|
||||||
|
dataSource,
|
||||||
|
symbol,
|
||||||
|
date: startDate
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const symbolProfilesToGather = (
|
||||||
|
await this.prismaService.symbolProfile.findMany({
|
||||||
|
orderBy: [{ symbol: 'asc' }],
|
||||||
|
select: {
|
||||||
|
dataSource: true,
|
||||||
|
Order: {
|
||||||
|
orderBy: [{ date: 'asc' }],
|
||||||
|
select: { date: true },
|
||||||
|
take: 1
|
||||||
|
},
|
||||||
|
scraperConfiguration: true,
|
||||||
|
symbol: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
).map((symbolProfile) => {
|
||||||
|
return {
|
||||||
|
...symbolProfile,
|
||||||
|
date: symbolProfile.Order?.[0]?.date ?? startDate
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return [
|
||||||
|
...this.getBenchmarksToGather(startDate),
|
||||||
|
...currencyPairsToGather,
|
||||||
|
...symbolProfilesToGather
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
public async reset() {
|
public async reset() {
|
||||||
Logger.log('Data gathering has been reset.');
|
Logger.log('Data gathering has been reset.');
|
||||||
|
|
||||||
@ -324,13 +424,7 @@ export class DataGatheringService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getBenchmarksToGather(startDate: Date): IDataGatheringItem[] {
|
private getBenchmarksToGather(startDate: Date): IDataGatheringItem[] {
|
||||||
const benchmarksToGather = benchmarks.map(({ dataSource, symbol }) => {
|
const benchmarksToGather: IDataGatheringItem[] = [];
|
||||||
return {
|
|
||||||
dataSource,
|
|
||||||
symbol,
|
|
||||||
date: startDate
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
if (this.configurationService.get('ENABLE_FEATURE_FEAR_AND_GREED_INDEX')) {
|
if (this.configurationService.get('ENABLE_FEATURE_FEAR_AND_GREED_INDEX')) {
|
||||||
benchmarksToGather.push({
|
benchmarksToGather.push({
|
||||||
@ -379,52 +473,6 @@ export class DataGatheringService {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getSymbolsMax(): Promise<IDataGatheringItem[]> {
|
|
||||||
const startDate =
|
|
||||||
(
|
|
||||||
await this.prismaService.order.findFirst({
|
|
||||||
orderBy: [{ date: 'asc' }]
|
|
||||||
})
|
|
||||||
)?.date ?? new Date();
|
|
||||||
|
|
||||||
const currencyPairsToGather = this.exchangeRateDataService
|
|
||||||
.getCurrencyPairs()
|
|
||||||
.map(({ dataSource, symbol }) => {
|
|
||||||
return {
|
|
||||||
dataSource,
|
|
||||||
symbol,
|
|
||||||
date: startDate
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const symbolProfilesToGather = (
|
|
||||||
await this.prismaService.symbolProfile.findMany({
|
|
||||||
orderBy: [{ symbol: 'asc' }],
|
|
||||||
select: {
|
|
||||||
dataSource: true,
|
|
||||||
Order: {
|
|
||||||
orderBy: [{ date: 'asc' }],
|
|
||||||
select: { date: true },
|
|
||||||
take: 1
|
|
||||||
},
|
|
||||||
scraperConfiguration: true,
|
|
||||||
symbol: true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
).map((symbolProfile) => {
|
|
||||||
return {
|
|
||||||
...symbolProfile,
|
|
||||||
date: symbolProfile.Order?.[0]?.date ?? startDate
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
return [
|
|
||||||
...this.getBenchmarksToGather(startDate),
|
|
||||||
...currencyPairsToGather,
|
|
||||||
...symbolProfilesToGather
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
private async getSymbolsProfileData(): Promise<IDataGatheringItem[]> {
|
private async getSymbolsProfileData(): Promise<IDataGatheringItem[]> {
|
||||||
const startDate = subDays(resetHours(new Date()), 7);
|
const startDate = subDays(resetHours(new Date()), 7);
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { baseCurrency } from '@ghostfolio/common/config';
|
import { baseCurrency } from '@ghostfolio/common/config';
|
||||||
import { DATE_FORMAT, getYesterday } from '@ghostfolio/common/helper';
|
import { DATE_FORMAT, getYesterday } from '@ghostfolio/common/helper';
|
||||||
import { Injectable, Logger } from '@nestjs/common';
|
import { Injectable, Logger } from '@nestjs/common';
|
||||||
import { DataSource } from '@prisma/client';
|
|
||||||
import { format } from 'date-fns';
|
import { format } from 'date-fns';
|
||||||
import { isEmpty, isNumber, uniq } from 'lodash';
|
import { isEmpty, isNumber, uniq } from 'lodash';
|
||||||
|
|
||||||
@ -40,7 +39,10 @@ export class ExchangeRateDataService {
|
|||||||
currency2,
|
currency2,
|
||||||
dataSource
|
dataSource
|
||||||
} of this.prepareCurrencyPairs(this.currencies)) {
|
} of this.prepareCurrencyPairs(this.currencies)) {
|
||||||
this.addCurrencyPairs({ currency1, currency2, dataSource });
|
this.currencyPairs.push({
|
||||||
|
dataSource,
|
||||||
|
symbol: `${currency1}${currency2}`
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.loadCurrencies();
|
await this.loadCurrencies();
|
||||||
@ -86,7 +88,7 @@ export class ExchangeRateDataService {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
this.currencyPairs.forEach(({ symbol }) => {
|
Object.keys(resultExtended).forEach((symbol) => {
|
||||||
const [currency1, currency2] = symbol.match(/.{1,3}/g);
|
const [currency1, currency2] = symbol.match(/.{1,3}/g);
|
||||||
const date = format(getYesterday(), DATE_FORMAT);
|
const date = format(getYesterday(), DATE_FORMAT);
|
||||||
|
|
||||||
@ -146,25 +148,6 @@ export class ExchangeRateDataService {
|
|||||||
return aValue;
|
return aValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private addCurrencyPairs({
|
|
||||||
currency1,
|
|
||||||
currency2,
|
|
||||||
dataSource
|
|
||||||
}: {
|
|
||||||
currency1: string;
|
|
||||||
currency2: string;
|
|
||||||
dataSource: DataSource;
|
|
||||||
}) {
|
|
||||||
this.currencyPairs.push({
|
|
||||||
dataSource,
|
|
||||||
symbol: `${currency1}${currency2}`
|
|
||||||
});
|
|
||||||
this.currencyPairs.push({
|
|
||||||
dataSource,
|
|
||||||
symbol: `${currency2}${currency1}`
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private async prepareCurrencies(): Promise<string[]> {
|
private async prepareCurrencies(): Promise<string[]> {
|
||||||
const currencies: string[] = [];
|
const currencies: string[] = [];
|
||||||
|
|
||||||
|
11
apps/api/src/services/market-data.module.ts
Normal file
11
apps/api/src/services/market-data.module.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { PrismaModule } from '@ghostfolio/api/services/prisma.module';
|
||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
|
||||||
|
import { MarketDataService } from './market-data.service';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
exports: [MarketDataService],
|
||||||
|
imports: [PrismaModule],
|
||||||
|
providers: [MarketDataService]
|
||||||
|
})
|
||||||
|
export class MarketDataModule {}
|
@ -1,9 +1,8 @@
|
|||||||
|
import { DateQuery } from '@ghostfolio/api/app/portfolio/interfaces/date-query.interface';
|
||||||
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
||||||
import { resetHours } from '@ghostfolio/common/helper';
|
import { resetHours } from '@ghostfolio/common/helper';
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { MarketData } from '@prisma/client';
|
import { MarketData, Prisma } from '@prisma/client';
|
||||||
|
|
||||||
import { DateQuery } from './interfaces/date-query.interface';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class MarketDataService {
|
export class MarketDataService {
|
||||||
@ -48,4 +47,22 @@ export class MarketDataService {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async marketDataItems(params: {
|
||||||
|
skip?: number;
|
||||||
|
take?: number;
|
||||||
|
cursor?: Prisma.MarketDataWhereUniqueInput;
|
||||||
|
where?: Prisma.MarketDataWhereInput;
|
||||||
|
orderBy?: Prisma.MarketDataOrderByInput;
|
||||||
|
}): Promise<MarketData[]> {
|
||||||
|
const { skip, take, cursor, where, orderBy } = params;
|
||||||
|
|
||||||
|
return this.prismaService.marketData.findMany({
|
||||||
|
cursor,
|
||||||
|
orderBy,
|
||||||
|
skip,
|
||||||
|
take,
|
||||||
|
where
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
@ -6,6 +6,6 @@
|
|||||||
"emitDecoratorMetadata": true,
|
"emitDecoratorMetadata": true,
|
||||||
"target": "es2015"
|
"target": "es2015"
|
||||||
},
|
},
|
||||||
"exclude": ["**/*.spec.ts"],
|
"exclude": ["**/*.spec.ts", "**/*.test.ts"],
|
||||||
"include": ["**/*.ts"]
|
"include": ["**/*.ts"]
|
||||||
}
|
}
|
||||||
|
@ -5,5 +5,5 @@
|
|||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"types": ["jest", "node"]
|
"types": ["jest", "node"]
|
||||||
},
|
},
|
||||||
"include": ["**/*.spec.ts", "**/*.d.ts"]
|
"include": ["**/*.spec.ts", "**/*.test.ts", "**/*.d.ts"]
|
||||||
}
|
}
|
||||||
|
@ -14,5 +14,8 @@ module.exports = {
|
|||||||
'jest-preset-angular/build/serializers/ng-snapshot',
|
'jest-preset-angular/build/serializers/ng-snapshot',
|
||||||
'jest-preset-angular/build/serializers/html-comment'
|
'jest-preset-angular/build/serializers/html-comment'
|
||||||
],
|
],
|
||||||
transform: { '^.+\\.(ts|js|html)$': 'jest-preset-angular' }
|
transform: {
|
||||||
|
'^.+.(ts|mjs|js|html)$': 'jest-preset-angular'
|
||||||
|
},
|
||||||
|
transformIgnorePatterns: ['node_modules/(?!.*.mjs$)']
|
||||||
};
|
};
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
<div class="py-2">
|
||||||
|
<div *ngFor="let itemByMonth of marketDataByMonth | keyvalue" class="d-flex">
|
||||||
|
<div class="date px-1 text-nowrap">{{ itemByMonth.key }}</div>
|
||||||
|
<div class="align-items-center d-flex flex-grow-1 px-1">
|
||||||
|
<div
|
||||||
|
*ngFor="let dayItem of days; let i = index"
|
||||||
|
class="day"
|
||||||
|
[title]="
|
||||||
|
(marketDataByMonth[itemByMonth.key][i + 1]?.date
|
||||||
|
| date: defaultDateFormat) ?? ''
|
||||||
|
"
|
||||||
|
[ngClass]="{
|
||||||
|
'available cursor-pointer':
|
||||||
|
marketDataByMonth[itemByMonth.key][i + 1]?.day == i + 1
|
||||||
|
}"
|
||||||
|
(click)="
|
||||||
|
marketDataByMonth[itemByMonth.key][i + 1] &&
|
||||||
|
onOpenMarketDataDetail(marketDataByMonth[itemByMonth.key][i + 1])
|
||||||
|
"
|
||||||
|
></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -0,0 +1,22 @@
|
|||||||
|
@import '~apps/client/src/styles/ghostfolio-style';
|
||||||
|
|
||||||
|
:host {
|
||||||
|
display: block;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
|
||||||
|
.date {
|
||||||
|
font-feature-settings: 'tnum';
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
}
|
||||||
|
|
||||||
|
.day {
|
||||||
|
background-color: var(--danger);
|
||||||
|
height: 0.5rem;
|
||||||
|
margin-right: 0.25rem;
|
||||||
|
width: 0.5rem;
|
||||||
|
|
||||||
|
&.available {
|
||||||
|
background-color: var(--success);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,83 @@
|
|||||||
|
import {
|
||||||
|
ChangeDetectionStrategy,
|
||||||
|
Component,
|
||||||
|
Input,
|
||||||
|
OnChanges,
|
||||||
|
OnInit
|
||||||
|
} from '@angular/core';
|
||||||
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
|
import { DEFAULT_DATE_FORMAT } from '@ghostfolio/common/config';
|
||||||
|
import { MarketData } from '@prisma/client';
|
||||||
|
import { format } from 'date-fns';
|
||||||
|
import { DeviceDetectorService } from 'ngx-device-detector';
|
||||||
|
import { Subject, takeUntil } from 'rxjs';
|
||||||
|
|
||||||
|
import { MarketDataDetailDialog } from './market-data-detail-dialog/market-data-detail-dialog.component';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
|
selector: 'gf-admin-market-data-detail',
|
||||||
|
styleUrls: ['./admin-market-data-detail.component.scss'],
|
||||||
|
templateUrl: './admin-market-data-detail.component.html'
|
||||||
|
})
|
||||||
|
export class AdminMarketDataDetailComponent implements OnChanges, OnInit {
|
||||||
|
@Input() marketData: MarketData[];
|
||||||
|
|
||||||
|
public days = Array(31);
|
||||||
|
public defaultDateFormat = DEFAULT_DATE_FORMAT;
|
||||||
|
public deviceType: string;
|
||||||
|
public marketDataByMonth: {
|
||||||
|
[yearMonth: string]: { [day: string]: MarketData & { day: number } };
|
||||||
|
} = {};
|
||||||
|
|
||||||
|
private unsubscribeSubject = new Subject<void>();
|
||||||
|
|
||||||
|
public constructor(
|
||||||
|
private deviceService: DeviceDetectorService,
|
||||||
|
private dialog: MatDialog
|
||||||
|
) {
|
||||||
|
this.deviceType = this.deviceService.getDeviceInfo().deviceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ngOnInit() {}
|
||||||
|
|
||||||
|
public ngOnChanges() {
|
||||||
|
this.marketDataByMonth = {};
|
||||||
|
|
||||||
|
for (const marketDataItem of this.marketData) {
|
||||||
|
const currentDay = parseInt(format(marketDataItem.date, 'd'), 10);
|
||||||
|
const key = format(marketDataItem.date, 'yyyy-MM');
|
||||||
|
|
||||||
|
if (!this.marketDataByMonth[key]) {
|
||||||
|
this.marketDataByMonth[key] = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
this.marketDataByMonth[key][currentDay] = {
|
||||||
|
...marketDataItem,
|
||||||
|
day: currentDay
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public onOpenMarketDataDetail({ date, marketPrice, symbol }: MarketData) {
|
||||||
|
const dialogRef = this.dialog.open(MarketDataDetailDialog, {
|
||||||
|
data: {
|
||||||
|
marketPrice,
|
||||||
|
symbol,
|
||||||
|
date: format(date, DEFAULT_DATE_FORMAT)
|
||||||
|
},
|
||||||
|
height: this.deviceType === 'mobile' ? '97.5vh' : '80vh',
|
||||||
|
width: this.deviceType === 'mobile' ? '100vw' : '50rem'
|
||||||
|
});
|
||||||
|
|
||||||
|
dialogRef
|
||||||
|
.afterClosed()
|
||||||
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
|
.subscribe(() => {});
|
||||||
|
}
|
||||||
|
|
||||||
|
public ngOnDestroy() {
|
||||||
|
this.unsubscribeSubject.next();
|
||||||
|
this.unsubscribeSubject.complete();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
|
||||||
|
|
||||||
|
import { AdminMarketDataDetailComponent } from './admin-market-data-detail.component';
|
||||||
|
import { GfMarketDataDetailDialogModule } from './market-data-detail-dialog/market-data-detail-dialog.module';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [AdminMarketDataDetailComponent],
|
||||||
|
exports: [AdminMarketDataDetailComponent],
|
||||||
|
imports: [CommonModule, GfMarketDataDetailDialogModule],
|
||||||
|
providers: [],
|
||||||
|
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||||
|
})
|
||||||
|
export class GfAdminMarketDataDetailModule {}
|
@ -0,0 +1,5 @@
|
|||||||
|
export interface MarketDataDetailDialogParams {
|
||||||
|
date: string;
|
||||||
|
marketPrice: number;
|
||||||
|
symbol: string;
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
import {
|
||||||
|
ChangeDetectionStrategy,
|
||||||
|
Component,
|
||||||
|
Inject,
|
||||||
|
OnDestroy
|
||||||
|
} from '@angular/core';
|
||||||
|
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||||
|
import { Subject } from 'rxjs';
|
||||||
|
|
||||||
|
import { MarketDataDetailDialogParams } from './interfaces/interfaces';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
host: { class: 'h-100' },
|
||||||
|
selector: 'gf-market-data-detail-dialog',
|
||||||
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
|
styleUrls: ['./market-data-detail-dialog.scss'],
|
||||||
|
templateUrl: 'market-data-detail-dialog.html'
|
||||||
|
})
|
||||||
|
export class MarketDataDetailDialog implements OnDestroy {
|
||||||
|
private unsubscribeSubject = new Subject<void>();
|
||||||
|
|
||||||
|
public constructor(
|
||||||
|
public dialogRef: MatDialogRef<MarketDataDetailDialog>,
|
||||||
|
@Inject(MAT_DIALOG_DATA) public data: MarketDataDetailDialogParams
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public ngOnInit() {}
|
||||||
|
|
||||||
|
public onCancel(): void {
|
||||||
|
this.dialogRef.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ngOnDestroy() {
|
||||||
|
this.unsubscribeSubject.next();
|
||||||
|
this.unsubscribeSubject.complete();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
<form class="d-flex flex-column h-100">
|
||||||
|
<h1 mat-dialog-title i18n>Details for {{ data.symbol }}</h1>
|
||||||
|
<div class="flex-grow-1" mat-dialog-content>
|
||||||
|
<div>
|
||||||
|
<mat-form-field appearance="outline" class="w-100">
|
||||||
|
<mat-label i18n>Date</mat-label>
|
||||||
|
<input matInput name="date" readonly [(ngModel)]="data.date" />
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<mat-form-field appearance="outline" class="w-100">
|
||||||
|
<mat-label i18n>MarketPrice</mat-label>
|
||||||
|
<input
|
||||||
|
matInput
|
||||||
|
name="marketPrice"
|
||||||
|
readonly
|
||||||
|
[(ngModel)]="data.marketPrice"
|
||||||
|
/>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="justify-content-end" mat-dialog-actions>
|
||||||
|
<button i18n mat-button (click)="onCancel()">Cancel</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
@ -0,0 +1,26 @@
|
|||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
|
||||||
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||||
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
|
import { MatDialogModule } from '@angular/material/dialog';
|
||||||
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||||
|
import { MatInputModule } from '@angular/material/input';
|
||||||
|
|
||||||
|
import { MarketDataDetailDialog } from './market-data-detail-dialog.component';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [MarketDataDetailDialog],
|
||||||
|
exports: [],
|
||||||
|
imports: [
|
||||||
|
CommonModule,
|
||||||
|
FormsModule,
|
||||||
|
MatButtonModule,
|
||||||
|
MatDialogModule,
|
||||||
|
MatFormFieldModule,
|
||||||
|
MatInputModule,
|
||||||
|
ReactiveFormsModule
|
||||||
|
],
|
||||||
|
providers: [],
|
||||||
|
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||||
|
})
|
||||||
|
export class GfMarketDataDetailDialogModule {}
|
@ -0,0 +1,7 @@
|
|||||||
|
:host {
|
||||||
|
display: block;
|
||||||
|
|
||||||
|
.mat-dialog-content {
|
||||||
|
max-height: unset;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,97 @@
|
|||||||
|
import {
|
||||||
|
ChangeDetectionStrategy,
|
||||||
|
ChangeDetectorRef,
|
||||||
|
Component,
|
||||||
|
OnDestroy,
|
||||||
|
OnInit
|
||||||
|
} from '@angular/core';
|
||||||
|
import { AdminService } from '@ghostfolio/client/services/admin.service';
|
||||||
|
import { DataService } from '@ghostfolio/client/services/data.service';
|
||||||
|
import { DEFAULT_DATE_FORMAT } from '@ghostfolio/common/config';
|
||||||
|
import { AdminMarketDataItem } from '@ghostfolio/common/interfaces/admin-market-data.interface';
|
||||||
|
import { DataSource, MarketData } from '@prisma/client';
|
||||||
|
import { Subject } from 'rxjs';
|
||||||
|
import { takeUntil } from 'rxjs/operators';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
|
selector: 'gf-admin-market-data',
|
||||||
|
styleUrls: ['./admin-market-data.scss'],
|
||||||
|
templateUrl: './admin-market-data.html'
|
||||||
|
})
|
||||||
|
export class AdminMarketDataComponent implements OnDestroy, OnInit {
|
||||||
|
public currentSymbol: string;
|
||||||
|
public defaultDateFormat = DEFAULT_DATE_FORMAT;
|
||||||
|
public marketData: AdminMarketDataItem[] = [];
|
||||||
|
public marketDataDetails: MarketData[] = [];
|
||||||
|
|
||||||
|
private unsubscribeSubject = new Subject<void>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
public constructor(
|
||||||
|
private adminService: AdminService,
|
||||||
|
private changeDetectorRef: ChangeDetectorRef,
|
||||||
|
private dataService: DataService
|
||||||
|
) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the controller
|
||||||
|
*/
|
||||||
|
public ngOnInit() {
|
||||||
|
this.fetchAdminMarketData();
|
||||||
|
}
|
||||||
|
|
||||||
|
public onGatherSymbol({
|
||||||
|
dataSource,
|
||||||
|
symbol
|
||||||
|
}: {
|
||||||
|
dataSource: DataSource;
|
||||||
|
symbol: string;
|
||||||
|
}) {
|
||||||
|
this.adminService
|
||||||
|
.gatherSymbol({ dataSource, symbol })
|
||||||
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
|
.subscribe(() => {});
|
||||||
|
}
|
||||||
|
|
||||||
|
public setCurrentSymbol(aSymbol: string) {
|
||||||
|
this.marketDataDetails = [];
|
||||||
|
|
||||||
|
if (this.currentSymbol === aSymbol) {
|
||||||
|
this.currentSymbol = '';
|
||||||
|
} else {
|
||||||
|
this.currentSymbol = aSymbol;
|
||||||
|
|
||||||
|
this.fetchAdminMarketDataBySymbol(this.currentSymbol);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ngOnDestroy() {
|
||||||
|
this.unsubscribeSubject.next();
|
||||||
|
this.unsubscribeSubject.complete();
|
||||||
|
}
|
||||||
|
|
||||||
|
private fetchAdminMarketData() {
|
||||||
|
this.dataService
|
||||||
|
.fetchAdminMarketData()
|
||||||
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
|
.subscribe(({ marketData }) => {
|
||||||
|
this.marketData = marketData;
|
||||||
|
|
||||||
|
this.changeDetectorRef.markForCheck();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private fetchAdminMarketDataBySymbol(aSymbol: string) {
|
||||||
|
this.dataService
|
||||||
|
.fetchAdminMarketDataBySymbol(aSymbol)
|
||||||
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
|
.subscribe(({ marketData }) => {
|
||||||
|
this.marketDataDetails = marketData;
|
||||||
|
|
||||||
|
this.changeDetectorRef.markForCheck();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<table class="gf-table w-100">
|
||||||
|
<thead>
|
||||||
|
<tr class="mat-header-row">
|
||||||
|
<th class="mat-header-cell px-1 py-2 text-right" i18n>#</th>
|
||||||
|
<th class="mat-header-cell px-1 py-2" i18n>Symbol</th>
|
||||||
|
<th class="mat-header-cell px-1 py-2" i18n>Data Source</th>
|
||||||
|
<th class="mat-header-cell px-1 py-2" i18n>First Transaction</th>
|
||||||
|
<th class="mat-header-cell px-1 py-2"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<ng-container *ngFor="let item of marketData; let i = index">
|
||||||
|
<tr
|
||||||
|
class="cursor-pointer mat-row"
|
||||||
|
(click)="setCurrentSymbol(item.symbol)"
|
||||||
|
>
|
||||||
|
<td class="mat-cell px-1 py-2 text-right">{{ i + 1 }}</td>
|
||||||
|
<td class="mat-cell px-1 py-2">{{ item.symbol }}</td>
|
||||||
|
<td class="mat-cell px-1 py-2">{{ item.dataSource}}</td>
|
||||||
|
<td class="mat-cell px-1 py-2">
|
||||||
|
{{ (item.date | date: defaultDateFormat) ?? '' }}
|
||||||
|
</td>
|
||||||
|
<td class="mat-cell px-1 py-2">
|
||||||
|
<button
|
||||||
|
class="mx-1 no-min-width px-2"
|
||||||
|
mat-button
|
||||||
|
[matMenuTriggerFor]="accountMenu"
|
||||||
|
(click)="$event.stopPropagation()"
|
||||||
|
>
|
||||||
|
<ion-icon name="ellipsis-vertical"></ion-icon>
|
||||||
|
</button>
|
||||||
|
<mat-menu #accountMenu="matMenu" xPosition="before">
|
||||||
|
<button
|
||||||
|
i18n
|
||||||
|
mat-menu-item
|
||||||
|
(click)="onGatherSymbol({dataSource: item.dataSource, symbol: item.symbol})"
|
||||||
|
>
|
||||||
|
Gather Data
|
||||||
|
</button>
|
||||||
|
</mat-menu>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr *ngIf="currentSymbol === item.symbol" class="mat-row">
|
||||||
|
<td></td>
|
||||||
|
<td colspan="4">
|
||||||
|
<gf-admin-market-data-detail
|
||||||
|
[marketData]="marketDataDetails"
|
||||||
|
></gf-admin-market-data-detail>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</ng-container>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -0,0 +1,19 @@
|
|||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
|
||||||
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
|
import { MatMenuModule } from '@angular/material/menu';
|
||||||
|
import { GfAdminMarketDataDetailModule } from '@ghostfolio/client/components/admin-market-data-detail/admin-market-data-detail.module';
|
||||||
|
|
||||||
|
import { AdminMarketDataComponent } from './admin-market-data.component';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [AdminMarketDataComponent],
|
||||||
|
imports: [
|
||||||
|
CommonModule,
|
||||||
|
GfAdminMarketDataDetailModule,
|
||||||
|
MatButtonModule,
|
||||||
|
MatMenuModule
|
||||||
|
],
|
||||||
|
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||||
|
})
|
||||||
|
export class GfAdminMarketDataModule {}
|
@ -0,0 +1,5 @@
|
|||||||
|
@import '~apps/client/src/styles/ghostfolio-style';
|
||||||
|
|
||||||
|
:host {
|
||||||
|
display: block;
|
||||||
|
}
|
@ -0,0 +1,150 @@
|
|||||||
|
import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
|
||||||
|
import { AdminService } from '@ghostfolio/client/services/admin.service';
|
||||||
|
import { CacheService } from '@ghostfolio/client/services/cache.service';
|
||||||
|
import { DataService } from '@ghostfolio/client/services/data.service';
|
||||||
|
import { UserService } from '@ghostfolio/client/services/user/user.service';
|
||||||
|
import { DEFAULT_DATE_FORMAT } from '@ghostfolio/common/config';
|
||||||
|
import { User } from '@ghostfolio/common/interfaces';
|
||||||
|
import {
|
||||||
|
differenceInSeconds,
|
||||||
|
formatDistanceToNowStrict,
|
||||||
|
isValid,
|
||||||
|
parseISO
|
||||||
|
} from 'date-fns';
|
||||||
|
import { Subject } from 'rxjs';
|
||||||
|
import { takeUntil } from 'rxjs/operators';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'gf-admin-overview',
|
||||||
|
styleUrls: ['./admin-overview.scss'],
|
||||||
|
templateUrl: './admin-overview.html'
|
||||||
|
})
|
||||||
|
export class AdminOverviewComponent implements OnDestroy, OnInit {
|
||||||
|
public dataGatheringInProgress: boolean;
|
||||||
|
public dataGatheringProgress: number;
|
||||||
|
public defaultDateFormat = DEFAULT_DATE_FORMAT;
|
||||||
|
public exchangeRates: { label1: string; label2: string; value: number }[];
|
||||||
|
public lastDataGathering: string;
|
||||||
|
public transactionCount: number;
|
||||||
|
public userCount: number;
|
||||||
|
public user: User;
|
||||||
|
|
||||||
|
private unsubscribeSubject = new Subject<void>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
public constructor(
|
||||||
|
private adminService: AdminService,
|
||||||
|
private cacheService: CacheService,
|
||||||
|
private changeDetectorRef: ChangeDetectorRef,
|
||||||
|
private dataService: DataService,
|
||||||
|
private userService: UserService
|
||||||
|
) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the controller
|
||||||
|
*/
|
||||||
|
public ngOnInit() {
|
||||||
|
this.fetchAdminData();
|
||||||
|
|
||||||
|
this.userService.stateChanged
|
||||||
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
|
.subscribe((state) => {
|
||||||
|
if (state?.user) {
|
||||||
|
this.user = state.user;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public onFlushCache() {
|
||||||
|
this.cacheService
|
||||||
|
.flush()
|
||||||
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
|
.subscribe(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.reload();
|
||||||
|
}, 300);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public onGatherMax() {
|
||||||
|
const confirmation = confirm(
|
||||||
|
'This action may take some time. Do you want to proceed?'
|
||||||
|
);
|
||||||
|
|
||||||
|
if (confirmation === true) {
|
||||||
|
this.adminService
|
||||||
|
.gatherMax()
|
||||||
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
|
.subscribe(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.reload();
|
||||||
|
}, 300);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public onGatherProfileData() {
|
||||||
|
this.adminService
|
||||||
|
.gatherProfileData()
|
||||||
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
|
.subscribe(() => {});
|
||||||
|
}
|
||||||
|
|
||||||
|
public formatDistanceToNow(aDateString: string) {
|
||||||
|
if (aDateString) {
|
||||||
|
const distanceString = formatDistanceToNowStrict(parseISO(aDateString), {
|
||||||
|
addSuffix: true
|
||||||
|
});
|
||||||
|
|
||||||
|
return Math.abs(differenceInSeconds(parseISO(aDateString), new Date())) <
|
||||||
|
60
|
||||||
|
? 'just now'
|
||||||
|
: distanceString;
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public ngOnDestroy() {
|
||||||
|
this.unsubscribeSubject.next();
|
||||||
|
this.unsubscribeSubject.complete();
|
||||||
|
}
|
||||||
|
|
||||||
|
private fetchAdminData() {
|
||||||
|
this.dataService
|
||||||
|
.fetchAdminData()
|
||||||
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
|
.subscribe(
|
||||||
|
({
|
||||||
|
dataGatheringProgress,
|
||||||
|
exchangeRates,
|
||||||
|
lastDataGathering,
|
||||||
|
transactionCount,
|
||||||
|
userCount
|
||||||
|
}) => {
|
||||||
|
this.dataGatheringProgress = dataGatheringProgress;
|
||||||
|
this.exchangeRates = exchangeRates;
|
||||||
|
|
||||||
|
if (isValid(parseISO(lastDataGathering?.toString()))) {
|
||||||
|
this.lastDataGathering = formatDistanceToNowStrict(
|
||||||
|
new Date(lastDataGathering),
|
||||||
|
{
|
||||||
|
addSuffix: true
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} else if (lastDataGathering === 'IN_PROGRESS') {
|
||||||
|
this.dataGatheringInProgress = true;
|
||||||
|
} else {
|
||||||
|
this.lastDataGathering = 'Starting soon...';
|
||||||
|
}
|
||||||
|
|
||||||
|
this.transactionCount = transactionCount;
|
||||||
|
this.userCount = userCount;
|
||||||
|
|
||||||
|
this.changeDetectorRef.markForCheck();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,107 @@
|
|||||||
|
<div class="container">
|
||||||
|
<div class="mb-5 row">
|
||||||
|
<div class="col">
|
||||||
|
<mat-card class="mb-3">
|
||||||
|
<mat-card-content>
|
||||||
|
<div
|
||||||
|
*ngIf="exchangeRates?.length > 0"
|
||||||
|
class="align-items-start d-flex my-3"
|
||||||
|
>
|
||||||
|
<div class="w-50" i18n>Exchange Rates</div>
|
||||||
|
<div class="w-50">
|
||||||
|
<table>
|
||||||
|
<tr *ngFor="let exchangeRate of exchangeRates">
|
||||||
|
<td class="d-flex">
|
||||||
|
<gf-value
|
||||||
|
[locale]="user?.settings?.locale"
|
||||||
|
[value]="1"
|
||||||
|
></gf-value>
|
||||||
|
</td>
|
||||||
|
<td class="pl-1">{{ exchangeRate.label1 }}</td>
|
||||||
|
<td class="px-1">=</td>
|
||||||
|
<td class="d-flex justify-content-end">
|
||||||
|
<gf-value
|
||||||
|
[locale]="user?.settings?.locale"
|
||||||
|
[precision]="4"
|
||||||
|
[value]="exchangeRate.value"
|
||||||
|
></gf-value>
|
||||||
|
</td>
|
||||||
|
<td class="pl-1">{{ exchangeRate.label2 }}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="d-flex my-3">
|
||||||
|
<div class="w-50" i18n>Data Gathering</div>
|
||||||
|
<div class="w-50">
|
||||||
|
<div>
|
||||||
|
<ng-container *ngIf="lastDataGathering"
|
||||||
|
>{{ lastDataGathering }}</ng-container
|
||||||
|
>
|
||||||
|
<ng-container *ngIf="dataGatheringInProgress" i18n
|
||||||
|
>In Progress ({{ dataGatheringProgress | percent : '1.2-2'
|
||||||
|
}})</ng-container
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="mt-2 overflow-hidden">
|
||||||
|
<div class="mb-2">
|
||||||
|
<button
|
||||||
|
class="mw-100"
|
||||||
|
color="accent"
|
||||||
|
mat-flat-button
|
||||||
|
(click)="onFlushCache()"
|
||||||
|
>
|
||||||
|
<ion-icon
|
||||||
|
class="mr-1"
|
||||||
|
name="close-circle-outline"
|
||||||
|
></ion-icon>
|
||||||
|
<span i18n>Reset Data Gathering</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="mb-2">
|
||||||
|
<button
|
||||||
|
class="mw-100"
|
||||||
|
color="warn"
|
||||||
|
mat-flat-button
|
||||||
|
[disabled]="dataGatheringInProgress"
|
||||||
|
(click)="onGatherMax()"
|
||||||
|
>
|
||||||
|
<ion-icon class="mr-1" name="warning-outline"></ion-icon>
|
||||||
|
<span i18n>Gather All Data</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<button
|
||||||
|
class="mb-2 mr-2 mw-100"
|
||||||
|
color="accent"
|
||||||
|
mat-flat-button
|
||||||
|
(click)="onGatherProfileData()"
|
||||||
|
>
|
||||||
|
<ion-icon
|
||||||
|
class="mr-1"
|
||||||
|
name="cloud-download-outline"
|
||||||
|
></ion-icon>
|
||||||
|
<span i18n>Gather Profile Data</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="d-flex my-3">
|
||||||
|
<div class="w-50" i18n>User Count</div>
|
||||||
|
<div class="w-50">{{ userCount }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="d-flex my-3">
|
||||||
|
<div class="w-50" i18n>Transaction Count</div>
|
||||||
|
<div class="w-50">
|
||||||
|
<ng-container *ngIf="transactionCount">
|
||||||
|
{{ transactionCount }} ({{ transactionCount / userCount | number
|
||||||
|
: '1.2-2' }} <span i18n>per User</span>)
|
||||||
|
</ng-container>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</mat-card-content>
|
||||||
|
</mat-card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -0,0 +1,17 @@
|
|||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
|
||||||
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
|
import { MatCardModule } from '@angular/material/card';
|
||||||
|
import { CacheService } from '@ghostfolio/client/services/cache.service';
|
||||||
|
import { GfValueModule } from '@ghostfolio/ui/value';
|
||||||
|
|
||||||
|
import { AdminOverviewComponent } from './admin-overview.component';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [AdminOverviewComponent],
|
||||||
|
exports: [],
|
||||||
|
imports: [CommonModule, GfValueModule, MatButtonModule, MatCardModule],
|
||||||
|
providers: [CacheService],
|
||||||
|
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||||
|
})
|
||||||
|
export class GfAdminOverviewModule {}
|
@ -0,0 +1,17 @@
|
|||||||
|
@import '~apps/client/src/styles/ghostfolio-style';
|
||||||
|
|
||||||
|
:host {
|
||||||
|
display: block;
|
||||||
|
|
||||||
|
.mat-flat-button {
|
||||||
|
::ng-deep {
|
||||||
|
.mat-button-wrapper {
|
||||||
|
display: block;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
|
||||||
|
import { DataService } from '@ghostfolio/client/services/data.service';
|
||||||
|
import { AdminData } from '@ghostfolio/common/interfaces';
|
||||||
|
import {
|
||||||
|
differenceInSeconds,
|
||||||
|
formatDistanceToNowStrict,
|
||||||
|
parseISO
|
||||||
|
} from 'date-fns';
|
||||||
|
import { Subject } from 'rxjs';
|
||||||
|
import { takeUntil } from 'rxjs/operators';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'gf-admin-users',
|
||||||
|
styleUrls: ['./admin-users.scss'],
|
||||||
|
templateUrl: './admin-users.html'
|
||||||
|
})
|
||||||
|
export class AdminUsersComponent implements OnDestroy, OnInit {
|
||||||
|
public users: AdminData['users'];
|
||||||
|
|
||||||
|
private unsubscribeSubject = new Subject<void>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
public constructor(
|
||||||
|
private changeDetectorRef: ChangeDetectorRef,
|
||||||
|
private dataService: DataService
|
||||||
|
) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the controller
|
||||||
|
*/
|
||||||
|
public ngOnInit() {
|
||||||
|
this.fetchAdminData();
|
||||||
|
}
|
||||||
|
|
||||||
|
public formatDistanceToNow(aDateString: string) {
|
||||||
|
if (aDateString) {
|
||||||
|
const distanceString = formatDistanceToNowStrict(parseISO(aDateString), {
|
||||||
|
addSuffix: true
|
||||||
|
});
|
||||||
|
|
||||||
|
return Math.abs(differenceInSeconds(parseISO(aDateString), new Date())) <
|
||||||
|
60
|
||||||
|
? 'just now'
|
||||||
|
: distanceString;
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public onDeleteUser(aId: string) {
|
||||||
|
const confirmation = confirm('Do you really want to delete this user?');
|
||||||
|
|
||||||
|
if (confirmation) {
|
||||||
|
this.dataService
|
||||||
|
.deleteUser(aId)
|
||||||
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
|
.subscribe({
|
||||||
|
next: () => {
|
||||||
|
this.fetchAdminData();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ngOnDestroy() {
|
||||||
|
this.unsubscribeSubject.next();
|
||||||
|
this.unsubscribeSubject.complete();
|
||||||
|
}
|
||||||
|
|
||||||
|
private fetchAdminData() {
|
||||||
|
this.dataService
|
||||||
|
.fetchAdminData()
|
||||||
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
|
.subscribe(({ users }) => {
|
||||||
|
this.users = users;
|
||||||
|
|
||||||
|
this.changeDetectorRef.markForCheck();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
86
apps/client/src/app/components/admin-users/admin-users.html
Normal file
86
apps/client/src/app/components/admin-users/admin-users.html
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<div class="users">
|
||||||
|
<table class="gf-table">
|
||||||
|
<thead>
|
||||||
|
<tr class="mat-header-row">
|
||||||
|
<th class="mat-header-cell px-1 py-2 text-right" i18n>#</th>
|
||||||
|
<th class="mat-header-cell px-1 py-2" i18n>User</th>
|
||||||
|
<th class="mat-header-cell px-1 py-2 text-right" i18n>
|
||||||
|
Registration
|
||||||
|
</th>
|
||||||
|
<th class="mat-header-cell px-1 py-2 text-right" i18n>
|
||||||
|
Accounts
|
||||||
|
</th>
|
||||||
|
<th class="mat-header-cell px-1 py-2 text-right" i18n>
|
||||||
|
Transactions
|
||||||
|
</th>
|
||||||
|
<th class="mat-header-cell px-1 py-2 text-right" i18n>
|
||||||
|
Engagement per Day
|
||||||
|
</th>
|
||||||
|
<th class="mat-header-cell px-1 py-2" i18n>Last Activitiy</th>
|
||||||
|
<th class="mat-header-cell px-1 py-2"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr *ngFor="let userItem of users; let i = index" class="mat-row">
|
||||||
|
<td class="mat-cell px-1 py-2 text-right">{{ i + 1 }}</td>
|
||||||
|
<td class="mat-cell px-1 py-2">
|
||||||
|
<div class="d-flex align-items-center">
|
||||||
|
<span class="d-none d-sm-inline-block"
|
||||||
|
>{{ userItem.alias || userItem.id }}</span
|
||||||
|
>
|
||||||
|
<span class="d-inline-block d-sm-none"
|
||||||
|
>{{ userItem.alias || (userItem.id | slice:0:5) +
|
||||||
|
'...' }}</span
|
||||||
|
>
|
||||||
|
<ion-icon
|
||||||
|
*ngIf="userItem?.subscription?.type === 'Premium'"
|
||||||
|
class="ml-1 text-muted"
|
||||||
|
name="diamond-outline"
|
||||||
|
></ion-icon>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td class="mat-cell px-1 py-2 text-right">
|
||||||
|
{{ formatDistanceToNow(userItem.createdAt) }}
|
||||||
|
</td>
|
||||||
|
<td class="mat-cell px-1 py-2 text-right">
|
||||||
|
{{ userItem.accountCount }}
|
||||||
|
</td>
|
||||||
|
<td class="mat-cell px-1 py-2 text-right">
|
||||||
|
{{ userItem.transactionCount }}
|
||||||
|
</td>
|
||||||
|
<td class="mat-cell px-1 py-2 text-right">
|
||||||
|
{{ userItem.engagement | number: '1.0-0' }}
|
||||||
|
</td>
|
||||||
|
<td class="mat-cell px-1 py-2">
|
||||||
|
{{ formatDistanceToNow(userItem.lastActivity) }}
|
||||||
|
</td>
|
||||||
|
<td class="mat-cell px-1 py-2">
|
||||||
|
<button
|
||||||
|
class="mx-1 no-min-width px-2"
|
||||||
|
mat-button
|
||||||
|
[matMenuTriggerFor]="accountMenu"
|
||||||
|
(click)="$event.stopPropagation()"
|
||||||
|
>
|
||||||
|
<ion-icon name="ellipsis-vertical"></ion-icon>
|
||||||
|
</button>
|
||||||
|
<mat-menu #accountMenu="matMenu" xPosition="before">
|
||||||
|
<button
|
||||||
|
i18n
|
||||||
|
mat-menu-item
|
||||||
|
[disabled]="userItem.id === user?.id"
|
||||||
|
(click)="onDeleteUser(userItem.id)"
|
||||||
|
>
|
||||||
|
Delete
|
||||||
|
</button>
|
||||||
|
</mat-menu>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -0,0 +1,14 @@
|
|||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
|
||||||
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
|
import { MatMenuModule } from '@angular/material/menu';
|
||||||
|
|
||||||
|
import { AdminUsersComponent } from './admin-users.component';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [AdminUsersComponent],
|
||||||
|
exports: [],
|
||||||
|
imports: [CommonModule, MatButtonModule, MatMenuModule],
|
||||||
|
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||||
|
})
|
||||||
|
export class GfAdminUsersModule {}
|
18
apps/client/src/app/components/admin-users/admin-users.scss
Normal file
18
apps/client/src/app/components/admin-users/admin-users.scss
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
@import '~apps/client/src/styles/ghostfolio-style';
|
||||||
|
|
||||||
|
:host {
|
||||||
|
display: block;
|
||||||
|
|
||||||
|
.users {
|
||||||
|
overflow-x: auto;
|
||||||
|
|
||||||
|
table {
|
||||||
|
min-width: 100%;
|
||||||
|
|
||||||
|
.mat-row,
|
||||||
|
.mat-header-row {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,8 @@
|
|||||||
<span class="flex-grow-1 text-truncate">{{ title }}</span>
|
<span
|
||||||
|
class="flex-grow-1 text-truncate"
|
||||||
|
[ngClass]="{ 'text-center': position === 'center' }"
|
||||||
|
>{{ title }}</span
|
||||||
|
>
|
||||||
<button
|
<button
|
||||||
*ngIf="deviceType !== 'mobile'"
|
*ngIf="deviceType !== 'mobile'"
|
||||||
class="no-min-width px-0"
|
class="no-min-width px-0"
|
||||||
|
@ -16,6 +16,7 @@ import {
|
|||||||
})
|
})
|
||||||
export class DialogHeaderComponent implements OnInit {
|
export class DialogHeaderComponent implements OnInit {
|
||||||
@Input() deviceType: string;
|
@Input() deviceType: string;
|
||||||
|
@Input() position: 'center' | 'left' = 'left';
|
||||||
@Input() title: string;
|
@Input() title: string;
|
||||||
|
|
||||||
@Output() closeButtonClicked = new EventEmitter<void>();
|
@Output() closeButtonClicked = new EventEmitter<void>();
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<ng-container *ngIf="user">
|
<ng-container *ngIf="user">
|
||||||
<a
|
<a
|
||||||
[routerLink]="['/']"
|
[routerLink]="['/']"
|
||||||
class="align-items-center d-flex h-100 mx-2 no-min-width px-2 rounded-0"
|
class="align-items-center d-flex h-100 no-min-width px-2 rounded-0"
|
||||||
mat-button
|
mat-button
|
||||||
>
|
>
|
||||||
<gf-logo></gf-logo>
|
<gf-logo></gf-logo>
|
||||||
|
@ -0,0 +1,84 @@
|
|||||||
|
import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
|
||||||
|
import { DataService } from '@ghostfolio/client/services/data.service';
|
||||||
|
import {
|
||||||
|
RANGE,
|
||||||
|
SettingsStorageService
|
||||||
|
} from '@ghostfolio/client/services/settings-storage.service';
|
||||||
|
import { UserService } from '@ghostfolio/client/services/user/user.service';
|
||||||
|
import { Position, User } from '@ghostfolio/common/interfaces';
|
||||||
|
import { hasPermission, permissions } from '@ghostfolio/common/permissions';
|
||||||
|
import { DateRange } from '@ghostfolio/common/types';
|
||||||
|
import { DeviceDetectorService } from 'ngx-device-detector';
|
||||||
|
import { Subject } from 'rxjs';
|
||||||
|
import { takeUntil } from 'rxjs/operators';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'gf-home-holdings',
|
||||||
|
styleUrls: ['./home-holdings.scss'],
|
||||||
|
templateUrl: './home-holdings.html'
|
||||||
|
})
|
||||||
|
export class HomeHoldingsComponent implements OnDestroy, OnInit {
|
||||||
|
public dateRange: DateRange;
|
||||||
|
public deviceType: string;
|
||||||
|
public hasPermissionToCreateOrder: boolean;
|
||||||
|
public positions: Position[];
|
||||||
|
public user: User;
|
||||||
|
|
||||||
|
private unsubscribeSubject = new Subject<void>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
public constructor(
|
||||||
|
private changeDetectorRef: ChangeDetectorRef,
|
||||||
|
private dataService: DataService,
|
||||||
|
private deviceService: DeviceDetectorService,
|
||||||
|
private settingsStorageService: SettingsStorageService,
|
||||||
|
private userService: UserService
|
||||||
|
) {
|
||||||
|
this.userService.stateChanged
|
||||||
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
|
.subscribe((state) => {
|
||||||
|
if (state?.user) {
|
||||||
|
this.user = state.user;
|
||||||
|
|
||||||
|
this.hasPermissionToCreateOrder = hasPermission(
|
||||||
|
this.user.permissions,
|
||||||
|
permissions.createOrder
|
||||||
|
);
|
||||||
|
|
||||||
|
this.changeDetectorRef.markForCheck();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the controller
|
||||||
|
*/
|
||||||
|
public ngOnInit() {
|
||||||
|
this.deviceType = this.deviceService.getDeviceInfo().deviceType;
|
||||||
|
|
||||||
|
this.dateRange =
|
||||||
|
<DateRange>this.settingsStorageService.getSetting(RANGE) || 'max';
|
||||||
|
|
||||||
|
this.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ngOnDestroy() {
|
||||||
|
this.unsubscribeSubject.next();
|
||||||
|
this.unsubscribeSubject.complete();
|
||||||
|
}
|
||||||
|
|
||||||
|
private update() {
|
||||||
|
this.dataService
|
||||||
|
.fetchPositions({ range: this.dateRange })
|
||||||
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
|
.subscribe((response) => {
|
||||||
|
this.positions = response.positions;
|
||||||
|
|
||||||
|
this.changeDetectorRef.markForCheck();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.changeDetectorRef.markForCheck();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<div class="container justify-content-center pb-3 px-3">
|
||||||
|
<div class="row">
|
||||||
|
<div class="align-items-center col-xs-12 col-md-8 offset-md-2">
|
||||||
|
<mat-card class="p-0">
|
||||||
|
<mat-card-content>
|
||||||
|
<gf-positions
|
||||||
|
[baseCurrency]="user?.settings?.baseCurrency"
|
||||||
|
[deviceType]="deviceType"
|
||||||
|
[locale]="user?.settings?.locale"
|
||||||
|
[positions]="positions"
|
||||||
|
[range]="dateRange"
|
||||||
|
></gf-positions>
|
||||||
|
</mat-card-content>
|
||||||
|
</mat-card>
|
||||||
|
<div *ngIf="hasPermissionToCreateOrder" class="text-center">
|
||||||
|
<a
|
||||||
|
class="mt-3"
|
||||||
|
i18n
|
||||||
|
mat-button
|
||||||
|
[routerLink]="['/portfolio', 'transactions']"
|
||||||
|
>Manage Transactions...</a
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -0,0 +1,23 @@
|
|||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
|
||||||
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
|
import { MatCardModule } from '@angular/material/card';
|
||||||
|
import { RouterModule } from '@angular/router';
|
||||||
|
import { GfPositionsModule } from '@ghostfolio/client/components/positions/positions.module';
|
||||||
|
|
||||||
|
import { HomeHoldingsComponent } from './home-holdings.component';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [HomeHoldingsComponent],
|
||||||
|
exports: [],
|
||||||
|
imports: [
|
||||||
|
CommonModule,
|
||||||
|
GfPositionsModule,
|
||||||
|
MatButtonModule,
|
||||||
|
MatCardModule,
|
||||||
|
RouterModule
|
||||||
|
],
|
||||||
|
providers: [],
|
||||||
|
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||||
|
})
|
||||||
|
export class GfHomeHoldingsModule {}
|
@ -0,0 +1,5 @@
|
|||||||
|
@import '~apps/client/src/styles/ghostfolio-style';
|
||||||
|
|
||||||
|
:host {
|
||||||
|
display: block;
|
||||||
|
}
|
@ -0,0 +1,74 @@
|
|||||||
|
import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
|
||||||
|
import { DataService } from '@ghostfolio/client/services/data.service';
|
||||||
|
import { UserService } from '@ghostfolio/client/services/user/user.service';
|
||||||
|
import { ghostfolioFearAndGreedIndexSymbol } from '@ghostfolio/common/config';
|
||||||
|
import { User } from '@ghostfolio/common/interfaces';
|
||||||
|
import { hasPermission, permissions } from '@ghostfolio/common/permissions';
|
||||||
|
import { DataSource } from '@prisma/client';
|
||||||
|
import { Subject } from 'rxjs';
|
||||||
|
import { takeUntil } from 'rxjs/operators';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'gf-home-market',
|
||||||
|
styleUrls: ['./home-market.scss'],
|
||||||
|
templateUrl: './home-market.html'
|
||||||
|
})
|
||||||
|
export class HomeMarketComponent implements OnDestroy, OnInit {
|
||||||
|
public fearAndGreedIndex: number;
|
||||||
|
public hasPermissionToAccessFearAndGreedIndex: boolean;
|
||||||
|
public isLoading = true;
|
||||||
|
public user: User;
|
||||||
|
|
||||||
|
private unsubscribeSubject = new Subject<void>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
public constructor(
|
||||||
|
private changeDetectorRef: ChangeDetectorRef,
|
||||||
|
private dataService: DataService,
|
||||||
|
private userService: UserService
|
||||||
|
) {
|
||||||
|
this.isLoading = true;
|
||||||
|
|
||||||
|
this.userService.stateChanged
|
||||||
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
|
.subscribe((state) => {
|
||||||
|
if (state?.user) {
|
||||||
|
this.user = state.user;
|
||||||
|
|
||||||
|
this.hasPermissionToAccessFearAndGreedIndex = hasPermission(
|
||||||
|
this.user.permissions,
|
||||||
|
permissions.accessFearAndGreedIndex
|
||||||
|
);
|
||||||
|
|
||||||
|
if (this.hasPermissionToAccessFearAndGreedIndex) {
|
||||||
|
this.dataService
|
||||||
|
.fetchSymbolItem({
|
||||||
|
dataSource: DataSource.RAKUTEN,
|
||||||
|
symbol: ghostfolioFearAndGreedIndexSymbol
|
||||||
|
})
|
||||||
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
|
.subscribe(({ marketPrice }) => {
|
||||||
|
this.fearAndGreedIndex = marketPrice;
|
||||||
|
this.isLoading = false;
|
||||||
|
|
||||||
|
this.changeDetectorRef.markForCheck();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.changeDetectorRef.markForCheck();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the controller
|
||||||
|
*/
|
||||||
|
public ngOnInit() {}
|
||||||
|
|
||||||
|
public ngOnDestroy() {
|
||||||
|
this.unsubscribeSubject.next();
|
||||||
|
this.unsubscribeSubject.complete();
|
||||||
|
}
|
||||||
|
}
|
25
apps/client/src/app/components/home-market/home-market.html
Normal file
25
apps/client/src/app/components/home-market/home-market.html
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<div
|
||||||
|
class="
|
||||||
|
align-items-center
|
||||||
|
container
|
||||||
|
d-flex
|
||||||
|
flex-grow-1
|
||||||
|
h-100
|
||||||
|
justify-content-center
|
||||||
|
w-100
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<div class="row w-100">
|
||||||
|
<div class="col-xs-12 col-md-8 offset-md-2">
|
||||||
|
<mat-card class="h-100">
|
||||||
|
<mat-card-content>
|
||||||
|
<gf-fear-and-greed-index
|
||||||
|
class="d-flex justify-content-center"
|
||||||
|
[fearAndGreedIndex]="fearAndGreedIndex"
|
||||||
|
[hidden]="isLoading"
|
||||||
|
></gf-fear-and-greed-index>
|
||||||
|
</mat-card-content>
|
||||||
|
</mat-card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -0,0 +1,15 @@
|
|||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
|
||||||
|
import { MatCardModule } from '@angular/material/card';
|
||||||
|
import { GfFearAndGreedIndexModule } from '@ghostfolio/client/components/fear-and-greed-index/fear-and-greed-index.module';
|
||||||
|
|
||||||
|
import { HomeMarketComponent } from './home-market.component';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [HomeMarketComponent],
|
||||||
|
exports: [],
|
||||||
|
imports: [CommonModule, GfFearAndGreedIndexModule, MatCardModule],
|
||||||
|
providers: [],
|
||||||
|
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||||
|
})
|
||||||
|
export class GfHomeMarketModule {}
|
@ -0,0 +1,5 @@
|
|||||||
|
@import '~apps/client/src/styles/ghostfolio-style';
|
||||||
|
|
||||||
|
:host {
|
||||||
|
display: block;
|
||||||
|
}
|
@ -0,0 +1,127 @@
|
|||||||
|
import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
|
||||||
|
import { ToggleOption } from '@ghostfolio/client/components/toggle/interfaces/toggle-option.type';
|
||||||
|
import { DataService } from '@ghostfolio/client/services/data.service';
|
||||||
|
import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service';
|
||||||
|
import {
|
||||||
|
RANGE,
|
||||||
|
SettingsStorageService
|
||||||
|
} from '@ghostfolio/client/services/settings-storage.service';
|
||||||
|
import { UserService } from '@ghostfolio/client/services/user/user.service';
|
||||||
|
import { PortfolioPerformance, User } from '@ghostfolio/common/interfaces';
|
||||||
|
import { DateRange } from '@ghostfolio/common/types';
|
||||||
|
import { LineChartItem } from '@ghostfolio/ui/line-chart/interfaces/line-chart.interface';
|
||||||
|
import { DeviceDetectorService } from 'ngx-device-detector';
|
||||||
|
import { Subject } from 'rxjs';
|
||||||
|
import { takeUntil } from 'rxjs/operators';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'gf-home-overview',
|
||||||
|
styleUrls: ['./home-overview.scss'],
|
||||||
|
templateUrl: './home-overview.html'
|
||||||
|
})
|
||||||
|
export class HomeOverviewComponent implements OnDestroy, OnInit {
|
||||||
|
public dateRange: DateRange;
|
||||||
|
public dateRangeOptions: ToggleOption[] = [
|
||||||
|
{ label: 'Today', value: '1d' },
|
||||||
|
{ label: 'YTD', value: 'ytd' },
|
||||||
|
{ label: '1Y', value: '1y' },
|
||||||
|
{ label: '5Y', value: '5y' },
|
||||||
|
{ label: 'Max', value: 'max' }
|
||||||
|
];
|
||||||
|
public deviceType: string;
|
||||||
|
public hasImpersonationId: boolean;
|
||||||
|
public historicalDataItems: LineChartItem[];
|
||||||
|
public isAllTimeHigh: boolean;
|
||||||
|
public isAllTimeLow: boolean;
|
||||||
|
public isLoadingPerformance = true;
|
||||||
|
public performance: PortfolioPerformance;
|
||||||
|
public user: User;
|
||||||
|
|
||||||
|
private unsubscribeSubject = new Subject<void>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
public constructor(
|
||||||
|
private changeDetectorRef: ChangeDetectorRef,
|
||||||
|
private dataService: DataService,
|
||||||
|
private deviceService: DeviceDetectorService,
|
||||||
|
private impersonationStorageService: ImpersonationStorageService,
|
||||||
|
private settingsStorageService: SettingsStorageService,
|
||||||
|
private userService: UserService
|
||||||
|
) {
|
||||||
|
this.userService.stateChanged
|
||||||
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
|
.subscribe((state) => {
|
||||||
|
if (state?.user) {
|
||||||
|
this.user = state.user;
|
||||||
|
|
||||||
|
this.changeDetectorRef.markForCheck();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the controller
|
||||||
|
*/
|
||||||
|
public ngOnInit() {
|
||||||
|
this.deviceType = this.deviceService.getDeviceInfo().deviceType;
|
||||||
|
|
||||||
|
this.impersonationStorageService
|
||||||
|
.onChangeHasImpersonation()
|
||||||
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
|
.subscribe((aId) => {
|
||||||
|
this.hasImpersonationId = !!aId;
|
||||||
|
|
||||||
|
this.changeDetectorRef.markForCheck();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.dateRange =
|
||||||
|
<DateRange>this.settingsStorageService.getSetting(RANGE) || 'max';
|
||||||
|
|
||||||
|
this.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
public onChangeDateRange(aDateRange: DateRange) {
|
||||||
|
this.dateRange = aDateRange;
|
||||||
|
this.settingsStorageService.setSetting(RANGE, this.dateRange);
|
||||||
|
this.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ngOnDestroy() {
|
||||||
|
this.unsubscribeSubject.next();
|
||||||
|
this.unsubscribeSubject.complete();
|
||||||
|
}
|
||||||
|
|
||||||
|
private update() {
|
||||||
|
this.isLoadingPerformance = true;
|
||||||
|
|
||||||
|
this.dataService
|
||||||
|
.fetchChart({ range: this.dateRange })
|
||||||
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
|
.subscribe((chartData) => {
|
||||||
|
this.historicalDataItems = chartData.chart.map((chartDataItem) => {
|
||||||
|
return {
|
||||||
|
date: chartDataItem.date,
|
||||||
|
value: chartDataItem.value
|
||||||
|
};
|
||||||
|
});
|
||||||
|
this.isAllTimeHigh = chartData.isAllTimeHigh;
|
||||||
|
this.isAllTimeLow = chartData.isAllTimeLow;
|
||||||
|
|
||||||
|
this.changeDetectorRef.markForCheck();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.dataService
|
||||||
|
.fetchPortfolioPerformance({ range: this.dateRange })
|
||||||
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
|
.subscribe((response) => {
|
||||||
|
this.performance = response;
|
||||||
|
this.isLoadingPerformance = false;
|
||||||
|
|
||||||
|
this.changeDetectorRef.markForCheck();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.changeDetectorRef.markForCheck();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
<div
|
||||||
|
class="
|
||||||
|
align-items-center
|
||||||
|
container
|
||||||
|
d-flex
|
||||||
|
flex-column
|
||||||
|
h-100
|
||||||
|
justify-content-center
|
||||||
|
overview
|
||||||
|
p-0
|
||||||
|
position-relative
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<div class="row w-100">
|
||||||
|
<div class="chart-container col">
|
||||||
|
<gf-line-chart
|
||||||
|
symbol="Performance"
|
||||||
|
[historicalDataItems]="historicalDataItems"
|
||||||
|
[ngClass]="{ 'pr-3': deviceType === 'mobile' }"
|
||||||
|
[showGradient]="true"
|
||||||
|
[showLoader]="false"
|
||||||
|
[showXAxis]="false"
|
||||||
|
[showYAxis]="false"
|
||||||
|
></gf-line-chart>
|
||||||
|
<div
|
||||||
|
*ngIf="historicalDataItems?.length === 0"
|
||||||
|
class="align-items-center d-flex h-100 justify-content-center w-100"
|
||||||
|
>
|
||||||
|
<div class="d-flex justify-content-center">
|
||||||
|
<gf-no-transactions-info-indicator></gf-no-transactions-info-indicator>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="overview-container row mt-1">
|
||||||
|
<div class="col">
|
||||||
|
<gf-portfolio-performance
|
||||||
|
class="pb-4"
|
||||||
|
[baseCurrency]="user?.settings?.baseCurrency"
|
||||||
|
[isAllTimeHigh]="isAllTimeHigh"
|
||||||
|
[isAllTimeLow]="isAllTimeLow"
|
||||||
|
[isLoading]="isLoadingPerformance"
|
||||||
|
[locale]="user?.settings?.locale"
|
||||||
|
[performance]="performance"
|
||||||
|
[showDetails]="!hasImpersonationId && !user.settings.isRestrictedView"
|
||||||
|
></gf-portfolio-performance>
|
||||||
|
<div class="text-center">
|
||||||
|
<gf-toggle
|
||||||
|
[defaultValue]="dateRange"
|
||||||
|
[isLoading]="isLoadingPerformance"
|
||||||
|
[options]="dateRangeOptions"
|
||||||
|
(change)="onChangeDateRange($event.value)"
|
||||||
|
></gf-toggle>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -0,0 +1,25 @@
|
|||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
|
||||||
|
import { RouterModule } from '@angular/router';
|
||||||
|
import { GfPortfolioPerformanceModule } from '@ghostfolio/client/components/portfolio-performance/portfolio-performance.module';
|
||||||
|
import { GfToggleModule } from '@ghostfolio/client/components/toggle/toggle.module';
|
||||||
|
import { GfLineChartModule } from '@ghostfolio/ui/line-chart/line-chart.module';
|
||||||
|
import { GfNoTransactionsInfoModule } from '@ghostfolio/ui/no-transactions-info';
|
||||||
|
|
||||||
|
import { HomeOverviewComponent } from './home-overview.component';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [HomeOverviewComponent],
|
||||||
|
exports: [],
|
||||||
|
imports: [
|
||||||
|
CommonModule,
|
||||||
|
GfLineChartModule,
|
||||||
|
GfNoTransactionsInfoModule,
|
||||||
|
GfPortfolioPerformanceModule,
|
||||||
|
GfToggleModule,
|
||||||
|
RouterModule
|
||||||
|
],
|
||||||
|
providers: [],
|
||||||
|
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||||
|
})
|
||||||
|
export class GfHomeOverviewModule {}
|
@ -0,0 +1,34 @@
|
|||||||
|
@import '~apps/client/src/styles/ghostfolio-style';
|
||||||
|
|
||||||
|
:host {
|
||||||
|
display: block;
|
||||||
|
|
||||||
|
.chart-container {
|
||||||
|
aspect-ratio: 16 / 9;
|
||||||
|
max-height: 50vh;
|
||||||
|
|
||||||
|
// Fallback for aspect-ratio (using padding hack)
|
||||||
|
@supports not (aspect-ratio: 16 / 9) {
|
||||||
|
&::before {
|
||||||
|
float: left;
|
||||||
|
padding-top: 56.25%;
|
||||||
|
content: '';
|
||||||
|
}
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
display: block;
|
||||||
|
content: '';
|
||||||
|
clear: both;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gf-line-chart {
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
z-index: -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
|
||||||
|
import { DataService } from '@ghostfolio/client/services/data.service';
|
||||||
|
import { UserService } from '@ghostfolio/client/services/user/user.service';
|
||||||
|
import { PortfolioSummary, User } from '@ghostfolio/common/interfaces';
|
||||||
|
import { Subject } from 'rxjs';
|
||||||
|
import { takeUntil } from 'rxjs/operators';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'gf-home-summary',
|
||||||
|
styleUrls: ['./home-summary.scss'],
|
||||||
|
templateUrl: './home-summary.html'
|
||||||
|
})
|
||||||
|
export class HomeSummaryComponent implements OnDestroy, OnInit {
|
||||||
|
public isLoading = true;
|
||||||
|
public summary: PortfolioSummary;
|
||||||
|
public user: User;
|
||||||
|
|
||||||
|
private unsubscribeSubject = new Subject<void>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
public constructor(
|
||||||
|
private changeDetectorRef: ChangeDetectorRef,
|
||||||
|
private dataService: DataService,
|
||||||
|
private userService: UserService
|
||||||
|
) {
|
||||||
|
this.userService.stateChanged
|
||||||
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
|
.subscribe((state) => {
|
||||||
|
if (state?.user) {
|
||||||
|
this.user = state.user;
|
||||||
|
|
||||||
|
this.changeDetectorRef.markForCheck();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the controller
|
||||||
|
*/
|
||||||
|
public ngOnInit() {
|
||||||
|
this.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ngOnDestroy() {
|
||||||
|
this.unsubscribeSubject.next();
|
||||||
|
this.unsubscribeSubject.complete();
|
||||||
|
}
|
||||||
|
|
||||||
|
private update() {
|
||||||
|
this.isLoading = true;
|
||||||
|
|
||||||
|
this.dataService
|
||||||
|
.fetchPortfolioSummary()
|
||||||
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
|
.subscribe((response) => {
|
||||||
|
this.summary = response;
|
||||||
|
this.isLoading = false;
|
||||||
|
|
||||||
|
this.changeDetectorRef.markForCheck();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.changeDetectorRef.markForCheck();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
<div class="container pb-3 px-3">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-12 col-md-8 offset-md-2">
|
||||||
|
<mat-card class="h-100">
|
||||||
|
<mat-card-header>
|
||||||
|
<mat-card-title i18n>Summary</mat-card-title>
|
||||||
|
</mat-card-header>
|
||||||
|
<mat-card-content>
|
||||||
|
<gf-portfolio-summary
|
||||||
|
[baseCurrency]="user?.settings?.baseCurrency"
|
||||||
|
[isLoading]="isLoading"
|
||||||
|
[locale]="user?.settings?.locale"
|
||||||
|
[summary]="summary"
|
||||||
|
></gf-portfolio-summary>
|
||||||
|
</mat-card-content>
|
||||||
|
</mat-card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -0,0 +1,21 @@
|
|||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
|
||||||
|
import { MatCardModule } from '@angular/material/card';
|
||||||
|
import { RouterModule } from '@angular/router';
|
||||||
|
import { GfPortfolioSummaryModule } from '@ghostfolio/client/components/portfolio-summary/portfolio-summary.module';
|
||||||
|
|
||||||
|
import { HomeSummaryComponent } from './home-summary.component';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [HomeSummaryComponent],
|
||||||
|
exports: [],
|
||||||
|
imports: [
|
||||||
|
CommonModule,
|
||||||
|
GfPortfolioSummaryModule,
|
||||||
|
MatCardModule,
|
||||||
|
RouterModule
|
||||||
|
],
|
||||||
|
providers: [],
|
||||||
|
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||||
|
})
|
||||||
|
export class GfHomeSummaryModule {}
|
@ -0,0 +1,5 @@
|
|||||||
|
@import '~apps/client/src/styles/ghostfolio-style';
|
||||||
|
|
||||||
|
:host {
|
||||||
|
display: block;
|
||||||
|
}
|
@ -43,6 +43,7 @@ export class PositionDetailDialog implements OnDestroy {
|
|||||||
public quantityPrecision = 2;
|
public quantityPrecision = 2;
|
||||||
public symbol: string;
|
public symbol: string;
|
||||||
public transactionCount: number;
|
public transactionCount: number;
|
||||||
|
public value: number;
|
||||||
|
|
||||||
private unsubscribeSubject = new Subject<void>();
|
private unsubscribeSubject = new Subject<void>();
|
||||||
|
|
||||||
@ -73,7 +74,8 @@ export class PositionDetailDialog implements OnDestroy {
|
|||||||
netPerformancePercent,
|
netPerformancePercent,
|
||||||
quantity,
|
quantity,
|
||||||
symbol,
|
symbol,
|
||||||
transactionCount
|
transactionCount,
|
||||||
|
value
|
||||||
}) => {
|
}) => {
|
||||||
this.assetSubClass = assetSubClass;
|
this.assetSubClass = assetSubClass;
|
||||||
this.averagePrice = averagePrice;
|
this.averagePrice = averagePrice;
|
||||||
@ -105,6 +107,7 @@ export class PositionDetailDialog implements OnDestroy {
|
|||||||
this.quantity = quantity;
|
this.quantity = quantity;
|
||||||
this.symbol = symbol;
|
this.symbol = symbol;
|
||||||
this.transactionCount = transactionCount;
|
this.transactionCount = transactionCount;
|
||||||
|
this.value = value;
|
||||||
|
|
||||||
if (isToday(parseISO(this.firstBuyDate))) {
|
if (isToday(parseISO(this.firstBuyDate))) {
|
||||||
// Add average price
|
// Add average price
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<gf-dialog-header
|
<gf-dialog-header
|
||||||
mat-dialog-title
|
mat-dialog-title
|
||||||
|
position="center"
|
||||||
[deviceType]="data.deviceType"
|
[deviceType]="data.deviceType"
|
||||||
[title]="name ?? symbol"
|
[title]="name ?? symbol"
|
||||||
(closeButtonClicked)="onClose()"
|
(closeButtonClicked)="onClose()"
|
||||||
@ -7,6 +8,17 @@
|
|||||||
|
|
||||||
<div class="flex-grow-1" mat-dialog-content>
|
<div class="flex-grow-1" mat-dialog-content>
|
||||||
<div class="container p-0">
|
<div class="container p-0">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12 d-flex justify-content-center mb-3">
|
||||||
|
<gf-value
|
||||||
|
size="large"
|
||||||
|
[currency]="data.baseCurrency"
|
||||||
|
[locale]="data.locale"
|
||||||
|
[value]="value"
|
||||||
|
></gf-value>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<gf-line-chart
|
<gf-line-chart
|
||||||
class="mb-4"
|
class="mb-4"
|
||||||
benchmarkLabel="Buy Price"
|
benchmarkLabel="Buy Price"
|
||||||
|
@ -254,10 +254,12 @@
|
|||||||
*matRowDef="let row; columns: displayedColumns"
|
*matRowDef="let row; columns: displayedColumns"
|
||||||
mat-row
|
mat-row
|
||||||
(click)="
|
(click)="
|
||||||
|
!row.isDraft &&
|
||||||
onOpenPositionDialog({
|
onOpenPositionDialog({
|
||||||
symbol: row.symbol
|
symbol: row.symbol
|
||||||
})
|
})
|
||||||
"
|
"
|
||||||
|
[ngClass]="{ 'is-draft': row.isDraft }"
|
||||||
></tr>
|
></tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
@ -24,7 +24,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.mat-row {
|
.mat-row {
|
||||||
|
&:not(.is-draft) {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
.type-badge {
|
.type-badge {
|
||||||
background-color: rgba(var(--palette-foreground-text), 0.05);
|
background-color: rgba(var(--palette-foreground-text), 0.05);
|
||||||
|
@ -1,11 +1,24 @@
|
|||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { RouterModule, Routes } from '@angular/router';
|
import { RouterModule, Routes } from '@angular/router';
|
||||||
|
import { AdminMarketDataComponent } from '@ghostfolio/client/components/admin-market-data/admin-market-data.component';
|
||||||
|
import { AdminOverviewComponent } from '@ghostfolio/client/components/admin-overview/admin-overview.component';
|
||||||
|
import { AdminUsersComponent } from '@ghostfolio/client/components/admin-users/admin-users.component';
|
||||||
import { AuthGuard } from '@ghostfolio/client/core/auth.guard';
|
import { AuthGuard } from '@ghostfolio/client/core/auth.guard';
|
||||||
|
|
||||||
import { AdminPageComponent } from './admin-page.component';
|
import { AdminPageComponent } from './admin-page.component';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: '', component: AdminPageComponent, canActivate: [AuthGuard] }
|
{
|
||||||
|
path: '',
|
||||||
|
component: AdminPageComponent,
|
||||||
|
canActivate: [AuthGuard],
|
||||||
|
children: [
|
||||||
|
{ path: '', redirectTo: 'overview', pathMatch: 'full' },
|
||||||
|
{ path: 'market-data', component: AdminMarketDataComponent },
|
||||||
|
{ path: 'overview', component: AdminOverviewComponent },
|
||||||
|
{ path: 'users', component: AdminUsersComponent }
|
||||||
|
]
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
@ -1,169 +1,26 @@
|
|||||||
import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
|
import { Component, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { AdminService } from '@ghostfolio/client/services/admin.service';
|
|
||||||
import { CacheService } from '@ghostfolio/client/services/cache.service';
|
|
||||||
import { DataService } from '@ghostfolio/client/services/data.service';
|
|
||||||
import { UserService } from '@ghostfolio/client/services/user/user.service';
|
|
||||||
import { DEFAULT_DATE_FORMAT } from '@ghostfolio/common/config';
|
|
||||||
import { AdminData, User } from '@ghostfolio/common/interfaces';
|
|
||||||
import {
|
|
||||||
differenceInSeconds,
|
|
||||||
formatDistanceToNowStrict,
|
|
||||||
isValid,
|
|
||||||
parseISO
|
|
||||||
} from 'date-fns';
|
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
host: { class: 'mb-5' },
|
|
||||||
selector: 'gf-admin-page',
|
selector: 'gf-admin-page',
|
||||||
styleUrls: ['./admin-page.scss'],
|
styleUrls: ['./admin-page.scss'],
|
||||||
templateUrl: './admin-page.html'
|
templateUrl: './admin-page.html'
|
||||||
})
|
})
|
||||||
export class AdminPageComponent implements OnDestroy, OnInit {
|
export class AdminPageComponent implements OnDestroy, OnInit {
|
||||||
public dataGatheringInProgress: boolean;
|
|
||||||
public dataGatheringProgress: number;
|
|
||||||
public defaultDateFormat = DEFAULT_DATE_FORMAT;
|
|
||||||
public exchangeRates: { label1: string; label2: string; value: number }[];
|
|
||||||
public lastDataGathering: string;
|
|
||||||
public transactionCount: number;
|
|
||||||
public userCount: number;
|
|
||||||
public user: User;
|
|
||||||
public users: AdminData['users'];
|
|
||||||
|
|
||||||
private unsubscribeSubject = new Subject<void>();
|
private unsubscribeSubject = new Subject<void>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
public constructor(
|
public constructor() {}
|
||||||
private adminService: AdminService,
|
|
||||||
private cacheService: CacheService,
|
|
||||||
private changeDetectorRef: ChangeDetectorRef,
|
|
||||||
private dataService: DataService,
|
|
||||||
private userService: UserService
|
|
||||||
) {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the controller
|
* Initializes the controller
|
||||||
*/
|
*/
|
||||||
public ngOnInit() {
|
public ngOnInit() {}
|
||||||
this.fetchAdminData();
|
|
||||||
|
|
||||||
this.userService.stateChanged
|
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
|
||||||
.subscribe((state) => {
|
|
||||||
if (state?.user) {
|
|
||||||
this.user = state.user;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public onFlushCache() {
|
|
||||||
this.cacheService
|
|
||||||
.flush()
|
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
|
||||||
.subscribe(() => {
|
|
||||||
setTimeout(() => {
|
|
||||||
window.location.reload();
|
|
||||||
}, 300);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public onGatherMax() {
|
|
||||||
const confirmation = confirm(
|
|
||||||
'This action may take some time. Do you want to proceed?'
|
|
||||||
);
|
|
||||||
|
|
||||||
if (confirmation === true) {
|
|
||||||
this.adminService
|
|
||||||
.gatherMax()
|
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
|
||||||
.subscribe(() => {
|
|
||||||
setTimeout(() => {
|
|
||||||
window.location.reload();
|
|
||||||
}, 300);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public onGatherProfileData() {
|
|
||||||
this.adminService
|
|
||||||
.gatherProfileData()
|
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
|
||||||
.subscribe(() => {});
|
|
||||||
}
|
|
||||||
|
|
||||||
public formatDistanceToNow(aDateString: string) {
|
|
||||||
if (aDateString) {
|
|
||||||
const distanceString = formatDistanceToNowStrict(parseISO(aDateString), {
|
|
||||||
addSuffix: true
|
|
||||||
});
|
|
||||||
|
|
||||||
return Math.abs(differenceInSeconds(parseISO(aDateString), new Date())) <
|
|
||||||
60
|
|
||||||
? 'just now'
|
|
||||||
: distanceString;
|
|
||||||
}
|
|
||||||
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
public onDeleteUser(aId: string) {
|
|
||||||
const confirmation = confirm('Do you really want to delete this user?');
|
|
||||||
|
|
||||||
if (confirmation) {
|
|
||||||
this.dataService
|
|
||||||
.deleteUser(aId)
|
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
|
||||||
.subscribe({
|
|
||||||
next: () => {
|
|
||||||
this.fetchAdminData();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ngOnDestroy() {
|
public ngOnDestroy() {
|
||||||
this.unsubscribeSubject.next();
|
this.unsubscribeSubject.next();
|
||||||
this.unsubscribeSubject.complete();
|
this.unsubscribeSubject.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
private fetchAdminData() {
|
|
||||||
this.dataService
|
|
||||||
.fetchAdminData()
|
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
|
||||||
.subscribe(
|
|
||||||
({
|
|
||||||
dataGatheringProgress,
|
|
||||||
exchangeRates,
|
|
||||||
lastDataGathering,
|
|
||||||
transactionCount,
|
|
||||||
userCount,
|
|
||||||
users
|
|
||||||
}) => {
|
|
||||||
this.dataGatheringProgress = dataGatheringProgress;
|
|
||||||
this.exchangeRates = exchangeRates;
|
|
||||||
this.users = users;
|
|
||||||
|
|
||||||
if (isValid(parseISO(lastDataGathering?.toString()))) {
|
|
||||||
this.lastDataGathering = formatDistanceToNowStrict(
|
|
||||||
new Date(lastDataGathering),
|
|
||||||
{
|
|
||||||
addSuffix: true
|
|
||||||
}
|
|
||||||
);
|
|
||||||
} else if (lastDataGathering === 'IN_PROGRESS') {
|
|
||||||
this.dataGatheringInProgress = true;
|
|
||||||
} else {
|
|
||||||
this.lastDataGathering = 'Starting soon...';
|
|
||||||
}
|
|
||||||
|
|
||||||
this.transactionCount = transactionCount;
|
|
||||||
this.userCount = userCount;
|
|
||||||
|
|
||||||
this.changeDetectorRef.markForCheck();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,195 +1,18 @@
|
|||||||
<div class="container">
|
<router-outlet></router-outlet>
|
||||||
<div class="mb-5 row">
|
|
||||||
<div class="col">
|
<nav mat-align-tabs="center" mat-tab-nav-bar>
|
||||||
<h3 class="d-flex justify-content-center mb-3" i18n>
|
<a
|
||||||
Admin Control Panel
|
*ngFor="let link of [
|
||||||
</h3>
|
{ iconName: 'reader-outline', path: 'overview' },
|
||||||
<mat-card class="mb-3">
|
{ iconName: 'people-outline', path: 'users' },
|
||||||
<mat-card-content>
|
{ iconName: 'server-outline', path: 'market-data' }
|
||||||
<div
|
]"
|
||||||
*ngIf="exchangeRates?.length > 0"
|
#rla="routerLinkActive"
|
||||||
class="align-items-start d-flex my-3"
|
mat-tab-link
|
||||||
|
routerLinkActive
|
||||||
|
[active]="rla.isActive"
|
||||||
|
[routerLink]="link.path"
|
||||||
>
|
>
|
||||||
<div class="w-50" i18n>Exchange Rates</div>
|
<ion-icon size="large" [name]="link.iconName"></ion-icon>
|
||||||
<div class="w-50">
|
</a>
|
||||||
<table>
|
</nav>
|
||||||
<tr *ngFor="let exchangeRate of exchangeRates">
|
|
||||||
<td class="d-flex">
|
|
||||||
<gf-value
|
|
||||||
[locale]="user?.settings?.locale"
|
|
||||||
[value]="1"
|
|
||||||
></gf-value>
|
|
||||||
</td>
|
|
||||||
<td class="pl-1">{{ exchangeRate.label1 }}</td>
|
|
||||||
<td class="px-1">=</td>
|
|
||||||
<td class="d-flex justify-content-end">
|
|
||||||
<gf-value
|
|
||||||
[locale]="user?.settings?.locale"
|
|
||||||
[precision]="4"
|
|
||||||
[value]="exchangeRate.value"
|
|
||||||
></gf-value>
|
|
||||||
</td>
|
|
||||||
<td class="pl-1">{{ exchangeRate.label2 }}</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="d-flex my-3">
|
|
||||||
<div class="w-50" i18n>Data Gathering</div>
|
|
||||||
<div class="w-50">
|
|
||||||
<div>
|
|
||||||
<ng-container *ngIf="lastDataGathering"
|
|
||||||
>{{ lastDataGathering }}</ng-container
|
|
||||||
>
|
|
||||||
<ng-container *ngIf="dataGatheringInProgress" i18n
|
|
||||||
>In Progress ({{ dataGatheringProgress | percent : '1.2-2'
|
|
||||||
}})</ng-container
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<div class="mt-2 overflow-hidden">
|
|
||||||
<div class="mb-2">
|
|
||||||
<button
|
|
||||||
class="mw-100"
|
|
||||||
color="accent"
|
|
||||||
mat-flat-button
|
|
||||||
(click)="onFlushCache()"
|
|
||||||
>
|
|
||||||
<ion-icon
|
|
||||||
class="mr-1"
|
|
||||||
name="close-circle-outline"
|
|
||||||
></ion-icon>
|
|
||||||
<span i18n>Reset Data Gathering</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div class="mb-2">
|
|
||||||
<button
|
|
||||||
class="mw-100"
|
|
||||||
color="warn"
|
|
||||||
mat-flat-button
|
|
||||||
[disabled]="dataGatheringInProgress"
|
|
||||||
(click)="onGatherMax()"
|
|
||||||
>
|
|
||||||
<ion-icon class="mr-1" name="warning-outline"></ion-icon>
|
|
||||||
<span i18n>Gather All Data</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<button
|
|
||||||
class="mb-2 mr-2 mw-100"
|
|
||||||
color="accent"
|
|
||||||
mat-flat-button
|
|
||||||
(click)="onGatherProfileData()"
|
|
||||||
>
|
|
||||||
<ion-icon
|
|
||||||
class="mr-1"
|
|
||||||
name="cloud-download-outline"
|
|
||||||
></ion-icon>
|
|
||||||
<span i18n>Gather Profile Data</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="d-flex my-3">
|
|
||||||
<div class="w-50" i18n>User Count</div>
|
|
||||||
<div class="w-50">{{ userCount }}</div>
|
|
||||||
</div>
|
|
||||||
<div class="d-flex my-3">
|
|
||||||
<div class="w-50" i18n>Transaction Count</div>
|
|
||||||
<div class="w-50">
|
|
||||||
<ng-container *ngIf="transactionCount">
|
|
||||||
{{ transactionCount }} ({{ transactionCount / userCount | number
|
|
||||||
: '1.2-2' }} <span i18n>per User</span>)
|
|
||||||
</ng-container>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</mat-card-content>
|
|
||||||
</mat-card>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col">
|
|
||||||
<h3 class="mb-3 text-center" i18n>Users</h3>
|
|
||||||
<div class="users">
|
|
||||||
<table class="gf-table">
|
|
||||||
<thead>
|
|
||||||
<tr class="mat-header-row">
|
|
||||||
<th class="mat-header-cell px-1 py-2 text-right" i18n>#</th>
|
|
||||||
<th class="mat-header-cell px-1 py-2" i18n>User</th>
|
|
||||||
<th class="mat-header-cell px-1 py-2 text-right" i18n>
|
|
||||||
Registration
|
|
||||||
</th>
|
|
||||||
<th class="mat-header-cell px-1 py-2 text-right" i18n>
|
|
||||||
Accounts
|
|
||||||
</th>
|
|
||||||
<th class="mat-header-cell px-1 py-2 text-right" i18n>
|
|
||||||
Transactions
|
|
||||||
</th>
|
|
||||||
<th class="mat-header-cell px-1 py-2 text-right" i18n>
|
|
||||||
Engagement per Day
|
|
||||||
</th>
|
|
||||||
<th class="mat-header-cell px-1 py-2" i18n>Last Activitiy</th>
|
|
||||||
<th class="mat-header-cell px-1 py-2"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr *ngFor="let userItem of users; let i = index" class="mat-row">
|
|
||||||
<td class="mat-cell px-1 py-2 text-right">{{ i + 1 }}</td>
|
|
||||||
<td class="mat-cell px-1 py-2">
|
|
||||||
<div class="d-flex align-items-center">
|
|
||||||
<span class="d-none d-sm-inline-block"
|
|
||||||
>{{ userItem.alias || userItem.id }}</span
|
|
||||||
>
|
|
||||||
<span class="d-inline-block d-sm-none"
|
|
||||||
>{{ userItem.alias || (userItem.id | slice:0:5) +
|
|
||||||
'...' }}</span
|
|
||||||
>
|
|
||||||
<ion-icon
|
|
||||||
*ngIf="userItem?.subscription?.type === 'Premium'"
|
|
||||||
class="ml-1 text-muted"
|
|
||||||
name="diamond-outline"
|
|
||||||
></ion-icon>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td class="mat-cell px-1 py-2 text-right">
|
|
||||||
{{ formatDistanceToNow(userItem.createdAt) }}
|
|
||||||
</td>
|
|
||||||
<td class="mat-cell px-1 py-2 text-right">
|
|
||||||
{{ userItem.accountCount }}
|
|
||||||
</td>
|
|
||||||
<td class="mat-cell px-1 py-2 text-right">
|
|
||||||
{{ userItem.transactionCount }}
|
|
||||||
</td>
|
|
||||||
<td class="mat-cell px-1 py-2 text-right">
|
|
||||||
{{ userItem.engagement | number: '1.0-0' }}
|
|
||||||
</td>
|
|
||||||
<td class="mat-cell px-1 py-2">
|
|
||||||
{{ formatDistanceToNow(userItem.lastActivity) }}
|
|
||||||
</td>
|
|
||||||
<td class="mat-cell px-1 py-2">
|
|
||||||
<button
|
|
||||||
class="mx-1 no-min-width px-2"
|
|
||||||
mat-button
|
|
||||||
[matMenuTriggerFor]="accountMenu"
|
|
||||||
(click)="$event.stopPropagation()"
|
|
||||||
>
|
|
||||||
<ion-icon name="ellipsis-vertical"></ion-icon>
|
|
||||||
</button>
|
|
||||||
<mat-menu #accountMenu="matMenu" xPosition="before">
|
|
||||||
<button
|
|
||||||
i18n
|
|
||||||
mat-menu-item
|
|
||||||
[disabled]="userItem.id === user?.id"
|
|
||||||
(click)="onDeleteUser(userItem.id)"
|
|
||||||
>
|
|
||||||
Delete
|
|
||||||
</button>
|
|
||||||
</mat-menu>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
@ -3,6 +3,10 @@ import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
|
|||||||
import { MatButtonModule } from '@angular/material/button';
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
import { MatCardModule } from '@angular/material/card';
|
import { MatCardModule } from '@angular/material/card';
|
||||||
import { MatMenuModule } from '@angular/material/menu';
|
import { MatMenuModule } from '@angular/material/menu';
|
||||||
|
import { MatTabsModule } from '@angular/material/tabs';
|
||||||
|
import { GfAdminMarketDataModule } from '@ghostfolio/client/components/admin-market-data/admin-market-data.module';
|
||||||
|
import { GfAdminOverviewModule } from '@ghostfolio/client/components/admin-overview/admin-overview.module';
|
||||||
|
import { GfAdminUsersModule } from '@ghostfolio/client/components/admin-users/admin-users.module';
|
||||||
import { CacheService } from '@ghostfolio/client/services/cache.service';
|
import { CacheService } from '@ghostfolio/client/services/cache.service';
|
||||||
import { GfValueModule } from '@ghostfolio/ui/value';
|
import { GfValueModule } from '@ghostfolio/ui/value';
|
||||||
|
|
||||||
@ -15,10 +19,14 @@ import { AdminPageComponent } from './admin-page.component';
|
|||||||
imports: [
|
imports: [
|
||||||
AdminPageRoutingModule,
|
AdminPageRoutingModule,
|
||||||
CommonModule,
|
CommonModule,
|
||||||
|
GfAdminMarketDataModule,
|
||||||
|
GfAdminOverviewModule,
|
||||||
|
GfAdminUsersModule,
|
||||||
GfValueModule,
|
GfValueModule,
|
||||||
MatButtonModule,
|
MatButtonModule,
|
||||||
MatCardModule,
|
MatCardModule,
|
||||||
MatMenuModule
|
MatMenuModule,
|
||||||
|
MatTabsModule
|
||||||
],
|
],
|
||||||
providers: [CacheService],
|
providers: [CacheService],
|
||||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||||
|
@ -2,29 +2,32 @@
|
|||||||
|
|
||||||
:host {
|
:host {
|
||||||
color: rgb(var(--dark-primary-text));
|
color: rgb(var(--dark-primary-text));
|
||||||
display: block;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
height: calc(100vh - 5rem);
|
||||||
|
overflow-y: auto;
|
||||||
|
|
||||||
.users {
|
padding-bottom: env(safe-area-inset-bottom);
|
||||||
overflow-x: auto;
|
padding-bottom: constant(safe-area-inset-bottom);
|
||||||
|
|
||||||
table {
|
|
||||||
min-width: 100%;
|
|
||||||
|
|
||||||
.mat-row,
|
|
||||||
.mat-header-row {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.mat-flat-button {
|
|
||||||
::ng-deep {
|
::ng-deep {
|
||||||
.mat-button-wrapper {
|
gf-admin-market-data,
|
||||||
display: block;
|
gf-admin-overview,
|
||||||
overflow: hidden;
|
gf-admin-users {
|
||||||
text-overflow: ellipsis;
|
flex: 1 1 auto;
|
||||||
white-space: nowrap;
|
overflow-y: auto;
|
||||||
width: 100%;
|
}
|
||||||
|
|
||||||
|
.mat-tab-header {
|
||||||
|
border-bottom: 0;
|
||||||
|
|
||||||
|
.mat-ink-bar {
|
||||||
|
visibility: hidden !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mat-tab-label-active {
|
||||||
|
color: rgba(var(--palette-primary-500), 1);
|
||||||
|
opacity: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,26 @@
|
|||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { RouterModule, Routes } from '@angular/router';
|
import { RouterModule, Routes } from '@angular/router';
|
||||||
|
import { HomeHoldingsComponent } from '@ghostfolio/client/components/home-holdings/home-holdings.component';
|
||||||
|
import { HomeMarketComponent } from '@ghostfolio/client/components/home-market/home-market.component';
|
||||||
|
import { HomeOverviewComponent } from '@ghostfolio/client/components/home-overview/home-overview.component';
|
||||||
|
import { HomeSummaryComponent } from '@ghostfolio/client/components/home-summary/home-summary.component';
|
||||||
import { AuthGuard } from '@ghostfolio/client/core/auth.guard';
|
import { AuthGuard } from '@ghostfolio/client/core/auth.guard';
|
||||||
|
|
||||||
import { HomePageComponent } from './home-page.component';
|
import { HomePageComponent } from './home-page.component';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: '', component: HomePageComponent, canActivate: [AuthGuard] }
|
{
|
||||||
|
path: '',
|
||||||
|
component: HomePageComponent,
|
||||||
|
canActivate: [AuthGuard],
|
||||||
|
children: [
|
||||||
|
{ path: '', redirectTo: 'overview', pathMatch: 'full' },
|
||||||
|
{ path: 'overview', component: HomeOverviewComponent },
|
||||||
|
{ path: 'holdings', component: HomeHoldingsComponent },
|
||||||
|
{ path: 'summary', component: HomeSummaryComponent },
|
||||||
|
{ path: 'market', component: HomeMarketComponent }
|
||||||
|
]
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
@ -1,34 +1,16 @@
|
|||||||
import {
|
import {
|
||||||
ChangeDetectorRef,
|
ChangeDetectorRef,
|
||||||
Component,
|
Component,
|
||||||
ElementRef,
|
|
||||||
HostBinding,
|
HostBinding,
|
||||||
OnDestroy,
|
OnDestroy,
|
||||||
OnInit,
|
OnInit
|
||||||
ViewChild
|
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { MatTabChangeEvent } from '@angular/material/tabs';
|
|
||||||
import { ToggleOption } from '@ghostfolio/client/components/toggle/interfaces/toggle-option.type';
|
|
||||||
import { DataService } from '@ghostfolio/client/services/data.service';
|
|
||||||
import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service';
|
import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service';
|
||||||
import {
|
|
||||||
RANGE,
|
|
||||||
SettingsStorageService
|
|
||||||
} from '@ghostfolio/client/services/settings-storage.service';
|
|
||||||
import { UserService } from '@ghostfolio/client/services/user/user.service';
|
import { UserService } from '@ghostfolio/client/services/user/user.service';
|
||||||
import { ghostfolioFearAndGreedIndexSymbol } from '@ghostfolio/common/config';
|
import { User } from '@ghostfolio/common/interfaces';
|
||||||
import {
|
|
||||||
PortfolioPerformance,
|
|
||||||
PortfolioSummary,
|
|
||||||
Position,
|
|
||||||
User
|
|
||||||
} from '@ghostfolio/common/interfaces';
|
|
||||||
import { hasPermission, permissions } from '@ghostfolio/common/permissions';
|
import { hasPermission, permissions } from '@ghostfolio/common/permissions';
|
||||||
import { DateRange } from '@ghostfolio/common/types';
|
|
||||||
import { LineChartItem } from '@ghostfolio/ui/line-chart/interfaces/line-chart.interface';
|
|
||||||
import { DataSource } from '@prisma/client';
|
|
||||||
import { DeviceDetectorService } from 'ngx-device-detector';
|
import { DeviceDetectorService } from 'ngx-device-detector';
|
||||||
import { Subject, Subscription } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil } from 'rxjs/operators';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -41,32 +23,9 @@ export class HomePageComponent implements OnDestroy, OnInit {
|
|||||||
return this.canCreateAccount;
|
return this.canCreateAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ViewChild('positionsContainer') positionsContainer: ElementRef;
|
|
||||||
|
|
||||||
public canCreateAccount: boolean;
|
public canCreateAccount: boolean;
|
||||||
public currentTabIndex = 0;
|
|
||||||
public dateRange: DateRange;
|
|
||||||
public dateRangeOptions: ToggleOption[] = [
|
|
||||||
{ label: 'Today', value: '1d' },
|
|
||||||
{ label: 'YTD', value: 'ytd' },
|
|
||||||
{ label: '1Y', value: '1y' },
|
|
||||||
{ label: '5Y', value: '5y' },
|
|
||||||
{ label: 'Max', value: 'max' }
|
|
||||||
];
|
|
||||||
public deviceType: string;
|
|
||||||
public fearAndGreedIndex: number;
|
|
||||||
public hasImpersonationId: boolean;
|
|
||||||
public hasPermissionToAccessFearAndGreedIndex: boolean;
|
public hasPermissionToAccessFearAndGreedIndex: boolean;
|
||||||
public hasPermissionToCreateOrder: boolean;
|
public tabs: { iconName: string; path: string }[] = [];
|
||||||
public historicalDataItems: LineChartItem[];
|
|
||||||
public isAllTimeHigh: boolean;
|
|
||||||
public isAllTimeLow: boolean;
|
|
||||||
public isLoadingPerformance = true;
|
|
||||||
public isLoadingSummary = true;
|
|
||||||
public performance: PortfolioPerformance;
|
|
||||||
public positions: Position[];
|
|
||||||
public routeQueryParams: Subscription;
|
|
||||||
public summary: PortfolioSummary;
|
|
||||||
public user: User;
|
public user: User;
|
||||||
|
|
||||||
private unsubscribeSubject = new Subject<void>();
|
private unsubscribeSubject = new Subject<void>();
|
||||||
@ -76,16 +35,19 @@ export class HomePageComponent implements OnDestroy, OnInit {
|
|||||||
*/
|
*/
|
||||||
public constructor(
|
public constructor(
|
||||||
private changeDetectorRef: ChangeDetectorRef,
|
private changeDetectorRef: ChangeDetectorRef,
|
||||||
private dataService: DataService,
|
|
||||||
private deviceService: DeviceDetectorService,
|
private deviceService: DeviceDetectorService,
|
||||||
private impersonationStorageService: ImpersonationStorageService,
|
private impersonationStorageService: ImpersonationStorageService,
|
||||||
private settingsStorageService: SettingsStorageService,
|
|
||||||
private userService: UserService
|
private userService: UserService
|
||||||
) {
|
) {
|
||||||
this.userService.stateChanged
|
this.userService.stateChanged
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
.subscribe((state) => {
|
.subscribe((state) => {
|
||||||
if (state?.user) {
|
if (state?.user) {
|
||||||
|
this.tabs = [
|
||||||
|
{ iconName: 'analytics-outline', path: 'overview' },
|
||||||
|
{ iconName: 'wallet-outline', path: 'holdings' },
|
||||||
|
{ iconName: 'reader-outline', path: 'summary' }
|
||||||
|
];
|
||||||
this.user = state.user;
|
this.user = state.user;
|
||||||
|
|
||||||
this.canCreateAccount = hasPermission(
|
this.canCreateAccount = hasPermission(
|
||||||
@ -99,24 +61,9 @@ export class HomePageComponent implements OnDestroy, OnInit {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (this.hasPermissionToAccessFearAndGreedIndex) {
|
if (this.hasPermissionToAccessFearAndGreedIndex) {
|
||||||
this.dataService
|
this.tabs.push({ iconName: 'newspaper-outline', path: 'market' });
|
||||||
.fetchSymbolItem({
|
|
||||||
dataSource: DataSource.RAKUTEN,
|
|
||||||
symbol: ghostfolioFearAndGreedIndexSymbol
|
|
||||||
})
|
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
|
||||||
.subscribe(({ marketPrice }) => {
|
|
||||||
this.fearAndGreedIndex = marketPrice;
|
|
||||||
|
|
||||||
this.changeDetectorRef.markForCheck();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.hasPermissionToCreateOrder = hasPermission(
|
|
||||||
this.user.permissions,
|
|
||||||
permissions.createOrder
|
|
||||||
);
|
|
||||||
|
|
||||||
this.changeDetectorRef.markForCheck();
|
this.changeDetectorRef.markForCheck();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -125,93 +72,10 @@ export class HomePageComponent implements OnDestroy, OnInit {
|
|||||||
/**
|
/**
|
||||||
* Initializes the controller
|
* Initializes the controller
|
||||||
*/
|
*/
|
||||||
public ngOnInit() {
|
public ngOnInit() {}
|
||||||
this.deviceType = this.deviceService.getDeviceInfo().deviceType;
|
|
||||||
|
|
||||||
this.impersonationStorageService
|
|
||||||
.onChangeHasImpersonation()
|
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
|
||||||
.subscribe((aId) => {
|
|
||||||
this.hasImpersonationId = !!aId;
|
|
||||||
|
|
||||||
this.changeDetectorRef.markForCheck();
|
|
||||||
});
|
|
||||||
|
|
||||||
this.dateRange =
|
|
||||||
<DateRange>this.settingsStorageService.getSetting(RANGE) || 'max';
|
|
||||||
|
|
||||||
this.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
public onChangeDateRange(aDateRange: DateRange) {
|
|
||||||
this.dateRange = aDateRange;
|
|
||||||
this.settingsStorageService.setSetting(RANGE, this.dateRange);
|
|
||||||
this.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
public onTabChanged(event: MatTabChangeEvent) {
|
|
||||||
this.currentTabIndex = event.index;
|
|
||||||
|
|
||||||
this.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ngOnDestroy() {
|
public ngOnDestroy() {
|
||||||
this.unsubscribeSubject.next();
|
this.unsubscribeSubject.next();
|
||||||
this.unsubscribeSubject.complete();
|
this.unsubscribeSubject.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
private update() {
|
|
||||||
if (this.currentTabIndex === 0) {
|
|
||||||
this.isLoadingPerformance = true;
|
|
||||||
|
|
||||||
this.dataService
|
|
||||||
.fetchChart({ range: this.dateRange })
|
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
|
||||||
.subscribe((chartData) => {
|
|
||||||
this.historicalDataItems = chartData.chart.map((chartDataItem) => {
|
|
||||||
return {
|
|
||||||
date: chartDataItem.date,
|
|
||||||
value: chartDataItem.value
|
|
||||||
};
|
|
||||||
});
|
|
||||||
this.isAllTimeHigh = chartData.isAllTimeHigh;
|
|
||||||
this.isAllTimeLow = chartData.isAllTimeLow;
|
|
||||||
|
|
||||||
this.changeDetectorRef.markForCheck();
|
|
||||||
});
|
|
||||||
|
|
||||||
this.dataService
|
|
||||||
.fetchPortfolioPerformance({ range: this.dateRange })
|
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
|
||||||
.subscribe((response) => {
|
|
||||||
this.performance = response;
|
|
||||||
this.isLoadingPerformance = false;
|
|
||||||
|
|
||||||
this.changeDetectorRef.markForCheck();
|
|
||||||
});
|
|
||||||
} else if (this.currentTabIndex === 1) {
|
|
||||||
this.dataService
|
|
||||||
.fetchPositions({ range: this.dateRange })
|
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
|
||||||
.subscribe((response) => {
|
|
||||||
this.positions = response.positions;
|
|
||||||
|
|
||||||
this.changeDetectorRef.markForCheck();
|
|
||||||
});
|
|
||||||
} else if (this.currentTabIndex === 2) {
|
|
||||||
this.isLoadingSummary = true;
|
|
||||||
|
|
||||||
this.dataService
|
|
||||||
.fetchPortfolioSummary()
|
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
|
||||||
.subscribe((response) => {
|
|
||||||
this.summary = response;
|
|
||||||
this.isLoadingSummary = false;
|
|
||||||
|
|
||||||
this.changeDetectorRef.markForCheck();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
this.changeDetectorRef.markForCheck();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,169 +1,14 @@
|
|||||||
<mat-tab-group
|
<router-outlet></router-outlet>
|
||||||
animationDuration="0ms"
|
|
||||||
class="position-absolute"
|
<nav mat-align-tabs="center" mat-tab-nav-bar>
|
||||||
headerPosition="below"
|
|
||||||
mat-align-tabs="center"
|
|
||||||
[disablePagination]="true"
|
|
||||||
(selectedTabChange)="onTabChanged($event)"
|
|
||||||
>
|
|
||||||
<mat-tab>
|
|
||||||
<ng-template mat-tab-label>
|
|
||||||
<ion-icon name="analytics-outline" size="large"></ion-icon>
|
|
||||||
</ng-template>
|
|
||||||
<div
|
|
||||||
class="
|
|
||||||
align-items-center
|
|
||||||
container
|
|
||||||
d-flex
|
|
||||||
flex-column
|
|
||||||
h-100
|
|
||||||
justify-content-center
|
|
||||||
overview
|
|
||||||
position-relative
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<div class="row w-100">
|
|
||||||
<div class="chart-container col">
|
|
||||||
<gf-line-chart
|
|
||||||
class="mr-3"
|
|
||||||
symbol="Performance"
|
|
||||||
[historicalDataItems]="historicalDataItems"
|
|
||||||
[showGradient]="true"
|
|
||||||
[showLoader]="false"
|
|
||||||
[showXAxis]="false"
|
|
||||||
[showYAxis]="false"
|
|
||||||
></gf-line-chart>
|
|
||||||
<div
|
|
||||||
*ngIf="historicalDataItems?.length === 0"
|
|
||||||
class="
|
|
||||||
align-items-center
|
|
||||||
chart-container
|
|
||||||
d-flex
|
|
||||||
justify-content-center
|
|
||||||
w-100
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<div class="d-flex justify-content-center">
|
|
||||||
<gf-no-transactions-info-indicator></gf-no-transactions-info-indicator>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="overview-container row mt-1">
|
|
||||||
<div class="col">
|
|
||||||
<gf-portfolio-performance
|
|
||||||
class="pb-4"
|
|
||||||
[baseCurrency]="user?.settings?.baseCurrency"
|
|
||||||
[isAllTimeHigh]="isAllTimeHigh"
|
|
||||||
[isAllTimeLow]="isAllTimeLow"
|
|
||||||
[isLoading]="isLoadingPerformance"
|
|
||||||
[locale]="user?.settings?.locale"
|
|
||||||
[performance]="performance"
|
|
||||||
[showDetails]="!hasImpersonationId && !user.settings.isRestrictedView"
|
|
||||||
></gf-portfolio-performance>
|
|
||||||
<div class="text-center">
|
|
||||||
<gf-toggle
|
|
||||||
[defaultValue]="dateRange"
|
|
||||||
[isLoading]="isLoadingPerformance"
|
|
||||||
[options]="dateRangeOptions"
|
|
||||||
(change)="onChangeDateRange($event.value)"
|
|
||||||
></gf-toggle>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</mat-tab>
|
|
||||||
<mat-tab>
|
|
||||||
<ng-template mat-tab-label>
|
|
||||||
<ion-icon name="wallet-outline" size="large"></ion-icon>
|
|
||||||
</ng-template>
|
|
||||||
<div class="container justify-content-center pb-3 px-3 positions">
|
|
||||||
<h3 class="d-flex justify-content-center mb-3" i18n>Holdings</h3>
|
|
||||||
<div class="row">
|
|
||||||
<div class="align-items-center col-xs-12 col-md-8 offset-md-2">
|
|
||||||
<div class="pb-2 text-center">
|
|
||||||
<gf-toggle
|
|
||||||
[defaultValue]="dateRange"
|
|
||||||
[isLoading]="isLoadingPerformance"
|
|
||||||
[options]="dateRangeOptions"
|
|
||||||
(change)="onChangeDateRange($event.value)"
|
|
||||||
></gf-toggle>
|
|
||||||
</div>
|
|
||||||
<mat-card class="p-0">
|
|
||||||
<mat-card-content>
|
|
||||||
<gf-positions
|
|
||||||
[baseCurrency]="user?.settings?.baseCurrency"
|
|
||||||
[deviceType]="deviceType"
|
|
||||||
[locale]="user?.settings?.locale"
|
|
||||||
[positions]="positions"
|
|
||||||
[range]="dateRange"
|
|
||||||
></gf-positions>
|
|
||||||
</mat-card-content>
|
|
||||||
</mat-card>
|
|
||||||
<div *ngIf="hasPermissionToCreateOrder" class="text-center">
|
|
||||||
<a
|
<a
|
||||||
class="mt-3"
|
*ngFor="let tab of tabs"
|
||||||
i18n
|
#rla="routerLinkActive"
|
||||||
mat-button
|
mat-tab-link
|
||||||
[routerLink]="['/portfolio', 'transactions']"
|
routerLinkActive
|
||||||
>Manage Transactions...</a
|
[active]="rla.isActive"
|
||||||
|
[routerLink]="tab.path"
|
||||||
>
|
>
|
||||||
</div>
|
<ion-icon size="large" [name]="tab.iconName"></ion-icon>
|
||||||
</div>
|
</a>
|
||||||
</div>
|
</nav>
|
||||||
</div>
|
|
||||||
</mat-tab>
|
|
||||||
<mat-tab>
|
|
||||||
<ng-template mat-tab-label>
|
|
||||||
<ion-icon name="reader-outline" size="large"></ion-icon>
|
|
||||||
</ng-template>
|
|
||||||
<div class="container pb-3 px-3 positions">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-xs-12 col-md-8 offset-md-2">
|
|
||||||
<mat-card class="h-100">
|
|
||||||
<mat-card-header>
|
|
||||||
<mat-card-title i18n>Summary</mat-card-title>
|
|
||||||
</mat-card-header>
|
|
||||||
<mat-card-content>
|
|
||||||
<gf-portfolio-summary
|
|
||||||
[baseCurrency]="user?.settings?.baseCurrency"
|
|
||||||
[isLoading]="isLoadingSummary"
|
|
||||||
[locale]="user?.settings?.locale"
|
|
||||||
[summary]="summary"
|
|
||||||
></gf-portfolio-summary>
|
|
||||||
</mat-card-content>
|
|
||||||
</mat-card>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</mat-tab>
|
|
||||||
<mat-tab *ngIf="hasPermissionToAccessFearAndGreedIndex">
|
|
||||||
<ng-template mat-tab-label>
|
|
||||||
<ion-icon name="newspaper-outline" size="large"></ion-icon>
|
|
||||||
</ng-template>
|
|
||||||
<div
|
|
||||||
class="
|
|
||||||
align-items-center
|
|
||||||
container
|
|
||||||
d-flex
|
|
||||||
flex-grow-1
|
|
||||||
h-100
|
|
||||||
justify-content-center
|
|
||||||
w-100
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<div class="row w-100">
|
|
||||||
<div class="col-xs-12 col-md-8 offset-md-2">
|
|
||||||
<mat-card class="h-100">
|
|
||||||
<mat-card-content>
|
|
||||||
<gf-fear-and-greed-index
|
|
||||||
class="d-flex justify-content-center"
|
|
||||||
[fearAndGreedIndex]="fearAndGreedIndex"
|
|
||||||
></gf-fear-and-greed-index>
|
|
||||||
</mat-card-content>
|
|
||||||
</mat-card>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</mat-tab>
|
|
||||||
</mat-tab-group>
|
|
||||||
|
@ -1,17 +1,11 @@
|
|||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
|
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
|
||||||
import { MatButtonModule } from '@angular/material/button';
|
|
||||||
import { MatCardModule } from '@angular/material/card';
|
|
||||||
import { MatTabsModule } from '@angular/material/tabs';
|
import { MatTabsModule } from '@angular/material/tabs';
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
import { GfFearAndGreedIndexModule } from '@ghostfolio/client/components/fear-and-greed-index/fear-and-greed-index.module';
|
import { GfHomeHoldingsModule } from '@ghostfolio/client/components/home-holdings/home-holdings.module';
|
||||||
import { GfPerformanceChartDialogModule } from '@ghostfolio/client/components/performance-chart-dialog/performance-chart-dialog.module';
|
import { GfHomeMarketModule } from '@ghostfolio/client/components/home-market/home-market.module';
|
||||||
import { GfPortfolioPerformanceModule } from '@ghostfolio/client/components/portfolio-performance/portfolio-performance.module';
|
import { GfHomeOverviewModule } from '@ghostfolio/client/components/home-overview/home-overview.module';
|
||||||
import { GfPortfolioSummaryModule } from '@ghostfolio/client/components/portfolio-summary/portfolio-summary.module';
|
import { GfHomeSummaryModule } from '@ghostfolio/client/components/home-summary/home-summary.module';
|
||||||
import { GfPositionsModule } from '@ghostfolio/client/components/positions/positions.module';
|
|
||||||
import { GfToggleModule } from '@ghostfolio/client/components/toggle/toggle.module';
|
|
||||||
import { GfLineChartModule } from '@ghostfolio/ui/line-chart/line-chart.module';
|
|
||||||
import { GfNoTransactionsInfoModule } from '@ghostfolio/ui/no-transactions-info';
|
|
||||||
|
|
||||||
import { HomePageRoutingModule } from './home-page-routing.module';
|
import { HomePageRoutingModule } from './home-page-routing.module';
|
||||||
import { HomePageComponent } from './home-page.component';
|
import { HomePageComponent } from './home-page.component';
|
||||||
@ -21,17 +15,11 @@ import { HomePageComponent } from './home-page.component';
|
|||||||
exports: [],
|
exports: [],
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
GfFearAndGreedIndexModule,
|
GfHomeHoldingsModule,
|
||||||
GfLineChartModule,
|
GfHomeMarketModule,
|
||||||
GfNoTransactionsInfoModule,
|
GfHomeOverviewModule,
|
||||||
GfPerformanceChartDialogModule,
|
GfHomeSummaryModule,
|
||||||
GfPortfolioPerformanceModule,
|
|
||||||
GfPortfolioSummaryModule,
|
|
||||||
GfPositionsModule,
|
|
||||||
GfToggleModule,
|
|
||||||
HomePageRoutingModule,
|
HomePageRoutingModule,
|
||||||
MatButtonModule,
|
|
||||||
MatCardModule,
|
|
||||||
MatTabsModule,
|
MatTabsModule,
|
||||||
RouterModule
|
RouterModule
|
||||||
],
|
],
|
||||||
|
@ -2,67 +2,29 @@
|
|||||||
|
|
||||||
:host {
|
:host {
|
||||||
color: rgb(var(--dark-primary-text));
|
color: rgb(var(--dark-primary-text));
|
||||||
display: block;
|
display: flex;
|
||||||
min-height: calc(100vh - 5rem);
|
flex-direction: column;
|
||||||
position: relative;
|
height: calc(100vh - 5rem);
|
||||||
|
overflow-y: auto;
|
||||||
|
|
||||||
|
padding-bottom: env(safe-area-inset-bottom);
|
||||||
|
padding-bottom: constant(safe-area-inset-bottom);
|
||||||
|
|
||||||
&.with-create-account-container {
|
&.with-create-account-container {
|
||||||
min-height: calc(100vh - 5rem - 3.5rem);
|
height: calc(100vh - 5rem - 3.5rem);
|
||||||
}
|
}
|
||||||
|
|
||||||
.mat-tab-group {
|
|
||||||
bottom: 0;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
top: 0;
|
|
||||||
|
|
||||||
margin-bottom: env(safe-area-inset-bottom);
|
|
||||||
margin-bottom: constant(safe-area-inset-bottom);
|
|
||||||
|
|
||||||
::ng-deep {
|
::ng-deep {
|
||||||
.mat-tab-body-wrapper {
|
gf-home-holdings,
|
||||||
height: 100%;
|
gf-home-market,
|
||||||
|
gf-home-overview,
|
||||||
.container {
|
gf-home-summary {
|
||||||
&.overview {
|
flex: 1 1 auto;
|
||||||
.chart-container {
|
overflow-y: auto;
|
||||||
aspect-ratio: 16 / 9;
|
|
||||||
max-height: 50vh;
|
|
||||||
|
|
||||||
// Fallback for aspect-ratio (using padding hack)
|
|
||||||
@supports not (aspect-ratio: 16 / 9) {
|
|
||||||
&::before {
|
|
||||||
float: left;
|
|
||||||
padding-top: 56.25%;
|
|
||||||
content: '';
|
|
||||||
}
|
|
||||||
|
|
||||||
&::after {
|
|
||||||
display: block;
|
|
||||||
content: '';
|
|
||||||
clear: both;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gf-line-chart {
|
|
||||||
bottom: 0;
|
|
||||||
left: 0;
|
|
||||||
position: absolute;
|
|
||||||
right: 0;
|
|
||||||
top: 0;
|
|
||||||
z-index: -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&.positions {
|
|
||||||
min-height: 100%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.mat-tab-header {
|
.mat-tab-header {
|
||||||
border-top: 0;
|
border-bottom: 0;
|
||||||
|
|
||||||
.mat-ink-bar {
|
.mat-ink-bar {
|
||||||
visibility: hidden !important;
|
visibility: hidden !important;
|
||||||
@ -76,35 +38,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
::ng-deep {
|
|
||||||
.mat-form-field-infix {
|
|
||||||
border-top: 0 solid transparent !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mat-form-field-wrapper {
|
|
||||||
padding-bottom: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mat-form-field-underline {
|
|
||||||
bottom: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mat-form-field-appearance-outline .mat-select-arrow-wrapper {
|
|
||||||
transform: translateY(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
:host-context(.is-dark-theme) {
|
:host-context(.is-dark-theme) {
|
||||||
color: rgb(var(--light-primary-text));
|
color: rgb(var(--light-primary-text));
|
||||||
|
|
||||||
.container {
|
|
||||||
&.overview {
|
|
||||||
.button-container {
|
|
||||||
.mat-flat-button {
|
|
||||||
background-color: rgba(255, 255, 255, $alpha-hover);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,22 @@
|
|||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { RouterModule, Routes } from '@angular/router';
|
import { RouterModule, Routes } from '@angular/router';
|
||||||
|
import { HomeHoldingsComponent } from '@ghostfolio/client/components/home-holdings/home-holdings.component';
|
||||||
|
import { HomeOverviewComponent } from '@ghostfolio/client/components/home-overview/home-overview.component';
|
||||||
import { AuthGuard } from '@ghostfolio/client/core/auth.guard';
|
import { AuthGuard } from '@ghostfolio/client/core/auth.guard';
|
||||||
|
|
||||||
import { ZenPageComponent } from './zen-page.component';
|
import { ZenPageComponent } from './zen-page.component';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: '', component: ZenPageComponent, canActivate: [AuthGuard] }
|
{
|
||||||
|
path: '',
|
||||||
|
component: ZenPageComponent,
|
||||||
|
canActivate: [AuthGuard],
|
||||||
|
children: [
|
||||||
|
{ path: '', redirectTo: 'overview', pathMatch: 'full' },
|
||||||
|
{ path: 'overview', component: HomeOverviewComponent },
|
||||||
|
{ path: 'holdings', component: HomeHoldingsComponent }
|
||||||
|
]
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
@ -3,25 +3,12 @@ import {
|
|||||||
AfterViewInit,
|
AfterViewInit,
|
||||||
ChangeDetectorRef,
|
ChangeDetectorRef,
|
||||||
Component,
|
Component,
|
||||||
ElementRef,
|
|
||||||
OnDestroy,
|
OnDestroy,
|
||||||
OnInit,
|
OnInit
|
||||||
ViewChild
|
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { MatTabChangeEvent } from '@angular/material/tabs';
|
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import { DataService } from '@ghostfolio/client/services/data.service';
|
|
||||||
import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service';
|
|
||||||
import { UserService } from '@ghostfolio/client/services/user/user.service';
|
import { UserService } from '@ghostfolio/client/services/user/user.service';
|
||||||
import {
|
import { User } from '@ghostfolio/common/interfaces';
|
||||||
PortfolioPerformance,
|
|
||||||
Position,
|
|
||||||
User
|
|
||||||
} from '@ghostfolio/common/interfaces';
|
|
||||||
import { hasPermission, permissions } from '@ghostfolio/common/permissions';
|
|
||||||
import { DateRange } from '@ghostfolio/common/types';
|
|
||||||
import { LineChartItem } from '@ghostfolio/ui/line-chart/interfaces/line-chart.interface';
|
|
||||||
import { DeviceDetectorService } from 'ngx-device-detector';
|
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { first, takeUntil } from 'rxjs/operators';
|
import { first, takeUntil } from 'rxjs/operators';
|
||||||
|
|
||||||
@ -31,19 +18,7 @@ import { first, takeUntil } from 'rxjs/operators';
|
|||||||
styleUrls: ['./zen-page.scss']
|
styleUrls: ['./zen-page.scss']
|
||||||
})
|
})
|
||||||
export class ZenPageComponent implements AfterViewInit, OnDestroy, OnInit {
|
export class ZenPageComponent implements AfterViewInit, OnDestroy, OnInit {
|
||||||
@ViewChild('positionsContainer') positionsContainer: ElementRef;
|
public tabs: { iconName: string; path: string }[] = [];
|
||||||
|
|
||||||
public currentTabIndex = 0;
|
|
||||||
public dateRange: DateRange = 'max';
|
|
||||||
public deviceType: string;
|
|
||||||
public hasImpersonationId: boolean;
|
|
||||||
public hasPermissionToCreateOrder: boolean;
|
|
||||||
public historicalDataItems: LineChartItem[];
|
|
||||||
public isAllTimeHigh: boolean;
|
|
||||||
public isAllTimeLow: boolean;
|
|
||||||
public isLoadingPerformance = true;
|
|
||||||
public performance: PortfolioPerformance;
|
|
||||||
public positions: Position[];
|
|
||||||
public user: User;
|
public user: User;
|
||||||
|
|
||||||
private unsubscribeSubject = new Subject<void>();
|
private unsubscribeSubject = new Subject<void>();
|
||||||
@ -54,9 +29,6 @@ export class ZenPageComponent implements AfterViewInit, OnDestroy, OnInit {
|
|||||||
public constructor(
|
public constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private changeDetectorRef: ChangeDetectorRef,
|
private changeDetectorRef: ChangeDetectorRef,
|
||||||
private dataService: DataService,
|
|
||||||
private deviceService: DeviceDetectorService,
|
|
||||||
private impersonationStorageService: ImpersonationStorageService,
|
|
||||||
private userService: UserService,
|
private userService: UserService,
|
||||||
private viewportScroller: ViewportScroller
|
private viewportScroller: ViewportScroller
|
||||||
) {
|
) {
|
||||||
@ -64,32 +36,18 @@ export class ZenPageComponent implements AfterViewInit, OnDestroy, OnInit {
|
|||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
.pipe(takeUntil(this.unsubscribeSubject))
|
||||||
.subscribe((state) => {
|
.subscribe((state) => {
|
||||||
if (state?.user) {
|
if (state?.user) {
|
||||||
|
this.tabs = [
|
||||||
|
{ iconName: 'analytics-outline', path: 'overview' },
|
||||||
|
{ iconName: 'wallet-outline', path: 'holdings' }
|
||||||
|
];
|
||||||
this.user = state.user;
|
this.user = state.user;
|
||||||
|
|
||||||
this.hasPermissionToCreateOrder = hasPermission(
|
|
||||||
this.user.permissions,
|
|
||||||
permissions.createOrder
|
|
||||||
);
|
|
||||||
|
|
||||||
this.changeDetectorRef.markForCheck();
|
this.changeDetectorRef.markForCheck();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public ngOnInit() {
|
public ngOnInit() {}
|
||||||
this.deviceType = this.deviceService.getDeviceInfo().deviceType;
|
|
||||||
|
|
||||||
this.impersonationStorageService
|
|
||||||
.onChangeHasImpersonation()
|
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
|
||||||
.subscribe((aId) => {
|
|
||||||
this.hasImpersonationId = !!aId;
|
|
||||||
|
|
||||||
this.changeDetectorRef.markForCheck();
|
|
||||||
});
|
|
||||||
|
|
||||||
this.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ngAfterViewInit(): void {
|
public ngAfterViewInit(): void {
|
||||||
this.route.fragment
|
this.route.fragment
|
||||||
@ -97,57 +55,8 @@ export class ZenPageComponent implements AfterViewInit, OnDestroy, OnInit {
|
|||||||
.subscribe((fragment) => this.viewportScroller.scrollToAnchor(fragment));
|
.subscribe((fragment) => this.viewportScroller.scrollToAnchor(fragment));
|
||||||
}
|
}
|
||||||
|
|
||||||
public onTabChanged(event: MatTabChangeEvent) {
|
|
||||||
this.currentTabIndex = event.index;
|
|
||||||
|
|
||||||
this.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ngOnDestroy() {
|
public ngOnDestroy() {
|
||||||
this.unsubscribeSubject.next();
|
this.unsubscribeSubject.next();
|
||||||
this.unsubscribeSubject.complete();
|
this.unsubscribeSubject.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
private update() {
|
|
||||||
if (this.currentTabIndex === 0) {
|
|
||||||
this.isLoadingPerformance = true;
|
|
||||||
|
|
||||||
this.dataService
|
|
||||||
.fetchChart({ range: this.dateRange })
|
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
|
||||||
.subscribe((chartData) => {
|
|
||||||
this.historicalDataItems = chartData.chart.map((chartDataItem) => {
|
|
||||||
return {
|
|
||||||
date: chartDataItem.date,
|
|
||||||
value: chartDataItem.value
|
|
||||||
};
|
|
||||||
});
|
|
||||||
this.isAllTimeHigh = chartData.isAllTimeHigh;
|
|
||||||
this.isAllTimeLow = chartData.isAllTimeLow;
|
|
||||||
|
|
||||||
this.changeDetectorRef.markForCheck();
|
|
||||||
});
|
|
||||||
|
|
||||||
this.dataService
|
|
||||||
.fetchPortfolioPerformance({ range: this.dateRange })
|
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
|
||||||
.subscribe((response) => {
|
|
||||||
this.performance = response;
|
|
||||||
this.isLoadingPerformance = false;
|
|
||||||
|
|
||||||
this.changeDetectorRef.markForCheck();
|
|
||||||
});
|
|
||||||
} else if (this.currentTabIndex === 1) {
|
|
||||||
this.dataService
|
|
||||||
.fetchPositions({ range: this.dateRange })
|
|
||||||
.pipe(takeUntil(this.unsubscribeSubject))
|
|
||||||
.subscribe((response) => {
|
|
||||||
this.positions = response.positions;
|
|
||||||
|
|
||||||
this.changeDetectorRef.markForCheck();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
this.changeDetectorRef.markForCheck();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,94 +1,14 @@
|
|||||||
<mat-tab-group
|
<router-outlet></router-outlet>
|
||||||
animationDuration="0ms"
|
|
||||||
class="position-absolute"
|
|
||||||
headerPosition="below"
|
|
||||||
mat-align-tabs="center"
|
|
||||||
[disablePagination]="true"
|
|
||||||
(selectedTabChange)="onTabChanged($event)"
|
|
||||||
>
|
|
||||||
<mat-tab>
|
|
||||||
<ng-template mat-tab-label>
|
|
||||||
<ion-icon name="analytics-outline" size="large"></ion-icon>
|
|
||||||
</ng-template>
|
|
||||||
<div
|
|
||||||
class="
|
|
||||||
container
|
|
||||||
d-flex
|
|
||||||
flex-column
|
|
||||||
h-100
|
|
||||||
justify-content-center
|
|
||||||
overview
|
|
||||||
position-relative
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<div class="row">
|
|
||||||
<div
|
|
||||||
class="chart-container d-flex flex-column col justify-content-center"
|
|
||||||
>
|
|
||||||
<gf-line-chart
|
|
||||||
class="mr-3"
|
|
||||||
symbol="Performance"
|
|
||||||
[historicalDataItems]="historicalDataItems"
|
|
||||||
[showGradient]="true"
|
|
||||||
[showLoader]="false"
|
|
||||||
[showXAxis]="false"
|
|
||||||
[showYAxis]="false"
|
|
||||||
></gf-line-chart>
|
|
||||||
<div
|
|
||||||
*ngIf="historicalDataItems?.length === 0"
|
|
||||||
class="d-flex justify-content-center"
|
|
||||||
>
|
|
||||||
<gf-no-transactions-info-indicator></gf-no-transactions-info-indicator>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="overview-container row mb-5 mt-1">
|
|
||||||
<div class="col">
|
|
||||||
<gf-portfolio-performance
|
|
||||||
class="pb-4"
|
|
||||||
[baseCurrency]="user?.settings?.baseCurrency"
|
|
||||||
[isAllTimeHigh]="isAllTimeHigh"
|
|
||||||
[isAllTimeLow]="isAllTimeLow"
|
|
||||||
[isLoading]="isLoadingPerformance"
|
|
||||||
[locale]="user?.settings?.locale"
|
|
||||||
[performance]="performance"
|
|
||||||
[showDetails]="!hasImpersonationId && !user.settings.isRestrictedView"
|
|
||||||
></gf-portfolio-performance>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</mat-tab>
|
|
||||||
|
|
||||||
<mat-tab>
|
<nav mat-align-tabs="center" mat-tab-nav-bar>
|
||||||
<ng-template mat-tab-label>
|
|
||||||
<ion-icon name="wallet-outline" size="large"></ion-icon>
|
|
||||||
</ng-template>
|
|
||||||
<div class="container justify-content-center pb-3 px-3 positions">
|
|
||||||
<h3 class="d-flex justify-content-center mb-3" i18n>Holdings</h3>
|
|
||||||
<div class="row">
|
|
||||||
<div class="align-items-center col">
|
|
||||||
<mat-card class="p-0">
|
|
||||||
<mat-card-content>
|
|
||||||
<gf-positions
|
|
||||||
[baseCurrency]="user?.settings?.baseCurrency"
|
|
||||||
[deviceType]="deviceType"
|
|
||||||
[locale]="user?.settings?.locale"
|
|
||||||
[positions]="positions"
|
|
||||||
[range]="dateRange"
|
|
||||||
></gf-positions>
|
|
||||||
</mat-card-content>
|
|
||||||
</mat-card>
|
|
||||||
<div *ngIf="hasPermissionToCreateOrder" class="text-center">
|
|
||||||
<a
|
<a
|
||||||
class="mt-3"
|
*ngFor="let tab of tabs"
|
||||||
i18n
|
#rla="routerLinkActive"
|
||||||
mat-button
|
mat-tab-link
|
||||||
[routerLink]="['/portfolio', 'transactions']"
|
routerLinkActive
|
||||||
>Manage Transactions...</a
|
[active]="rla.isActive"
|
||||||
|
[routerLink]="tab.path"
|
||||||
>
|
>
|
||||||
</div>
|
<ion-icon size="large" [name]="tab.iconName"></ion-icon>
|
||||||
</div>
|
</a>
|
||||||
</div>
|
</nav>
|
||||||
</div>
|
|
||||||
</mat-tab>
|
|
||||||
</mat-tab-group>
|
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
|
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
|
||||||
import { MatButtonModule } from '@angular/material/button';
|
|
||||||
import { MatCardModule } from '@angular/material/card';
|
|
||||||
import { MatTabsModule } from '@angular/material/tabs';
|
import { MatTabsModule } from '@angular/material/tabs';
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
import { GfPortfolioPerformanceModule } from '@ghostfolio/client/components/portfolio-performance/portfolio-performance.module';
|
import { GfHomeHoldingsModule } from '@ghostfolio/client/components/home-holdings/home-holdings.module';
|
||||||
import { GfPositionsModule } from '@ghostfolio/client/components/positions/positions.module';
|
import { GfHomeOverviewModule } from '@ghostfolio/client/components/home-overview/home-overview.module';
|
||||||
import { GfLineChartModule } from '@ghostfolio/ui/line-chart/line-chart.module';
|
|
||||||
import { GfNoTransactionsInfoModule } from '@ghostfolio/ui/no-transactions-info';
|
|
||||||
|
|
||||||
import { ZenPageRoutingModule } from './zen-page-routing.module';
|
import { ZenPageRoutingModule } from './zen-page-routing.module';
|
||||||
import { ZenPageComponent } from './zen-page.component';
|
import { ZenPageComponent } from './zen-page.component';
|
||||||
@ -17,12 +13,8 @@ import { ZenPageComponent } from './zen-page.component';
|
|||||||
exports: [],
|
exports: [],
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
GfLineChartModule,
|
GfHomeHoldingsModule,
|
||||||
GfNoTransactionsInfoModule,
|
GfHomeOverviewModule,
|
||||||
GfPortfolioPerformanceModule,
|
|
||||||
GfPositionsModule,
|
|
||||||
MatButtonModule,
|
|
||||||
MatCardModule,
|
|
||||||
MatTabsModule,
|
MatTabsModule,
|
||||||
RouterModule,
|
RouterModule,
|
||||||
ZenPageRoutingModule
|
ZenPageRoutingModule
|
||||||
|
@ -2,63 +2,23 @@
|
|||||||
|
|
||||||
:host {
|
:host {
|
||||||
color: rgb(var(--dark-primary-text));
|
color: rgb(var(--dark-primary-text));
|
||||||
display: block;
|
display: flex;
|
||||||
min-height: calc(100vh - 5rem);
|
flex-direction: column;
|
||||||
position: relative;
|
height: calc(100vh - 5rem);
|
||||||
|
overflow-y: auto;
|
||||||
|
|
||||||
.mat-tab-group {
|
padding-bottom: env(safe-area-inset-bottom);
|
||||||
bottom: 0;
|
padding-bottom: constant(safe-area-inset-bottom);
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
top: 0;
|
|
||||||
|
|
||||||
margin-bottom: env(safe-area-inset-bottom);
|
|
||||||
margin-bottom: constant(safe-area-inset-bottom);
|
|
||||||
|
|
||||||
::ng-deep {
|
::ng-deep {
|
||||||
.mat-tab-body-wrapper {
|
gf-home-holdings,
|
||||||
height: 100%;
|
gf-home-overview {
|
||||||
|
flex: 1 1 auto;
|
||||||
.container {
|
overflow-y: auto;
|
||||||
&.overview {
|
|
||||||
.chart-container {
|
|
||||||
aspect-ratio: 16 / 9;
|
|
||||||
max-height: 50vh;
|
|
||||||
|
|
||||||
// Fallback for aspect-ratio (using padding hack)
|
|
||||||
@supports not (aspect-ratio: 16 / 9) {
|
|
||||||
&::before {
|
|
||||||
float: left;
|
|
||||||
padding-top: 56.25%;
|
|
||||||
content: '';
|
|
||||||
}
|
|
||||||
|
|
||||||
&::after {
|
|
||||||
display: block;
|
|
||||||
content: '';
|
|
||||||
clear: both;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gf-line-chart {
|
|
||||||
bottom: 0;
|
|
||||||
left: 0;
|
|
||||||
position: absolute;
|
|
||||||
right: 0;
|
|
||||||
top: 0;
|
|
||||||
z-index: -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&.positions {
|
|
||||||
min-height: 100%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.mat-tab-header {
|
.mat-tab-header {
|
||||||
border-top: 0;
|
border-bottom: 0;
|
||||||
|
|
||||||
.mat-ink-bar {
|
.mat-ink-bar {
|
||||||
visibility: hidden !important;
|
visibility: hidden !important;
|
||||||
@ -71,18 +31,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
:host-context(.is-dark-theme) {
|
:host-context(.is-dark-theme) {
|
||||||
color: rgb(var(--light-primary-text));
|
color: rgb(var(--light-primary-text));
|
||||||
|
|
||||||
.container {
|
|
||||||
&.overview {
|
|
||||||
.button-container {
|
|
||||||
.mat-flat-button {
|
|
||||||
background-color: rgba(255, 255, 255, $alpha-hover);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
import { DataSource } from '@prisma/client';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@ -14,4 +15,17 @@ export class AdminService {
|
|||||||
public gatherProfileData() {
|
public gatherProfileData() {
|
||||||
return this.http.post<void>(`/api/admin/gather/profile-data`, {});
|
return this.http.post<void>(`/api/admin/gather/profile-data`, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public gatherSymbol({
|
||||||
|
dataSource,
|
||||||
|
symbol
|
||||||
|
}: {
|
||||||
|
dataSource: DataSource;
|
||||||
|
symbol: string;
|
||||||
|
}) {
|
||||||
|
return this.http.post<void>(
|
||||||
|
`/api/admin/gather/${dataSource}/${symbol}`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,8 @@ import {
|
|||||||
Access,
|
Access,
|
||||||
Accounts,
|
Accounts,
|
||||||
AdminData,
|
AdminData,
|
||||||
|
AdminMarketData,
|
||||||
|
AdminMarketDataDetails,
|
||||||
Export,
|
Export,
|
||||||
InfoItem,
|
InfoItem,
|
||||||
PortfolioChart,
|
PortfolioChart,
|
||||||
@ -64,6 +66,23 @@ export class DataService {
|
|||||||
return this.http.get<AdminData>('/api/admin');
|
return this.http.get<AdminData>('/api/admin');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public fetchAdminMarketData() {
|
||||||
|
return this.http.get<AdminMarketData>('/api/admin/market-data');
|
||||||
|
}
|
||||||
|
|
||||||
|
public fetchAdminMarketDataBySymbol(
|
||||||
|
aSymbol: string
|
||||||
|
): Observable<AdminMarketDataDetails> {
|
||||||
|
return this.http.get<any>(`/api/admin/market-data/${aSymbol}`).pipe(
|
||||||
|
map((data) => {
|
||||||
|
for (const item of data.marketData) {
|
||||||
|
item.date = parseISO(item.date);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public deleteAccess(aId: string) {
|
public deleteAccess(aId: string) {
|
||||||
return this.http.delete<any>(`/api/access/${aId}`);
|
return this.http.delete<any>(`/api/access/${aId}`);
|
||||||
}
|
}
|
||||||
|
@ -18,16 +18,6 @@
|
|||||||
* BROWSER POLYFILLS
|
* BROWSER POLYFILLS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
|
|
||||||
// import 'classlist.js'; // Run `npm install --save classlist.js`.
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Web Animations `@angular/platform-browser/animations`
|
|
||||||
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
|
|
||||||
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
|
|
||||||
*/
|
|
||||||
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* By default, zone.js will patch all possible macroTask and DomEvents
|
* By default, zone.js will patch all possible macroTask and DomEvents
|
||||||
* user can disable parts of macroTask/DomEvents patch by setting following flags
|
* user can disable parts of macroTask/DomEvents patch by setting following flags
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
@import './styles/bootstrap';
|
@import './styles/bootstrap';
|
||||||
@import './styles/table';
|
@import './styles/table';
|
||||||
|
|
||||||
@import '~angular-material-css-vars/main';
|
@import '~angular-material-css-vars/src/lib/main';
|
||||||
|
|
||||||
@import '~svgmap/dist/svgMap';
|
@import '~svgmap/dist/svgMap';
|
||||||
|
|
||||||
@ -134,6 +134,10 @@ ngx-skeleton-loader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cursor-pointer {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
.gf-table {
|
.gf-table {
|
||||||
@include gf-table;
|
@include gf-table;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
$mat-css-dark-theme-selector: '.is-dark-theme';
|
$mat-css-dark-theme-selector: '.is-dark-theme';
|
||||||
|
|
||||||
@import '~angular-material-css-vars/public-util';
|
@import '~angular-material-css-vars/src/lib/public-util';
|
||||||
|
|
||||||
$alpha-disabled-text: 0.38;
|
$alpha-disabled-text: 0.38;
|
||||||
$alpha-hover: 0.04;
|
$alpha-hover: 0.04;
|
||||||
|
@ -6,5 +6,5 @@
|
|||||||
"types": ["jest", "node"]
|
"types": ["jest", "node"]
|
||||||
},
|
},
|
||||||
"files": ["src/test-setup.ts"],
|
"files": ["src/test-setup.ts"],
|
||||||
"include": ["**/*.spec.ts", "**/*.d.ts"]
|
"include": ["**/*.spec.ts", "**/*.test.ts", "**/*.d.ts"]
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,5 @@
|
|||||||
import { IDataGatheringItem } from '@ghostfolio/api/services/interfaces/interfaces';
|
|
||||||
import { DataSource } from '@prisma/client';
|
|
||||||
|
|
||||||
export const baseCurrency = 'USD';
|
export const baseCurrency = 'USD';
|
||||||
|
|
||||||
export const benchmarks: Partial<IDataGatheringItem>[] = [
|
|
||||||
{ dataSource: DataSource.YAHOO, symbol: 'VOO' }
|
|
||||||
];
|
|
||||||
|
|
||||||
export const ghostfolioScraperApiSymbolPrefix = '_GF_';
|
export const ghostfolioScraperApiSymbolPrefix = '_GF_';
|
||||||
export const ghostfolioCashSymbol = `${ghostfolioScraperApiSymbolPrefix}CASH`;
|
export const ghostfolioCashSymbol = `${ghostfolioScraperApiSymbolPrefix}CASH`;
|
||||||
export const ghostfolioFearAndGreedIndexSymbol = `${ghostfolioScraperApiSymbolPrefix}FEAR_AND_GREED_INDEX`;
|
export const ghostfolioFearAndGreedIndexSymbol = `${ghostfolioScraperApiSymbolPrefix}FEAR_AND_GREED_INDEX`;
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
import { MarketData } from '@prisma/client';
|
||||||
|
|
||||||
|
export interface AdminMarketDataDetails {
|
||||||
|
marketData: MarketData[];
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
export interface AdminMarketData {
|
||||||
|
marketData: AdminMarketDataItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AdminMarketDataItem {
|
||||||
|
symbol: string;
|
||||||
|
}
|
@ -1,6 +1,8 @@
|
|||||||
import { Access } from './access.interface';
|
import { Access } from './access.interface';
|
||||||
import { Accounts } from './accounts.interface';
|
import { Accounts } from './accounts.interface';
|
||||||
import { AdminData } from './admin-data.interface';
|
import { AdminData } from './admin-data.interface';
|
||||||
|
import { AdminMarketDataDetails } from './admin-market-data-details.interface';
|
||||||
|
import { AdminMarketData } from './admin-market-data.interface';
|
||||||
import { Export } from './export.interface';
|
import { Export } from './export.interface';
|
||||||
import { InfoItem } from './info-item.interface';
|
import { InfoItem } from './info-item.interface';
|
||||||
import { PortfolioChart } from './portfolio-chart.interface';
|
import { PortfolioChart } from './portfolio-chart.interface';
|
||||||
@ -23,6 +25,8 @@ export {
|
|||||||
Access,
|
Access,
|
||||||
Accounts,
|
Accounts,
|
||||||
AdminData,
|
AdminData,
|
||||||
|
AdminMarketData,
|
||||||
|
AdminMarketDataDetails,
|
||||||
Export,
|
Export,
|
||||||
InfoItem,
|
InfoItem,
|
||||||
PortfolioChart,
|
PortfolioChart,
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
import { Role } from '@prisma/client';
|
import { Role } from '@prisma/client';
|
||||||
|
|
||||||
export function isApiTokenAuthorized(aApiToken: string) {
|
|
||||||
return aApiToken === 'Bearer fc804dead6ff45b98da4e5530f6aa3cb';
|
|
||||||
}
|
|
||||||
|
|
||||||
export const permissions = {
|
export const permissions = {
|
||||||
accessAdminControl: 'accessAdminControl',
|
accessAdminControl: 'accessAdminControl',
|
||||||
accessFearAndGreedIndex: 'accessFearAndGreedIndex',
|
accessFearAndGreedIndex: 'accessFearAndGreedIndex',
|
||||||
|
@ -5,5 +5,5 @@
|
|||||||
"types": []
|
"types": []
|
||||||
},
|
},
|
||||||
"include": ["**/*.ts"],
|
"include": ["**/*.ts"],
|
||||||
"exclude": ["**/*.spec.ts"]
|
"exclude": ["**/*.spec.ts", "**/*.test.ts"]
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,13 @@
|
|||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"**/*.spec.ts",
|
"**/*.spec.ts",
|
||||||
|
"**/*.test.ts",
|
||||||
"**/*.spec.tsx",
|
"**/*.spec.tsx",
|
||||||
|
"**/*.test.tsx",
|
||||||
"**/*.spec.js",
|
"**/*.spec.js",
|
||||||
|
"**/*.test.js",
|
||||||
"**/*.spec.jsx",
|
"**/*.spec.jsx",
|
||||||
|
"**/*.test.jsx",
|
||||||
"**/*.d.ts"
|
"**/*.d.ts"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"emitDecoratorMetadata": true
|
"emitDecoratorMetadata": true
|
||||||
},
|
},
|
||||||
"exclude": ["../**/*.spec.ts"],
|
"exclude": ["../**/*.spec.ts", "../**/*.test.ts"],
|
||||||
"include": ["../src/**/*", "*.js"]
|
"include": ["../src/**/*", "*.js"]
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user