Skip to content

Commit de655e5

Browse files
authored
Merge pull request #215 from iteratec/feature/showPerformanceAspectMetricsInFrontend
Feature: shown page metrics are now the added performance aspects.
2 parents 223aeed + 8e263b2 commit de655e5

File tree

21 files changed

+120
-96
lines changed

21 files changed

+120
-96
lines changed

frontend/src/app/enums/metric.enum.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export enum PerformanceAspectTypes {
2+
PAGE_CONSTRUCTION_STARTED = "PAGE_CONSTRUCTION_STARTED",
3+
PAGE_SHOWS_USEFUL_CONTENT = "PAGE_SHOWS_USEFUL_CONTENT",
4+
PAGE_IS_USABLE = "PAGE_IS_USABLE"
5+
}

frontend/src/app/models/perfomance-aspect.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ export type ExtendedPerformanceAspect = PerformanceAspect & BrowserInfoDto
1717
export interface PerformanceAspectType {
1818
name: string
1919
icon: string
20+
unit: string
2021
}

frontend/src/app/modules/application-dashboard/application-dashboard.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ <h2 class="card">{{ 'frontend.de.iteratec.osm.applicationDashboard.kpi.title' |
3131
[selectedApplication]="selectedApplication$ | async"
3232
class="card"></osm-application-job-status>
3333

34-
<osm-page *ngFor="let metric of pages$ | async" [metricsForPage]="metric"
34+
<osm-page *ngFor="let metric of pages$ | async" [metricsForPage]="metric" [aspectTypes]="aspectTypes$ | async"
3535
[lastDateOfResult]="(selectedApplication$ | async)?.dateOfLastResults"
3636
[application]="selectedApplication$ | async"
3737
class="card"></osm-page>

frontend/src/app/modules/application-dashboard/application-dashboard.component.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {PageMetricsDto} from "./models/page-metrics.model";
88
import {ApplicationCsi, ApplicationCsiById} from "../../models/application-csi.model";
99
import {Csi} from "../../models/csi.model";
1010
import {FailingJobStatistic} from "./models/failing-job-statistic.model";
11+
import {PerformanceAspectService} from "../../services/performance-aspect.service";
12+
import {PerformanceAspectType} from "../../models/perfomance-aspect.model";
1113

1214
@Component({
1315
selector: 'osm-application-dashboard',
@@ -24,13 +26,15 @@ export class ApplicationDashboardComponent implements OnDestroy {
2426
isLoading$: Observable<boolean>;
2527
failingJobStatistic$: Observable<FailingJobStatistic>;
2628
selectedApplication$: Observable<Application>;
29+
aspectTypes$: Observable<PerformanceAspectType[]>;
2730

2831
constructor(
2932
private route: ActivatedRoute,
3033
private router: Router,
31-
private applicationService: ApplicationService
34+
private applicationService: ApplicationService,
35+
private performanceAspectService: PerformanceAspectService
3236
) {
33-
this.pages$ = this.applicationService.metrics$;
37+
this.pages$ = this.applicationService.aspectMetrics$;
3438
this.applications$ = applicationService.applications$.pipe(
3539
filter(response => !response.isLoading && !!response.data),
3640
map(response => response.data)
@@ -47,6 +51,7 @@ export class ApplicationDashboardComponent implements OnDestroy {
4751
.subscribe(([navParams, applications]) => this.handleNavigation(navParams.get('applicationId'), applications));
4852
this.failingJobStatistic$ = this.applicationService.failingJobStatistics$;
4953
this.selectedApplication$ = this.applicationService.selectedApplication$;
54+
this.aspectTypes$ = this.performanceAspectService.aspectTypes$;
5055
}
5156

5257
private handleNavigation(applicationId: string, applications: Application[]) {
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<div class="metric"
22
title=" {{ isAvailable() ? '' : ('frontend.de.iteratec.osm.applicationDashboard.noMeasuredValue.hint' | translate) }}">
3-
<i [ngClass]="metric?.icon" class="metric-icon"></i>
3+
<i [ngClass]="metric?.icon" class="metric-icon" title="{{ 'frontend.de.iteratec.osm.performance-aspect.' + metric?.name + '.description' | translate }}"></i>
44
<div class="metric-value">{{ isAvailable() ? value : "n/a"}}</div>
5-
<div class="metric-unit" *ngIf="isAvailable()">{{ metric?.unit}}</div>
6-
<div class="metric-description">{{ metric?.name }}</div>
5+
<div class="metric-unit" *ngIf="isAvailable()">{{ determineUnit(metric?.unit) }}</div>
6+
<div class="metric-description">{{ 'frontend.de.iteratec.osm.performance-aspect.' + metric?.name + '.user-centric-question' | translate }}</div>
7+
<div ></div>
78
</div>

frontend/src/app/modules/application-dashboard/components/page-metric/page-metric.component.spec.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {ApplicationService} from "../../../../services/application.service";
55
import {By} from "@angular/platform-browser";
66
import {Unit} from "../../../../enums/unit.enum";
77
import {DebugElement} from "@angular/core";
8-
import {Metric} from "../../../../enums/metric.enum";
98
import {SharedMocksModule} from "../../../../testing/shared-mocks.module";
9+
import {PerformanceAspectType} from "../../../../models/perfomance-aspect.model";
1010

1111
describe('PageMetricComponent', () => {
1212
let component: PageMetricComponent;
@@ -38,7 +38,11 @@ describe('PageMetricComponent', () => {
3838
});
3939
it("should show the value if the value is available", () => {
4040
const value: string = "2.34";
41-
const metric: Metric = new Metric("SpeedIndex", Unit.SECONDS, 'far fa-eye');
41+
const metric: PerformanceAspectType = {
42+
name: 'PAGE_CONSTRUCTION_STARTED',
43+
icon: 'fas fa-eye',
44+
unit: 'ms'
45+
};
4246
component.value = value;
4347
component.metric = metric;
4448

@@ -52,7 +56,11 @@ describe('PageMetricComponent', () => {
5256
});
5357
it("should be 'n/a' and without unit if the value is empty", () => {
5458
const value: string = "";
55-
const metric: Metric = new Metric("SpeedIndex", Unit.SECONDS, 'far fa-eye');
59+
const metric: PerformanceAspectType = {
60+
name: 'PAGE_CONSTRUCTION_STARTED',
61+
icon: 'fas fa-eye',
62+
unit: 'ms'
63+
};
5664
component.value = value;
5765
component.metric = metric;
5866

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {Component, Input} from '@angular/core';
2-
import {Metric} from "../../../../enums/metric.enum";
2+
import {Unit} from "../../../../enums/unit.enum";
3+
import {PerformanceAspectType} from "../../../../models/perfomance-aspect.model";
34

45
@Component({
56
selector: 'osm-page-metric',
@@ -8,10 +9,18 @@ import {Metric} from "../../../../enums/metric.enum";
89
})
910

1011
export class PageMetricComponent {
11-
@Input() metric: Metric;
12+
@Input() metric: PerformanceAspectType;
1213
@Input() value: string;
1314

15+
Unit: typeof Unit = Unit;
16+
1417
public isAvailable(): boolean {
1518
return this.value !== '';
1619
}
20+
21+
determineUnit(unit: string): string {
22+
if (unit === 'ms') {
23+
return Unit.SECONDS
24+
}
25+
}
1726
}

frontend/src/app/modules/application-dashboard/components/page/page.component.html

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ <h2>
77
<osm-csi-value-medium [csiValue]="pageCsi$ | async" [csiDate]="pageCsiDate$ | async"
88
[showLoading]="isLoading" [lastResultDate]="lastDateOfResult"></osm-csi-value-medium>
99
<div class="metric-list">
10-
<osm-page-metric [value]="transform(convertMillisecsToSecs(metricsForPage?.speedIndex))"
11-
[metric]="metrics.SPEED_INDEX"></osm-page-metric>
12-
<osm-page-metric [value]="transform(convertMillisecsToSecs(metricsForPage?.docCompleteTimeInMillisecs))"
13-
[metric]="metrics.DOCUMENT_COMPLETE"></osm-page-metric>
14-
<osm-page-metric [value]="transform(convertToMib(metricsForPage?.fullyLoadedIncomingBytes))"
15-
[metric]="metrics.BYTES_FULLY_LOADED"></osm-page-metric>
10+
<osm-page-metric [value]="transform(convertMillisecsToSecs(metricsForPage?.PAGE_CONSTRUCTION_STARTED))"
11+
[metric]="findCorrectPerformanceAspectType(PerformanceAspectTypes.PAGE_CONSTRUCTION_STARTED)"></osm-page-metric>
12+
<osm-page-metric [value]="transform(convertMillisecsToSecs(metricsForPage?.PAGE_SHOWS_USEFUL_CONTENT))"
13+
[metric]="findCorrectPerformanceAspectType(PerformanceAspectTypes.PAGE_SHOWS_USEFUL_CONTENT)"></osm-page-metric>
14+
<osm-page-metric [value]="transform(convertMillisecsToSecs(metricsForPage?.PAGE_IS_USABLE))"
15+
[metric]="findCorrectPerformanceAspectType(PerformanceAspectTypes.PAGE_IS_USABLE)"></osm-page-metric>
1616
</div>
17+
1718
</div>

frontend/src/app/modules/application-dashboard/components/page/page.component.spec.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,14 @@ describe('PageComponent', () => {
4040
beforeEach(() => {
4141
fixture = TestBed.createComponent(PageComponent);
4242
component = fixture.componentInstance;
43-
component.application = new Application({name: 'app', id: 1})
43+
component.application = new Application({name: 'app', id: 1});
44+
component.aspectTypes = [{name: 'aspect-type-name', icon: 'aspect-type-icon', unit: 'aspect-type-unit'}];
4445
component.metricsForPage = {
4546
pageId: 1,
4647
pageName: 'page',
47-
speedIndex: 2000,
48-
docCompleteTimeInMillisecs: 1800,
49-
fullyLoadedIncomingBytes: 3000
48+
PAGE_CONSTRUCTION_STARTED: 2000,
49+
PAGE_SHOWS_USEFUL_CONTENT: 1800,
50+
PAGE_IS_USABLE: 3000
5051
};
5152
fixture.detectChanges();
5253
});

0 commit comments

Comments
 (0)