Skip to content

Commit ca44da5

Browse files
Save Work
1 parent 1eb511f commit ca44da5

File tree

4 files changed

+134
-47
lines changed

4 files changed

+134
-47
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.result-switch {
2+
position: absolute;
3+
right: 30px;
4+
top: 8px;
5+
}
6+
7+
.result-switch-label {
8+
display: inline;
9+
}

src/app/elements/charts/testRunsResultsGraph/testRun.results.chart.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<div *ngIf="lineChartData.length > 0" style="display: block; padding: 0 10px 0 10px;">
2+
<div class="result-switch">
3+
<div class="result-switch-label">{{switchLabel}}</div>
4+
<ui-switch id="result-switch" size="small" [ngModel]="switchState" (change)="switch()"></ui-switch>
5+
</div>
26
<canvas baseChart height="70" *ngIf="lineChartData.length > 0"
37
[datasets]="lineChartData"
48
[labels]="lineChartLabels"
Lines changed: 120 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,34 @@
1-
import { Component, Input, OnChanges } from '@angular/core';
1+
import { Component, Input, OnChanges, OnInit } from '@angular/core';
22
import { SimpleRequester } from '../../../services/simple-requester';
33
import { TestResultService } from '../../../services/test-result.service';
44
import { FinalResult } from '../../../shared/models/final-result';
55
import { FinalResultService } from '../../../services/final_results.service';
66
import { Router, ActivatedRoute } from '@angular/router';
77
import { TestRunService } from '../../../services/testRun.service';
88
import { TestRunStat } from '../../../shared/models/testrunStats';
9+
import { ResultResolutionService } from '../../../services/result-resolution.service';
10+
import { ResultResolution } from '../../../shared/models/result_resolution';
11+
import { GlobalDataService } from '../../../services/globaldata.service';
912

1013

1114
@Component({
1215
selector: 'testrun-result-timeline',
1316
templateUrl: './testRun.results.chart.html',
17+
styleUrls: ['./testRun.results.chart.css'],
1418
providers: [
1519
SimpleRequester,
1620
FinalResultService,
1721
TestResultService
1822
]
1923
})
2024

