Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compare to a report from different scenario #417

Merged
merged 3 commits into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/app/item-detail/stats-compare/stats-compare.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ thead {
.compare-menu-item {
margin-left: 10px;
}

.scenario-select-form {
padding-bottom: 2rem;
}
18 changes: 16 additions & 2 deletions src/app/item-detail/stats-compare/stats-compare.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,34 @@
<span class="compare-menu-item"> Compare To Baseline</span>
</button>
<button *ngIf="comparingData" class="btn btn-sm" (click)="resetStatsData()" ngbDropdownItem><i class="fas fa-undo-alt"></i><span class="compare-menu-item"> Remove Comparison</span></button>
<a *ngIf="comparingData" class="btn btn-sm" ngbDropdownItem target="_blank" href="/project/{{params.projectName}}/scenario/{{params.scenarioName}}/item/{{comparedMetadata.id}}"><i class="fas fa-external-link-alt"></i><span class="compare-menu-item"> Open Comparing Report</span></a>
<a *ngIf="comparingData" class="btn btn-sm" ngbDropdownItem target="_blank" href="/project/{{params.projectName}}/scenario/{{selectedScenario}}/item/{{comparedMetadata.id}}"><i class="fas fa-external-link-alt"></i><span class="compare-menu-item"> Open Comparing Report</span></a>
</div>
</div>


<ng-template #content let-modal>
<div class="modal-header">
<h5 class="modal-title" id="modal-basic-title">Choose test run to compare</h5>
<h5 class="modal-title" id="modal-basic-title">Select Test Report To Compare</h5>

<button type="button" style="outline: none;" class="btn-close" aria-label="Close"
(click)="modal.dismiss('Cross click')">

</button>
</div>
<div class="modal-body">
<form class="row g-3 scenario-select-form">
<div class="col-md-4">
<label for="scenarioSelect" class="form-label">Scenario</label>
<select id="scenarioSelect" class='form-select rounded-left' [(ngModel)]="selectedScenario" [ngModelOptions]="{standalone: true}" (change)="loadScenario($event)">
<option *ngFor="let scenario of scenarios" value='{{scenario.name}}'>{{scenario.name}}</option>
</select>

</div>
</form>




<div class="col" *ngIf="items$ | async; let items">
<div class="responsive-table">
<table class="table items" [mfData]="items.data" #mf="mfDataTable">
Expand Down
27 changes: 21 additions & 6 deletions src/app/item-detail/stats-compare/stats-compare.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { Component, OnInit, Output, EventEmitter, Input } from "@angular/core";
import { NgbModal } from "@ng-bootstrap/ng-bootstrap";
import { ItemsService } from "src/app/items.service";
import { ActivatedRoute, Params } from "@angular/router";
import { Observable } from "rxjs";
import { ItemDetail, Items } from "src/app/items.service.model";
import { Observable, Subscription } from "rxjs";
import { IScenarios, ItemDetail, Items } from "src/app/items.service.model";
import { ItemsApiService } from "src/app/items-api.service";
import { ComparisonChartService } from "../../_services/comparison-chart.service";
import { ToastrService } from "ngx-toastr";
import { ComparisonStatsService } from "../../_services/comparison-stats.service";
import { ScenarioApiService } from "../../scenario-api.service";

const LIMIT = 15;
const OFFSET = 15;
Expand All @@ -28,6 +29,8 @@ export class StatsCompareComponent implements OnInit {
comparingData: ItemDetail;
comparedMetadata: { id: string; maxVu: number };
comparisonWarning = [];
scenarios: IScenarios[];
selectedScenario: string;


@Input() itemData: ItemDetail;
Expand All @@ -40,25 +43,30 @@ export class StatsCompareComponent implements OnInit {
private itemsApiService: ItemsApiService,
private route: ActivatedRoute,
private comparisonChartService: ComparisonChartService,
private comparisonStatsService: ComparisonStatsService
private comparisonStatsService: ComparisonStatsService,
private scenarioApiService: ScenarioApiService,
) {
}

ngOnInit() {
this.items$ = this.itemsService.items$;
this.route.params.subscribe(_ => {
this.params = _;
this.selectedScenario = _.scenarioName;
});
this.scenarioApiService.fetchScenarios(this.params.projectName).subscribe(_ => {
this.scenarios = _;
});
}

open(content) {
this.modalService.open(content, { size: "xl" });
this.itemsService.fetchItems(this.params.projectName, this.params.scenarioName, { limit: LIMIT, offset: 0 });
this.itemsService.fetchItems(this.params.projectName, this.selectedScenario, { limit: LIMIT, offset: 0 });
}

loadMore() {
const offset = (this.page - 1) * OFFSET;
this.itemsService.fetchItems(this.params.projectName, this.params.scenarioName, { limit: LIMIT, offset });
this.itemsService.fetchItems(this.params.projectName, this.selectedScenario, { limit: LIMIT, offset });
}

onSelectionChange(id) {
Expand All @@ -67,7 +75,7 @@ export class StatsCompareComponent implements OnInit {

loadItemToCompare() {
if (this.selectedTestItem) {
this.itemsApiService.fetchItemDetail(this.params.projectName, this.params.scenarioName, this.selectedTestItem)
this.itemsApiService.fetchItemDetail(this.params.projectName, this.selectedScenario, this.selectedTestItem)
.subscribe(_ => {
this.itemToCompare({
statistics: _.statistics,
Expand Down Expand Up @@ -135,4 +143,11 @@ export class StatsCompareComponent implements OnInit {
this.comparisonChartService.resetPlot();
this.comparisonStatsService.setRequestStats(null);
}

loadScenario(event) {
console.log(event.target.value)
const scenario = event.target.value
this.selectedScenario = scenario
this.itemsService.fetchItems(this.params.projectName, scenario, { limit: LIMIT, offset: 0 });
}
}
Loading