Browse Source

Prepare for filters.tags

pull/2838/head
Thomas Kaul 2 years ago
parent
commit
3957e05942
  1. 11
      apps/client/src/app/pages/portfolio/activities/activities-page.component.ts
  2. 16
      apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts
  3. 4
      apps/client/src/app/pages/portfolio/analysis/analysis-page.html
  4. 17
      apps/client/src/app/services/user/user.service.ts

11
apps/client/src/app/pages/portfolio/activities/activities-page.component.ts

@ -122,18 +122,9 @@ export class ActivitiesPageComponent implements OnDestroy, OnInit {
public fetchActivities() { public fetchActivities() {
if (this.user?.settings?.isExperimentalFeatures === true) { if (this.user?.settings?.isExperimentalFeatures === true) {
const filters: Filter[] = [];
if (this.user?.settings?.['filters.tags']) {
filters.push({
id: this.user.settings['filters.tags'][0],
type: 'TAG'
});
}
this.dataService this.dataService
.fetchActivities({ .fetchActivities({
filters, filters: this.userService.getFilters() ?? [],
skip: this.pageIndex * this.pageSize, skip: this.pageIndex * this.pageSize,
sortColumn: this.sortColumn, sortColumn: this.sortColumn,
sortDirection: this.sortDirection, sortDirection: this.sortDirection,

16
apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts

@ -225,7 +225,7 @@ export class AnalysisPageComponent implements OnDestroy, OnInit {
private fetchDividendsAndInvestments() { private fetchDividendsAndInvestments() {
this.dataService this.dataService
.fetchDividends({ .fetchDividends({
filters: this.activeFilters, filters: this.userService.getFilters() ?? this.activeFilters,
groupBy: this.mode, groupBy: this.mode,
range: this.user?.settings?.dateRange range: this.user?.settings?.dateRange
}) })
@ -238,7 +238,7 @@ export class AnalysisPageComponent implements OnDestroy, OnInit {
this.dataService this.dataService
.fetchInvestments({ .fetchInvestments({
filters: this.activeFilters, filters: this.userService.getFilters() ?? this.activeFilters,
groupBy: this.mode, groupBy: this.mode,
range: this.user?.settings?.dateRange range: this.user?.settings?.dateRange
}) })
@ -252,16 +252,16 @@ export class AnalysisPageComponent implements OnDestroy, OnInit {
? translate('YEAR') ? translate('YEAR')
: translate('YEARS') : translate('YEARS')
: this.streaks?.currentStreak === 1 : this.streaks?.currentStreak === 1
? translate('MONTH') ? translate('MONTH')
: translate('MONTHS'); : translate('MONTHS');
this.unitLongestStreak = this.unitLongestStreak =
this.mode === 'year' this.mode === 'year'
? this.streaks?.longestStreak === 1 ? this.streaks?.longestStreak === 1
? translate('YEAR') ? translate('YEAR')
: translate('YEARS') : translate('YEARS')
: this.streaks?.longestStreak === 1 : this.streaks?.longestStreak === 1
? translate('MONTH') ? translate('MONTH')
: translate('MONTHS'); : translate('MONTHS');
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
}); });
@ -313,7 +313,7 @@ export class AnalysisPageComponent implements OnDestroy, OnInit {
this.dataService this.dataService
.fetchPortfolioPerformance({ .fetchPortfolioPerformance({
filters: this.activeFilters, filters: this.userService.getFilters() ?? this.activeFilters,
range: this.user?.settings?.dateRange range: this.user?.settings?.dateRange
}) })
.pipe(takeUntil(this.unsubscribeSubject)) .pipe(takeUntil(this.unsubscribeSubject))
@ -358,7 +358,7 @@ export class AnalysisPageComponent implements OnDestroy, OnInit {
this.dataService this.dataService
.fetchPositions({ .fetchPositions({
filters: this.activeFilters, filters: this.userService.getFilters() ?? this.activeFilters,
range: this.user?.settings?.dateRange range: this.user?.settings?.dateRange
}) })
.pipe(takeUntil(this.unsubscribeSubject)) .pipe(takeUntil(this.unsubscribeSubject))

4
apps/client/src/app/pages/portfolio/analysis/analysis-page.html

@ -1,6 +1,7 @@
<div class="container"> <div class="container">
<h1 class="d-none d-sm-block h3 mb-3 text-center" i18n>Analysis</h1> <h1 class="d-none d-sm-block h3 mb-3 text-center" i18n>Analysis</h1>
<div *ngIf="!user?.settings?.isExperimentalFeatures" class="my-4 text-center"> @if (!user?.settings?.isExperimentalFeatures) {
<div class="my-4 text-center">
<gf-toggle <gf-toggle
[defaultValue]="user?.settings?.dateRange" [defaultValue]="user?.settings?.dateRange"
[isLoading]="isLoadingBenchmarkComparator || isLoadingInvestmentChart" [isLoading]="isLoadingBenchmarkComparator || isLoadingInvestmentChart"
@ -14,6 +15,7 @@
[placeholder]="placeholder" [placeholder]="placeholder"
(valueChanged)="filters$.next($event)" (valueChanged)="filters$.next($event)"
></gf-activities-filter> ></gf-activities-filter>
}
<div class="mb-5 row"> <div class="mb-5 row">
<div class="col-lg"> <div class="col-lg">
<gf-benchmark-comparator <gf-benchmark-comparator

17
apps/client/src/app/services/user/user.service.ts

@ -4,7 +4,7 @@ import { MatDialog } from '@angular/material/dialog';
import { ObservableStore } from '@codewithdan/observable-store'; import { ObservableStore } from '@codewithdan/observable-store';
import { SubscriptionInterstitialDialogParams } from '@ghostfolio/client/components/subscription-interstitial-dialog/interfaces/interfaces'; import { SubscriptionInterstitialDialogParams } from '@ghostfolio/client/components/subscription-interstitial-dialog/interfaces/interfaces';
import { SubscriptionInterstitialDialog } from '@ghostfolio/client/components/subscription-interstitial-dialog/subscription-interstitial-dialog.component'; import { SubscriptionInterstitialDialog } from '@ghostfolio/client/components/subscription-interstitial-dialog/subscription-interstitial-dialog.component';
import { User } from '@ghostfolio/common/interfaces'; import { Filter, User } from '@ghostfolio/common/interfaces';
import { hasPermission, permissions } from '@ghostfolio/common/permissions'; import { hasPermission, permissions } from '@ghostfolio/common/permissions';
import { parseISO } from 'date-fns'; import { parseISO } from 'date-fns';
import { DeviceDetectorService } from 'ngx-device-detector'; import { DeviceDetectorService } from 'ngx-device-detector';
@ -46,6 +46,21 @@ export class UserService extends ObservableStore<UserStoreState> {
} }
} }
public getFilters() {
const user = this.getState().user;
return user?.settings?.isExperimentalFeatures === true
? user.settings['filters.tags']
? <Filter[]>[
{
id: user.settings['filters.tags'][0],
type: 'TAG'
}
]
: []
: undefined;
}
public remove() { public remove() {
this.setState({ user: null }, UserStoreActions.RemoveUser); this.setState({ user: null }, UserStoreActions.RemoveUser);
} }

Loading…
Cancel
Save