21-
export class TestRunsResultsTimelineComponent implements OnChanges {
25+
export class TestRunsResultsTimelineComponent implements OnInit, OnChanges {
2226
@Input() testRunsStat: TestRunStat[];
27+
switchState = false;
28+
switchLabel = 'Results';
29+
projectId: number;
2330
listOfFinalResults: FinalResult[];
31+
listOfResolutions: ResultResolution[];
2432
lineChartOptions: any = {
2533
hover: {
2634
mode: 'nearest',
@@ -32,15 +40,9 @@ export class TestRunsResultsTimelineComponent implements OnChanges {
3240
scales: {
3341
xAxes: [{
3442
type: 'time',
43+
distribution: 'linear',
3544
time: {
36-
displayFormats: {
37-
quarter: 'MMM YYYY',
38-
day: 'll HH:mm',
39-
hour: 'll HH:mm',
40-
second: 'll HH:mm',
41-
millisecond: 'll HH:mm',
42-
minute: 'll HH:mm'
43-
},
45+
minUnit: 'day',
4446
tooltipFormat: 'll HH:mm'
4547
},
4648
scaleLabel: {
@@ -61,71 +63,138 @@ export class TestRunsResultsTimelineComponent implements OnChanges {
6163
lineChartType = 'line';
6264
lineChartLabels: Array<any> = [];
6365

66+
colors = {
67+
danger: {
68+
fill: '#dc3545',
69+
stroke: '#dc3545',
70+
},
71+
success: {
72+
fill: '#28a745',
73+
stroke: '#28a745',
74+
},
75+
primary: {
76+
fill: '#007bff',
77+
stroke: '#007bff',
78+
},
79+
warning: {
80+
fill: '#ffc107',
81+
stroke: '#ffc107',
82+
},
83+
info: {
84+
fill: '#17a2b8',
85+
stroke: '#17a2b8',
86+
},
87+
point: {
88+
stroke: '#fff'
89+
}
90+
};
91+
6492
public lineChartColors: Array<any> = [
6593
{
66-
backgroundColor: 'rgba(224, 0, 0, 0.8)',
67-
borderColor: 'rgba(224, 0, 0, 1)',
68-
pointBackgroundColor: 'rgba(204, 0, 0, 1)',
69-
pointBorderColor: '#fff',
70-
pointHoverBackgroundColor: '#fff',
71-
pointHoverBorderColor: 'rgba(224, 0, 0, 1)'
94+
pointBorderColor: this.colors.point.stroke,
95+
backgroundColor: this.colors.danger.fill
7296
},
7397
{
74-
backgroundColor: 'rgba(0, 153, 0, 0.8)',
75-
borderColor: 'rgba(0, 133, 0, 1)',
76-
pointBackgroundColor: 'rgba(0, 133, 0, 1',
77-
pointBorderColor: '#fff',
78-
pointHoverBackgroundColor: '#fff',
79-
pointHoverBorderColor: 'rgba(0, 133, 0, 0.8)'
98+
pointBorderColor: this.colors.point.stroke,
99+
backgroundColor: this.colors.success.fill
80100
},
81101
{
82-
backgroundColor: 'rgba(51, 102, 255, 0.8)',
83-
borderColor: 'rgba(51, 102, 255, 1)',
84-
pointBackgroundColor: 'rgba(51, 102, 255, 1)',
85-
pointBorderColor: '#fff',
86-
pointHoverBackgroundColor: '#fff',
87-
pointHoverBorderColor: 'rgba(51, 102, 255, 0.8)'
102+
pointBorderColor: this.colors.point.stroke,
103+
backgroundColor: this.colors.primary.fill
88104
},
89105
{
90-
backgroundColor: 'rgba(255, 102, 0, 0.8)',
91-
borderColor: 'rgba(255, 102, 0, 1)',
92-
pointBackgroundColor: 'rgba(255, 102, 0, 1)',
93-
pointBorderColor: '#fff',
94-
pointHoverBackgroundColor: '#fff',
95-
pointHoverBorderColor: 'rgba(255, 102, 0, 0.8)'
106+
pointBorderColor: this.colors.point.stroke,
107+
backgroundColor: this.colors.warning.fill
96108
},
97109
{
98-
backgroundColor: 'rgba(91, 192, 222, 0.8)',
99-
borderColor: 'rgba(91, 192, 222, 1)',
100-
pointBackgroundColor: 'rgba(91, 192, 222, 1)',
101-
pointBorderColor: '#fff',
102-
pointHoverBackgroundColor: '#fff',
103-
pointHoverBorderColor: 'rgba(91, 192, 222, 0.8)'
110+
pointBorderColor: this.colors.point.stroke,
111+
backgroundColor: this.colors.info.fill
104112
}
105113
];
106114

107115
constructor(
108116
private finalResultService: FinalResultService,
109-
private testRunService: TestRunService,
117+
private resolutionService: ResultResolutionService,
118+
public globaldata: GlobalDataService,
110119
private route: ActivatedRoute,
111-
private router: Router
112120
) {
113121
}
114122

123+
ngOnInit(): void {
124+
this.globaldata.currentProject$.subscribe(project => this.projectId = project.id);
125+
}
126+
115127
async ngOnChanges() {
116128
if (!this.listOfFinalResults || this.listOfFinalResults.length < 1) {
117129
this.listOfFinalResults = await this.finalResultService.getFinalResult({});
130+
this.listOfResolutions = [{
131+
color: 1,
132+
name: 'App Issue'
133+
}, {
134+
color: 2,
135+
name: 'Passed'
136+
}, {
137+
color: 4,
138+
name: 'Not Assigned'
139+
}, {
140+
color: 3,
141+
name: 'Test Issues'
142+
}, {
143+
color: 5,
144+
name: 'Other'
145+
}];
118146
this.fillData();
119147
} else {
120148
this.fillData();
121149
}
122150
}
123151

124-
async fillData() {
125-
await this.fillChartData();
152+
fillData() {
153+
if (this.switchState) {
154+
this.fillByResolution();
155+
} else {
156+
this.fillByResult();
157+
}
126158
}
127159

128-
fillChartData() {
160+
fillByResolution() {
161+
this.testRunsStat = this.testRunsStat.filter(x => x.finish_time);
162+
this.testRunsStat = this.testRunsStat.sort((a, b) => new Date(a.finish_time).getTime() - new Date(b.finish_time).getTime());
163+
this.lineChartData = [];
164+
for (const resolution of this.listOfResolutions) {
165+
const dataArray: any[] = [];
166+
let hidden = true;
167+
for (const resultsSet of this.testRunsStat) {
168+
switch (resolution.color) {
169+
case 1:
170+
if (resultsSet.app_issue !== 0) { hidden = false; }
171+
dataArray.push({ x: resultsSet.finish_time, y: resultsSet.app_issue, ts: resultsSet });
172+
break;
173+
case 2:
174+
if (resultsSet.passed !== 0) { hidden = false; }
175+
dataArray.push({ x: resultsSet.finish_time, y: resultsSet.passed, ts: resultsSet });
176+
break;
177+
case 4:
178+
if (resultsSet.not_assigned !== 0) { hidden = false; }
179+
dataArray.push({ x: resultsSet.finish_time, y: resultsSet.not_assigned, ts: resultsSet });
180+
break;
181+
case 3:
182+
if (resultsSet.warning !== 0) { hidden = false; }
183+
dataArray.push({ x: resultsSet.finish_time, y: resultsSet.warning, ts: resultsSet });
184+
break;
185+
case 5:
186+
if (resultsSet.other !== 0) { hidden = false; }
187+
dataArray.push({ x: resultsSet.finish_time, y: resultsSet.other, ts: resultsSet });
188+
break;
189+
}
190+
}
191+
console.log(hidden);
192+
this.lineChartData.push({ data: dataArray, label: resolution.name, hidden: hidden, lineTension: 0.1 });
193+
}
194+
console.log(this.lineChartData);
195+
}
196+
197+
fillByResult() {
129198
this.testRunsStat = this.testRunsStat.filter(x => x.finish_time);
130199
this.testRunsStat = this.testRunsStat.sort((a, b) => new Date(a.finish_time).getTime() - new Date(b.finish_time).getTime());
131200
this.lineChartData = [];
@@ -156,7 +225,7 @@ export class TestRunsResultsTimelineComponent implements OnChanges {
156225
break;
157226
}
158227
}
159-
this.lineChartData.push({ data: dataArray, label: finalResult.name, hidden: hidden });
228+
this.lineChartData.push({ data: dataArray, label: finalResult.name, hidden: hidden, lineTension: 0.1 });
160229
}
161230
}
162231

@@ -167,4 +236,9 @@ export class TestRunsResultsTimelineComponent implements OnChanges {
167236
window.open(`#/project/${this.route.snapshot.params['projectId']}/testrun/${this.lineChartData[datasetIndex].data[dataIndex].ts.id}`);
168237
}
169238
}
239+
240+
switch() {
241+
this.switchState = !this.switchState;
242+
this.fillData();
243+
}
170244
}

src/environments/environment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export const environment = {
22
production: false,
3-
host: 'http://localhost:8080/api'
3+
host: 'http://reportingportal:8080/api'
44
};

0 commit comments

Comments
 (0)