|
@ -41,7 +41,7 @@ import { AccountWithValue, DateRange, GroupBy } from '@ghostfolio/common/types'; |
|
|
import { translate } from '@ghostfolio/ui/i18n'; |
|
|
import { translate } from '@ghostfolio/ui/i18n'; |
|
|
import { DataSource, Order as OrderModel } from '@prisma/client'; |
|
|
import { DataSource, Order as OrderModel } from '@prisma/client'; |
|
|
import { format, parseISO } from 'date-fns'; |
|
|
import { format, parseISO } from 'date-fns'; |
|
|
import { cloneDeep, groupBy } from 'lodash'; |
|
|
import { cloneDeep, groupBy, isNumber } from 'lodash'; |
|
|
import { Observable } from 'rxjs'; |
|
|
import { Observable } from 'rxjs'; |
|
|
import { map } from 'rxjs/operators'; |
|
|
import { map } from 'rxjs/operators'; |
|
|
|
|
|
|
|
@ -299,6 +299,12 @@ export class DataService { |
|
|
].dateOfFirstActivity |
|
|
].dateOfFirstActivity |
|
|
? parseISO(response.holdings[symbol].dateOfFirstActivity) |
|
|
? parseISO(response.holdings[symbol].dateOfFirstActivity) |
|
|
: undefined; |
|
|
: undefined; |
|
|
|
|
|
|
|
|
|
|
|
response.holdings[symbol].value = isNumber( |
|
|
|
|
|
response.holdings[symbol].value |
|
|
|
|
|
) |
|
|
|
|
|
? response.holdings[symbol].value |
|
|
|
|
|
: response.holdings[symbol].valueInPercentage; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -333,8 +339,22 @@ export class DataService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public fetchPortfolioPublic(aId: string) { |
|
|
public fetchPortfolioPublic(aId: string) { |
|
|
return this.http.get<PortfolioPublicDetails>( |
|
|
return this.http |
|
|
`/api/v1/portfolio/public/${aId}` |
|
|
.get<PortfolioPublicDetails>(`/api/v1/portfolio/public/${aId}`) |
|
|
|
|
|
.pipe( |
|
|
|
|
|
map((response) => { |
|
|
|
|
|
if (response.holdings) { |
|
|
|
|
|
for (const symbol of Object.keys(response.holdings)) { |
|
|
|
|
|
response.holdings[symbol].value = isNumber( |
|
|
|
|
|
response.holdings[symbol].value |
|
|
|
|
|
) |
|
|
|
|
|
? response.holdings[symbol].value |
|
|
|
|
|
: response.holdings[symbol].valueInPercentage; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return response; |
|
|
|
|
|
}) |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|