|
|
@ -3,6 +3,7 @@ import { CreateAccessDto, UpdateAccessDto } from '@ghostfolio/common/dtos'; |
|
|
import { Filter, PortfolioPosition } from '@ghostfolio/common/interfaces'; |
|
|
import { Filter, PortfolioPosition } from '@ghostfolio/common/interfaces'; |
|
|
import { AccountWithPlatform } from '@ghostfolio/common/types'; |
|
|
import { AccountWithPlatform } from '@ghostfolio/common/types'; |
|
|
import { validateObjectForForm } from '@ghostfolio/common/utils'; |
|
|
import { validateObjectForForm } from '@ghostfolio/common/utils'; |
|
|
|
|
|
import { translate } from '@ghostfolio/ui/i18n'; |
|
|
import { NotificationService } from '@ghostfolio/ui/notifications'; |
|
|
import { NotificationService } from '@ghostfolio/ui/notifications'; |
|
|
import { |
|
|
import { |
|
|
GfPortfolioFilterFormComponent, |
|
|
GfPortfolioFilterFormComponent, |
|
|
@ -37,7 +38,7 @@ import { |
|
|
import { MatFormFieldModule } from '@angular/material/form-field'; |
|
|
import { MatFormFieldModule } from '@angular/material/form-field'; |
|
|
import { MatInputModule } from '@angular/material/input'; |
|
|
import { MatInputModule } from '@angular/material/input'; |
|
|
import { MatSelectModule } from '@angular/material/select'; |
|
|
import { MatSelectModule } from '@angular/material/select'; |
|
|
import { AccessPermission } from '@prisma/client'; |
|
|
import { AccessPermission, AssetClass } from '@prisma/client'; |
|
|
import { StatusCodes } from 'http-status-codes'; |
|
|
import { StatusCodes } from 'http-status-codes'; |
|
|
import { EMPTY, catchError } from 'rxjs'; |
|
|
import { EMPTY, catchError } from 'rxjs'; |
|
|
|
|
|
|
|
|
@ -110,6 +111,18 @@ export class GfCreateOrUpdateAccessDialogComponent implements OnInit { |
|
|
] |
|
|
] |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this.assetClasses = Object.keys(AssetClass) |
|
|
|
|
|
.map((assetClass) => { |
|
|
|
|
|
return { |
|
|
|
|
|
id: assetClass, |
|
|
|
|
|
label: translate(assetClass), |
|
|
|
|
|
type: 'ASSET_CLASS' as const |
|
|
|
|
|
}; |
|
|
|
|
|
}) |
|
|
|
|
|
.sort((a, b) => { |
|
|
|
|
|
return a.label.localeCompare(b.label); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
this.userService |
|
|
this.userService |
|
|
.get() |
|
|
.get() |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
@ -117,13 +130,21 @@ export class GfCreateOrUpdateAccessDialogComponent implements OnInit { |
|
|
this.accounts = accounts; |
|
|
this.accounts = accounts; |
|
|
this.hasExperimentalFeatures = settings.isExperimentalFeatures ?? false; |
|
|
this.hasExperimentalFeatures = settings.isExperimentalFeatures ?? false; |
|
|
|
|
|
|
|
|
this.tags = tags |
|
|
this.tags = |
|
|
.filter(({ isUsed }) => isUsed) |
|
|
tags |
|
|
.map(({ id, name }) => ({ |
|
|
?.filter(({ isUsed }) => { |
|
|
id, |
|
|
return isUsed; |
|
|
label: name, |
|
|
}) |
|
|
type: 'TAG' as const |
|
|
?.map(({ id, name }) => { |
|
|
})); |
|
|
return { |
|
|
|
|
|
id, |
|
|
|
|
|
label: translate(name), |
|
|
|
|
|
type: 'TAG' as const |
|
|
|
|
|
}; |
|
|
|
|
|
}) |
|
|
|
|
|
?.sort((a, b) => { |
|
|
|
|
|
return a.label.localeCompare(b.label); |
|
|
|
|
|
}) ?? []; |
|
|
|
|
|
|
|
|
this.updateFiltersFormControl(this.data.access?.settings?.filters); |
|
|
this.updateFiltersFormControl(this.data.access?.settings?.filters); |
|
|
|
|
|
|
|
|
@ -216,26 +237,24 @@ export class GfCreateOrUpdateAccessDialogComponent implements OnInit { |
|
|
|
|
|
|
|
|
private loadHoldings() { |
|
|
private loadHoldings() { |
|
|
this.dataService |
|
|
this.dataService |
|
|
.fetchPortfolioDetails({}) |
|
|
.fetchPortfolioHoldings() |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe((response) => { |
|
|
.subscribe(({ holdings }) => { |
|
|
if (response.holdings) { |
|
|
this.holdings = holdings |
|
|
this.holdings = Object.values(response.holdings); |
|
|
.filter(({ assetProfile }) => { |
|
|
|
|
|
return ( |
|
|
const assetClassesSet = new Set<string>(); |
|
|
assetProfile.assetSubClass && |
|
|
Object.values(response.holdings).forEach((holding) => { |
|
|
!['CASH'].includes(assetProfile.assetSubClass) |
|
|
if (holding.assetProfile.assetClass) { |
|
|
); |
|
|
assetClassesSet.add(holding.assetProfile.assetClass); |
|
|
}) |
|
|
} |
|
|
.sort((a, b) => { |
|
|
|
|
|
return (a.assetProfile.name ?? '').localeCompare( |
|
|
|
|
|
b.assetProfile.name ?? '' |
|
|
|
|
|
); |
|
|
}); |
|
|
}); |
|
|
this.assetClasses = Array.from(assetClassesSet).map((ac) => ({ |
|
|
|
|
|
id: ac, |
|
|
|
|
|
label: ac, |
|
|
|
|
|
type: 'ASSET_CLASS' as const |
|
|
|
|
|
})); |
|
|
|
|
|
|
|
|
|
|
|
this.updateFiltersFormControl(this.data.access?.settings?.filters); |
|
|
this.updateFiltersFormControl(this.data.access?.settings?.filters); |
|
|
} |
|
|
|
|
|
this.changeDetectorRef.markForCheck(); |
|
|
this.changeDetectorRef.markForCheck(); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|