@@ -3,30 +3,38 @@ import { Router, ActivatedRoute } from '@angular/router';
3
3
import { Issue } from '../../../../shared/models/issue' ;
4
4
import { Label } from '../../../../shared/models/general' ;
5
5
import { User } from '../../../../shared/models/user' ;
6
+ import { TestRun } from 'src/app/shared/models/testrun' ;
6
7
import { UserService } from 'src/app/services/user/user.services' ;
7
8
import { IssueService } from 'src/app/services/issue/issue.service' ;
8
- import { PermissionsService , EGlobalPermissions , ELocalPermissions } from 'src/app/services/permissions/current-permissions.service' ;
9
+ import { ProjectService } from '../../../../services/project/project.service' ;
10
+ import { TestResultService } from 'src/app/services/test-result/test-result.service' ;
11
+ import { TestRunService } from 'src/app/services/testrun/testrun.service' ;
12
+ import {
13
+ PermissionsService ,
14
+ EGlobalPermissions ,
15
+ ELocalPermissions
16
+ } from 'src/app/services/permissions/current-permissions.service' ;
9
17
import { ResultResolutionService } from 'src/app/services/result-resolution/result-resolution.service' ;
10
18
import { TFColumn , TFSorting , TFOrder , TFColumnType } from 'src/app/elements/table-filter/tfColumn' ;
11
19
import { ResultResolution } from 'src/app/shared/models/result-resolution' ;
12
20
import { LocalPermissions } from 'src/app/shared/models/local-permissions' ;
13
- import { ProjectService } from '../../../../services/project/project.service' ;
14
21
15
22
@Component ( {
16
23
templateUrl : './issue-list.component.html' ,
17
24
styleUrls : [ './issue-list.component.scss' ]
18
25
} )
19
26
export class IssueListComponent implements OnInit {
20
-
21
27
constructor (
22
28
public userService : UserService ,
23
29
private router : Router ,
24
30
private route : ActivatedRoute ,
25
31
private issueService : IssueService ,
26
32
private permissions : PermissionsService ,
27
33
private resolutionService : ResultResolutionService ,
28
- private projectService : ProjectService
29
- ) { }
34
+ private projectService : ProjectService ,
35
+ private testResultService : TestResultService ,
36
+ private testRunService : TestRunService
37
+ ) { }
30
38
31
39
projectId : number ;
32
40
issues : Issue [ ] ;
@@ -40,32 +48,51 @@ export class IssueListComponent implements OnInit {
40
48
defSort : TFSorting = { property : 'created' , order : TFOrder . asc } ;
41
49
hideCreateModal = true ;
42
50
isAiOn : boolean ;
51
+ testRuns : TestRun [ ] ;
43
52
44
53
async ngOnInit ( ) {
45
54
this . projectId = this . route . snapshot . params . projectId ;
46
55
[ this . issues , this . resolutions , this . canEdit , this . projectUsers , this . statuses , this . isAiOn ] = await Promise . all ( [
47
56
this . issueService . getIssues ( { project_id : this . projectId } ) ,
48
57
this . resolutionService . getResolution ( this . projectId ) ,
49
- this . permissions . hasProjectPermissions ( this . projectId ,
50
- [ EGlobalPermissions . manager ] , [ ELocalPermissions . manager , ELocalPermissions . engineer ] ) ,
58
+ this . permissions . hasProjectPermissions (
59
+ this . projectId ,
60
+ [ EGlobalPermissions . manager ] ,
61
+ [ ELocalPermissions . manager , ELocalPermissions . engineer ]
62
+ ) ,
51
63
this . userService . getProjectUsers ( this . projectId ) ,
52
64
this . issueService . getIssueStatuses ( ) ,
53
- ( ( await this . projectService . getProject ( this . projectId ) ) . ai_resolutions === 1 )
65
+ ( await this . projectService . getProject ( this . projectId ) ) . ai_resolutions === 1
54
66
] ) ;
55
- this . projectUsers = this . projectUsers . filter ( user => user . admin === 1 || user . manager === 1 || user . engineer === 1 ) ;
56
- this . users = this . projectUsers . map ( x => x . user ) ;
67
+ this . projectUsers = this . projectUsers . filter (
68
+ ( user ) => user . admin === 1 || user . manager === 1 || user . engineer === 1
69
+ ) ;
70
+ this . users = this . projectUsers . map ( ( x ) => x . user ) ;
71
+ this . testRuns = await this . testRunService . getTestRun ( { project_id : this . projectId } ) ;
57
72
this . addLinks ( ) ;
73
+ this . addAffectedTestsAndRuns ( ) ;
58
74
this . createColumns ( ) ;
59
75
}
60
76
61
77
async addLinks ( ) {
62
- this . issues . forEach ( issue => {
63
- issue [ 'external_link' ] = issue . external_url
64
- ? { text : 'Open' , link : issue . external_url }
65
- : { } ;
78
+ this . issues . forEach ( ( issue ) => {
79
+ issue [ 'external_link' ] = issue . external_url ? { text : 'Open' , link : issue . external_url } : { } ;
66
80
} ) ;
67
81
}
68
82
83
+ async addAffectedTestsAndRuns ( ) {
84
+ const testResults = await this . testResultService . getTestResultsStat ( this . projectId , null , null ) ;
85
+ for ( const issue of this . issues ) {
86
+ const affectedTestsArray = testResults . filter ( ( result ) => Number ( result . issue_id ) === issue . id ) ;
87
+ issue [ 'affected_tests_amount' ] = affectedTestsArray . length ;
88
+ issue [ 'test_runs' ] = [ ] ;
89
+ for ( const test of affectedTestsArray ) {
90
+ issue [ 'test_runs' ] . push ( this . testRuns . find ( ( run ) => run . id === test . test_run_id ) ) ;
91
+ }
92
+ issue [ 'test_runs' ] = [ ...new Set ( issue [ 'test_runs' ] ) ] ;
93
+ }
94
+ }
95
+
69
96
async updateIssue ( issue : Issue ) {
70
97
if ( issue . resolution ) {
71
98
issue . resolution_id = issue . resolution . id ;
@@ -87,7 +114,7 @@ export class IssueListComponent implements OnInit {
87
114
this . issueService . getAiIssues ( this . projectId ) ;
88
115
}
89
116
90
- async execute ( result : { executed : boolean , result ?: Issue } ) {
117
+ async execute ( result : { executed : boolean ; result ?: Issue } ) {
91
118
this . hideCreateModal = true ;
92
119
if ( result . executed ) {
93
120
await this . updateList ( ) ;
@@ -99,12 +126,13 @@ export class IssueListComponent implements OnInit {
99
126
}
100
127
101
128
rowClicked ( issue : Issue ) {
102
- return this . router . navigate ( [ ' /project/' + this . route . snapshot . params [ 'projectId' ] + ' /issue/' + issue . id ] ) ;
129
+ return this . router . navigate ( [ ` /project/${ this . route . snapshot . params [ 'projectId' ] } /issue/${ issue . id } ` ] ) ;
103
130
}
104
131
105
132
private async updateList ( ) {
106
133
this . issues = await this . issueService . getIssues ( { project_id : this . projectId } ) ;
107
134
this . addLinks ( ) ;
135
+ this . addAffectedTestsAndRuns ( ) ;
108
136
}
109
137
110
138
private createColumns ( ) {
@@ -114,8 +142,9 @@ export class IssueListComponent implements OnInit {
114
142
property : 'id' ,
115
143
sorting : true ,
116
144
type : TFColumnType . text ,
117
- class : 'fit' ,
118
- } , {
145
+ class : 'fit'
146
+ } ,
147
+ {
119
148
name : 'Status' ,
120
149
property : 'status' ,
121
150
filter : true ,
@@ -127,7 +156,8 @@ export class IssueListComponent implements OnInit {
127
156
propToShow : [ 'name' ]
128
157
} ,
129
158
class : 'fit'
130
- } , {
159
+ } ,
160
+ {
131
161
name : 'Resolution' ,
132
162
property : 'resolution' ,
133
163
filter : true ,
@@ -139,7 +169,8 @@ export class IssueListComponent implements OnInit {
139
169
propToShow : [ 'name' ]
140
170
} ,
141
171
class : 'fit'
142
- } , {
172
+ } ,
173
+ {
143
174
name : 'Title' ,
144
175
property : 'title' ,
145
176
filter : true ,
@@ -150,7 +181,29 @@ export class IssueListComponent implements OnInit {
150
181
creationLength : 500 ,
151
182
required : true
152
183
}
153
- } , {
184
+ } ,
185
+ {
186
+ name : 'Affected Tests Amount' ,
187
+ property : 'affected_tests_amount' ,
188
+ sorting : true ,
189
+ type : TFColumnType . number ,
190
+ class : 'ft-width-175'
191
+ } ,
192
+ {
193
+ name : 'Test Runs' ,
194
+ property : 'test_runs' ,
195
+ filter : true ,
196
+ type : TFColumnType . multiselect ,
197
+ lookup : {
198
+ propToShow : [ 'build_name' ] ,
199
+ values : this . testRuns
200
+ } ,
201
+ editable : false ,
202
+ bulkEdit : true ,
203
+ sorting : true ,
204
+ class : 'ft-width-250'
205
+ } ,
206
+ {
154
207
name : 'Assignee' ,
155
208
property : 'assignee' ,
156
209
type : TFColumnType . autocomplete ,
@@ -163,17 +216,19 @@ export class IssueListComponent implements OnInit {
163
216
propToShow : [ 'first_name' , 'second_name' ]
164
217
} ,
165
218
class : 'fit'
166
- } , {
219
+ } ,
220
+ {
167
221
name : 'Created' ,
168
222
property : 'created' ,
169
223
type : TFColumnType . date ,
170
224
class : 'fit'
171
- } , {
225
+ } ,
226
+ {
172
227
name : 'External Issue' ,
173
228
property : 'external_link' ,
174
229
type : TFColumnType . externalLink ,
175
230
class : 'ft-width-250'
176
- } ,
231
+ }
177
232
] ;
178
233
179
234
this . hiddenColumns = [
@@ -182,12 +237,13 @@ export class IssueListComponent implements OnInit {
182
237
property : 'description' ,
183
238
type : TFColumnType . longtext ,
184
239
class : 'ft-width-250'
185
- } , {
240
+ } ,
241
+ {
186
242
name : 'Expression' ,
187
243
property : 'expression' ,
188
244
type : TFColumnType . text ,
189
245
class : 'ft-width-250'
190
- } ,
246
+ }
191
247
] ;
192
248
}
193
249
}
0 commit comments