1
- import { Component , Input , OnChanges } from '@angular/core' ;
1
+ import { Component , Input , OnChanges , OnInit } from '@angular/core' ;
2
2
import { SimpleRequester } from '../../../services/simple-requester' ;
3
3
import { TestResultService } from '../../../services/test-result.service' ;
4
4
import { FinalResult } from '../../../shared/models/final-result' ;
5
5
import { FinalResultService } from '../../../services/final_results.service' ;
6
6
import { Router , ActivatedRoute } from '@angular/router' ;
7
7
import { TestRunService } from '../../../services/testRun.service' ;
8
8
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' ;
9
12
10
13
11
14
@Component ( {
12
15
selector : 'testrun-result-timeline' ,
13
16
templateUrl : './testRun.results.chart.html' ,
17
+ styleUrls : [ './testRun.results.chart.css' ] ,
14
18
providers : [
15
19
SimpleRequester ,
16
20
FinalResultService ,
17
21
TestResultService
18
22
]
19
23
} )
20
24
21
- export class TestRunsResultsTimelineComponent implements OnChanges {
25
+ export class TestRunsResultsTimelineComponent implements OnInit , OnChanges {
22
26
@Input ( ) testRunsStat : TestRunStat [ ] ;
27
+ switchState = false ;
28
+ switchLabel = 'Results' ;
29
+ projectId : number ;
23
30
listOfFinalResults : FinalResult [ ] ;
31
+ listOfResolutions : ResultResolution [ ] ;
24
32
lineChartOptions : any = {
25
33
hover : {
26
34
mode : 'nearest' ,
@@ -32,15 +40,9 @@ export class TestRunsResultsTimelineComponent implements OnChanges {
32
40
scales : {
33
41
xAxes : [ {
34
42
type : 'time' ,
43
+ distribution : 'linear' ,
35
44
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' ,
44
46
tooltipFormat : 'll HH:mm'
45
47
} ,
46
48
scaleLabel : {
@@ -61,71 +63,138 @@ export class TestRunsResultsTimelineComponent implements OnChanges {
61
63
lineChartType = 'line' ;
62
64
lineChartLabels : Array < any > = [ ] ;
63
65
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
+
64
92
public lineChartColors : Array < any > = [
65
93
{
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
72
96
} ,
73
97
{
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
80
100
} ,
81
101
{
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
88
104
} ,
89
105
{
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
96
108
} ,
97
109
{
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
104
112
}
105
113
] ;
106
114
107
115
constructor (
108
116
private finalResultService : FinalResultService ,
109
- private testRunService : TestRunService ,
117
+ private resolutionService : ResultResolutionService ,
118
+ public globaldata : GlobalDataService ,
110
119
private route : ActivatedRoute ,
111
- private router : Router
112
120
) {
113
121
}
114
122
123
+ ngOnInit ( ) : void {
124
+ this . globaldata . currentProject$ . subscribe ( project => this . projectId = project . id ) ;
125
+ }
126
+
115
127
async ngOnChanges ( ) {
116
128
if ( ! this . listOfFinalResults || this . listOfFinalResults . length < 1 ) {
117
129
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
+ } ] ;
118
146
this . fillData ( ) ;
119
147
} else {
120
148
this . fillData ( ) ;
121
149
}
122
150
}
123
151
124
- async fillData ( ) {
125
- await this . fillChartData ( ) ;
152
+ fillData ( ) {
153
+ if ( this . switchState ) {
154
+ this . fillByResolution ( ) ;
155
+ } else {
156
+ this . fillByResult ( ) ;
157
+ }
126
158
}
127
159
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 ( ) {
129
198
this . testRunsStat = this . testRunsStat . filter ( x => x . finish_time ) ;
130
199
this . testRunsStat = this . testRunsStat . sort ( ( a , b ) => new Date ( a . finish_time ) . getTime ( ) - new Date ( b . finish_time ) . getTime ( ) ) ;
131
200
this . lineChartData = [ ] ;
@@ -156,7 +225,7 @@ export class TestRunsResultsTimelineComponent implements OnChanges {
156
225
break ;
157
226
}
158
227
}
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 } ) ;
160
229
}
161
230
}
162
231
@@ -167,4 +236,9 @@ export class TestRunsResultsTimelineComponent implements OnChanges {
167
236
window . open ( `#/project/${ this . route . snapshot . params [ 'projectId' ] } /testrun/${ this . lineChartData [ datasetIndex ] . data [ dataIndex ] . ts . id } ` ) ;
168
237
}
169
238
}
239
+
240
+ switch ( ) {
241
+ this . switchState = ! this . switchState ;
242
+ this . fillData ( ) ;
243
+ }
170
244
}
0 commit comments