From 4f590e5e0e438187d5bc48a8263c688134f53f3d Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Mon, 6 Nov 2017 18:51:10 +0100 Subject: [PATCH] Dashboard fixed --- .../dashboard/pages/dashboard-page.component.ts | 12 ++++++++---- src/Squidex/app/shared/components/app-context.ts | 4 ++++ .../app/shared/guards/unset-app.guard.spec.ts | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Squidex/app/features/dashboard/pages/dashboard-page.component.ts b/src/Squidex/app/features/dashboard/pages/dashboard-page.component.ts index 2f798a2f9..25e67d56e 100644 --- a/src/Squidex/app/features/dashboard/pages/dashboard-page.component.ts +++ b/src/Squidex/app/features/dashboard/pages/dashboard-page.component.ts @@ -66,19 +66,22 @@ export class DashboardPageComponent implements OnInit { } public ngOnInit() { - this.usagesService.getTodayStorage(this.ctx.appName) + this.ctx.appChanges + .switchMap(app => this.usagesService.getTodayStorage(app.name)) .subscribe(dto => { this.assetsCurrent = dto.size; this.assetsMax = dto.maxAllowed; }); - this.usagesService.getMonthCalls(this.ctx.appName) + this.ctx.appChanges + .switchMap(app => this.usagesService.getMonthCalls(app.name)) .subscribe(dto => { this.callsCurrent = dto.count; this.callsMax = dto.maxAllowed; }); - this.usagesService.getStorageUsages(this.ctx.appName, DateTime.today().addDays(-20), DateTime.today()) + this.ctx.appChanges + .switchMap(app => this.usagesService.getStorageUsages(app.name, DateTime.today().addDays(-20), DateTime.today())) .subscribe(dtos => { this.chartStorageCount = { labels: createLabels(dtos), @@ -111,7 +114,8 @@ export class DashboardPageComponent implements OnInit { }; }); - this.usagesService.getCallsUsages(this.ctx.appName, DateTime.today().addDays(-20), DateTime.today()) + this.ctx.appChanges + .switchMap(app => this.usagesService.getCallsUsages(app.name, DateTime.today().addDays(-20), DateTime.today())) .subscribe(dtos => { this.chartCallsCount = { labels: createLabels(dtos), diff --git a/src/Squidex/app/shared/components/app-context.ts b/src/Squidex/app/shared/components/app-context.ts index ac77c6021..f9418223c 100644 --- a/src/Squidex/app/shared/components/app-context.ts +++ b/src/Squidex/app/shared/components/app-context.ts @@ -30,6 +30,10 @@ export class AppContext implements OnDestroy { return this.appField; } + public get appChanges(): Observable { + return this.appsStore.selectedApp; + } + public get appName(): string { return this.appField ? this.appField.name : ''; } diff --git a/src/Squidex/app/shared/guards/unset-app.guard.spec.ts b/src/Squidex/app/shared/guards/unset-app.guard.spec.ts index 9a9508277..e98222b70 100644 --- a/src/Squidex/app/shared/guards/unset-app.guard.spec.ts +++ b/src/Squidex/app/shared/guards/unset-app.guard.spec.ts @@ -31,9 +31,9 @@ describe('UnsetAppGuard', () => { .subscribe(value => { result = value; }); - + expect(result).toBeTruthy(); - + appStoreService.verify(x => x.selectApp(null), Times.once()); }); }); \ No newline at end of file