|
@ -15,7 +15,7 @@ import { |
|
|
ViewChild, |
|
|
ViewChild, |
|
|
ViewChildren |
|
|
ViewChildren |
|
|
} from '@angular/core'; |
|
|
} from '@angular/core'; |
|
|
import { FormControl } from '@angular/forms'; |
|
|
import { FormBuilder, FormControl } from '@angular/forms'; |
|
|
import { MatMenuTrigger } from '@angular/material/menu'; |
|
|
import { MatMenuTrigger } from '@angular/material/menu'; |
|
|
import { AdminService } from '@ghostfolio/client/services/admin.service'; |
|
|
import { AdminService } from '@ghostfolio/client/services/admin.service'; |
|
|
import { DataService } from '@ghostfolio/client/services/data.service'; |
|
|
import { DataService } from '@ghostfolio/client/services/data.service'; |
|
@ -110,6 +110,9 @@ export class AssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
{ label: $localize`5Y`, value: '5y' }, |
|
|
{ label: $localize`5Y`, value: '5y' }, |
|
|
{ label: $localize`Max`, value: 'max' } |
|
|
{ label: $localize`Max`, value: 'max' } |
|
|
]; |
|
|
]; |
|
|
|
|
|
public filterForm = this.formBuilder.group({ |
|
|
|
|
|
tag: new FormControl<string>(undefined) |
|
|
|
|
|
}); |
|
|
public isLoading = false; |
|
|
public isLoading = false; |
|
|
public isOpen = false; |
|
|
public isOpen = false; |
|
|
public placeholder = $localize`Find holding...`; |
|
|
public placeholder = $localize`Find holding...`; |
|
@ -119,7 +122,6 @@ export class AssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
holdings: [] |
|
|
holdings: [] |
|
|
}; |
|
|
}; |
|
|
public tags: Tag[] = []; |
|
|
public tags: Tag[] = []; |
|
|
public tagsFormControl = new FormControl<string>(undefined); |
|
|
|
|
|
|
|
|
|
|
|
private keyManager: FocusKeyManager<AssistantListItemComponent>; |
|
|
private keyManager: FocusKeyManager<AssistantListItemComponent>; |
|
|
private unsubscribeSubject = new Subject<void>(); |
|
|
private unsubscribeSubject = new Subject<void>(); |
|
@ -127,7 +129,8 @@ export class AssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
public constructor( |
|
|
public constructor( |
|
|
private adminService: AdminService, |
|
|
private adminService: AdminService, |
|
|
private changeDetectorRef: ChangeDetectorRef, |
|
|
private changeDetectorRef: ChangeDetectorRef, |
|
|
private dataService: DataService |
|
|
private dataService: DataService, |
|
|
|
|
|
private formBuilder: FormBuilder |
|
|
) {} |
|
|
) {} |
|
|
|
|
|
|
|
|
public ngOnInit() { |
|
|
public ngOnInit() { |
|
@ -140,6 +143,19 @@ export class AssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
}; |
|
|
}; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this.filterForm |
|
|
|
|
|
.get('tag') |
|
|
|
|
|
.valueChanges.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
|
|
|
.subscribe((tagId) => { |
|
|
|
|
|
const tag = this.tags.find(({ id }) => { |
|
|
|
|
|
return id === tagId; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this.selectedTagChanged.emit(tag); |
|
|
|
|
|
|
|
|
|
|
|
this.onCloseAssistant(); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
this.searchFormControl.valueChanges |
|
|
this.searchFormControl.valueChanges |
|
|
.pipe( |
|
|
.pipe( |
|
|
map((searchTerm) => { |
|
|
map((searchTerm) => { |
|
@ -181,8 +197,14 @@ export class AssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
|
|
|
|
|
|
public ngOnChanges() { |
|
|
public ngOnChanges() { |
|
|
this.dateRangeFormControl.setValue(this.user?.settings?.dateRange ?? null); |
|
|
this.dateRangeFormControl.setValue(this.user?.settings?.dateRange ?? null); |
|
|
this.tagsFormControl.setValue( |
|
|
|
|
|
this.user?.settings?.['filters.tags']?.[0] ?? null |
|
|
this.filterForm.setValue( |
|
|
|
|
|
{ |
|
|
|
|
|
tag: this.user?.settings?.['filters.tags']?.[0] ?? null |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
emitEvent: false |
|
|
|
|
|
} |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -219,16 +241,6 @@ export class AssistantComponent implements OnChanges, OnDestroy, OnInit { |
|
|
this.closed.emit(); |
|
|
this.closed.emit(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public onTagChange() { |
|
|
|
|
|
const selectedTag = this.tags.find(({ id }) => { |
|
|
|
|
|
return id === this.tagsFormControl.value; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this.selectedTagChanged.emit(selectedTag); |
|
|
|
|
|
|
|
|
|
|
|
this.onCloseAssistant(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public setIsOpen(aIsOpen: boolean) { |
|
|
public setIsOpen(aIsOpen: boolean) { |
|
|
this.isOpen = aIsOpen; |
|
|
this.isOpen = aIsOpen; |
|
|
} |
|
|
} |
|
|