@@ -43,13 +43,39 @@ const convertDate = (date) => {
4343 return formattedDate . toString ( ) ;
4444} ;
4545
46+ // Converts the duration time in ms and returns a string in format: w days x hours y minutes z seconds
47+ // duration: time in ms
48+ const convertDuration = ( duration ) => {
49+ let durationTime = duration ;
50+ let durationString = '' ;
51+
52+ const days = Math . floor ( durationTime / ( 1000 * 60 * 60 * 24 ) ) ;
53+ if ( days > 0 ) {
54+ durationTime -= ( days * 1000 * 60 * 60 * 24 ) ;
55+ durationString += `${ days } days - ` ;
56+ }
57+ const hours = Math . floor ( durationTime / ( 1000 * 60 * 60 ) ) ;
58+ if ( hours > 0 ) {
59+ durationTime -= ( hours * 1000 * 60 * 60 ) ;
60+ durationString += `${ hours } hours - ` ;
61+ }
62+ const minutes = Math . floor ( durationTime / ( 1000 * 60 ) ) ;
63+ if ( minutes > 0 ) {
64+ durationTime -= ( minutes * 1000 * 60 ) ;
65+ durationString += `${ minutes } minutes - ` ;
66+ }
67+ const seconds = durationTime / 1000 ;
68+ durationString += `${ seconds . toFixed ( 3 ) } seconds` ;
69+ return durationString ;
70+ } ;
71+
4672/** Function to get the row data of workflow states table. */
4773const rowData = ( { StateHistory } ) => StateHistory . map ( ( item ) => ( {
4874 id : item . Guid . toString ( ) ,
4975 name : item . Name ,
5076 enteredTime : convertDate ( item . EnteredTime . toString ( ) ) ,
5177 finishedTime : convertDate ( item . FinishedTime . toString ( ) ) ,
52- duration : item . Duration . toFixed ( 3 ) . toString ( ) ,
78+ duration : convertDuration ( item . Duration * 1000 ) ,
5379} ) ) ;
5480
5581/** Function to return the header, row and status data required for the RequestWorkflowStatus component. */
@@ -59,6 +85,20 @@ export const workflowStatusData = (response) => {
5985 return undefined ;
6086 }
6187 const rows = response . context ? rowData ( response . context ) : [ ] ;
88+ if ( response . context && response . context . State ) {
89+ const state = response . context . State ;
90+ const currentTime = new Date ( ) ; // Date Object for current time
91+ const oldTime = Date . parse ( state . EnteredTime ) ; // ms since start time to entered time in UTC
92+ const durationTime = currentTime . getTime ( ) - oldTime ; // ms from entered time to current time
93+
94+ rows . push ( {
95+ id : state . Guid . toString ( ) ,
96+ name : { text : state . Name , icon : 'fa fa-play' } ,
97+ enteredTime : convertDate ( state . EnteredTime . toString ( ) ) ,
98+ finishedTime : '' ,
99+ duration : convertDuration ( durationTime ) ,
100+ } ) ;
101+ }
62102 const headers = headerData ( ) ;
63103 const name = response . name || response . description ;
64104 return {
0 commit comments