|
|
|
@ -62,9 +62,9 @@ import { |
|
|
|
import { GfAssistantListItemComponent } from './assistant-list-item/assistant-list-item.component'; |
|
|
|
import { SearchMode } from './enums/search-mode'; |
|
|
|
import { |
|
|
|
IDateRangeOption, |
|
|
|
ISearchResultItem, |
|
|
|
ISearchResults |
|
|
|
DateRangeOption, |
|
|
|
SearchResultItem, |
|
|
|
SearchResults |
|
|
|
} from './interfaces/interfaces'; |
|
|
|
|
|
|
|
@Component({ |
|
|
|
@ -140,7 +140,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
public accounts: AccountWithPlatform[] = []; |
|
|
|
public assetClasses: Filter[] = []; |
|
|
|
public dateRangeFormControl = new FormControl<string>(undefined); |
|
|
|
public dateRangeOptions: IDateRangeOption[] = []; |
|
|
|
public dateRangeOptions: DateRangeOption[] = []; |
|
|
|
public holdings: PortfolioPosition[] = []; |
|
|
|
public isLoading = { |
|
|
|
accounts: false, |
|
|
|
@ -159,7 +159,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
} |
|
|
|
); |
|
|
|
public searchFormControl = new FormControl(''); |
|
|
|
public searchResults: ISearchResults = { |
|
|
|
public searchResults: SearchResults = { |
|
|
|
accounts: [], |
|
|
|
assetProfiles: [], |
|
|
|
holdings: [], |
|
|
|
@ -226,7 +226,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
assetProfiles: [], |
|
|
|
holdings: [], |
|
|
|
quickLinks: [] |
|
|
|
} as ISearchResults; |
|
|
|
} as SearchResults; |
|
|
|
|
|
|
|
if (!searchTerm) { |
|
|
|
return of(results).pipe( |
|
|
|
@ -241,7 +241,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
const accounts$: Observable<Partial<ISearchResults>> = |
|
|
|
const accounts$: Observable<Partial<SearchResults>> = |
|
|
|
this.searchAccounts(searchTerm).pipe( |
|
|
|
map((accounts) => ({ |
|
|
|
accounts: accounts.slice( |
|
|
|
@ -251,7 +251,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
})), |
|
|
|
catchError((error) => { |
|
|
|
console.error('Error fetching accounts for assistant:', error); |
|
|
|
return of({ accounts: [] as ISearchResultItem[] }); |
|
|
|
return of({ accounts: [] as SearchResultItem[] }); |
|
|
|
}), |
|
|
|
tap(() => { |
|
|
|
this.isLoading.accounts = false; |
|
|
|
@ -259,7 +259,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
}) |
|
|
|
); |
|
|
|
|
|
|
|
const assetProfiles$: Observable<Partial<ISearchResults>> = this |
|
|
|
const assetProfiles$: Observable<Partial<SearchResults>> = this |
|
|
|
.hasPermissionToAccessAdminControl |
|
|
|
? this.searchAssetProfiles(searchTerm).pipe( |
|
|
|
map((assetProfiles) => ({ |
|
|
|
@ -273,21 +273,21 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
'Error fetching asset profiles for assistant:', |
|
|
|
error |
|
|
|
); |
|
|
|
return of({ assetProfiles: [] as ISearchResultItem[] }); |
|
|
|
return of({ assetProfiles: [] as SearchResultItem[] }); |
|
|
|
}), |
|
|
|
tap(() => { |
|
|
|
this.isLoading.assetProfiles = false; |
|
|
|
this.changeDetectorRef.markForCheck(); |
|
|
|
}) |
|
|
|
) |
|
|
|
: of({ assetProfiles: [] as ISearchResultItem[] }).pipe( |
|
|
|
: of({ assetProfiles: [] as SearchResultItem[] }).pipe( |
|
|
|
tap(() => { |
|
|
|
this.isLoading.assetProfiles = false; |
|
|
|
this.changeDetectorRef.markForCheck(); |
|
|
|
}) |
|
|
|
); |
|
|
|
|
|
|
|
const holdings$: Observable<Partial<ISearchResults>> = |
|
|
|
const holdings$: Observable<Partial<SearchResults>> = |
|
|
|
this.searchHoldings(searchTerm).pipe( |
|
|
|
map((holdings) => ({ |
|
|
|
holdings: holdings.slice( |
|
|
|
@ -297,7 +297,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
})), |
|
|
|
catchError((error) => { |
|
|
|
console.error('Error fetching holdings for assistant:', error); |
|
|
|
return of({ holdings: [] as ISearchResultItem[] }); |
|
|
|
return of({ holdings: [] as SearchResultItem[] }); |
|
|
|
}), |
|
|
|
tap(() => { |
|
|
|
this.isLoading.holdings = false; |
|
|
|
@ -305,7 +305,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
}) |
|
|
|
); |
|
|
|
|
|
|
|
const quickLinks$: Observable<Partial<ISearchResults>> = of( |
|
|
|
const quickLinks$: Observable<Partial<SearchResults>> = of( |
|
|
|
this.searchQuickLinks(searchTerm) |
|
|
|
).pipe( |
|
|
|
map((quickLinks) => ({ |
|
|
|
@ -322,7 +322,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
|
|
|
|
return merge(accounts$, assetProfiles$, holdings$, quickLinks$).pipe( |
|
|
|
scan( |
|
|
|
(acc: ISearchResults, curr: Partial<ISearchResults>) => ({ |
|
|
|
(acc: SearchResults, curr: Partial<SearchResults>) => ({ |
|
|
|
...acc, |
|
|
|
...curr |
|
|
|
}), |
|
|
|
@ -331,7 +331,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
assetProfiles: [], |
|
|
|
holdings: [], |
|
|
|
quickLinks: [] |
|
|
|
} as ISearchResults |
|
|
|
} as SearchResults |
|
|
|
) |
|
|
|
); |
|
|
|
}), |
|
|
|
@ -622,7 +622,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
}, this.PRESELECTION_DELAY); |
|
|
|
} |
|
|
|
|
|
|
|
private searchAccounts(aSearchTerm: string): Observable<ISearchResultItem[]> { |
|
|
|
private searchAccounts(aSearchTerm: string): Observable<SearchResultItem[]> { |
|
|
|
return this.dataService |
|
|
|
.fetchAccounts({ |
|
|
|
filters: [ |
|
|
|
@ -652,7 +652,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
|
|
|
|
private searchAssetProfiles( |
|
|
|
aSearchTerm: string |
|
|
|
): Observable<ISearchResultItem[]> { |
|
|
|
): Observable<SearchResultItem[]> { |
|
|
|
return this.adminService |
|
|
|
.fetchAdminMarketData({ |
|
|
|
filters: [ |
|
|
|
@ -685,7 +685,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
private searchHoldings(aSearchTerm: string): Observable<ISearchResultItem[]> { |
|
|
|
private searchHoldings(aSearchTerm: string): Observable<SearchResultItem[]> { |
|
|
|
return this.dataService |
|
|
|
.fetchPortfolioHoldings({ |
|
|
|
filters: [ |
|
|
|
@ -717,7 +717,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
private searchQuickLinks(aSearchTerm: string): ISearchResultItem[] { |
|
|
|
private searchQuickLinks(aSearchTerm: string): SearchResultItem[] { |
|
|
|
const searchTerm = aSearchTerm.toLowerCase(); |
|
|
|
|
|
|
|
const allRoutes = Object.values(internalRoutes) |
|
|
|
|