From 17f8d66738329045cb52b35c870b3bce012a60b9 Mon Sep 17 00:00:00 2001 From: Ludek <13610612+ludeknovy@users.noreply.github.com> Date: Wed, 26 May 2021 18:41:06 +0200 Subject: [PATCH] label focus (#156) --- src/app/analyze-chart.service.spec.ts | 12 +++++ src/app/analyze-chart.service.ts | 24 +++++++++ .../control-panel/control-panel.component.css | 23 +------- .../control-panel/control-panel.component.ts | 2 +- .../analyze-charts.component.html | 2 +- .../analyze-charts.component.ts | 33 ++++++++---- .../item-detail/item-detail.component.html | 4 +- src/app/item-detail/item-detail.component.ts | 9 +++- .../performance-analysis.component.css | 2 +- .../performance-analysis.component.html | 4 +- .../performance-analysis.component.ts | 22 +++++--- .../request-stats-compare.component.css | 4 +- .../request-stats-compare.component.html | 9 +++- .../request-stats-compare.component.ts | 53 ++++++++++++------- src/app/shared-styles.css | 8 +-- src/app/top-panel/top-panel.component.html | 29 +++++----- src/app/top-panel/top-panel.component.scss | 8 +-- src/app/top-panel/top-panel.component.ts | 4 +- 18 files changed, 160 insertions(+), 92 deletions(-) create mode 100644 src/app/analyze-chart.service.spec.ts create mode 100644 src/app/analyze-chart.service.ts diff --git a/src/app/analyze-chart.service.spec.ts b/src/app/analyze-chart.service.spec.ts new file mode 100644 index 00000000..7298a81c --- /dev/null +++ b/src/app/analyze-chart.service.spec.ts @@ -0,0 +1,12 @@ +import { TestBed } from '@angular/core/testing'; + +import { AnalyzeChartService } from './analyze-chart.service'; + +describe('AnalyzeChartService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: AnalyzeChartService = TestBed.get(AnalyzeChartService); + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/analyze-chart.service.ts b/src/app/analyze-chart.service.ts new file mode 100644 index 00000000..bdf20039 --- /dev/null +++ b/src/app/analyze-chart.service.ts @@ -0,0 +1,24 @@ +import { Injectable } from '@angular/core'; +import {BehaviorSubject, Subject} from 'rxjs'; +import {Metrics} from './item-detail/metrics'; + +@Injectable({ + providedIn: 'root' +}) +export class AnalyzeChartService { + + public subject = new Subject(); + private dataSource = new BehaviorSubject(null); + currentData = this.dataSource.asObservable(); + + constructor() { } + + changeMessage(data: AnalyzeChartData) { + this.dataSource.next(data); + } +} + +interface AnalyzeChartData { + metrics?: Metrics[]; + label: string; +} diff --git a/src/app/control-panel/control-panel.component.css b/src/app/control-panel/control-panel.component.css index 0f80ebad..242544f0 100644 --- a/src/app/control-panel/control-panel.component.css +++ b/src/app/control-panel/control-panel.component.css @@ -1,29 +1,10 @@ #top-panel { - margin-left: 195px; - margin-right: 195px; + margin-left: 10px; + margin-right: 10px; margin-top: 20px; border-radius: 0.2rem; } -@media (max-width: 1550px) { - #top-panel { - margin-left: 95px; - margin-right: 85px; - } -} -@media (max-width: 1350px) { - #top-panel { - margin-left: 45px; - margin-right: 35px; - } -} -@media (max-width: 1150px) { - #top-panel { - margin-left: 12px; - margin-right: 30px; - } -} - .navbar-toggler { border: none; } diff --git a/src/app/control-panel/control-panel.component.ts b/src/app/control-panel/control-panel.component.ts index 39edbc7c..a73dec4a 100644 --- a/src/app/control-panel/control-panel.component.ts +++ b/src/app/control-panel/control-panel.component.ts @@ -3,7 +3,7 @@ import { Component } from '@angular/core'; @Component({ selector: 'app-control-panel', templateUrl: './control-panel.component.html', - styleUrls: ['./control-panel.component.css'] + styleUrls: ['./control-panel.component.css', '../shared-styles.css'] }) export class ControlPanelComponent { diff --git a/src/app/item-detail/analyze-charts/analyze-charts.component.html b/src/app/item-detail/analyze-charts/analyze-charts.component.html index 9081a2ba..738dc439 100644 --- a/src/app/item-detail/analyze-charts/analyze-charts.component.html +++ b/src/app/item-detail/analyze-charts/analyze-charts.component.html @@ -9,7 +9,7 @@
-
+
diff --git a/src/app/item-detail/analyze-charts/analyze-charts.component.ts b/src/app/item-detail/analyze-charts/analyze-charts.component.ts index 845796be..1d8f664e 100644 --- a/src/app/item-detail/analyze-charts/analyze-charts.component.ts +++ b/src/app/item-detail/analyze-charts/analyze-charts.component.ts @@ -2,13 +2,14 @@ import {Component, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core' import { customChartSettings } from 'src/app/graphs/item-detail'; import * as Highcharts from 'highcharts'; import { ItemsApiService } from 'src/app/items-api.service'; +import {AnalyzeChartService} from '../../analyze-chart.service'; @Component({ selector: 'app-analyze-charts', templateUrl: './analyze-charts.component.html', styleUrls: ['./analyze-charts.component.css', '../item-detail.component.scss'] }) -export class AnalyzeChartsComponent implements OnInit, OnChanges { +export class AnalyzeChartsComponent implements OnInit { @Input() params: { projectName: string, scenarioName: string, id: string }; @Input() chartLines: ChartLines; @@ -30,7 +31,8 @@ export class AnalyzeChartsComponent implements OnInit, OnChanges { preloadedSeries; constructor( - private itemApiService: ItemsApiService + private itemApiService: ItemsApiService, + private analyzeChartService: AnalyzeChartService ) { } @@ -44,14 +46,27 @@ export class AnalyzeChartsComponent implements OnInit, OnChanges { this.updateChart(_); this.preloadedSeries = _; }); - } + this.analyzeChartService.currentData.subscribe(data => { + let chartLines; + if (data) { + const { label, metrics } = data; + if (metrics && metrics.length > 0) { + chartLines = metrics.map(_ => ({ name: label, metric: _ })); + } else { + // add all available lines + const labelLines = []; + this.chartLines.labels.forEach((value, key) => { + const labelFound = value.find((_) => _.name === data.label); + if (labelFound) { + labelLines.push({ name: data.label, metric: key }); + } + }); + chartLines = labelLines; + } + this.updateChart(chartLines); + } + }); - ngOnChanges(changes: SimpleChanges) { - if (changes.showPerformanceAnalysisLines && changes.showPerformanceAnalysisLines.currentValue) { - const { label, metrics } = changes.showPerformanceAnalysisLines.currentValue; - const chartLines = metrics.map(_ => ({ name: label, metric: _ })); - this.updateChart(chartLines); - } } chartUpdated(event: [{ name: string, metric: string }]) { diff --git a/src/app/item-detail/item-detail.component.html b/src/app/item-detail/item-detail.component.html index 77056ebf..65f99e20 100644 --- a/src/app/item-detail/item-detail.component.html +++ b/src/app/item-detail/item-detail.component.html @@ -64,7 +64,7 @@
- +
@@ -349,7 +349,7 @@
SUT Statistics
- +
diff --git a/src/app/item-detail/item-detail.component.ts b/src/app/item-detail/item-detail.component.ts index 2a589823..414115ff 100644 --- a/src/app/item-detail/item-detail.component.ts +++ b/src/app/item-detail/item-detail.component.ts @@ -24,6 +24,7 @@ import { bytesToMbps, roundNumberTwoDecimals } from './calculations'; import { logScaleButton } from '../graphs/log-scale-button'; import { ItemStatusValue } from './item-detail.model'; import {Metrics} from './metrics'; +import {AnalyzeChartService} from '../analyze-chart.service'; @Component({ selector: 'app-item-detail', @@ -70,7 +71,8 @@ export class ItemDetailComponent implements OnInit { private itemsService: ItemsApiService, private spinner: NgxSpinnerService, private sharedMainBarService: SharedMainBarService, - private toastr: ToastrService + private toastr: ToastrService, + private analyzeChartService: AnalyzeChartService ) { this.Math = Math; } @@ -107,6 +109,11 @@ export class ItemDetailComponent implements OnInit { this.generateCharts(); this.spinner.hide(); }); + this.analyzeChartService.currentData.subscribe(data => { + if (data) { + this.activeId = 2; + } + }); } private getChartLines() { diff --git a/src/app/item-detail/performance-analysis/performance-analysis.component.css b/src/app/item-detail/performance-analysis/performance-analysis.component.css index 50fe544d..a59a7043 100644 --- a/src/app/item-detail/performance-analysis/performance-analysis.component.css +++ b/src/app/item-detail/performance-analysis/performance-analysis.component.css @@ -4,5 +4,5 @@ .perf-analysis-table { margin-top: 10px; - line-height: 0.3rem; + line-height: 0.4rem; } diff --git a/src/app/item-detail/performance-analysis/performance-analysis.component.html b/src/app/item-detail/performance-analysis/performance-analysis.component.html index daec7ea3..959b5434 100644 --- a/src/app/item-detail/performance-analysis/performance-analysis.component.html +++ b/src/app/item-detail/performance-analysis/performance-analysis.component.html @@ -35,7 +35,7 @@
Performance Analysis
- {{_.label}} + {{_.label}} {{_.onePerc}} {{_.p99}} {{_.avgResponseTime}} @@ -74,7 +74,7 @@
Performance Analysis
- {{_.label}} + {{_.label}} {{_.variability}} {{_.minResponseTime}} {{_.avgResponseTime}} diff --git a/src/app/item-detail/performance-analysis/performance-analysis.component.ts b/src/app/item-detail/performance-analysis/performance-analysis.component.ts index 75550ce8..db1717f3 100644 --- a/src/app/item-detail/performance-analysis/performance-analysis.component.ts +++ b/src/app/item-detail/performance-analysis/performance-analysis.component.ts @@ -1,6 +1,8 @@ -import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; +import {Component, EventEmitter, Inject, Input, OnInit, Output} from '@angular/core'; import {animate, state, style, transition, trigger} from '@angular/animations'; import {Metrics} from '../metrics'; +import {AnalyzeChartService} from '../../analyze-chart.service'; +import {DOCUMENT} from '@angular/common'; @Component({ selector: 'app-performance-analysis', @@ -19,7 +21,6 @@ export class PerformanceAnalysisComponent implements OnInit { @Input() itemData; @Input() labelsChartLines; @Output() overallChartChange = new EventEmitter<{}>(); - @Output() analyzeChartChange = new EventEmitter<{}>(); perfAnalysis = { @@ -44,7 +45,7 @@ export class PerformanceAnalysisComponent implements OnInit { foldedBottom = 'closed'; Math: any; - constructor() { + constructor(private analyzeChartService: AnalyzeChartService) { this.Math = Math; } @@ -157,18 +158,25 @@ export class PerformanceAnalysisComponent implements OnInit { } - showSteadyResponseTimeInChart(label: string) { + showSteadyResponseTimeInChart(label: string, anchorElement: string) { this.showLabelInChart([Metrics.ResponseTimeAvg, Metrics.ResponseTimeMin], label); - + const el = document.getElementById(anchorElement); + setTimeout(() => { + el.scrollIntoView({behavior: 'smooth'}); + }); } - showOnePercResponseTimeInChart(label: string) { + showOnePercResponseTimeInChart(label: string, anchorElement: string) { this.showLabelInChart([Metrics.ResponseTimeAvg, Metrics.ResponseTimeP99], label); + const el = document.getElementById(anchorElement); + setTimeout(() => { + el.scrollIntoView({behavior: 'smooth'}); + }); } private showLabelInChart(metrics: Metrics[], label: string) { - this.analyzeChartChange.emit({ label, metrics }); + this.analyzeChartService.changeMessage({ metrics, label }); } private hasLabelChart(metrics: Metrics[], label: string) { diff --git a/src/app/item-detail/request-stats-compare/request-stats-compare.component.css b/src/app/item-detail/request-stats-compare/request-stats-compare.component.css index 8b137891..5e38bc04 100644 --- a/src/app/item-detail/request-stats-compare/request-stats-compare.component.css +++ b/src/app/item-detail/request-stats-compare/request-stats-compare.component.css @@ -1 +1,3 @@ - +.label-focus { + margin-left: 5px; +} diff --git a/src/app/item-detail/request-stats-compare/request-stats-compare.component.html b/src/app/item-detail/request-stats-compare/request-stats-compare.component.html index ffa910ea..f1f86119 100644 --- a/src/app/item-detail/request-stats-compare/request-stats-compare.component.html +++ b/src/app/item-detail/request-stats-compare/request-stats-compare.component.html @@ -36,6 +36,9 @@
Request Statistics
+ +
@@ -72,7 +75,7 @@
Request Statistics mbps
@@ -82,7 +85,7 @@
Request Statistics
- + @@ -107,6 +110,8 @@
Request Statistics + +
diff --git a/src/app/item-detail/request-stats-compare/request-stats-compare.component.ts b/src/app/item-detail/request-stats-compare/request-stats-compare.component.ts index 63bb4730..6cc9d344 100644 --- a/src/app/item-detail/request-stats-compare/request-stats-compare.component.ts +++ b/src/app/item-detail/request-stats-compare/request-stats-compare.component.ts @@ -1,17 +1,17 @@ -import {Component, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core'; -import {ToastrService} from 'ngx-toastr'; -import {ItemsApiService} from 'src/app/items-api.service'; -import {ItemParams} from 'src/app/scenario/item-controls/item-controls.model'; -import {bytesToMbps, roundNumberTwoDecimals} from '../calculations'; +import { Component, Input, OnInit, OnDestroy } from '@angular/core'; +import { ItemParams } from 'src/app/scenario/item-controls/item-controls.model'; +import { bytesToMbps, roundNumberTwoDecimals } from '../calculations'; +import { AnalyzeChartService } from '../../analyze-chart.service'; +import { ItemsApiService } from 'src/app/items-api.service'; +import { ToastrService } from 'ngx-toastr'; @Component({ selector: 'app-request-stats-compare', templateUrl: './request-stats-compare.component.html', styleUrls: ['./request-stats-compare.component.css', '../item-detail.component.scss'] }) -export class RequestStatsCompareComponent implements OnInit, OnChanges { +export class RequestStatsCompareComponent implements OnInit, OnDestroy { - @Input() externalSearchTerm: string; @Input() itemData; @Input() isAnonymous: boolean; @Input() params: ItemParams; @@ -19,27 +19,31 @@ export class RequestStatsCompareComponent implements OnInit, OnChanges { comparingData; comparedData; comparedDataMs; - compareMode = false; labelsData; comparisonWarning = []; comparedMetadata; comparisonMs = true; - unitDesc = 'ms'; + externalSearchTerm = ''; constructor( private itemsService: ItemsApiService, - private toastr: ToastrService + private toastr: ToastrService, + private analyzeChartService: AnalyzeChartService ) { } ngOnInit() { this.labelsData = this.itemData.statistics; + this.analyzeChartService.currentData.subscribe(data => { + if (data && data.label) { + this.search(data.label); + this.externalSearchTerm = data.label; + } + }); } - ngOnChanges(changes: SimpleChanges) { - if (changes.externalSearchTerm) { - this.search(changes.externalSearchTerm.currentValue); - } + ngOnDestroy() { + this.analyzeChartService.changeMessage(null); } resetStatsData() { @@ -59,10 +63,16 @@ export class RequestStatsCompareComponent implements OnInit, OnChanges { } } + clearSearch() { + const dataToFilter = this.comparedData || this.itemData.statistics; + this.labelsData = dataToFilter; + this.externalSearchTerm = ''; + } + itemToCompare(data) { this.resetStatsData(); this.comparingData = data; - this.comparedMetadata = {id: data.id, maxVu: data.maxVu}; + this.comparedMetadata = { id: data.id, maxVu: data.maxVu }; if (data.maxVu !== this.itemData.overview.maxVu) { this.comparisonWarning.push(`VU do differ ${this.itemData.overview.maxVu} vs. ${data.maxVu}`); } @@ -115,11 +125,11 @@ export class RequestStatsCompareComponent implements OnInit, OnChanges { this.params.projectName, this.params.scenarioName, id).subscribe(_ => this.itemToCompare({ - statistics: _.statistics, - maxVu: _.overview.maxVu, - environment: _.environment, - id - })); + statistics: _.statistics, + maxVu: _.overview.maxVu, + environment: _.environment, + id + })); } showComparisonWarnings() { @@ -194,4 +204,7 @@ export class RequestStatsCompareComponent implements OnInit, OnChanges { return '%'; } + focusLabel(label: string) { + this.analyzeChartService.changeMessage({ label }); + } } diff --git a/src/app/shared-styles.css b/src/app/shared-styles.css index b27e6bf6..46dc1973 100644 --- a/src/app/shared-styles.css +++ b/src/app/shared-styles.css @@ -1,14 +1,14 @@ @media (min-width: 1550px) { .content-container { - padding-left: 200px; - padding-right: 200px; + padding-left: 110px; + padding-right: 110px; } } @media (max-width: 1550px) { .content-container { - padding-left: 100px; - padding-right: 100px; + padding-left: 70px; + padding-right: 70px; } } diff --git a/src/app/top-panel/top-panel.component.html b/src/app/top-panel/top-panel.component.html index 5c6d4482..9efcccd5 100644 --- a/src/app/top-panel/top-panel.component.html +++ b/src/app/top-panel/top-panel.component.html @@ -13,33 +13,34 @@
-
-
- - -
diff --git a/src/app/top-panel/top-panel.component.scss b/src/app/top-panel/top-panel.component.scss index dec85313..7f1c86e3 100644 --- a/src/app/top-panel/top-panel.component.scss +++ b/src/app/top-panel/top-panel.component.scss @@ -1,13 +1,13 @@ .top-bar { - padding-left: 210px; - padding-right: 210px; + padding-left: 120px; + padding-right: 120px; } @media (max-width: 1550px) { .top-bar { - padding-left: 110px; - padding-right: 110px; + padding-left: 80px; + padding-right: 80px; } } diff --git a/src/app/top-panel/top-panel.component.ts b/src/app/top-panel/top-panel.component.ts index 4805cdc2..feaa71f0 100644 --- a/src/app/top-panel/top-panel.component.ts +++ b/src/app/top-panel/top-panel.component.ts @@ -1,4 +1,4 @@ -import { AfterViewInit, Component, OnInit } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { ProjectService } from '../project.service'; import { ProjectsListing } from '../project-api.service.model'; import { Observable } from 'rxjs'; @@ -9,7 +9,7 @@ import { ChangeDetectorRef } from '@angular/core'; @Component({ selector: 'app-top-panel', templateUrl: './top-panel.component.html', - styleUrls: ['./top-panel.component.scss'] + styleUrls: ['./top-panel.component.scss', '../shared-styles.css'] }) export class TopPanelComponent implements OnInit {
- error rate + errors
{{_.label}}{{_.label}} {{_.samples}} {{_.avgResponseTime}} {{_.minResponseTime}}