|
|
@ -153,8 +153,8 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
}); |
|
|
|
public holdings: PortfolioPosition[] = []; |
|
|
|
public isLoading = { |
|
|
|
assetProfiles: false, |
|
|
|
accounts: false, |
|
|
|
assetProfiles: false, |
|
|
|
holdings: false, |
|
|
|
quickLinks: false |
|
|
|
}; |
|
|
@ -162,8 +162,8 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
public placeholder = $localize`Find account, holding or page...`; |
|
|
|
public searchFormControl = new FormControl(''); |
|
|
|
public searchResults: ISearchResults = { |
|
|
|
assetProfiles: [], |
|
|
|
accounts: [], |
|
|
|
assetProfiles: [], |
|
|
|
holdings: [], |
|
|
|
quickLinks: [] |
|
|
|
}; |
|
|
@ -201,14 +201,14 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
.pipe( |
|
|
|
map((searchTerm) => { |
|
|
|
this.isLoading = { |
|
|
|
assetProfiles: true, |
|
|
|
accounts: true, |
|
|
|
assetProfiles: true, |
|
|
|
holdings: true, |
|
|
|
quickLinks: true |
|
|
|
}; |
|
|
|
this.searchResults = { |
|
|
|
assetProfiles: [], |
|
|
|
accounts: [], |
|
|
|
assetProfiles: [], |
|
|
|
holdings: [], |
|
|
|
quickLinks: [] |
|
|
|
}; |
|
|
@ -221,8 +221,8 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
distinctUntilChanged(), |
|
|
|
switchMap((searchTerm) => { |
|
|
|
const results = { |
|
|
|
assetProfiles: [], |
|
|
|
accounts: [], |
|
|
|
assetProfiles: [], |
|
|
|
holdings: [], |
|
|
|
quickLinks: [] |
|
|
|
} as ISearchResults; |
|
|
@ -231,8 +231,8 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
return of(results).pipe( |
|
|
|
tap(() => { |
|
|
|
this.isLoading = { |
|
|
|
assetProfiles: false, |
|
|
|
accounts: false, |
|
|
|
assetProfiles: false, |
|
|
|
holdings: false, |
|
|
|
quickLinks: false |
|
|
|
}; |
|
|
@ -240,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 |
|
|
@ -269,25 +288,6 @@ 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(); |
|
|
|
}) |
|
|
|
); |
|
|
|
|
|
|
|
// Holdings
|
|
|
|
const holdings$: Observable<Partial<ISearchResults>> = |
|
|
|
this.searchHoldings(searchTerm).pipe( |
|
|
@ -324,15 +324,15 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
); |
|
|
|
|
|
|
|
// Merge all results
|
|
|
|
return merge(quickLinks$, assetProfiles$, accounts$, holdings$).pipe( |
|
|
|
return merge(accounts$, assetProfiles$, holdings$, quickLinks$).pipe( |
|
|
|
scan( |
|
|
|
(acc: ISearchResults, curr: Partial<ISearchResults>) => ({ |
|
|
|
...acc, |
|
|
|
...curr |
|
|
|
}), |
|
|
|
{ |
|
|
|
assetProfiles: [], |
|
|
|
accounts: [], |
|
|
|
assetProfiles: [], |
|
|
|
holdings: [], |
|
|
|
quickLinks: [] |
|
|
|
} as ISearchResults |
|
|
@ -349,8 +349,8 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
error: (error) => { |
|
|
|
console.error('Assistant search stream error:', error); |
|
|
|
this.searchResults = { |
|
|
|
assetProfiles: [], |
|
|
|
accounts: [], |
|
|
|
assetProfiles: [], |
|
|
|
holdings: [], |
|
|
|
quickLinks: [] |
|
|
|
}; |
|
|
@ -358,8 +358,8 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
}, |
|
|
|
complete: () => { |
|
|
|
this.isLoading = { |
|
|
|
assetProfiles: false, |
|
|
|
accounts: false, |
|
|
|
assetProfiles: false, |
|
|
|
holdings: false, |
|
|
|
quickLinks: false |
|
|
|
}; |
|
|
@ -479,15 +479,15 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
|
|
|
|
public initialize() { |
|
|
|
this.isLoading = { |
|
|
|
assetProfiles: true, |
|
|
|
accounts: true, |
|
|
|
assetProfiles: true, |
|
|
|
holdings: true, |
|
|
|
quickLinks: true |
|
|
|
}; |
|
|
|
this.keyManager = new FocusKeyManager(this.assistantListItems).withWrap(); |
|
|
|
this.searchResults = { |
|
|
|
assetProfiles: [], |
|
|
|
accounts: [], |
|
|
|
assetProfiles: [], |
|
|
|
holdings: [], |
|
|
|
quickLinks: [] |
|
|
|
}; |
|
|
@ -502,8 +502,8 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
}); |
|
|
|
|
|
|
|
this.isLoading = { |
|
|
|
assetProfiles: false, |
|
|
|
accounts: false, |
|
|
|
assetProfiles: false, |
|
|
|
holdings: false, |
|
|
|
quickLinks: false |
|
|
|
}; |
|
|
@ -595,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[]> { |
|
|
@ -662,34 +690,6 @@ 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, platform }) => { |
|
|
|
return { |
|
|
|
id, |
|
|
|
name, |
|
|
|
platform, |
|
|
|
mode: SearchMode.ACCOUNT as const |
|
|
|
}; |
|
|
|
}); |
|
|
|
}), |
|
|
|
takeUntil(this.unsubscribeSubject) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
private searchQuickLinks(aSearchTerm: string): ISearchResultItem[] { |
|
|
|
const searchTerm = aSearchTerm.toLowerCase(); |
|
|
|
|
|
|
|