@@ -22,6 +22,7 @@ import { DurationService } from 'app/shared/duration/duration.service';
2222import { CDSWebWorker } from 'app/shared/worker/web.worker' ;
2323import { ProjectState } from 'app/store/project.state' ;
2424import { WorkflowState , WorkflowStateModel } from 'app/store/workflow.state' ;
25+ import cloneDeep from 'lodash-es/cloneDeep' ;
2526import { Observable , Subscription } from 'rxjs' ;
2627
2728@Component ( {
@@ -56,7 +57,7 @@ export class WorkflowStepLogComponent implements OnInit, OnDestroy {
5657 doneExec : Date ;
5758 duration : string ;
5859 selectedLine : number ;
59- splittedLogs : { lineNumber : number , value : string } [ ] = [ ] ;
60+ splittedLogs : { lineNumber : number , value : string } [ ] ;
6061 splittedLogsToDisplay : { lineNumber : number , value : string } [ ] = [ ] ;
6162 limitFrom : number ;
6263 limitTo : number ;
@@ -117,7 +118,7 @@ export class WorkflowStepLogComponent implements OnInit, OnDestroy {
117118 if ( nrj . job . step_status && nrj . job . step_status . length >= this . stepOrder + 1 ) {
118119 let status = nrj . job . step_status [ this . stepOrder ] . status ;
119120 if ( ! this . stepStatus || status !== this . stepStatus . status ) {
120- if ( ! this . stepStatus ) {
121+ if ( ! this . stepStatus ) {
121122 this . initWorker ( ) ;
122123 this . showLogs = true ;
123124 } else if ( this . pipelineBuildStatusEnum . isActive ( this . stepStatus . status ) &&
@@ -231,7 +232,7 @@ export class WorkflowStepLogComponent implements OnInit, OnDestroy {
231232
232233 parseLogs ( ) {
233234 let tmpLogs = this . getLogsSplitted ( ) ;
234- if ( ( ! this . splittedLogs && ! tmpLogs ) || ( this . splittedLogs && tmpLogs && this . splittedLogs . length === tmpLogs . length ) ) {
235+ if ( ( ! this . splittedLogs && ! tmpLogs ) || ( this . splittedLogs && tmpLogs && this . splittedLogs . length === tmpLogs . length ) ) {
235236 return ;
236237 }
237238 if ( ! this . splittedLogs || this . splittedLogs . length > tmpLogs . length ) {
@@ -243,19 +244,20 @@ export class WorkflowStepLogComponent implements OnInit, OnDestroy {
243244 } ) ;
244245 } else {
245246 this . splittedLogs . push ( ...tmpLogs . slice ( this . splittedLogs . length ) . map ( ( log , i ) => {
246- if ( this . ansiViewSelected ) {
247- return { lineNumber : this . splittedLogs . length + i , value : this . ansi_up . ansi_to_html ( log ) } ;
248- }
249- return { lineNumber : this . splittedLogs . length + i , value : log } ;
247+ if ( this . ansiViewSelected ) {
248+ return { lineNumber : this . splittedLogs . length + i + 1 , value : this . ansi_up . ansi_to_html ( log ) } ;
249+ }
250+ return { lineNumber : this . splittedLogs . length + i + 1 , value : log } ;
250251 } ) ) ;
251252 }
252- if ( ! this . allLogsView && this . splittedLogs . length > this . MAX_PRETTY_LOGS_LINES && ! this . _route . snapshot . fragment ) {
253+
254+ this . splittedLogsToDisplay = cloneDeep ( this . splittedLogs ) ;
255+ if ( ! this . allLogsView && this . splittedLogsToDisplay . length > this . MAX_PRETTY_LOGS_LINES && ! this . _route . snapshot . fragment ) {
253256 this . limitFrom = 30 ;
254257 this . limitTo = this . splittedLogs . length - 40 ;
255258 this . splittedLogsToDisplay . splice ( this . limitFrom , this . limitTo - this . limitFrom ) ;
256- } else {
257- this . splittedLogsToDisplay = this . splittedLogs ;
258259 }
260+
259261 this . _cd . markForCheck ( ) ;
260262 }
261263
@@ -325,12 +327,13 @@ export class WorkflowStepLogComponent implements OnInit, OnDestroy {
325327 showAllLogs ( ) {
326328 this . loadingMore = true ;
327329 this . allLogsView = true ;
330+ this . _cd . markForCheck ( ) ;
328331 setTimeout ( ( ) => {
329332 this . limitFrom = null ;
330333 if ( this . splittedLogs . length > this . MAX_PRETTY_LOGS_LINES ) {
331334 this . basicView = true ;
332335 }
333- this . splittedLogsToDisplay = this . splittedLogs ;
336+ this . splittedLogsToDisplay = cloneDeep ( this . splittedLogs ) ;
334337 this . loadingMore = false ;
335338 this . _cd . markForCheck ( ) ;
336339 } , 0 ) ;
0 commit comments