@@ -6,34 +6,36 @@ import { TestRunService } from '../../../services/testRun.service';
6
6
import { ProjectService } from '../../../services/project.service' ;
7
7
import { TestRunStat } from '../../../shared/models/testrunStats' ;
8
8
import { AuditService } from '../../../services/audits.service' ;
9
- import { Audit , AuditNotification } from '../../../shared/models/audit' ;
9
+ import { Audit } from '../../../shared/models/audit' ;
10
10
import { GlobalDataService } from '../../../services/globaldata.service' ;
11
11
import { TFColumn , TFColumnType } from '../../../elements/table/tfColumn' ;
12
12
import { IssueService } from '../../../services/issue.service' ;
13
13
import { Issue } from '../../../shared/models/issue' ;
14
14
import { SingleLineBarChartData } from '../../../elements/single-line-bar-chart/single-line-bar-chart.component' ;
15
15
import { TestSuiteService } from '../../../services/testSuite.service' ;
16
16
import { TestSuite } from '../../../shared/models/testSuite' ;
17
+ import { faExclamationTriangle } from '@fortawesome/free-solid-svg-icons' ;
17
18
18
19
@Component ( {
19
20
templateUrl : './project-view.component.html' ,
20
21
styleUrls : [ './project-view.component.css' ]
21
22
} )
22
23
export class ProjectViewComponent implements OnInit {
24
+ icons = { faExclamationTriangle } ;
25
+ activateParts : number [ ] = [ ] ;
23
26
audits : Audit [ ] ;
24
27
suites : TestSuite [ ] ;
25
28
project : Project ;
26
29
testRuns : TestRun [ ] ;
27
30
testRun : TestRun ;
28
31
testRunStats : TestRunStat [ ] ;
29
32
hideAll = true ;
30
- auditNotification : AuditNotification ;
31
- notification : { text : string , type : string } ;
33
+ notification : string ;
32
34
testRunColumns : TFColumn [ ] = [
33
35
{ name : 'Build Name' , property : 'build_name' , type : TFColumnType . text } ,
34
36
{ name : 'Execution Environment' , property : 'execution_environment' , type : TFColumnType . text } ,
37
+ { name : 'Suite' , property : 'test_suite.name' , type : TFColumnType . text } ,
35
38
{ name : 'Start Time' , property : 'start_time' , type : TFColumnType . date , class : 'fit' } ,
36
- { name : 'Finish Time' , property : 'finish_time' , type : TFColumnType . date , class : 'fit' } ,
37
39
{ name : 'Pass Rate' , property : 'failed' , type : TFColumnType . percent , class : 'fit' } ,
38
40
] ;
39
41
issueColumns : TFColumn [ ] = [ { name : 'Id' , property : 'id' , type : TFColumnType . text , class : 'fit' } ,
@@ -73,25 +75,22 @@ export class ProjectViewComponent implements OnInit {
73
75
this . testRun = { project_id : projectId , debug : 0 } ;
74
76
this . project = { id : projectId } ;
75
77
76
- this . allIssues = await this . issueService . getIssues ( {
77
- project_id : projectId
78
- } ) ;
78
+ this . project = ( await this . projectService . getProjects ( this . project ) . toPromise ( ) ) [ 0 ] ;
79
79
80
- this . myIssues = this . allIssues . filter ( x => x . status_id != 4 && x . status_id != 2 && x . assignee_id === this . globaldata . currentUser . id ) ;
80
+ [ this . allIssues , this . suites , this . testRuns , this . testRunStats ] = await Promise . all ( [
81
+ this . issueService . getIssues ( { project_id : projectId } ) ,
82
+ this . testSuiteService . getTestSuite ( { project_id : projectId } ) ,
83
+ this . testrunService . getTestRun ( this . testRun , 5 ) ,
84
+ this . testrunService . getTestsRunStats ( this . testRun )
85
+ ] )
81
86
82
- this . suites = await this . testSuiteService . getTestSuite ( { project_id : projectId } ) ;
83
- this . project = ( await this . projectService . getProjects ( this . project ) . toPromise ( ) ) [ 0 ] ;
87
+ this . myIssues = this . allIssues . filter ( x => x . status_id != 4 && x . status_id != 2 && x . assignee_id === this . globaldata . currentUser . id ) ;
84
88
85
89
if ( this . globaldata . auditModule ) {
86
- this . auditService . getAudits ( { project : { id : this . project . id } } ) . subscribe ( audits => {
87
- this . audits = audits ;
88
- this . generateAuditNotification ( ) ;
89
- this . setAuditNotification ( ) ;
90
- } ) ;
90
+ this . audits = await this . auditService . getAudits ( { project : { id : this . project . id } } ) . toPromise ( ) ;
91
+ this . notification = this . generateAuditNotification ( this . audits ) ;
91
92
}
92
93
93
- this . testRuns = await this . testrunService . getTestRun ( this . testRun , 5 ) ;
94
- this . testRunStats = await this . testrunService . getTestsRunStats ( this . testRun ) ;
95
94
this . testRuns . forEach ( testrun => {
96
95
testrun [ 'failed' ] = this . getNumberOfFails ( testrun . id ) ;
97
96
} ) ;
@@ -114,77 +113,37 @@ export class ProjectViewComponent implements OnInit {
114
113
return this . testrunService . getPassRate ( stats ) ;
115
114
}
116
115
117
- openTestRun ( testRunId : number ) {
118
- this . router . navigate ( [ ' /project/' + this . project . id + ' /testrun/' + testRunId ] ) ;
116
+ openTestRun ( testRun : TestRun ) {
117
+ this . router . navigate ( [ ` /project/${ testRun . project_id } /testrun/${ testRun . id } ` ] ) ;
119
118
}
120
119
121
- generateAuditNotification ( ) {
122
- const latest : Audit = this . audits . filter ( x => x . submitted ) . length > 0
123
- ? this . audits . sort ( function ( a , b ) { return new Date ( b . submitted ) . getTime ( ) - new Date ( a . submitted ) . getTime ( ) ; } ) [ 0 ]
124
- : undefined ;
125
- const opened : Audit = this . audits . find ( x => x . status . id !== 4 ) ;
126
- this . auditNotification = {
127
- last_submitted : latest ,
128
- has_opened_audit : opened !== undefined ,
129
- next_due_date : opened
130
- ? opened . due_date
131
- : latest
132
- ? this . auditService . createDueDate ( new Date ( new Date ( latest . submitted ) . setHours ( 0 , 0 , 0 , 0 ) ) )
133
- : this . auditService . createDueDate ( new Date ( new Date ( this . project . created ) . setHours ( 0 , 0 , 0 , 0 ) ) )
134
- } ;
120
+ openIssue ( issue : Issue ) {
121
+ this . router . navigate ( [ `/project/${ issue . project_id } /issue/${ issue . id } ` ] ) ;
135
122
}
136
123
137
- setAuditNotification ( ) {
138
- if ( new Date ( this . auditNotification . next_due_date )
139
- < new Date ( new Date ( new Date ( ) . setDate ( new Date ( ) . getDate ( ) ) ) . setHours ( 0 , 0 , 0 , 0 ) ) ) {
140
- this . notification = {
141
- text : `Next Audit should have been submitted on ${
142
- new Date ( this . auditNotification . next_due_date ) . toDateString ( )
143
- } and is now overdue! Please contact your audit administrator to get more details on next audit progress.`,
144
- type : 'danger'
145
- } ;
146
- } else if ( ! this . auditNotification . has_opened_audit
147
- && new Date ( this . auditNotification . next_due_date . toString ( ) ) >= new Date ( new Date ( ) . setHours ( 0 , 0 , 0 , 0 ) )
148
- && new Date ( this . auditNotification . next_due_date . toString ( ) ) <= new Date ( new Date ( ) . setDate ( new Date ( ) . getDate ( ) + 14 ) ) ) {
149
- const days = this . daysdifference ( new Date ( new Date ( ) . setHours ( 0 , 0 , 0 , 0 ) ) ,
150
- new Date ( this . auditNotification . next_due_date . toString ( ) ) ) ;
151
- this . notification = {
152
- text : `Next Audit should be submitted ${
153
- days === 0 ? 'today' : `in ${ days } ${ days > 1 ? 'days' : 'day' } `
154
- } but is still not created in the system. Please contact your audit administrator to schedule a new Audit for your project.`,
155
- type : 'warning'
156
- } ;
157
- } else if ( this . auditNotification . has_opened_audit && this . audits . length > 0 ) {
158
- this . notification = {
159
- text : `New Audit is created and planned to be finished by ${ new Date ( this . auditNotification . next_due_date ) . toDateString ( ) } ` ,
160
- type : 'success'
161
- } ;
162
- }
163
-
164
- if ( this . auditNotification . last_submitted && this . audits . length > 0 ) {
165
- const message = `Last project Audit was submitted on ${
166
- new Date ( this . auditNotification . last_submitted . submitted ) . toDateString ( )
167
- } with a result of ${ this . auditNotification . last_submitted . result } %`;
168
-
169
- if ( ! this . notification ) { this . notification = { text : undefined , type : undefined } ; }
170
- this . notification . text = this . notification . text
171
- ? `${ this . notification . text } \r\n ${ message } `
172
- : message ;
173
-
174
- this . notification . type = this . notification . type ? this . notification . type : this . notification . type = 'success' ;
124
+ generateAuditNotification ( audits : Audit [ ] ) : string {
125
+ if ( ! audits || audits . length === 0 ) {
126
+ return `This project has no audits! Please contact your audit administrator to schedule a new Audit for your project.`
175
127
}
176
-
177
- if ( ! this . notification || ! this . notification . text ) {
178
- this . notification = {
179
- text : `This project has no audits! Please contact your audit administrator to schedule a new Audit for your project.` ,
180
- type : 'warning'
181
- } ;
128
+ const lastSubmitted : Audit = this . audits . filter ( x => x . submitted ) . length > 0
129
+ ? this . audits . sort ( function ( a , b ) { return new Date ( b . submitted ) . getTime ( ) - new Date ( a . submitted ) . getTime ( ) ; } ) [ 0 ]
130
+ : undefined ;
131
+ if ( lastSubmitted ) {
132
+ const lastSubmittedDate = new Date ( lastSubmitted . submitted ) ;
133
+ const nextDueDate = new Date ( lastSubmittedDate ) . setMonth ( lastSubmittedDate . getMonth ( ) + 6 ) ;
134
+ if ( nextDueDate < new Date ( ) . getTime ( ) ) {
135
+ return `Over half a year has passed since last submitted Audit. Please make sure the process of the new Audit is going well.`
136
+ }
182
137
}
183
138
}
184
139
185
- getDateAsText ( date : Date ) {
186
- return date . toDateString ( ) ;
187
- }
140
+ showMeaningful ( ) {
141
+ this . activateParts = [ 0 , 1 ] ;
142
+ } ;
143
+
144
+ hideMeaningful ( ) {
145
+ this . activateParts = [ ] ;
146
+ } ;
188
147
189
148
IsHideAll ( ) {
190
149
if ( this . testRunStats ) {
@@ -195,14 +154,6 @@ export class ProjectViewComponent implements OnInit {
195
154
return this . hideAll ;
196
155
}
197
156
198
- daysdifference ( date1 , date2 ) {
199
- const ONEDAY = 1000 * 60 * 60 * 24 ;
200
- const date1_ms = date1 . getTime ( ) ;
201
- const date2_ms = date2 . getTime ( ) ;
202
- const difference_ms = Math . abs ( date1_ms - date2_ms ) ;
203
- return Math . round ( difference_ms / ONEDAY ) ;
204
- }
205
-
206
157
getQualityInfo ( suites : TestSuite [ ] , testRunStats : TestRunStat [ ] ) : { current : { quality : number , NA : number , testIssue : number , other : number , appIssue : number , passed : number , total : number } , average : number } {
207
158
const testRunStatsBySuite = [ ] ;
208
159
for ( const suite of suites ) {
0 commit comments