|
|
@ -153,14 +153,16 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
}); |
|
|
|
public holdings: PortfolioPosition[] = []; |
|
|
|
public isLoading = { |
|
|
|
accounts: false, |
|
|
|
assetProfiles: false, |
|
|
|
holdings: false, |
|
|
|
quickLinks: false |
|
|
|
}; |
|
|
|
public isOpen = false; |
|
|
|
public placeholder = $localize`Find holding or page...`; |
|
|
|
public placeholder = $localize`Find account, holding or page...`; |
|
|
|
public searchFormControl = new FormControl(''); |
|
|
|
public searchResults: ISearchResults = { |
|
|
|
accounts: [], |
|
|
|
assetProfiles: [], |
|
|
|
holdings: [], |
|
|
|
quickLinks: [] |
|
|
@ -199,11 +201,13 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
.pipe( |
|
|
|
map((searchTerm) => { |
|
|
|
this.isLoading = { |
|
|
|
accounts: true, |
|
|
|
assetProfiles: true, |
|
|
|
holdings: true, |
|
|
|
quickLinks: true |
|
|
|
}; |
|
|
|
this.searchResults = { |
|
|
|
accounts: [], |
|
|
|
assetProfiles: [], |
|
|
|
holdings: [], |
|
|
|
quickLinks: [] |
|
|
@ -217,6 +221,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
distinctUntilChanged(), |
|
|
|
switchMap((searchTerm) => { |
|
|
|
const results = { |
|
|
|
accounts: [], |
|
|
|
assetProfiles: [], |
|
|
|
holdings: [], |
|
|
|
quickLinks: [] |
|
|
@ -226,6 +231,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
return of(results).pipe( |
|
|
|
tap(() => { |
|
|
|
this.isLoading = { |
|
|
|
accounts: false, |
|
|
|
assetProfiles: false, |
|
|
|
holdings: false, |
|
|
|
quickLinks: false |
|
|
@ -234,6 +240,25 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
// Accounts
|
|
|
|
const accounts$: Observable<Partial<ISearchResults>> = |
|
|
|
this.searchAccounts(searchTerm).pipe( |
|
|
|
map((accounts) => ({ |
|
|
|
accounts: accounts.slice( |
|
|
|
0, |
|
|
|
GfAssistantComponent.SEARCH_RESULTS_DEFAULT_LIMIT |
|
|
|
) |
|
|
|
})), |
|
|
|
catchError((error) => { |
|
|
|
console.error('Error fetching accounts for assistant:', error); |
|
|
|
return of({ accounts: [] as ISearchResultItem[] }); |
|
|
|
}), |
|
|
|
tap(() => { |
|
|
|
this.isLoading.accounts = false; |
|
|
|
this.changeDetectorRef.markForCheck(); |
|
|
|
}) |
|
|
|
); |
|
|
|
|
|
|
|
// Asset profiles
|
|
|
|
const assetProfiles$: Observable<Partial<ISearchResults>> = this |
|
|
|
.hasPermissionToAccessAdminControl |
|
|
@ -299,13 +324,14 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
); |
|
|
|
|
|
|
|
// Merge all results
|
|
|
|
return merge(quickLinks$, assetProfiles$, holdings$).pipe( |
|
|
|
return merge(accounts$, assetProfiles$, holdings$, quickLinks$).pipe( |
|
|
|
scan( |
|
|
|
(acc: ISearchResults, curr: Partial<ISearchResults>) => ({ |
|
|
|
...acc, |
|
|
|
...curr |
|
|
|
}), |
|
|
|
{ |
|
|
|
accounts: [], |
|
|
|
assetProfiles: [], |
|
|
|
holdings: [], |
|
|
|
quickLinks: [] |
|
|
@ -323,6 +349,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
error: (error) => { |
|
|
|
console.error('Assistant search stream error:', error); |
|
|
|
this.searchResults = { |
|
|
|
accounts: [], |
|
|
|
assetProfiles: [], |
|
|
|
holdings: [], |
|
|
|
quickLinks: [] |
|
|
@ -331,6 +358,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
}, |
|
|
|
complete: () => { |
|
|
|
this.isLoading = { |
|
|
|
accounts: false, |
|
|
|
assetProfiles: false, |
|
|
|
holdings: false, |
|
|
|
quickLinks: false |
|
|
@ -451,12 +479,14 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
|
|
|
|
public initialize() { |
|
|
|
this.isLoading = { |
|
|
|
accounts: true, |
|
|
|
assetProfiles: true, |
|
|
|
holdings: true, |
|
|
|
quickLinks: true |
|
|
|
}; |
|
|
|
this.keyManager = new FocusKeyManager(this.assistantListItems).withWrap(); |
|
|
|
this.searchResults = { |
|
|
|
accounts: [], |
|
|
|
assetProfiles: [], |
|
|
|
holdings: [], |
|
|
|
quickLinks: [] |
|
|
@ -472,6 +502,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
}); |
|
|
|
|
|
|
|
this.isLoading = { |
|
|
|
accounts: false, |
|
|
|
assetProfiles: false, |
|
|
|
holdings: false, |
|
|
|
quickLinks: false |
|
|
@ -564,6 +595,34 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
private searchAccounts(aSearchTerm: string): Observable<ISearchResultItem[]> { |
|
|
|
return this.dataService |
|
|
|
.fetchAccounts({ |
|
|
|
filters: [ |
|
|
|
{ |
|
|
|
id: aSearchTerm, |
|
|
|
type: 'SEARCH_QUERY' |
|
|
|
} |
|
|
|
] |
|
|
|
}) |
|
|
|
.pipe( |
|
|
|
catchError(() => { |
|
|
|
return EMPTY; |
|
|
|
}), |
|
|
|
map(({ accounts }) => { |
|
|
|
return accounts.map(({ id, name }) => { |
|
|
|
return { |
|
|
|
id, |
|
|
|
name, |
|
|
|
routerLink: internalRoutes.accounts.routerLink, |
|
|
|
mode: SearchMode.ACCOUNT as const |
|
|
|
}; |
|
|
|
}); |
|
|
|
}), |
|
|
|
takeUntil(this.unsubscribeSubject) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
private searchAssetProfiles( |
|
|
|
aSearchTerm: string |
|
|
|
): Observable<ISearchResultItem[]> { |
|
|
|