mirror of https://github.com/ghostfolio/ghostfolio
committed by
GitHub
41 changed files with 450 additions and 127 deletions
@ -1,7 +1,9 @@ |
|||||
|
import { HistoricalDataItem } from '@ghostfolio/api/app/portfolio/interfaces/portfolio-position-detail.interface'; |
||||
import { DataSource } from '@prisma/client'; |
import { DataSource } from '@prisma/client'; |
||||
|
|
||||
export interface SymbolItem { |
export interface SymbolItem { |
||||
currency: string; |
currency: string; |
||||
dataSource: DataSource; |
dataSource: DataSource; |
||||
|
historicalData: HistoricalDataItem[]; |
||||
marketPrice: number; |
marketPrice: number; |
||||
} |
} |
||||
|
@ -0,0 +1,6 @@ |
|||||
|
import { IsString } from 'class-validator'; |
||||
|
|
||||
|
export class PropertyDto { |
||||
|
@IsString() |
||||
|
value: string; |
||||
|
} |
@ -0,0 +1,11 @@ |
|||||
|
import { PrismaModule } from '@ghostfolio/api/services/prisma.module'; |
||||
|
import { Module } from '@nestjs/common'; |
||||
|
|
||||
|
import { PropertyService } from './property.service'; |
||||
|
|
||||
|
@Module({ |
||||
|
exports: [PropertyService], |
||||
|
imports: [PrismaModule], |
||||
|
providers: [PropertyService] |
||||
|
}) |
||||
|
export class PropertyModule {} |
@ -0,0 +1,43 @@ |
|||||
|
import { PrismaService } from '@ghostfolio/api/services/prisma.service'; |
||||
|
import { PROPERTY_CURRENCIES } from '@ghostfolio/common/config'; |
||||
|
import { Injectable } from '@nestjs/common'; |
||||
|
|
||||
|
@Injectable() |
||||
|
export class PropertyService { |
||||
|
public constructor(private readonly prismaService: PrismaService) {} |
||||
|
|
||||
|
public async get() { |
||||
|
const response: { |
||||
|
[key: string]: object | string | string[]; |
||||
|
} = { |
||||
|
[PROPERTY_CURRENCIES]: [] |
||||
|
}; |
||||
|
|
||||
|
const properties = await this.prismaService.property.findMany(); |
||||
|
|
||||
|
for (const property of properties) { |
||||
|
let value = property.value; |
||||
|
|
||||
|
try { |
||||
|
value = JSON.parse(property.value); |
||||
|
} catch {} |
||||
|
|
||||
|
response[property.key] = value; |
||||
|
} |
||||
|
|
||||
|
return response; |
||||
|
} |
||||
|
|
||||
|
public async getByKey(aKey: string) { |
||||
|
const properties = await this.get(); |
||||
|
return properties?.[aKey]; |
||||
|
} |
||||
|
|
||||
|
public async put({ key, value }: { key: string; value: string }) { |
||||
|
return this.prismaService.property.upsert({ |
||||
|
create: { key, value }, |
||||
|
update: { value }, |
||||
|
where: { key } |
||||
|
}); |
||||
|
} |
||||
|
} |
@ -1,13 +1,13 @@ |
|||||
<div class="align-items-center d-flex flex-row"> |
<div class="align-items-center d-flex flex-row"> |
||||
<div class="h3 mb-0 mr-2">{{ fearAndGreedIndexEmoji }}</div> |
<div class="h2 mb-0 mr-2">{{ fearAndGreedIndexEmoji }}</div> |
||||
<div> |
<div> |
||||
<div class="h3 mb-0"> |
<div class="h4 mb-0"> |
||||
<span class="mr-2">{{ fearAndGreedIndexText }}</span> |
<span class="mr-2">{{ fearAndGreedIndexText }}</span> |
||||
<small class="text-muted" |
<small class="text-muted" |
||||
><strong>{{ fearAndGreedIndex }}</strong |
><strong>{{ fearAndGreedIndex }}</strong |
||||
>/100</small |
>/100</small |
||||
> |
> |
||||
</div> |
</div> |
||||
<small class="d-block" i18n>Market Mood</small> |
<small class="d-block" i18n>Current Market Mood</small> |
||||
</div> |
</div> |
||||
</div> |
</div> |
||||
|
Loading…
Reference in new issue