diff --git a/frontend/src/app/modules/page/dashboard/abstraction/dashboard.facade.ts b/frontend/src/app/modules/page/dashboard/abstraction/dashboard.facade.ts index 6b9c2b9ecd..d3ecb6fe25 100644 --- a/frontend/src/app/modules/page/dashboard/abstraction/dashboard.facade.ts +++ b/frontend/src/app/modules/page/dashboard/abstraction/dashboard.facade.ts @@ -45,6 +45,9 @@ export class DashboardFacade { private readonly alertsService: AlertsService ) {} + public get dashboardStats$(): Observable> { + return this.dashboardState.dashboardStats$; + } public get numberOfTotalMyParts$(): Observable> { return this.dashboardState.numberOfTotalMyParts$; } @@ -129,7 +132,7 @@ export class DashboardFacade { this.dashboardState.setNumberOfOwnOpenAlertsReceived({data: dashboardStats.ownOpenAlertsReceived}) this.dashboardState.setNumberOfOwnOpenInvestigationsCreated({data: dashboardStats.ownOpenInvestigationsCreated}) this.dashboardState.setNumberOfOwnOpenAlertsCreated({data: dashboardStats.ownOpenAlertsCreated}) - + this.dashboardState.setDashboardStats({data: dashboardStats}) }, error: error => { diff --git a/frontend/src/app/modules/page/dashboard/core/dashboard.state.ts b/frontend/src/app/modules/page/dashboard/core/dashboard.state.ts index 3f80cf1146..1b2e589e92 100644 --- a/frontend/src/app/modules/page/dashboard/core/dashboard.state.ts +++ b/frontend/src/app/modules/page/dashboard/core/dashboard.state.ts @@ -25,6 +25,7 @@ import {Notifications} from '@shared/model/notification.model'; import {State} from '@shared/model/state'; import {Observable} from 'rxjs'; import {View} from 'src/app/modules/shared/model/view.model'; +import {DashboardStats} from "@page/dashboard/model/dashboard.model"; @Injectable() export class DashboardState { @@ -52,9 +53,7 @@ export class DashboardState { private readonly _numberOfOwnOpenInvestigationsCreated$: State> = new State>({ loader: true }); private readonly _numberOfOwnOpenAlertsReceived$: State> = new State>({ loader: true }); private readonly _numberOfOwnOpenAlertsCreated$: State> = new State>({ loader: true }); - - - + private readonly _dashboardStats$: State> = new State>({ loader: true }); // recent notifications private readonly _recentReceivedInvestigations$: State> = new State>({ loader: true }); @@ -205,12 +204,17 @@ export class DashboardState { this._numberOfOwnOpenAlertsCreated$.update(count); } + public setDashboardStats(dashboardStatus: View): void { + this._dashboardStats$.update(dashboardStatus); + } + + public get dashboardStats$(): Observable> { + return this._dashboardStats$.observable; + } /** * recent notifications getter/setter */ - - public get recentReceivedInvestigations$(): Observable> { return this._recentReceivedInvestigations$.observable; } diff --git a/frontend/src/app/modules/page/dashboard/presentation/dashboard.component.html b/frontend/src/app/modules/page/dashboard/presentation/dashboard.component.html index 7e335e8fac..70a3401ce7 100644 --- a/frontend/src/app/modules/page/dashboard/presentation/dashboard.component.html +++ b/frontend/src/app/modules/page/dashboard/presentation/dashboard.component.html @@ -23,7 +23,7 @@
>; public readonly numberOfOwnAlertsCreated$: Observable>; + public readonly dashboardStats$: Observable> public readonly investigationsReceived$: Observable>; public readonly investigationsCreated$: Observable>; public readonly alertsReceived$: Observable>; @@ -71,6 +73,7 @@ export class DashboardComponent implements OnInit, OnDestroy { constructor(private readonly dashboardFacade: DashboardFacade, private readonly router: Router) { + this.dashboardStats$ = this.dashboardFacade.dashboardStats$; this.numberOfTotalMyParts$ = this.dashboardFacade.numberOfTotalMyParts$; this.numberOfTotalOtherParts$ = this.dashboardFacade.numberOfTotalOtherParts$; @@ -82,6 +85,7 @@ export class DashboardComponent implements OnInit, OnDestroy { this.numberOfOwnAlertsCreated$ = this.dashboardFacade.numberOfOwnOpenAlertsCreated$; + this.investigationsReceived$ = this.dashboardFacade.recentReceivedInvestigations$; this.investigationsCreated$ = this.dashboardFacade.recentCreatedInvestigations$; this.alertsReceived$ = this.dashboardFacade.recentReceivedAlerts$ @@ -94,6 +98,12 @@ export class DashboardComponent implements OnInit, OnDestroy { this.alertLink = alertLink; this.alertParams = alertQueryParams; + // TODO make sure you load data from dashboard state + this.dashboardStats$.subscribe(value => { + value.data.totalOwnParts; + }) + // todo replace attribute with the one from dashboardstate + this.partsMetricData = [ { metricName: 'totalAmount', @@ -102,6 +112,7 @@ export class DashboardComponent implements OnInit, OnDestroy { } ] +// todo replace attribute with the one from dashboardstate this.otherPartsMetricData = [ { @@ -110,7 +121,7 @@ export class DashboardComponent implements OnInit, OnDestroy { metricUnit: 'parts' } ]; - +// todo replace attribute with the one from dashboardstate this.investigationsMetricData = [ { metricName: 'amountReceived',